Filter löschen
Filter löschen

Solver stops, but should not

2 Ansichten (letzte 30 Tage)
Tim
Tim am 24 Nov. 2018
Kommentiert: Walter Roberson am 25 Nov. 2018
Hey,
in the following code I represent 3 houses with 3 energy storages and they can share energy with another. The goal is to maximize the energy in each house, but they should avoid going in to the negative direction. When I give the houses lowerbounds of 0 and the solution cant avoid being 0 for one house I dont receive a solution. How should I tell Matlab that I want to maximize each house seperatly ?
Edit: I would like to use "energyprob.Objective = H3 * H2 * H1;" ,but I read that matlab cant do this. Is that true?
Thank you so much!
energyprob = optimproblem;
% 3 Houses 3 Storages one day
% H1 = optimvar('H1','LowerBound',0,'UpperBound',10);
% H2 = optimvar('H2','LowerBound',0,'UpperBound',10);
% H3 = optimvar('H3','LowerBound',0,'UpperBound',10);
H1 = optimvar('H1','UpperBound',10);
H2 = optimvar('H2','UpperBound',10);
H3 = optimvar('H3','UpperBound',10);
E1 = optimvar('E1','LowerBound',0,'UpperBound',10);
E2 = optimvar('E2','LowerBound',0,'UpperBound',10);
E3 = optimvar('E3','LowerBound',0,'UpperBound',10);
E_in_1 = optimvar('E_in_1','LowerBound',0,'UpperBound',10);
E_in_2 = optimvar('E_in_2','LowerBound',0,'UpperBound',10);
E_in_3 = optimvar('E_in_3','LowerBound',0,'UpperBound',10);
E_out_1 = optimvar('E_out_1','LowerBound',0,'UpperBound',10);
E_out_2 = optimvar('E_out_2','LowerBound',0,'UpperBound',10);
E_out_3 = optimvar('E_out_3','LowerBound',0,'UpperBound',10);
Anz_E = 3;
PV = 1; % energy from the sun
E_start = 4;
E_start_ges = Anz_E*(PV + E_start); % 15
Bedarf1 = 3; % Energy Demand
Bedarf2 = 3; % Energy Demand
Bedarf3 = 6; % Energy Demand
energyprob.Constraints.start1 = E1 == E_in_1 - E_out_1 + E_out_2 + E_out_3;
energyprob.Constraints.start2 = E2 == E_in_2 - E_out_2 + E_out_1 + E_out_3;
energyprob.Constraints.start3 = E3 == E_in_3 - E_out_3 + E_out_2 + E_out_1;
energyprob.Constraints.start4 = E3 + E1 + E2 == E_start_ges;
energyprob.Constraints.start6 = E_out_1 + E_out_2 + E_out_3 == E_in_1 + E_in_2 + E_in_3;
energyprob.Constraints.HE11 = H1 >= 0;
energyprob.Constraints.HE21 = H2 >= 0;
energyprob.Constraints.HE31 = H3 >= 0;
energyprob.Constraints.HE1 = H1 == E1 - Bedarf1;
energyprob.Constraints.HE2 = H2 == E2 - Bedarf2;
energyprob.Constraints.HE3 = H3 == E3 - Bedarf3;
energyprob.Objective = H3 + H2 + H1;
% energyprob.Objective = H3
energyprob.ObjectiveSense = 'maximize';
[sol,fval] = solve(energyprob)
  3 Kommentare
Tim
Tim am 25 Nov. 2018
thank you! I will try another solver then. Should I use Fmincon ?
Walter Roberson
Walter Roberson am 25 Nov. 2018
fmincon is one possibility. Note that it is a local minimizer, not a global minimizer.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by