[Osi] Problem using FlopC++ with GLPK

Stefan Vigerske stefan at math.hu-berlin.de
Sun Sep 20 12:33:38 EDT 2009


Hi,

having a closer look, I think the problem is partly in FlopC++ and
partly in Glpk.

The call MP_variable x(N); creates variables with upper bound 9.9e+32,
which are then passed as upper bounds to Glpk.
Since glpk's value for infinity is around 1.79769e+308, it does see
infinity as upper bound, but 9.9e+32.
With such large values, Glpk does not behave well.

One workaround I see is to add the line
    MP_model::getDefaultModel().Solver=new OsiGlpkSolverInterface;
in the beginning.
Then FlopC++ initializes the variable upper bounds with
OsiGlpk::getInfinity(), which gives the correct value.

See here for the essential codeline in FlopC++:
https://projects.coin-or.org/FlopC++/browser/releases/1.0.6/FlopCpp/src/MP_model.cpp#L90

I tried only Glpk 4.37, but think that 4.38 should work fine too.

Stefan

Ted Ralphs schrieb:
> It's very possible that you are the first to try that particular
> combination, but if things are working with Cbc, I would say that the
> problem must either be with Glpk itself or with the implementation of
> OsiGlpk. If you want to try to debug it, you should be able to create
> the same MIP in LP format and put it directly into OsiGlpk and see
> what happens then. aving a test case within Osi will definitely help
> us find the problem. Unfortunately, I'm not sure if anyone is actively
> developing FlopC++ at the moment, but if the problem is with OsiGlpk,
> we should be able to fix it.
> 
> Cheers,
> 
> Ted
> 
> On Sat, Sep 19, 2009 at 12:03 PM, Renato Bruni <bruni at diei.unipg.it> wrote:
>> Yes, I tried cbc and it works good.
>> Does anybody know if there are incompatibilities between the versions
>> of  FlopC++ 1.0.6 and GLPK 4.38? In this case, which version of
>> GLPK should be used?
>>
>> Thanks,
>> Renato
>>
>> ----- Original Message ----- From: "Ted Ralphs" <ted at lehigh.edu>
>> To: "Renato Bruni" <renato.bruni at diei.unipg.it>
>> Cc: <osi at list.coin-or.org>
>> Sent: Saturday, September 19, 2009 4:06 PM
>> Subject: Re: [Osi] Problem using FlopC++ with GLPK
>>
>>
>> Did you try it with another solver to see if the result is the same?
>> This would tell you whether the problems is with FlopC++ or
>> Glpk/OsiGlpk.
>>
>> Cheers,
>>
>> Ted
>>
>> On Thu, Sep 17, 2009 at 12:33 PM, Renato Bruni
>> <renato.bruni at diei.unipg.it> wrote:
>>> Hello everybody,
>>>
>>> we have some strange behaviour using FlopC++ 1.0.6 (having inside Osi
>>> 0.100.0) and GLPK 4.38.
>>>
>>> If we run the following example, with 5 variables and 2 constraints, we
>>> obtain solution x=(0, 2, 0, 0, 0) and objective= 2
>>> but the solution should be x=(4, 0, 0, 0, 0) and objective= 4
>>>
>>> #include "flopc.hpp"
>>> using namespace flopc;
>>> #include <OsiGlpkSolverInterface.hpp>
>>>
>>> int main() {
>>> MP_model modello(new OsiGlpkSolverInterface);
>>> MP_set N(5);
>>> MP_variable x(N);
>>> x.integer();
>>>
>>> MP_constraint vinc1;
>>> MP_constraint vinc2;
>>> vinc1 = 2*x(0) + 4*x(1) + 6*x(4) == 8;
>>> vinc2 = x(0) + x(4) <= 100;
>>> modello.add(vinc1);
>>> modello.add(vinc2);
>>>
>>> modello.maximize( x(0) + x(1) + x(4) );
>>> x.display("Optimal solution per x:");
>>> }
>>>
>>> If we run this other example, that is the same model with 5 variables and
>>> 2 constraints, we obtain solution x=(4, 0, 0, 0, 96) and objective= 4
>>> but the solution should be, like before, x=(4, 0, 0, 0, 0) and objective=
>>> 4
>>>
>>> #include "flopc.hpp"
>>> using namespace flopc;
>>> #include <OsiGlpkSolverInterface.hpp>
>>>
>>> int main() {
>>> MP_model modello(new OsiGlpkSolverInterface);
>>> MP_set N(5);
>>> MP_set S(5);
>>> MP_subset<1> Sub(S);
>>> Sub.insert(0);
>>> Sub.insert(1);
>>> Sub.insert(4);
>>>
>>> MP_variable x(N);
>>> x.integer();
>>>
>>> MP_data COEFF(Sub);
>>> int i;
>>> for(i=0; i<Sub.size();i++)
>>> COEFF(i)= 2*(i+1);//vector COEFF={2,4,6}
>>> COEFF.display("COEFF ");
>>>
>>> MP_constraint vinc1;
>>> MP_constraint vinc2;
>>> vinc1 = sum(Sub, COEFF(Sub)*x(Sub))==8;//2x0+4x1+6x4==8
>>> vinc2 = x(0) + x(4) <= 100;
>>> modello.add(vinc1);
>>> modello.add(vinc2);
>>>
>>> modello.maximize( sum(Sub, x(Sub)) );//max(x(0)+x(1)+x(4))
>>> x.display("Optimal solution per x:");
>>> }
>>>
>>> Which can be the reason(s) of this incorrect behaviour?
>>> Are there incompatibilities between the versions of FlopC++ 1.0.6 and GLPK
>>> 4.38? In this case, which version of GLPK should be used?
>>>
>>> Thanks for your help.
>>> Best regards,
>>> Renato Bruni
>>>
>>>
>>> _______________________________________________
>>> Osi mailing list
>>> Osi at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/osi
>>>
>>
>>
>> --
>> Dr. Ted Ralphs
>> Associate Professor, Lehigh University
>> (610) 628-1280
>> ted 'at' lehigh 'dot' edu
>> coral.ie.lehigh.edu/~ted
>>
>>
>> _______________________________________________
>> Osi mailing list
>> Osi at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/osi
>>
>>
> 
> 
> 




More information about the Osi mailing list