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

4 ビュー (過去 30 日間)
lorenzo vallerini
lorenzo vallerini 2021 年 11 月 5 日
回答済み: Alan Weiss 2021 年 11 月 8 日
n = numel(daily_Ppv);
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);
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;
PowerFlow.Constraints.BAT(i) = Pbe(i)>0;
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 件)





Community Treasure Hunt

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

Start Hunting!

Translated by