BCP_lp_result.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 
4 #include "CoinHelperFunctions.hpp"
5 #include "OsiSolverInterface.hpp"
6 #include "BCP_lp_result.hpp"
7 
8 void
9 BCP_lp_result::get_results(OsiSolverInterface& lp)
10 {
11  lp.getDblParam(OsiPrimalTolerance, _primal_tolerance);
12  lp.getDblParam(OsiDualTolerance, _dual_tolerance);
13  lp.getStrParam(OsiSolverName, _solvername);
14  delete[] _x;
15  delete[] _pi;
16  delete[] _dj;
17  delete[] _lhs;
18  _x = 0;
19  _pi = 0;
20  _dj = 0;
21  _lhs = 0;
22 
23  _termcode = 0;
24  _termcode |= (lp.isAbandoned() ? BCP_Abandoned : 0);
25  _termcode |= (lp.isProvenOptimal() ? BCP_ProvenOptimal : 0);
26  _termcode |= (lp.isProvenPrimalInfeasible() ? BCP_ProvenPrimalInf : 0);
27  _termcode |= (lp.isProvenDualInfeasible() ? BCP_ProvenDualInf : 0);
28  if (_solvername != "Ipopt") {
29  _termcode |= (lp.isPrimalObjectiveLimitReached() ? BCP_PrimalObjLimReached : 0);
30  }
31  _termcode |= (lp.isDualObjectiveLimitReached() ? BCP_DualObjLimReached : 0);
32  _termcode |= (lp.isIterationLimitReached() ? BCP_IterationLimit : 0);
33 
34  if ((_termcode & BCP_Abandoned) == 0) {
35  _iternum = lp.getIterationCount();
36  _objval = lp.getObjValue();
37 
38  const int colnum = lp.getNumCols();
39  _x = new double[colnum];
40  CoinDisjointCopyN(lp.getColSolution(), colnum, _x);
41 
42  if (_solvername == "Ipopt") {
43  _dj = NULL;
44  } else {
45  _dj = new double[colnum];
46  CoinDisjointCopyN(lp.getReducedCost(), colnum, _dj);
47  }
48 
49  const int rownum = lp.getNumRows();
50  _pi = new double[rownum];
51  CoinDisjointCopyN(lp.getRowPrice(), rownum, _pi);
52  _lhs = new double[rownum];
53  CoinDisjointCopyN(lp.getRowActivity(), rownum, _lhs);
54  }
55 }
double * _lhs
The left hand sides.
int _termcode
The termination code of the algorithm.
void fint fint fint real fint real real real real real real real real real fint real fint * lp
double _objval
The solution value.
int _iternum
The number of iterations the algorithm took (however the algorithm used interprets "iteration")...
double * _x
The primal solution.
double * _dj
The reduced costs.
double * _pi
The dual solution.
double _primal_tolerance
The zero-tolerance used by the LP solver for the primal solution.
double _dual_tolerance
The zero-tolerance used by the LP solver for the dual solution.
void get_results(OsiSolverInterface &lp_solver)
Get the result from the LP solver.
std::string _solvername
The name of the LP solver used.