Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

BCP_lp_result.cpp

00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include "CoinHelperFunctions.hpp"
00005 #include "OsiSolverInterface.hpp"
00006 #include "BCP_lp_result.hpp"
00007 
00008 static inline int BCP_getTermcode(OsiSolverInterface& lp)
00009 {
00010    int tc = 0;
00011    tc |= (lp.isAbandoned() ? BCP_Abandoned : 0);
00012    tc |= (lp.isProvenOptimal() ? BCP_ProvenOptimal : 0);
00013    tc |= (lp.isProvenPrimalInfeasible() ? BCP_ProvenPrimalInf : 0);
00014    tc |= (lp.isProvenDualInfeasible() ? BCP_ProvenDualInf : 0);
00015    tc |= (lp.isPrimalObjectiveLimitReached() ? BCP_PrimalObjLimReached : 0);
00016    tc |= (lp.isDualObjectiveLimitReached() ? BCP_DualObjLimReached : 0);
00017    tc |= (lp.isIterationLimitReached() ? BCP_IterationLimit : 0);
00018   
00019   return tc;
00020 }
00021 
00022 void
00023 BCP_lp_result::get_results(OsiSolverInterface& lp_solver)
00024 {
00025   lp_solver.getDblParam(OsiPrimalTolerance, _primal_tolerance);
00026   lp_solver.getDblParam(OsiDualTolerance, _dual_tolerance);
00027   delete[] _x;
00028   delete[] _pi;
00029   delete[] _dj;
00030   delete[] _lhs;
00031   _x = 0;
00032   _pi = 0;
00033   _dj = 0;
00034   _lhs = 0;
00035 
00036   _termcode = BCP_getTermcode(lp_solver);
00037   if ((_termcode & BCP_Abandoned) == 0) {
00038     _iternum = lp_solver.getIterationCount();
00039     _objval = lp_solver.getObjValue();
00040     
00041     const int colnum = lp_solver.getNumCols();
00042     _x   = new double[colnum];
00043     CoinDisjointCopyN(lp_solver.getColSolution(), colnum, _x);
00044     _dj  = new double[colnum];
00045     CoinDisjointCopyN(lp_solver.getReducedCost(), colnum, _dj);
00046 
00047     const int rownum = lp_solver.getNumRows();
00048     _pi  = new double[rownum];
00049     CoinDisjointCopyN(lp_solver.getRowPrice(), rownum, _pi);
00050     _lhs = new double[rownum];
00051     CoinDisjointCopyN(lp_solver.getRowActivity(), rownum, _lhs);
00052   }
00053 }

Generated on Wed Dec 3 14:32:29 2003 for BCP by doxygen 1.3.5