I am a full-time consultant and provide services related to the design, implementation and deployment of mathematical programming, optimization and data-science applications. I also teach courses and workshops. Usually I cannot blog about projects I am doing, but there are many technical notes I'd like to share. Not in the least so I have an easy way to search and find them again myself. You can reach me at erwin@amsterdamoptimization.com.

Friday, January 30, 2009

> Hi I am trying to solve a certain linear integer problem with lp_solve.> I know that the solution set (24 variables) is (1,2...,24) and I am trying to figure out a way to input to lp_solve this array in order to get a feasible solution.

> In other words is it possible to put have a (or a set) of constraints saying that x1 ,x2,....,x24 belong to (1 ,2,...24) set but they are distinct (for instance x1=24, x2=3,x3=21 etc...).

However I would always urge you to try out solvers on your particular models as they may behave very differently than the benchmark models. Drop me a note if you need me to run some models or need access to evaluation systems.

Wednesday, January 28, 2009

Sometimes progress logs pose some interesting questions. In the Cplex log below we solve a problem with 2016 binary variables (after presolving). However the progress log seems to indicate that when we start 2036 of them are integer infeasible.

Tuesday, January 27, 2009

Whenever a MIP model is very slow I try to invent "redundant" constraints that can be added to the model. Here is an example with Cplex. We report number of nodes needed to prove optimality on some small examples of a (proprietary) scheduling model:

case

with

without

8-3-2

23

34

8-6-2

0

7290

9-3-3

0

81

9-4-3

0

180

9-5-3

74

87738

As can be seen the version with the redundant equation added has much better performance. Furthermore it is noted that the duality gap was much smaller.

Monday, January 26, 2009

> How to model that an employe must work at least as 5 successive periods and at most as 8 successive periods with mathprog.

There are a few ways to model this, and without knowing more about the model it is difficult to give definite advise, but here is a suggestion of a possible formulation taken from a machine scheduling model I developed a little while ago:

I ignored the details about what to do with the boundaries. The last condition adds also an implied restriction on when the machine can be turned on again (after 8 periods), so it may be better to model this as:

For multiple persons j we would need x[j,t], SwitchOn[j,t], SwitchOff[j,t]. A different way would be to organize x[j,t,len] where t is the start time and len is the length of occupation (len=5,6,7,8). This approach has more integer variables but may solve fast depending on the situation.

Thursday, January 22, 2009

Updated lp2gams to distinguish names with different casing. In lpsolve a variable x is different from a variable X while in GAMS they are the same. We added some code to make sure the generated GAMS names are unique. If needed we add an underscore to the name.

Tuesday, January 20, 2009

>> where> i=1..n observations,> j=1..m describing dimensions,> a(j) parameters to be identified,> x(i,j) describing values for observation i,> b(i) observed values,> s1(i), s2(i) deviations of the described value from the observed value.>> For realistics instances I have > 100.000 observations. Many instances> have rows i with equal x(i,j) but different b(i) (describing variables are> equal but observations different). I wonder if there is a modeling trick> to aggregate these rows into 1 or 2 constraints.

Don't know. But I have some suggestions to try out:

If j is large you may want to solve a larger but sparser problem where you prevent repeating the same sum(j, a(j)*x(i,j)) but using extra variables

The MSF code contains a large parameter that is read through data binding, together with a minimal (one variable, one constraint) model. The GAMS code calls GDXXRW to read the spreadsheet and then the intermediate GDX file is read again by GAMS. We display the cardinality of p as a check we read all numbers.

I am recently involved in a practical application of a scheduling problem related to the Social Golfer Problem. The particular application is somewhat more complicated, but we could use the GAMS/Cplex model described here as a starting point.

For smaller instances of the pure Social Golfer Problem, it is convenient to use a CSP approach. Here is a formulation in OML (Microsoft Solver Foundation):

Model[

// N : number of golfers// NG : number of groups// T : number of rounds// GS : group size (N/NG)

Parameters[Integers,N=16,NG=4,T=5,GS=4], // Would prefer: GS=N/NG but OML does not allow (constant) expressions // in parameter statements

Decisions[ Integers[0,1], Foreach[{i,N},{g,NG},{t,T},x[i,g,t]] ],

Constraints[ // each golfer has to play each round Foreach[{i,N},{t,T},Sum[{g,NG},x[i,g,t]] == 1],

The condition on number of times players can meet can be implemented quite straightforwardly. In the MIP model we needed to linearize this constraint, but in the CSP framework we can use the nonlinear formulation directly. A big advantage of CSP over MIP is that many constructs can be modeling in a more natural, straightforward fashion. Note that we added some exploitation of symmetry: once we have checked how many times golfer i meets golfer j we no longer need to check golfer j meeting golfer i.

The last two constraints fix the first round and first player. This (without loss of generality) reduces the size of the problem.