[Coin-lpsolver] ClpSolve problem
John J Forrest
jjforre at us.ibm.com
Sun Jul 3 12:42:10 EDT 2005
Totally my stupidity - is it better now.
I have added your patches (they broke CBC but I fixed that)
John
François Galea <francois.galea at prism.uvsq.fr>
Sent by: coin-lpsolver-bounces at list.coin-or.org
06/30/2005 07:01 AM
To
coin-lpsolver at list.coin-or.org
cc
Subject
[Coin-lpsolver] ClpSolve problem
Hello,
I have met several segmentation fault errors, when I use the
ClpSimplex::initialSolve( ClpSolve & ) method for starting a new solve.
The example attached program doesn't work, if I choose to switch
presolve off. If I switch it on, everything works (provided the Clp
sources have been patched with the patch I sent before, otherwise the
names changes won't work). Some other pieces of code I've got crash even
if I set presolve on.
I haven't understood enough the internals of ClpSimplex and ClpModel to
be sure about what is wrong.
Could somebody tell me what's wrong ?
Thanks,
François
--
François Galea
Equipe OPALE - Laboratoire PRiSM
Université de Versailles-Saint Quentin en Yvelines
45 av Etats-Unis F-78035 Versailles CEDEX
Tél. : +33 1 39 25 40 50
#include <cstdio>
#include "ClpSimplex.hpp"
#include "CoinBuild.hpp"
int main( int argc, char * argv[] )
{
const static struct { double a, b, c, d; } p [] =
{
{ 5.0, 0.0, 7.0, 3.0 },
{ 8.0, 0.0, 7.0, 6.0 },
{ 0.0, 10.0, 3.0, 9.0 },
{ 1.0, 8.0, 5.0, 9.0 },
{ 2.0, 0.0, 0.0, 7.0 },
{ 0.0, 4.0, 5.0, 0.0 },
{ 0.0, 1.0, 6.0, 2.0 },
{ 2.0, 0.0, 8.0, 3.0 }
};
const static char * columnNames [2] = { "x", "y" };
double k, obj;
char buf[ 10 ];
char * rowname = buf;
double val[ 2 ];
int ind[ 2 ];
unsigned int i;
const double * sol;
ClpSimplex lp;
CoinBuild * buildObject;
ClpSolve * solveOptions;
lp.setStrParam( ClpProbName, "foo" );
buildObject = new CoinBuild( 1 );
buildObject->addCol( 0, NULL, NULL, 0.0, +COIN_DBL_MAX, 4 );
buildObject->addCol( 0, NULL, NULL, 0.0, +COIN_DBL_MAX, 3 );
lp.addColumns( *buildObject );
delete buildObject;
lp.copyColumnNames( columnNames, 0, 2 );
buildObject = new CoinBuild( 0 );
ind[ 0 ] = 0;
ind[ 1 ] = 1;
for( i = 0; i < (sizeof( p ) / sizeof( p[0] )); i++ )
{
k = p[i].a * p[i].d - p[i].c * p[i].b;
val[0] = (p[i].d-p[i].b)/k;
val[1] = (p[i].a-p[i].c)/k;
if( ((1.0-val[0]*4.0)/val[1]) > 5.0 )
buildObject->addRow( 2, ind, val, 0.0, 1.0 );
else
buildObject->addRow( 2, ind, val, 1.0, +COIN_DBL_MAX );
}
lp.setOptimizationDirection( -1.0 );
lp.addRows( *buildObject );
for( i = 0; i < (sizeof( p ) / sizeof( p[0] )); i++ )
{
sprintf( buf, "c%d", i );
lp.copyRowNames( &rowname, i, i+1 );
}
delete buildObject;
solveOptions = new ClpSolve();
solveOptions->setSolveType( ClpSolve::useDual );
solveOptions->setPresolveType( ClpSolve::presolveOff, 0 );
// solveOptions->setPresolveType( ClpSolve::presolveOn, 5 );
lp.setLogLevel( 1 );
lp.initialSolve( *solveOptions );
delete solveOptions;
lp.writeMps( "foo.mps" );
obj = -lp.rawObjectiveValue();
sol = lp.getColSolution();
printf( "obj = %f\nx = %f\ny = %f\n", obj, sol[ 0 ], sol[ 1 ] );
return 0;
}
_______________________________________________
Coin-lpsolver mailing list
Coin-lpsolver at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-lpsolver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/clp/attachments/20050703/2a4a074b/attachment.html>
More information about the Clp
mailing list