21 b.
options()->GetNumericValue(
"tiny_element",
tiny_,
"bonmin.");
26 OsiSolverInterface *si,
27 const double *
x,
bool getObj)
34 Ipopt::TNLP::IndexStyleEnum index_style;
39 model->
get_nlp_info( n, m, nnz_jac_g, nnz_h_lag, index_style);
46 model->
eval_jac_g(n, x, 1, m, nnz_jac_g, &iRow[0], &jCol[0], NULL);
47 model->
eval_jac_g(n, x, 1, m, nnz_jac_g, NULL, NULL, &vals[0]);
50 if(index_style == Ipopt::TNLP::FORTRAN_STYLE){
51 for(
int k = 0 ;
k < nnz_jac_g ;
k++){
57 model->
eval_g(n, x, 1, m, &g[0]);
64 model->
get_bounds_info(n, &colLow[0], &colUp[0], m, &rowLow[0], &rowUp[0]);
66 double infty = si->getInfinity();
67 double nlp_infty =
infty;
71 for(
int i = 0 ; i <
m ; i++) {
72 if(rowLow[i] > - nlp_infty){
73 rowLow[i] = (rowLow[i] - g[i]);
76 if(rowUp[i] < nlp_infty){
77 rowUp[i] = (rowUp[i] - g[i]);
84 for(
int i = 0 ; i < nnz_jac_g ; i++) {
86 cleanNnz(vals[i],colLow[jCol[i]], colUp[jCol[i]],
87 rowLow[iRow[i]], rowUp[iRow[i]],
91 rowLow[iRow[i]] += vals[i] * x[jCol[i]];
92 rowUp[iRow[i]] += vals[i] *x[jCol[i]];
95 CoinPackedMatrix mat(
true, &iRow[0], &jCol[0], &vals[0], nnz_jac_g);
96 mat.setDimensions(m,n);
100 si->loadProblem(mat, &colLow[0], &colUp[0], &obj[0], &rowLow[0], &rowUp[0]);
102 for(
int i = 0 ; i <
n ; i++) {
108 std::cout<<
"Linear stuff"<<std::endl;
110 model->
eval_f(n, &obj[0], 1, zero);
111 si->setDblParam(OsiObjOffset, -zero);
117 si->setObjective(&obj[0]);
124 si->addCol(a,-si->getInfinity(), si->getInfinity(), 1.);
130 model->
eval_f(n, x, 1, ub);
133 CoinPackedVector objCut;
134 CoinPackedVector * v = &objCut;
136 for(
int i = 0; i<
n ; i++) {
139 if(
cleanNnz(obj[i],colLow[i], colUp[i],
140 -si->getInfinity(), 0,
151 if(
cleanNnz(obj[i],colLow[i], colUp[i],
152 -si->getInfinity(), 0,
163 si->addRow(objCut, lb, ub);
168 std::ostringstream os;
171 std::string f_name = os.str();
172 si->writeMps(f_name.c_str());
bool cleanNnz(double &value, double colLower, double colUpper, double rowLower, double rowUpper, double colsol, double &lb, double &ub, double tiny, double veryTiny)
Facilitator to clean up coefficient.
const TMINLP2TNLP * problem() const
get pointer to the TMINLP2TNLP adapter
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
virtual bool isInteger(int columnNumber) const
Return true if column is integer.
void fint fint fint real * a
void extractLinearRelaxation(Bonmin::OsiTMINLPInterface &minlp, OsiSolverInterface *si, const double *x, bool getObj)
Build the Outer approximation in minlp and put it in si.
void fint fint fint real fint real real real real real real real real real * e
virtual bool get_constraints_linearity(Ipopt::Index m, LinearityType *const_types)
Returns the constraint linearity.
A class to have all elements necessary to setup a branch-and-bound.
void initialize(Bonmin::BabSetupBase &b)
Initialize using options.
double tiny_
If constraint coefficient is below this, we try to remove it.
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
The caller is allowed to modify the bounds, so this method returns the internal bounds information...
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Returns the vector of constraint values in x.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Returns the vector of the gradient of the objective w.r.t.
double veryTiny_
If constraint coefficient is below this, we neglect it.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
void fint fint fint real fint real real real real real real * g
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Returns the value of the objective function in x.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, TNLP::IndexStyleEnum &index_style)
This call is just passed onto the TMINLP object.
virtual bool hasLinearObjective()
returns true if objective is linear.
static int nTimesCalled
Count the number of linear outer approximations taken.
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Returns the jacobian of the constraints.
void fint fint fint real fint real * x