How do I use multiple cores to speed up the construction of my constraint matrix that is to be fed to CPLEX using cplexmilp function?

2 views (last 30 days)
Hello,
This is my first time in the forum. I have been using MATLAB for quite some time. Currently, I'm using MATLAB to construct a constraint matrix of a MILP and then feed it to CPLEX via the cplexmilp function. However, the model has quite a lot of variables and constraints and it takes a lot (really too much) of time to build the matrices and solve the problem. Hence, I would like to ask you for some advice on speeding up the construction of my constraint matrix. I can sample a piece of my code here which can give you some idea about the problem.
B6_M2 = zeros( num_nodes(1), num_variables(1) );
rhs_B6_M2 = zeros( num_nodes(1), 1 );
for i = 1:num_nodes(1)
for j = 1:num_vnodes(1)
for k = 1:num_demands(1)
B6_M2( i, ( ( i - 1 ) * num_demands(1) ) + ( ( j - 1 ) * num_nodes(1) * num_demands(1) ) + k ) = -1;
end
end
B6_M2( i, num_xvar + num_fvar + i ) = 1;
end
The above piece of code is one such constraint of the MILP, which contains many more constraints and I'd like to exploit my CPU processing capacity to speed up the matrix build. The specifications of my system are
_Processor: Intel® Core™ i7-3930K CPU @ 3.20GHz × 12
Memory: 62.9 GiB_
Ubuntu
_Release 12.04 (precise) 64-bit
Kernel Linux 3.2.0-70-generic_
Thank You
Varun
  4 Comments
Johannes
Johannes on 22 Mar 2018
I found a solution that worked for me. I was feeding in my constraints row by row. But you can feed them into CPLEX together.
https://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.0/ilog.odms.cplex.help/refmatlabcplex/html/classCplex.html
The part of my script for creating the matrix went from hours to a single minute.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!