fmincon and constrains

1 回表示 (過去 30 日間)
John Miller
John Miller 2012 年 6 月 16 日
Hello, I have a funktion f(x)
f and x are vector which I want to minimize with fmincon()
How can I implement follwing constrain:
x~=y this means the solution x is unequal to a vector y that I know

採用された回答

Titus Edelhofer
Titus Edelhofer 2012 年 6 月 16 日
Hi,
if you know that x(1)=a why don't you take x(1) out of the optimization problem? But if you want to keep it, just let lb(1)=ub(1)=a (i.e., lower and upper bound for x(1)=a).
For the first one: this is equal to saying
abs(x-y)>=aConst
where aConst is some value saying who "unequal" they shoud be. Reformulating as
-abs(x-y)+aConst<=0
gives a nonlinear constraint, see doc for fmincon.
Titus
  4 件のコメント
Titus Edelhofer
Titus Edelhofer 2012 年 6 月 16 日
Look here:
http://www.mathworks.de/help/toolbox/optim/ug/fmincon.html
look out for "nonlcon". In fact it's for you: c = -abs(x-y) + aConst;
John Miller
John Miller 2012 年 6 月 16 日
my f(x) is a function that returns a vector ==> fmincon can not handle vectorfields
is there any other function in matlab that can handle functions that returns vectors?

サインインしてコメントする。

その他の回答 (2 件)

John Miller
John Miller 2012 年 6 月 16 日
My function f is a VECTOR ==> fmincon can not handle vectorfield... my f(x) is a function that returns a vector...
Has anyone some ideas?
Thank you..

Sargondjani
Sargondjani 2012 年 6 月 17 日
if you want to minimize all the values in the vector, you can sum them and use that as your objective....
about the not equal thing: i think it will make your problem non-differentiable, so you can not use fmincon in this way...
you would have to do it some other way: solve fmincon for all discrete cases or use genetic algorithm
  2 件のコメント
John Miller
John Miller 2012 年 6 月 17 日
genetic algorithm sounds good, do you mean this :http://www.mathworks.de/products/global-optimization/demos.html?file=/products/demos/shipping/globaloptim/gaconstrained.html
my objectiv is a vectorfield..so do you think I can just sum them like f1+f2+f3+...?
Thank You
Sargondjani
Sargondjani 2012 年 6 月 17 日
why not?? im mean, if you minimize 10 values that is the same as taking the minimum of the sum of those values... although you have to be carefull with scaling (the change in the objective of each fi)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by