필터 지우기
필터 지우기

Writing Constaints for simulannealbnd

조회 수: 1 (최근 30일)
Saifullah Khalid
Saifullah Khalid 2017년 6월 22일
댓글: Saifullah Khalid 2017년 6월 23일
I am trying to optimize an objective using simulannealbnd function. I have constraints of upper and lower bounds on decision variable x. The constraints are: x > 0 and sum(x)< Maximum_Average_Price. I have coded as follow but the resultant sum(x) goes beyond Maximum_Average_Price. I would appreciate any help.
x0=[price(1:4), priceDash(5:28)];
lb = ones(1,28);
ub= min(sum(x0), price_avg_max);

채택된 답변

Alan Weiss
Alan Weiss 2017년 6월 22일
The constraint you have is not a bound, it is a linear inequality constraint that cannot be represented by a bound.
I strongly suggest that you do not use simulannealbnd for this problem, and instead use fmincon if your objective function is smooth, and use patternsearch otherwise. If you are looking for a global solution, then start the solver from a variety of initial points
x0 = lb + rand(size(lb)).*(ub - lb);
By the way, you wrote that your lower bound is x >= 1, not x >= 0, since you said lb = ones and not zeros.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 4
Alan Weiss
Alan Weiss 2017년 6월 23일
No and no. A linear constraint is not the same as a bound constraint. Draw yourself a picture of x1 + x2 <= 1, and see if you can figure out how to get that picture as a bound constraint. The answer is no, you cannot.
You will have to do one of several things:
  1. Write your own simulated annealing solver that accepts linear constraints.
  2. Use a different solver.
  3. Find a different problem.
Sorry, that is the set of choices.
Alan Weiss
MATLAB mathematical toolbox documentation
Saifullah Khalid
Saifullah Khalid 2017년 6월 23일
Alan Weiss, thank you very much for detailed comment. This is indeed a great help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver 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