MILP problem which is a function of time
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sibabalo noludwwe
el 14 de Abr. de 2020
Comentada: sibabalo noludwwe
el 1 de Mayo de 2020
i have solved my MILP problem using intlinprog, that part was fine. I am now extending the same problem but now it is depedent on time (i.e. I was to solve the optimization problem for each hour time step).
my question is: How do I extend my objective function and constraints to be time depedent?
thank you
9 comentarios
Respuesta aceptada
Ameer Hamza
el 14 de Abr. de 2020
I have modified this example from the documentation: https://www.mathworks.com/help/optim/ug/intlinprog.html#mw_cd504ff9-629b-402f-acb0-7aa7c7926290 to explain the effect of using the solution from the previous time step as an initial point for the next iteration. In the following example, I used a for loop to solve an MILP problem 20 times, each time slightly varying the objective function.
First, check the code which does not use the solution from the last iteration as an initial guess of next iteration. The initial guess is always the same.
Aeq = [22 13 26 33 21 3 14 26
39 16 22 28 26 30 23 24
18 14 29 27 30 38 26 26
41 26 28 36 18 38 16 26];
beq = [ 7872
10466
11322
12058];
N = 8;
lb = zeros(N,1);
intcon = 1:N;
f = [2 10 13 17 7 5 7 3];
x0 = [8 62 23 103 53 84 46 34];
opts = optimoptions('intlinprog', 'Display', 'off');
tic
for i=1:20
f(3:5) = randi([1 15], 1, 3); % objective function is changed in each iteration
[x2,fval2] = intlinprog(f,intcon,[],[],Aeq,beq,lb,[],x0,opts);
end
toc
Time of execution
Elapsed time is 24.518613 seconds.
The following code update the initial guess
Aeq = [22 13 26 33 21 3 14 26
39 16 22 28 26 30 23 24
18 14 29 27 30 38 26 26
41 26 28 36 18 38 16 26];
beq = [ 7872
10466
11322
12058];
N = 8;
lb = zeros(N,1);
intcon = 1:N;
f = [2 10 13 17 7 5 7 3];
x0 = [8 62 23 103 53 84 46 34];
opts = optimoptions('intlinprog', 'Display', 'off');
tic
for i=1:20
f(3:5) = randi([1 15], 1, 3);
[x2,fval2] = intlinprog(f,intcon,[],[],Aeq,beq,lb,[],x0,opts);
x0 = x2;
end
toc
Time of execution
Elapsed time is 8.489186 seconds.
This example shows a speed gain of about 3 times. The actual gain can vary from problem to problem, but still, it is better than just using a random initial guess.
19 comentarios
Ameer Hamza
el 30 de Abr. de 2020
This is quite strange behavior. I couldn't see any reason why this should be happening. I recommend starting two instances of MATLAB and run both code line by line. You will definitely see the difference at some point.
Más respuestas (1)
Ver también
Categorías
Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!