Problem-Based Optimisation - "Linprog stopped because it exceeded its allocated memory"
Show older comments
I am trying to solve a simple linear optimisation problem using the "Problem-Based Optimisation" approach. To solve the optimisation problem I use "linprog" and the "dual-simplex-algorithm".

The number of variables and constraints depends on the number of time steps T. The variable T in turn depends on the considered time period t and the duration of a single time step dt. I can solve the problem if I keep the number of time steps small enough or if I use the "Solver-Based Optimisation" approach. However, I must be able to solve the problem for a period of 24h with time steps of 15/60. This results in a number of T = 97 time steps. With this number of time steps, I recieive the following error message: "Linprog stopped because it exceeded its allocated memory". I don't understand why the "Problem-Based Optimisation" approach run out of memory for such a small problem.
Here is my code:
dt = 15/60;
t = [0:dt:24]; %Charging time 24h
T = length(t)
E_Batt = 22;
E_inital = 9;
E_min = 12;
P_max = 10;
P_min = 0;
E_1 = optimvar('E_1',T,"UpperBound",E_Batt);
P_1 = optimvar('P_1',T,"LowerBound",P_min,"UpperBound",P_max);
Charging_1 = optimproblem();
Charging_1.ObjectiveSense = 'maximize';
RowConstraints = optimconstr(T);
for n = 1:T
if n~=1
RowConstraints(n) = E_1(n-1) - E_1(n) + P_1(n)*dt == 0;
else
RowConstraints(n) = E_1(n) == E_inital;
end
end
Charging_1.Constraints.c = RowConstraints;
% show(Charging_1.Constraints.c);
objfun = sum(E_1);
Charging_1.Objective = objfun;
% show(Charging_1.Objective)
Schedule = solve(Charging_1);
Schedule.E_1
Schedule.P_1
figure(1)
plot(t,Schedule.E_1)
title('Ladezustand')
xlabel('Ladezeit [h]')
ylabel('SoC [%]')
figure(2)
bar(t,Schedule.P_1)
title('Ladeleistung')
xlabel('Ladezeit [h]')
ylabel('Leistung [kW]')
Is there any issue with my code?
Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
