Does the order affect LP performance
The setup and result are
1. Run the m file as it is, the result shows time1 is roughly time2 ✖ 10;
2. Exchange the orders of two functions, that is, first run x = linprog(f,[],[],Aeq, beq, lb, ub, opts)
and then run x = linprog(f,[],[],Aeq, beq, lb, ub);, the results show that time1 roughly equals to time2;
3. first run x = linprog(f,[],[],Aeq, beq, lb, ub), second run x = linprog(f,[],[],Aeq, beq, lb, ub, opts), third run x = linprog(f,[],[],Aeq, beq, lb, ub)
The results show that time1 is roughly time2 ✖ 10, time3 roughly time2 ✖ 2;
4. First run x = linprog(f,[],[],Aeq, beq, lb, ub, opts), second x = linprog(f,[],[],Aeq, beq, lb, ub), third x = linprog(f,[],[],Aeq, beq, lb, ub, opts)
The results show that time1 roughly equals to time2, time2 roughly time3 ✖ 2 .
I am wondering why the order affects the results so much. Could you please help me with this?
The m file goes like this:
clear all
f = ones(1250,1);
Aeq = randi([-100,100],625,1250);
beq = zeros(625,1);
lb = zeros(1250,1);
ub = Inf*ones(1250,1);
tic
x = linprog(f,[],[],Aeq, beq, lb, ub);
time1 = toc;
opts = optimoptions('linprog','Preprocess','none');
tic;
x = linprog(f,[],[],Aeq, beq, lb, ub, opts);
time2 = toc;
times = [time1 time2]
-
Are you using the linprog function in the Gurobi examples directory or Matlab's built-in one?
With the built-in one, I can reproduce your running times, with Gurobi's I cannot.
0
Please sign in to leave a comment.
Comments
1 comment