Azzera filtri
Azzera filtri

optimization of energy management system _problem objective error

2 visualizzazioni (ultimi 30 giorni)
Hi,
i am getting error for below code of optimisation objective:
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • Objective must be a scalar OptimizationExpression or a struct containing a scalar OptimizationExpression.Please help
prob.Objective =dt*Price'*PbattupsV +dt*Price'*PbattdchV*Nb_dch1V'+ dt*Price'*PbattchV*Nb_ch1V' ;

Risposte (1)

prabhat kumar sharma
prabhat kumar sharma il 2 Mag 2024
Hi NN,
I understand the error message you're encountering indicates that the expression assigned to prob.Objective is not being recognized as a scalar OptimizationExpression or a struct containing a scalar OptimizationExpression.
The objective function in optimization problems should result in a single scalar value that the solver attempts to minimize or maximize. When you're setting up an optimization problem in MATLAB, it's essential to ensure that the objective function conforms to this expectation.
Your objective function seems to be trying to compute a cost or value by multiplying time intervals (dt), prices (Price), and battery power variables (PbattupsV, PbattdchV, PbattchV) adjusted by efficiency (Nb_dch1V, Nb_ch1V).
However, without seeing the complete context or definitions of these variables, a potential issues can be identified:
Dimensionality: Ensure that the final result of the objective function is indeed a scalar. This means the matrix or vector operations inside must ultimately condense down to a single value. Use functions like sum if necessary to aggregate results.
You can refer this similar question for further refrence: https://www.mathworks.com/matlabcentral/answers/1439564-error-in-prob-objective
I hope it helps!

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by