91 virtual std::string appName ()
175 CouenneMINLPInterface ();
191 problem_ = tminlp2tnlp;}
194 CouenneMINLPInterface (
const CouenneMINLPInterface &);
200 CouenneMINLPInterface &
operator=(
const CouenneMINLPInterface& rhs);
203 virtual ~CouenneMINLPInterface ();
206 void readOptionFile(
const std::string & fileName);
209 const Ipopt::SmartPtr<Ipopt::OptionsList>
options()
const;
212 Ipopt::SmartPtr<Ipopt::OptionsList>
options();
232 virtual void resolveForCost(
int numretry,
bool keepWs);
237 virtual void resolveForRobustness(
int numretry);
260 void continuingOnAFailure()
262 hasContinuedAfterNlpFailure_ =
true;
266 bool hasContinuedOnAFailure()
268 return hasContinuedAfterNlpFailure_;
272 void ignoreFailures()
274 pretendFailIsInfeasible_ = 2;
278 void forceInfeasible()
280 problem_->set_obj_value(1e200);
284 void forceBranchable()
286 problem_->set_obj_value(-1e200);
287 problem_->force_fractionnal_sol();
313 bool setStrParam(OsiStrParam key,
const std::string & value);
315 bool getIntParam(OsiIntParam key,
int& value)
const;
317 bool getDblParam(OsiDblParam key,
double& value)
const;
319 bool getStrParam(OsiStrParam key, std::string& value)
const;
322 inline double getPushFact()
const
407 virtual bool isBinary(
int columnNumber)
const;
412 virtual bool isInteger (
int columnNumber)
const;
424 const int * getPriorities()
const
426 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
428 return branch->priorities;
433 const int * getBranchingDirections()
const
435 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
437 return branch->branchingDirections;
441 const double * getUpPsCosts()
const
443 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
445 return branch->upPsCosts;
449 const double * getDownPsCosts()
const
451 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
453 return branch->downPsCosts;
484 int nCallOptimizeTNLP()
486 return nCallOptimizeTNLP_;
490 double totalNlpSolveTime()
492 return totalNlpSolveTime_;
496 int totalIterations()
498 return totalIterations_;
511 virtual void setColLower(
int elementIndex,
double elementValue );
515 virtual void setColUpper(
int elementIndex,
double elementValue );
530 virtual void setRowLower(
int elementIndex,
double elementValue );
533 virtual void setRowUpper(
int elementIndex,
double elementValue );
536 virtual void setRowType(
int index,
char sense,
double rightHandSide,
579 virtual bool setWarmStart(
const CoinWarmStart* warmstart);
581 void setExposeWarmStart(
bool value) {
582 exposeWarmStart_ = value;
585 bool getExposeWarmStart() {
586 return exposeWarmStart_;
589 void randomStartingPoint();
595 throw SimpleError(
"Needs coding for this interface",
"basisIsAvailable");
611 void setNumIterationSuspect(
int value)
613 numIterationSuspect_ = value;
655 virtual void setObjCoeff(
int elementIndex,
double elementValue )
657 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
663 virtual void addCol(
const CoinPackedVectorBase& vec,
664 const double collb,
const double colub,
667 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
673 virtual void deleteCols(
const int num,
const int * colIndices)
675 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
681 virtual void addRow(
const CoinPackedVectorBase& vec,
682 const double rowlb,
const double rowub)
684 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
690 virtual void addRow(
const CoinPackedVectorBase& vec,
691 const char rowsen,
const double rowrhs,
694 throw SimpleError(
"CouenneMINLPInterface model does not implement this function.",
699 virtual void deleteRows(
const int num,
const int * rowIndices)
703 problem_->removeCuts(num, rowIndices);
709 virtual void loadProblem(
const CoinPackedMatrix& matrix,
710 const double* collb,
const double* colub,
712 const double* rowlb,
const double* rowub)
714 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
722 double*& collb,
double*& colub,
double*& obj,
723 double*& rowlb,
double*& rowub)
725 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
731 virtual void loadProblem(
const CoinPackedMatrix& matrix,
732 const double* collb,
const double* colub,
734 const char* rowsen,
const double* rowrhs,
735 const double* rowrng)
737 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
744 double*& collb,
double*& colub,
double*& obj,
745 char*& rowsen,
double*& rowrhs,
748 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
755 virtual void loadProblem(
const int numcols,
const int numrows,
756 const int* start,
const int* index,
758 const double* collb,
const double* colub,
760 const double* rowlb,
const double* rowub)
762 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
768 virtual void loadProblem(
const int numcols,
const int numrows,
769 const int* start,
const int* index,
771 const double* collb,
const double* colub,
773 const char* rowsen,
const double* rowrhs,
774 const double* rowrng)
776 throw SimpleError(
"CouenneMINLPInterface model does not implement this function.",
782 virtual int readMps(
const char *filename,
783 const char *extension =
"mps")
785 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
792 virtual void writeMps(
const char *filename,
793 const char *extension =
"mps",
794 double objSense=0.0)
const
796 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
801 virtual std::vector<double*>
getDualRays(
int maxNumRays)
const
803 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
808 virtual std::vector<double*>
getPrimalRays(
int maxNumRays)
const
810 throw SimpleError(
"CouenneMINLPInterface does not implement this function.",
825 void turnOffSolverOutput(){
826 app_->turnOffOutput();}
827 void turnOnSolverOutput(){
828 app_->turnOnOutput();}
839 const TMINLP2TNLP *
problem()
const
849 const TMINLP * model()
const
854 Bonmin::TMINLP * model()
859 const Bonmin::TNLPSolver * solver()
const
864 TNLPSolver * solver()
889 app_->enableWarmStart();
898 void getOuterApproximation(OsiCuts &cs,
bool getObj,
const double * x2,
bool global)
906 void getOuterApproximation(OsiCuts &cs,
const double * x,
bool getObj,
const double * x2,
bool global){
907 getOuterApproximation(cs, x, getObj, x2, 0., global);}
912 virtual void getOuterApproximation(OsiCuts &cs,
const double * x,
bool getObj,
const double * x2,
913 double theta,
bool global);
916 virtual void getConstraintOuterApproximation(OsiCuts & cs,
int constraintNumber,
918 const double * x2,
bool global);
921 void getConstraintOuterApproximation(OsiCuts & cs,
int constraintNumber,
922 const double * x2,
bool global){
923 getConstraintOuterApproximation(cs, constraintNumber,
getColSolution(),x2,global);
927 void getBendersCut(OsiCuts &cs,
const double * x,
const double *lambda,
bool getObj = 1);
936 double getFeasibilityOuterApproximation(
int n,
const double * x_bar,
const int *ind, OsiCuts &cs,
bool addOnlyViolated,
bool global);
947 double solveFeasibilityProblem(
int n,
const double * x_bar,
const int* ind,
double a,
double s,
int L);
957 double solveFeasibilityProblem(
int n,
const double * x_bar,
const int* ind,
int L,
double cutoff);
961 void switchToFeasibilityProblem(
int n,
const double * x_bar,
const int* ind,
double a,
double s,
int L);
965 void switchToFeasibilityProblem(
int n,
const double * x_bar,
const int* ind,
966 double rhs_local_branching_constraint);
969 void switchToOriginalProblem();
976 enum OaMessagesTypes {
977 CUT_NOT_VIOLATED_ENOUGH = 0,
978 VIOLATED_OA_CUT_GENERATED,
980 OA_MESSAGES_DUMMY_END
984 class OaMessages :
public CoinMessages{
991 class OaMessageHandler :
public CoinMessageHandler{
994 OaMessageHandler():CoinMessageHandler(){
997 OaMessageHandler(FILE * fp):CoinMessageHandler(fp){
1000 virtual ~OaMessageHandler(){
1003 OaMessageHandler(
const OaMessageHandler &other):
1004 CoinMessageHandler(other){}
1006 OaMessageHandler(
const CoinMessageHandler &other):
1007 CoinMessageHandler(other){}
1009 OaMessageHandler & operator=(
const OaMessageHandler &rhs){
1013 virtual CoinMessageHandler* clone()
const{
1014 return new OaMessageHandler(*
this);}
1016 void print(OsiRowCut &row);
1019 void setOaMessageHandler(
const CoinMessageHandler &handler){
1021 oaHandler_ =
new OaMessageHandler(handler);
1028 virtual ApplyCutsReturnCode
applyCuts(
const OsiCuts & cs,
1029 double effectivenessLb = 0.0){
1031 problem_->addCuts(cs);
1032 ApplyCutsReturnCode rc;
1036 virtual void applyRowCuts(
int numberCuts,
const OsiRowCut * cuts);
1040 virtual void applyRowCuts(
int numberCuts,
const OsiRowCut ** cuts)
1044 problem_->addCuts(numberCuts, cuts);
1048 obj the objective value of x.
1049 double getConstraintsViolation(
const double * x,
double & obj);
1052 value where obj is the estimated objective value of x.
1053 double getNonLinearitiesViolation(
const double *x,
const double obj);
1057 void extractInterfaceParams();
1061 virtual void setAppDefaultOptions(Ipopt::SmartPtr<Ipopt::OptionsList> Options);
1064 static void registerOptions (Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
1066 Ipopt::SmartPtr<Bonmin::RegisteredOptions> regOptions(){
1068 return app_->roptions();
1076 void SetStrongBrachingSolver(Ipopt::SmartPtr<StrongBranchingSolver> strong_branching_solver);
1093 enum RandomGenerationType{
1094 uniform =0, perturb=1, perturb_suffix=2};
1096 int initializeJacobianArrays();
1103 void solveAndCheckErrors(
bool doResolve,
bool throwOnFailure,
1104 const char * whereFrom);
1111 const OsiRowCut * cut = &rc;
1112 problem_->addCuts(1, &cut);
1118 throw SimpleError(
"Ipopt model does not implement this function.",
1130 Ipopt::SmartPtr<TMINLP> tminlp_;
1132 Ipopt::SmartPtr<TMINLP2TNLP> problem_;
1134 Ipopt::SmartPtr<Ipopt::TNLP> problem_to_optimize_;
1136 bool feasibility_mode_;
1138 Ipopt::SmartPtr<TNLPSolver> app_;
1141 std::list<Ipopt::SmartPtr<TNLPSolver> > debug_apps_;
1147 CoinWarmStart* warmstart_;
1152 void freeCachedColRim();
1154 void freeCachedRowRim();
1156 void freeCachedData();
1159 void extractSenseRhsAndRange()
const;
1161 mutable char *rowsense_;
1164 mutable double *rhs_;
1167 mutable double *rowrange_;
1170 mutable double *reducedCosts_;
1172 double OsiDualObjectiveLimit_;
1174 mutable bool hasVarNamesFile_;
1177 int nCallOptimizeTNLP_;
1179 double totalNlpSolveTime_;
1181 int totalIterations_;
1183 double maxRandomRadius_;
1185 int randomGenerationType_;
1187 double max_perturbation_;
1191 int numRetryInitial_;
1193 int numRetryResolve_;
1195 int numRetryInfeasibles_;
1197 int numRetryUnsolved_;
1203 int pretendFailIsInfeasible_;
1205 bool hasContinuedAfterNlpFailure_;
1208 int numIterationSuspect_ ;
1212 bool hasBeenOptimized_;
1216 mutable double * obj_;
1218 static bool hasPrintedOptions;
1221 Ipopt::SmartPtr<TNLP2FPNLP> feasibilityProblem_;
1248 TNLPSolver::ReturnStatus optimizationStatus_;
1250 bool exposeWarmStart_;
1254 SmartPtr<CutStrengthener> cutStrengthener_;
1260 OaMessages oaMessages_;
1262 OaMessageHandler * oaHandler_;
1266 void createApplication(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
1267 Ipopt::SmartPtr<Ipopt::OptionsList>
options,
1268 Ipopt::SmartPtr<Ipopt::Journalist> journalist);
1270 CouenneMINLPInterface(Ipopt::SmartPtr<TNLPSolver> app);
1273 bool internal_setWarmStart(
const CoinWarmStart* ws);
1276 CoinWarmStart* internal_getWarmStart()
const;
1279 SmartPtr<StrongBranchingSolver> strong_branching_solver_;
1281 TNLPSolver::ReturnStatus optimizationStatusBeforeHotStart_;
1282 static const char * OPT_SYMB;
1283 static const char * FAILED_SYMB;
1284 static const char * INFEAS_SYMB;
1285 static const char * UNBOUND_SYMB;
1287 const char * statusAsString(TNLPSolver::ReturnStatus r){
1288 if(r == TNLPSolver::solvedOptimal || r == TNLPSolver::solvedOptimalTol){
1290 else if(r == TNLPSolver::provenInfeasible){
1291 return INFEAS_SYMB;}
1292 else if(r == TNLPSolver::unbounded){
1293 return UNBOUND_SYMB;}
1294 else return FAILED_SYMB;
1296 const char * statusAsString(){
1297 return statusAsString(optimizationStatus_);}