[Coin-discuss] OsiSolverInterface use and in particular OsiClpSolverInterface
Vivian De Smedt
vivian at vdesmedt.com
Mon Dec 16 14:58:12 EST 2002
Dear Osi,
To reply to FP Fasno mail asking complementary information about my problem.
In my experience of OsiSolverInterface based on Cplex and Glpk interface
implementation lead me to define problem following the next recipe:
- starting with an empty model
- adding columns with no content
- adding rows with coefficient
- set the sense
In attachement you will find a program that work only if the INIT flag is
defined.
It equivalent work fine for Cplex, Glpk and Vol algorhithme (that last one
version should replace infinite bound of variable by finite one but that's
an explicit limitation of the solver).
Hoping that it help to understand what I mean in my previous mail.
Thank to every one for your reply and contributions.
Vivian De Smedt.
-------------- next part --------------
#pragma warning(disable:4786)
#include <stdio.h>
#include "OsiClpSolverInterface.hpp"
#include "CoinPackedVector.hpp"
int main()
{
OsiClpSolverInterface *s = new OsiClpSolverInterface();
double dEmpty = 0;
int iEmpty = 0;
char cEmpty = '?';
#ifdef INIT
s->loadProblem(0, 0, &iEmpty, &iEmpty, &dEmpty, &dEmpty, &dEmpty, &dEmpty, &dEmpty, &dEmpty);
double inf = s->getInfinity();
CoinPackedVector c;
#endif
s->addCol(c, 0, inf, 3);
s->addCol(c, 0, inf, 1);
CoinPackedVector r1;
r1.insert(0, 2);
r1.insert(1, 1);
s->addRow(r1, -inf, 10);
CoinPackedVector r2;
r2.insert(0, 1);
r2.insert(1, 3);
s->addRow(r2, -inf, 15);
s->setObjSense(-1);
s->resolve();
printf("%f %f\n", s->getColSolution()[0], s->getColSolution()[1]);
s->setObjCoeff(0, 1);
s->setObjCoeff(1, 1);
s->resolve();
printf("%f %f\n", s->getColSolution()[0], s->getColSolution()[1]);
return 0;
}
More information about the Coin-discuss
mailing list