How to configure the initial solution for MILP

660 views
Skip to first unread message

Viet Anh Nguyen

unread,
Aug 29, 2011, 12:04:54 PM8/29/11
to AIMMS - The Modeling System
Hi everyone,

I am having a problem which is similar to a Bin packing problem, and I
would like to minimize the number of bins I need to use to pack all
the stuff. I would like to implement an algorithm like this in AIMMS:

Step 0: Initialize number of bins = 0

Step 1: Add 1 bin. Optimize with the current number of bins.

Step 2: If not all are inserted, go to step 1, else finish.

I would like to use the solution after each step 2 to be the initial
solution of the MILP at step 1. The MILP at step 1 is changing each
time since the number of bins is different.

I have been looking through the Language Reference but I still cannot
make the things work as I want. I have a set naming Bins_Set which
specifies data{Bin001...Bin004} for example, and the MILP will have 4
bins.

Below is what I have:

GenGMP := GMP::Instance::Generate(BinPacking_MILP,FormatString("%e",
BinPacking_MILP));
session := GMP::Instance::CreateSolverSession(GenGMP);
!! Copy the initial solution from the variables in AIMMS to
!! solution number 1 of the generated mathematical program.
GMP::Solution::RetrieveFromModel(GenGMP,1);
!! Send the solution stored in solution 1 to the solver session
GMP::Solution::SendToSolverSession(session, 1);
!GMP::Solution::SetMIPStartFlag(GenGMP,1,1,1);
!! Call the solver session to actually solve the problem.
GMP::SolverSession::Execute(session);
!! Copy the solution from the solver session into solution 1.
GMP::Solution::RetrieveFromSolverSession(session, 1);
!! Store this solution in the AIMMS variables and constraints.
GMP::Solution::SendToModel(GenGMP, 1);


I think what is missing is the link between GenGMP in line 1 and
GenGMP in the last line since they should be 2 different models.

I would really appreciate if someone could look into my problem and
tell me the correct way to implement what I need.

Thank you very much and have a nice day.

Regards,

Okan

unread,
Sep 5, 2011, 1:01:41 PM9/5/11
to AIMMS - The Modeling System

Hello,

I am planning to do something very similar to a scheduling problem
which is a bit similar in a sense to bin packing. Could you make what
you intend to do or do you still have the same problem? If you could
initialize a solution to your MILP can you please explain how it is
done? I hope you could solve your solution though.

Kind Regards,

Okan

Marcel Hunting

unread,
Sep 6, 2011, 6:54:02 AM9/6/11
to AIMMS - The Modeling System
Hi,

To pass an initial MIP solution to the solver you should set one of
the following options:

CPLEX : General - Advanced start -> Use advanced basis
GUROBI: MIP – MIP Start -> Yes
MOSEK : MIP – MIP Start -> Yes
CBC : MIP - MIP Start -> On

Marcel Hunting
AIMMS Software Developer

Gustavo Simão

unread,
Sep 9, 2011, 4:04:56 PM9/9/11
to AIMMS - The Modeling System
Hi Marcel and Okan!

I have the same problem, but I don´t know how to assign the initial
solution values of my variables.

thanks,

Gustavo

Pim

unread,
Sep 11, 2011, 9:34:00 PM9/11/11
to AIMMS - The Modeling System
Hi,

After setting the options that Marcel indicated the solver will pick
up the so-called level values of the variables as initial solution
values, so you can provide your initial solution by simply assigning
values to the variables before doing a solve.

Pim

Viet Anh Nguyen

unread,
Sep 17, 2011, 11:21:01 AM9/17/11
to AIMMS - The Modeling System
An important point is that the initial solution has to be a feasible
solution to the MP, otherwise the initial solution will be rejected.

In our problem, we found out that our optimal solution of the last
iteration (with n bins, for example) is not a feasible to the current
iteration (with n+1 bins). We then decided to use explicit constraints
(insert constraints in the declaration) instead of using the variable
definitions, and everything worked out nicely. We do not have to write
any GMP code, just implement as Pim and Marcel have suggested.

@Okan: I took the idea from this article
http://yetanothermathprogrammingconsultant.blogspot.com/2011/08/bin-packing.html
, and what I wanted is just a simple greedy heuristics to see whether
I can perform better than the 17 bins the blogger is reporting.

Viet Anh
Reply all
Reply to author
Forward
0 new messages