How can setup optimset for custom data types.

2 Ansichten (letzte 30 Tage)
Triveni
Triveni am 28 Dez. 2015
Bearbeitet: Matt J am 20 Jan. 2016
I'm putting xo as initial guess. I want custom data just restricted x0 subset [0,30], by create permutation.
x0 = [30 30 30 30 30 30 0 0 0 0 0 0 0 0 30 30 30 30 30 30];
[x, fval] = fminsearch(@objfun, x0);
  1 Kommentar
Alan Weiss
Alan Weiss am 28 Dez. 2015
I am sorry, but I do not understand what you are asking. Your image is from a ga example, but your question seems to be about fminsearch.
So can you please explain what you are trying to do, and what the problem is?
Alan Weiss
MATLAB mathematical toolbox documentation

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 28 Dez. 2015
Bearbeitet: Matt J am 28 Dez. 2015
Rewrite the problem in terms of binary variables 0<=y(i)<=1 where y=x/30. Then use the IntCon argument and bound constraints to minimize in terms of y,
N=numberofVariables;
LB=zeros(1,N);
UB=ones(1,N);
IntCon=1:N;
fun=@(y) FitnessFcn(30*y);
x = 30*ga(fun,N,[],[],[],[],LB,UB,IntCon,options);
  4 Kommentare
Triveni
Triveni am 20 Jan. 2016
@Walter, I'm sorry...but your code is not running.
Undefined function or variable
'options'.
when i remove options...
Error using ga (line 278)
Fitness function must be a function
handle.
Error using functionHandleOrCell (line
12)
The constraint function must be a
function handle.
Error in validate (line 181)
[nonlcon,NonconFcnArgs] =
functionHandleOrCell('NonconFcn',nonlcon);
Error in gacommon (line 73)
[options,nvars,FitnessFcn,NonconFcn] =
validate(options,type,nvars,fun,nonlcon,user_options);
Error in ga (line 327)
[x,fval,exitFlag,output,population,scores,FitnessFcn,nvars,Aineq,bineq,Aeq,beq,lb,ub,
...
Matt J
Matt J am 20 Jan. 2016
Bearbeitet: Matt J am 20 Jan. 2016
You should be wondering why Matlab thinks "options" is undefined, when the code you posted in your question defines it explicitly...
Regardless, Walter's solution will ultimately not work as written because (see My Remark) it tries to use IntCon and linear equalities simultaneously, which ga() does not allow.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by