# Reducing execution time for codes with many binary variable.

Question asked by s1473341@sms.ed.ac.uk on Apr 13, 2016
Latest reply on Apr 14, 2016 by s1473341@sms.ed.ac.uk

I have written a mosel code to solve a problem using the BIG M linearisation approach.

My code contains over 7,000  binary variables and is taking too long to compute (47 minutes).

Without using binary variables, it computes in 1.6 seconds but the binary variables are essential to get the perfect result(integer).

How can I reformulate the binary variables such that the model will have a faster execution time?

Which other way can I use to code the BIG M linearisation approach?

Portions of the code are written below.

declarations

I: set of integer

T:set of integer

B: set of integer

g: array (I,T,B) of mpvar

mewmin: array (I,T,B) of mpvar

w1: array (I,T,B) of mpvar

end-declarations

M:=100000

forall (i in I, t in T, b in B)do

w1(i,t,b) is_binary

mewmin(i,t,b)>=0; g(i,t,b)>=0

mewmin(i,t,b)<=w1(i,t,b)*M

g(i,t,b)<=(1-w1(i,t,b))*M

end-do