9 #ifndef BonminTMINLP2OsiLP_H
10 #define BonminTMINLP2OsiLP_H
14 #include "IpSmartPtr.hpp"
18 class OsiSolverInterface;
46 void set_tols(
double tiny,
double very_tiny,
double rhs_relax,
double infty){
72 virtual void extract(OsiSolverInterface *si,
73 const double * x,
bool getObj) = 0;
81 virtual void get_oas(OsiCuts & cs,
82 const double * x,
bool getObj,
bool global)
const = 0;
88 inline bool cleanNnz(
double &value,
double colLower,
double colUpper,
89 double rowLower,
double rowUpper,
double colsol,
90 double & lb,
double &ub,
double tiny,
double veryTiny)
const;
114 Ipopt::SmartPtr<Bonmin::TMINLP2TNLP>
model_;
121 double rowLower,
double rowUpper,
double colsol,
122 double & lb,
double &ub,
double tiny,
double veryTiny)
const
124 if(fabs(value)>= tiny)
return 1;
127 if(fabs(value)<veryTiny)
return 0;
131 bool colUpBounded = colUpper < 10000;
132 bool colLoBounded = colLower > -10000;
133 bool rowNotLoBounded = rowLower <= - infty;
134 bool rowNotUpBounded = rowUpper >= infty;
135 bool pos = value > 0;
137 if(colLoBounded && !pos && rowNotUpBounded) {
138 lb += value * (colsol - colLower);
142 if(colLoBounded && pos && rowNotLoBounded) {
143 ub += value * (colsol - colLower);
147 if(colUpBounded && pos && rowNotUpBounded) {
148 lb += value * (colsol - colUpper);
152 if(colUpBounded && !pos && rowNotLoBounded) {
153 ub += value * (colsol - colUpper);
TMINLP2OsiLP(const TMINLP2OsiLP &other)
Copy constructor.
static int nTimesCalled
Count the number of linear outer approximations taken.
virtual TMINLP2OsiLP * clone() const =0
virtual copy constructor
double tiny_
If constraint coefficient is below this, we try to remove it.
Ipopt::SmartPtr< Bonmin::TMINLP2TNLP > model_
double rhs_relax_
Amount by which to relax OA constraints RHSes.
void set_tols(double tiny, double very_tiny, double rhs_relax, double infty)
TMINLP2OsiLP & operator=(const TMINLP2OsiLP &rhs)
Assignment operator.
double very_tiny_
If constraint coefficient is below this, we neglect it.
vector< double > value_
Values of jacobian.
virtual void get_oas(OsiCuts &cs, const double *x, bool getObj, bool global) const =0
Get OAs of nonlinear constraints in x.
void set_model(Bonmin::TMINLP2TNLP *model)
A transformer class to build outer approximations i.e.
bool cleanNnz(double &value, double colLower, double colUpper, double rowLower, double rowUpper, double colsol, double &lb, double &ub, double tiny, double veryTiny) const
Facilitator to clean up coefficient.
~TMINLP2OsiLP()
Destructor.
TMINLP2OsiLP()
Default constructor.
vector< int > jCol_
Cache Jacobian matrix.
void initialize_jac_storage()
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
virtual void get_refined_oa(OsiCuts &cs) const =0
Get OAs of nonlinear constraints in x.
vector< Ipopt::TNLP::LinearityType > const_types_
vector< int > iRow_
Rows of jacobian.
virtual void extract(OsiSolverInterface *si, const double *x, bool getObj)=0
Build the Outer approximation of model_ in x and put it in si.