How to use a decision variable from optimization problem into an if else statement?

조회 수: 21 (최근 30일)
Here Tins is a decision variable of size=(24,1) in my optimization problem. The value of Tins(min_des) =20 while value of Tins(max_des) = 23. When I input the if else statement using Tins variable for value comparison, then the following error is shown by matlab:-
Please suggest the corrective measure. Thanks in advance
  댓글 수: 6
Paramvir Singh
Paramvir Singh 2018년 5월 1일
Is the information provided regarding the problem not sufficient?
Matt J
Matt J 2018년 5월 1일
편집: Matt J 2018년 5월 1일
It's way too much. An optimization problem has the following form
min f(x)
subject to g(x)<=0, h(x)=0
I'm looking for you to tell me, in your case, what x,f,g,and h are.

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

채택된 답변

Mary Fenelon
Mary Fenelon 2018년 5월 2일
The if-constraints (logical constraints, implication constraints) can be modeled with linear constraints and binary variables.
To see how to do this, suppose you have a binary variable y that should be 1 when x > 0. The constraint x - M*y <= 0, where M is an upper bound on x, will enforce this. When x > 0, y must be 1; the only other possible value for y is 0 and if y were 0, the constraint reduces to x <= 0, a contradiction.
To formulate constraint (6), make two constraints
  • (Tmin - Tins) - M1*(1-BCac) <= 0 where M1 is an upper bound on (Tmin - Tins)
  • (Tins - Tmax) - M2*BCac <= 0 where M2 is an upper bound on (Tins - Tmax)
The resulting constraints are called big-M constraints or indicator constraints. The y variable is called an indicator variable.
  댓글 수: 3
Paramvir Singh
Paramvir Singh 2018년 5월 5일
In the code for my constraint (6), I have another doubt if for a value of Tins=27, although second constraint is being satisfied, but for the first constraint, for Tins=27,
Both BCac=0 or 1 satisfy the constraint. I think due to this reason my intlinprog solver is not giving a feasible solution.
Any help in this regard would be appreciated.
Amir Hossein Nazeri
Amir Hossein Nazeri 2022년 4월 5일
@Paramvir Singh Hi Paramvir, Is your problem solved? Can you share your Matlab code with me if possible? Or if you have any Github or so...
Thanks!
Amir

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by