12 #include "CoinHelperFunctions.hpp"
13 #include "CoinTime.hpp"
27 #define THRESHOLD_OUTPUT_REFORMULATE 1000
29 using namespace Couenne;
34 double now = CoinCpuTime ();
37 jnlst_ -> Printf (Ipopt::J_ERROR,
J_COUENNE,
"Reformulating problem: ");
49 for (
int i =
nVars(); i--;) {
59 for (std::vector <exprVar *>::iterator i =
variables_.begin ();
73 "Problem size before reformulation: %d variables (%d integer), %d constraints.\n",
80 "Problem infeasible after reformulation\n");
82 for (
int i =
nVars (); i--;)
83 Ub (i) = - (
Lb (i) = 1.);
95 bool *isInt =
new bool[
nVars()];
96 for(
int i=0; i<
nVars(); i++) {
113 int objind =
objectives_ [0] -> Body () -> Index ();
114 cutoff = objind >= 0 ?
X (objind) :
objectives_ [0] -> Body () -> Value ();
121 "Couenne: initial solution (value %g) is MINLP feasible\n",
124 #ifdef FM_TRACE_OPTSOL
139 int objind =
objectives_ [0] -> Body () -> Index ();
140 cutoff = objind >= 0 ?
X (objind) :
objectives_ [0] -> Body () -> Value ();
144 "Couenne: initial solution (value %g) is MINLP feasible\n",
147 #ifdef FM_TRACE_OPTSOL
172 jnlst_->Printf (Ipopt::J_WARNING,
J_PROBLEM,
"Initializing auxiliaries\n");
180 for (
int i=0; i<
nVars(); i++)
189 "Problem size after reformulation: %d variables (%d integer), %d constraints.\n",
198 art_cutoff = COIN_DBL_MAX,
199 art_lower = -COIN_DBL_MAX;
201 bonBase_ -> options() -> GetNumericValue (
"art_cutoff", art_cutoff,
"couenne.");
202 bonBase_ -> options() -> GetNumericValue (
"art_lower", art_lower,
"couenne.");
204 if (art_cutoff < 1.e50)
setCutOff (art_cutoff);
205 if (art_lower > -1.e50) {
206 int indobj =
objectives_ [0] -> Body () -> Index ();
220 jnlst_ -> Printf (Ipopt::J_ERROR,
J_COUENNE,
"%.1f seconds\n", CoinCpuTime () - now);
222 jnlst_ -> Printf (Ipopt::J_ERROR,
J_COUENNE,
"Reformulation: %.1f seconds\n", CoinCpuTime () - now);
Cut Generator for linear convexifications.
void realign()
clear all spurious variables pointers not referring to the variables_ vector
int nVars() const
Total number of variables.
void update(const double *givenSol, const int givenCard, const double givenVal, const double givenMaxViol)
std::vector< CouenneObjective * > objectives_
Objectives.
int nIntVars_
Number of discrete variables.
int nOrigCons_
Number of original constraints (disregarding those that turned into auxiliary variable definition) ...
CouNumber & lb(register int index)
current lower bound
void print(std::ostream &=std::cout)
Display current representation of problem: objective, linear and nonlinear constraints, and auxiliary variables.
void setCutOff(CouNumber cutoff, const CouNumber *sol=NULL) const
Set cutoff.
int nOrigIntVars_
Number of original integer variables.
bool checkNLP2(const double *solution, const double obj, const bool careAboutObj, const bool stopAtFirstViol, const bool checkAll, const double precision) const
Return true if either solution or recomputed_solution obtained using getAuxs() from the original vari...
Domain * domain() const
return current point & bounds
int nIntVars() const
Number of integer variables.
void setInitIsInt(const bool *givenIsInt, const int givenCard)
CouenneRecordBestSol * getRecordBestSol() const
returns recorded best solution
void setupSymmetry()
empty if no NTY, symmetry data structure setup otherwise
Bonmin::BabSetupBase * bonBase_
options
std::vector< CouenneConstraint * > constraints_
Constraints.
void setInitDomUb(const CouNumber *givenUb, const int givenCard)
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
CouenneRecordBestSol * recBSol
Domain domain_
current point and bounds;
CouNumber * Ub() const
Return vector of upper bounds.
bool standardize()
Break problem's nonlinear constraints in simple expressions to be convexified later.
bool orbitalBranching_
use orbital branching?
void fillQuadIndices()
Look for quadratic terms to be used with SDP cuts.
void initAuxs() const
Initialize auxiliary variables and their bounds from original variables.
double CouNumber
main number type in Couenne
void reformulate(CouenneCutGenerator *=NULL)
preprocess problem in order to extract linear relaxations etc.
int nOrigVars_
Number of original variables.
CouNumber * X() const
Return vector of variables.
bool readOptimum(std::string *fname=NULL)
Read best known solution from file given in argument.
void createUnusedOriginals()
Some originals may be unused due to their zero multiplicity (that happens when they are duplicates)...
void push(int dim, CouNumber *x, CouNumber *lb, CouNumber *ub, bool copy=true)
save current point and start using another
int nCons() const
Get number of constraints.
double getFeasTol()
returns feasibility tolerance
JnlstPtr jnlst_
SmartPointer to the Journalist.
bool checkNLP(const double *solution, double &obj, bool recompute=false) const
Check if solution is MINLP feasible.
DomainPoint * current()
return current point
const Ipopt::EJournalCategory J_COUENNE(Ipopt::J_USER8)
const Ipopt::EJournalCategory J_PROBLEM(Ipopt::J_USER4)
void fillDependence(Bonmin::BabSetupBase *base, CouenneCutGenerator *=NULL)
fill dependence_ structure
void setInitDomLb(const CouNumber *givenLb, const int givenCard)
void fint fint fint real fint real * x
CouNumber * Lb() const
Return vector of lower bounds.
bool isInteger(CouNumber x)
is this number integer?