필터 지우기
필터 지우기

How to define a binary variable as part of constraints in the optimization problem(fmincon)?

조회 수: 21 (최근 30일)
I'm working on an optimization problem that optimizes the cost for a microgrid including Battery Storage Units. I used the fmincon function and wrote all constraints except the nonlinear inequalities c(x) which I indicated below. u_ch(t) is a binary variable and can be "1" when the battery is charging or be "0" when it is discharging. I need to know at which time the battery is charging or discharging so I need to calculate "u_ch(t)".
The problem is that I couldn't manage to define a binary variable in Matlab and use it for fmincon. P_Batt_charge(t) and P_Batt_disharge (t) are also decision variables. End of the optimization, I also need to calculate the values of them for each t. Is there any suggestion how can I write these constraints?
P_Batt_charge(t) ≤ 150kW*u_ch (t)
P_Batt_disharge (t)≤180kW*(1-u_ch) (t))

채택된 답변

Alan Weiss
Alan Weiss 2022년 2월 4일
편집: Alan Weiss 2022년 2월 4일
fmincon does not accept binary constraints, or any integer constraints. The only solvers that accept a nonlinear objective function or constraint function and integer constraints are ga and surrogateopt.
It is often possible to approximate the costs and constraints using linear objectives and constraints. If you can do that, you can use intlinprog as the solver. For an energy-related example, see Optimal Dispatch of Power Generators: Problem-Based.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 7
Alan Weiss
Alan Weiss 2022년 2월 6일
As the Release Notes state, linear constraints were introduced to surrogateopt in R2021a. Without seeing the error, I suspect that you have an older version.
Alan Weiss
MATLAB mathematical toolbox documentation
Mehmet Türker TAKCI
Mehmet Türker TAKCI 2022년 2월 6일
Hi, yes I use R2020b. So, I need to install R2021a or above to use all types of constraints. Ok, many thanks for all information.

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

추가 답변 (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