bugGNU Octave - Bugs: bug #63326, [octave forge] (ga) ga function...


bug #63326: [octave forge] (ga) ga function output unbounded results

Submitter:  Liang Tang <lt1234>
Submitted:  Mon 07 Nov 2022 11:16:14 AM UTC
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  lt1234 Open/Closed:  * Open
Release:  * 7.1.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Thu 22 Dec 2022 03:25:28 PM UTC, comment #4: 

After I reported this bug, I spent more time to find out the available options.  I am writing this note to document what I know now in case others experience the same issue later. 

I always appreciate the packages kindly provided by Octave community.  The only purpose of this note is to state my feedback/observations on ga package with the intention that this note might help to make the package more useful and benefit other people who share my needs.

Optimization algorithms in general can be categorized into methods require objective function derivatives and methods require only objective function.  

One characteristics of non-derivative optimization algorithm is its ability to control numbers of function evaluations
through population size and number of iterations/generation.  For problems with expensive function evaluation, this approach
may provide great relief. For my own purpose, lowing computation expense has always been a main focus point when I use Octave for more intensive computation.  Global optimization
and neural network are two examples.    

To summarize, I have four main points:
(1) Octave ga is capable of unconstrained optimization.  It appears to me that the original author was aware of discrepancies of the ga syntax and the functionalities it actually provides.  
(2) There are other open source ga package/toolbox available.  I eventually chose to use the one below due to its functionalities and documentation. It is for unconstrained optimization
(3) Octave sqp illustrates an excellent formulation for constructing constrained optimization solution. I follow sqp's equation construction to build up constraints/bounds. 
(4) Penalty method is probably the most popular method for ga or pso to handle constraint violation. There are still many recent technical papers on this subject, which implies that no method is found to work universally.  With very small modifications, the penalty formulation that works for me is found at
https://github.com/sdnchen/psomatlab  The conventional penalty form such as augmented lagrangian method did not help.  Convergence checking for exiting also speeds up the solution. 


Liang Tang <lt1234>
Wed 09 Nov 2022 02:15:41 PM UTC, comment #3: 

I think the more correct ga options for the simple example below should be

ga_options = gaoptimset('Generations', 100, 'PopulationSize', 30, 'PopInitRange', [LB,UB],  'Vectorized', 'off');

Without any workaround, the output remains the same, x=0.  Thanks.

Liang Tang <lt1234>
Mon 07 Nov 2022 01:53:20 PM UTC, comment #2: 

Hi John, I would also recommend you to verify if other constraints are actually applied. 

I place a brutal work around in _ga_problem_ near Line 80 to get around the issue. It is a wrong way to fix this UB/LB issue. 

NextPopulation=min(max(NextPopulation, LB), UB);


Liang Tang <lt1234>
Mon 07 Nov 2022 01:21:31 PM UTC, comment #1: 

looking at the code, it does look like lb and ub are not currently used anywhere

John Donoghue <lostbard>
Group Member
Mon 07 Nov 2022 11:16:14 AM UTC, original submission:  

I use Octave 7.1.0 with ga 1.10.3 on windows 10 64x. 

ga *|  0.10.3 | C:\Octave\Octave-7.1.0\mingw64\share\octave\packages\ga-0.10.3

The one variable simple problem below gave a wrong answer. x=0 is output.  The correct result should be x=LB. 

LB/UB appear to be ineffective.  I have not found any document to indicate if there are limitations on ga function. 

pkg load ga
fun=@(x) x.^2
x0=1.75; LB=1; UB=2;
ga_options = gaoptimset('Generations', 100, 'PopulationSize', 30, 'InitialPopulation', x0,  'Vectorized', 'off');
[x, fval, exitflag, output, population, scores] = ga (fitnessfcn=fun, nvars=1, A=[], b=[], Aeq=[], beq=[], LB, UB, nonlcon=[], ga_options);x  % x = -1.9613e-11 or some other near zero values


Liang Tang <lt1234>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by lt1234 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-07 mmuetzel SummaryOctave Forge ga package/function output unbounded results [octave forge] (ga) ga function output unbounded results
    2022-11-07 lostbard StatusNone Confirmed

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code