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

1 vue (au cours des 30 derniers jours)
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!

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by