Put it differently, I just need an example where either conditions vector A or equal2 vector B includes a variable which is a function with input fval
fmincon - conditions must depend on optimization output
4 views (last 30 days)
Show older comments
Jan Morawietz
on 15 May 2015
Commented: Jan Morawietz
on 15 May 2015
How do I make this fmincon function work. The optimization output fval is supposed to have influence on the condition vector A.
1) If I predefine fval, A is not depending on the optimization output. 2) If I make a loop statement and duplicate the optimization problems, then saying that the loop must stop once x(1st. optimization) - x(2nd. optimization) = 0, matlab cannot solve this because in case the latter fmincon function did not find any solution (my case), the iteration simply is repeated xxx times.
In Excel this is a question of seconds - I have spend about two weeks with this problem - any help !
A = [fval*5];
B = [5];
ffun = @(x)x^3 + x^4;
[x fval] = fmincon(ffun,1,[],[],A,B,[],[]);
Accepted Answer
Alan Weiss
on 15 May 2015
You cannot have the A and B inputs depend on the output of fmincon. However, you CAN have a nonlinear constraint function be anything you like, including the output of fmincon. If you choose to solve your problem using nonlinear constraints, you might want to use this technique to avoid computing the objective and constraints twice. And, as always, you have to use nonlinear constraints using the correct syntax, including giving two outputs c and ceq even if one of the outputs is empty.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!