How to solve the error "Conversion to logical from optim.prob​​lemdef.Op​t​imizatio​nC​onstrai​nt is not possible!"

1 次查看(过去 30 天)
n = numel(daily_Ppv);
% VARIABLES
Ppvg = optimvar('Ppvg',1,n,'LowerBound',0,'UpperBound',daily_Ppv);
Ppvb = optimvar('Ppvb',1,n,'LowerBound',0,'UpperBound',daily_Ppv);
Pbe = optimvar('Pbe',1,n,'LowerBound',0,'Upperbound',Pemax);
Ppve = optimvar('Ppve',1,n,'LowerBound',0,'UpperBound',daily_Ppv);
Pelet = optimvar('pelet',1,n,'LowerBound',0,'UpperBound',Pemax);
SOC = optimvar('SOC',1,n,'LowerBound',SOCmin,'UpperBound',SOCmax);
% CONSTRAINS
PowerFlow.Constraints.PPV = daily_Ppv==Ppvb+ Ppvg + Ppve;
PowerFlow.Constraints.PB = Ppvb*eta_pvb <= Pbmax;
PowerFlow.Constraints.ELET1 = Pelet == Ppve*eta_pve + Pbe*eta_be;
PowerFlow.Constraints.ELET2 = Pelet <= Pemax;
PowerFlow.Constraints.BAT = optimconstr(n);
for i = 1:n
if Ppve(i) >= Pelet(i) %% this line reports the error
PowerFlow.Constraints.BAT(i) = Pbe(i)==0;
else
PowerFlow.Constraints.BAT(i) = Pbe(i)>0;
end
Hi, I have meet the pfollowing problem in MATLAB. The battery cannot charge/discharge at the same time so, in the last constraints I tried to write this. When I ran the code the error says: "Conversion to logical from optim.problemdef.OptimizationInequality is not possible."
Appreciate for your help!

采纳的回答

Alan Weiss
Alan Weiss 2021-11-8
You probably need to formulate your constraints according to the procedures in Integer and Logical Modeling.
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by