Bonmin 1.4trunk
|
00001 // (C) Copyright International Business Machines Corporation, Carnegie Mellon University 2004, 2007 00002 // All Rights Reserved. 00003 // This code is published under the Common Public License. 00004 // 00005 // Authors : 00006 // Pierre Bonami, Carnegie Mellon University, 00007 // Carl D. Laird, Carnegie Mellon University, 00008 // Andreas Waechter, International Business Machines Corporation 00009 // 00010 // Date : 12/01/2004 00011 00012 00013 #ifndef OsiTMINLPInterface_H 00014 #define OsiTMINLPInterface_H 00015 00016 #define INT_BIAS 0e-8 00017 00018 #include <string> 00019 #include <iostream> 00020 00021 #include "OsiSolverInterface.hpp" 00022 #include "CoinWarmStartBasis.hpp" 00023 00024 #include "BonCutStrengthener.hpp" 00025 //#include "BonRegisteredOptions.hpp" 00026 00027 namespace Bonmin { 00028 class TMINLP; 00029 class TMINLP2TNLP; 00030 class TNLP2FPNLP; 00031 class TNLPSolver; 00032 class RegisteredOptions; 00033 class StrongBranchingSolver; 00034 00036 enum Solver{ 00037 EIpopt=0 , 00038 EFilterSQP , 00039 EAll 00040 }; 00047 class OsiTMINLPInterface : public OsiSolverInterface 00048 { 00049 friend class BonminParam; 00050 00051 public: 00052 00053 //############################################################################# 00054 00059 class SimpleError : public CoinError 00060 { 00061 private: 00062 SimpleError(); 00063 00064 public: 00066 SimpleError(std::string message, 00067 std::string methodName, 00068 std::string f = std::string(), 00069 int l = -1) 00070 : 00071 CoinError(message,methodName,std::string("OsiTMINLPInterface"), f, l) 00072 {} 00073 } 00074 ; 00075 00076 #ifdef __LINE__ 00077 #define SimpleError(x, y) SimpleError((x), (y), __FILE__, __LINE__) 00078 #endif 00079 00080 // Error when problem is not solved 00081 TNLPSolver::UnsolvedError * newUnsolvedError(int num, Ipopt::SmartPtr<TMINLP2TNLP> problem, std::string name){ 00082 return app_->newUnsolvedError(num, problem, name); 00083 } 00084 //############################################################################# 00085 00086 enum WarmStartModes{ 00087 None, 00088 FakeBasis, 00089 Optimum, 00090 InteriorPoint}; 00091 00093 enum MessagesTypes{ 00094 SOLUTION_FOUND, 00095 INFEASIBLE_SOLUTION_FOUND, 00096 UNSOLVED_PROBLEM_FOUND, 00097 WARNING_RESOLVING , 00098 WARN_SUCCESS_WS, 00099 WARN_SUCCESS_RANDOM, 00100 WARN_CONTINUING_ON_FAILURE, 00101 SUSPECT_PROBLEM, 00102 SUSPECT_PROBLEM2, 00103 IPOPT_SUMMARY , 00104 BETTER_SOL , 00105 LOG_HEAD, 00106 LOG_FIRST_LINE, 00107 LOG_LINE, 00108 ALTERNATE_OBJECTIVE, 00109 WARN_RESOLVE_BEFORE_INITIAL_SOLVE , 00112 ERROR_NO_TNLPSOLVER , 00113 WARNING_NON_CONVEX_OA , 00114 SOLVER_DISAGREE_STATUS , 00115 SOLVER_DISAGREE_VALUE , 00116 OSITMINLPINTERFACE_DUMMY_END 00117 }; 00118 00119 //############################################################################# 00120 00121 00123 class Messages : public CoinMessages 00124 { 00125 public: 00127 Messages(); 00128 }; 00129 00130 00131 //############################################################################# 00132 00133 00136 00137 OsiTMINLPInterface(); 00138 00140 void initialize(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions, 00141 Ipopt::SmartPtr<Ipopt::OptionsList> options, 00142 Ipopt::SmartPtr<Ipopt::Journalist> journalist, 00143 const std::string & prefix, 00144 Ipopt::SmartPtr<TMINLP> tminlp); 00145 00147 void initialize(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions, 00148 Ipopt::SmartPtr<Ipopt::OptionsList> options, 00149 Ipopt::SmartPtr<Ipopt::Journalist> journalist, 00150 Ipopt::SmartPtr<TMINLP> tminlp){ 00151 initialize(roptions, options, journalist, "bonmin.", tminlp); 00152 } 00153 00155 void setModel(Ipopt::SmartPtr<TMINLP> tminlp); 00157 void setSolver(Ipopt::SmartPtr<TNLPSolver> app); 00159 void use(Ipopt::SmartPtr<TMINLP2TNLP> tminlp2tnlp); 00162 OsiTMINLPInterface (const OsiTMINLPInterface &); 00163 00165 OsiSolverInterface * clone(bool copyData = true) const; 00166 00168 OsiTMINLPInterface & operator=(const OsiTMINLPInterface& rhs); 00169 00171 virtual ~OsiTMINLPInterface (); 00172 00173 00175 void readOptionFile(const std::string & fileName); 00176 00178 const Ipopt::SmartPtr<Ipopt::OptionsList> options() const; 00180 Ipopt::SmartPtr<Ipopt::OptionsList> options(); 00181 00182 const char * prefix() const{ 00183 if(!IsValid(app_)) { 00184 messageHandler()->message(ERROR_NO_TNLPSOLVER, messages_)<<CoinMessageEol; 00185 return NULL; 00186 } 00187 else 00188 return app_->prefix(); 00189 } 00191 //--------------------------------------------------------------------------- 00194 00195 virtual void initialSolve(); 00196 00198 virtual void initialSolve(const char * whereFrom); 00199 00205 virtual void resolve(); 00206 00212 virtual void resolve(const char * whereFrom); 00213 00216 virtual void resolveForCost(int numretry, bool keepWs); 00217 00221 virtual void resolveForRobustness(int numretry); 00222 00224 virtual void branchAndBound() 00225 { 00226 throw SimpleError("Function not implemented for OsiTMINLPInterface","branchAndBound()"); 00227 } 00229 00230 00231 00232 //--------------------------------------------------------------------------- 00234 00235 00236 virtual bool isAbandoned() const; 00238 virtual bool isProvenOptimal() const; 00240 virtual bool isProvenPrimalInfeasible() const; 00242 virtual bool isProvenDualInfeasible() const; 00244 virtual bool isPrimalObjectiveLimitReached() const; 00246 virtual bool isDualObjectiveLimitReached() const; 00248 virtual bool isIterationLimitReached() const; 00249 00251 void continuingOnAFailure() 00252 { 00253 hasContinuedAfterNlpFailure_ = true; 00254 } 00255 00256 00257 //Added by Claudia 00258 00259 double getNewCutoffDecr() 00260 { 00261 return newCutoffDecr; 00262 } 00263 00264 void setNewCutoffDecr(double d) 00265 { 00266 newCutoffDecr = d; 00267 } 00268 00269 00271 bool hasContinuedOnAFailure() 00272 { 00273 return hasContinuedAfterNlpFailure_; 00274 } 00276 void ignoreFailures() 00277 { 00278 pretendFailIsInfeasible_ = 2; 00279 } 00281 void forceInfeasible() 00282 { 00283 problem_->set_obj_value(1e200); 00284 } 00286 void forceBranchable() 00287 { 00288 problem_->set_obj_value(-1e200); 00289 problem_->force_fractionnal_sol(); 00290 } 00292 00293 00294 //--------------------------------------------------------------------------- 00310 // Set an integer parameter 00311 bool setIntParam(OsiIntParam key, int value); 00312 // Set an double parameter 00313 bool setDblParam(OsiDblParam key, double value); 00314 // Set a string parameter 00315 bool setStrParam(OsiStrParam key, const std::string & value); 00316 // Get an integer parameter 00317 bool getIntParam(OsiIntParam key, int& value) const; 00318 // Get an double parameter 00319 bool getDblParam(OsiDblParam key, double& value) const; 00320 // Get a string parameter 00321 bool getStrParam(OsiStrParam key, std::string& value) const; 00322 00323 // Get the push values for starting point 00324 inline double getPushFact() const 00325 { 00326 return pushValue_; 00327 } 00328 00330 00331 00332 //--------------------------------------------------------------------------- 00345 00346 virtual int getNumCols() const; 00347 00349 virtual int getNumRows() const; 00350 00352 const OsiSolverInterface::OsiNameVec& getVarNames() ; 00354 virtual const double * getColLower() const; 00355 00357 virtual const double * getColUpper() const; 00358 00368 virtual const char * getRowSense() const; 00369 00378 virtual const double * getRightHandSide() const; 00379 00388 virtual const double * getRowRange() const; 00389 00391 virtual const double * getRowLower() const; 00392 00394 virtual const double * getRowUpper() const; 00395 00398 virtual double getObjSense() const 00399 { 00400 return 1; 00401 } 00402 00404 virtual bool isContinuous(int colNumber) const; 00405 00407 virtual bool isBinary(int columnNumber) const; 00408 00413 virtual bool isInteger(int columnNumber) const; 00414 00416 virtual bool isIntegerNonBinary(int columnNumber) const; 00417 00419 virtual bool isFreeBinary(int columnNumber) const; 00420 00422 virtual double getInfinity() const; 00423 00425 const int * getPriorities() const 00426 { 00427 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo(); 00428 if(branch) 00429 return branch->priorities; 00430 else return NULL; 00431 } 00433 const int * getBranchingDirections() const 00434 { 00435 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo(); 00436 if(branch) 00437 return branch->branchingDirections; 00438 else return NULL; 00439 } 00440 const double * getUpPsCosts() const 00441 { 00442 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo(); 00443 if(branch) 00444 return branch->upPsCosts; 00445 else return NULL; 00446 } 00447 const double * getDownPsCosts() const 00448 { 00449 const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo(); 00450 if(branch) 00451 return branch->downPsCosts; 00452 else return NULL; 00453 } 00454 00455 00457 00460 00461 virtual const double * getColSolution() const; 00462 00464 virtual const double * getRowPrice() const; 00465 00467 virtual const double * getReducedCost() const; 00468 00471 virtual const double * getRowActivity() const; 00472 00473 00478 virtual int getIterationCount() const; 00479 00481 int nCallOptimizeTNLP() 00482 { 00483 return nCallOptimizeTNLP_; 00484 } 00486 double totalNlpSolveTime() 00487 { 00488 return totalNlpSolveTime_; 00489 } 00491 int totalIterations() 00492 { 00493 return totalIterations_; 00494 } 00495 00496 00498 //------------------------------------------------------------------------- 00502 00505 virtual void setColLower( int elementIndex, double elementValue ); 00506 00509 virtual void setColUpper( int elementIndex, double elementValue ); 00510 00514 virtual void setColLower(const double * array); 00515 00519 virtual void setColUpper(const double * array); 00520 00521 00524 virtual void setRowLower( int elementIndex, double elementValue ); 00525 00528 virtual void setRowUpper( int elementIndex, double elementValue ); 00529 00531 virtual void setRowType(int index, char sense, double rightHandSide, 00532 double range); 00533 00534 00539 virtual void setObjSense(double s); 00540 00545 virtual void setColSolution(const double *colsol); 00546 00551 virtual void setRowPrice(const double * rowprice); 00552 00554 00555 00556 //--------------------------------------------------------------------------- 00559 00566 virtual CoinWarmStart *getEmptyWarmStart () const; 00567 00569 virtual CoinWarmStart* getWarmStart() const; 00570 00573 virtual bool setWarmStart(const CoinWarmStart* warmstart); 00574 00575 void setWarmStartMode(int mode) { 00576 warmStartMode_ = (WarmStartModes) mode; 00577 } 00578 WarmStartModes getWarmStartMode() { 00579 return warmStartMode_; 00580 } 00581 00582 void randomStartingPoint(); 00583 00584 //Returns true if a basis is available 00585 virtual bool basisIsAvailable() const 00586 { 00587 // Throw an exception 00588 throw SimpleError("Needs coding for this interface", "basisIsAvailable"); 00589 } 00590 00591 00593 00594 //------------------------------------------------------------------------- 00598 virtual void setContinuous(int index); 00600 virtual void setInteger(int index); 00602 00603 //Set numIterationSuspect_ 00604 void setNumIterationSuspect(int value) 00605 { 00606 numIterationSuspect_ = value; 00607 } 00608 00614 00617 virtual int getNumElements() const 00618 { 00619 return -1; 00620 } 00621 00622 00627 virtual const double * getObjCoefficients() const; 00628 00631 virtual const CoinPackedMatrix * getMatrixByRow() const 00632 { 00633 return NULL; 00634 } 00635 00636 00639 virtual const CoinPackedMatrix * getMatrixByCol() const 00640 { 00641 return NULL; 00642 } 00643 00646 virtual void setObjCoeff( int elementIndex, double elementValue ) 00647 { 00648 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00649 "setObjCoeff"); 00650 } 00651 00654 virtual void addCol(const CoinPackedVectorBase& vec, 00655 const double collb, const double colub, 00656 const double obj) 00657 { 00658 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00659 "addCol"); 00660 } 00663 virtual void deleteCols(const int num, const int * colIndices) 00664 { 00665 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00666 "deleteCols"); 00667 } 00668 00671 virtual void addRow(const CoinPackedVectorBase& vec, 00672 const double rowlb, const double rowub) 00673 { 00674 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00675 "addRow"); 00676 } 00679 virtual void addRow(const CoinPackedVectorBase& vec, 00680 const char rowsen, const double rowrhs, 00681 const double rowrng) 00682 { 00683 throw SimpleError("OsiTMINLPInterface model does not implement this function.", 00684 "addRow"); 00685 } 00688 virtual void deleteRows(const int num, const int * rowIndices) 00689 { 00690 if(num) 00691 freeCachedRowRim(); 00692 problem_->removeCuts(num, rowIndices); 00693 } 00694 00695 00698 virtual void loadProblem(const CoinPackedMatrix& matrix, 00699 const double* collb, const double* colub, 00700 const double* obj, 00701 const double* rowlb, const double* rowub) 00702 { 00703 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00704 "loadProblem"); 00705 } 00706 00707 00710 virtual void assignProblem(CoinPackedMatrix*& matrix, 00711 double*& collb, double*& colub, double*& obj, 00712 double*& rowlb, double*& rowub) 00713 { 00714 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00715 "assignProblem"); 00716 } 00717 00720 virtual void loadProblem(const CoinPackedMatrix& matrix, 00721 const double* collb, const double* colub, 00722 const double* obj, 00723 const char* rowsen, const double* rowrhs, 00724 const double* rowrng) 00725 { 00726 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00727 "loadProblem"); 00728 } 00729 00732 virtual void assignProblem(CoinPackedMatrix*& matrix, 00733 double*& collb, double*& colub, double*& obj, 00734 char*& rowsen, double*& rowrhs, 00735 double*& rowrng) 00736 { 00737 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00738 "assignProblem"); 00739 } 00740 00741 00744 virtual void loadProblem(const int numcols, const int numrows, 00745 const int* start, const int* index, 00746 const double* value, 00747 const double* collb, const double* colub, 00748 const double* obj, 00749 const double* rowlb, const double* rowub) 00750 { 00751 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00752 "loadProblem"); 00753 } 00754 00757 virtual void loadProblem(const int numcols, const int numrows, 00758 const int* start, const int* index, 00759 const double* value, 00760 const double* collb, const double* colub, 00761 const double* obj, 00762 const char* rowsen, const double* rowrhs, 00763 const double* rowrng) 00764 { 00765 throw SimpleError("OsiTMINLPInterface model does not implement this function.", 00766 "loadProblem"); 00767 } 00768 00771 virtual int readMps(const char *filename, 00772 const char *extension = "mps") 00773 { 00774 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00775 "readMps"); 00776 } 00777 00778 00781 virtual void writeMps(const char *filename, 00782 const char *extension = "mps", 00783 double objSense=0.0) const 00784 { 00785 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00786 "writeMps"); 00787 } 00788 00790 virtual std::vector<double*> getDualRays(int maxNumRays, bool fullRay) const 00791 { 00792 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00793 "getDualRays"); 00794 } 00795 00797 virtual std::vector<double*> getPrimalRays(int maxNumRays) const 00798 { 00799 throw SimpleError("OsiTMINLPInterface does not implement this function.", 00800 "getPrimalRays"); 00801 } 00802 00804 00805 00806 00807 //--------------------------------------------------------------------------- 00808 00809 00810 00814 void setSolverOutputToDefault(){ 00815 app_->setOutputToDefault();} 00816 void forceSolverOutput(int log_level){ 00817 app_->forceSolverOutput(log_level);} 00819 00822 00823 virtual double getObjValue() const; 00824 00826 00828 const TMINLP2TNLP * problem() const 00829 { 00830 return GetRawPtr(problem_); 00831 } 00832 00833 TMINLP2TNLP * problem() 00834 { 00835 return GetRawPtr(problem_); 00836 } 00837 00838 const TMINLP * model() const 00839 { 00840 return GetRawPtr(tminlp_); 00841 } 00842 00843 Bonmin::TMINLP * model() 00844 { 00845 return GetRawPtr(tminlp_); 00846 } 00847 00848 const Bonmin::TNLPSolver * solver() const 00849 { 00850 return GetRawPtr(app_); 00851 } 00852 00853 const std::list<Ipopt::SmartPtr<TNLPSolver> >& debug_apps() const{ 00854 return debug_apps_; 00855 } 00856 00857 TNLPSolver * solver() 00858 { 00859 return GetRawPtr(app_); 00860 } 00869 virtual void extractLinearRelaxation(OsiSolverInterface &si, const double *x, 00870 bool getObj = 1); 00871 00873 virtual void addObjectiveFunction(OsiSolverInterface &si, const double * x); 00874 #if 1 00875 00879 virtual void extractLinearRelaxation(OsiSolverInterface &si, bool getObj = 1, 00880 bool solveNlp = 1){ 00881 if(solveNlp) 00882 initialSolve("build initial OA"); 00883 extractLinearRelaxation(si, getColSolution(), getObj); 00884 if(solveNlp){ 00885 app_->enableWarmStart(); 00886 setColSolution(problem()->x_sol()); 00887 setRowPrice(problem()->duals_sol()); 00888 } 00889 } 00890 #endif 00891 00894 void getOuterApproximation(OsiCuts &cs, int getObj, const double * x2, bool global) 00895 { 00896 getOuterApproximation(cs, getColSolution(), getObj, x2, global); 00897 } 00898 00902 void getOuterApproximation(OsiCuts &cs, const double * x, int getObj, const double * x2, bool global){ 00903 getOuterApproximation(cs, x, getObj, x2, 0., global);} 00904 00908 virtual void getOuterApproximation(OsiCuts &cs, const double * x, int getObj, const double * x2, 00909 double theta, bool global); 00910 00912 virtual void getConstraintOuterApproximation(OsiCuts & cs, int constraintNumber, 00913 const double * x, 00914 const double * x2, bool global); 00915 00917 void getConstraintOuterApproximation(OsiCuts & cs, int constraintNumber, 00918 const double * x2, bool global){ 00919 getConstraintOuterApproximation(cs, constraintNumber, getColSolution(),x2,global); 00920 } 00921 00922 00924 void getBendersCut(OsiCuts &cs, bool global); 00925 00935 double solveFeasibilityProblem(int n, const double * x_bar, const int* ind, double a, double s, int L); 00936 00945 double solveFeasibilityProblem(int n, const double * x_bar, const int* ind, int L, double cutoff); 00946 00949 void switchToFeasibilityProblem(int n, const double * x_bar, const int* ind, double a, double s, int L); 00950 00953 void switchToFeasibilityProblem(int n, const double * x_bar, const int* ind, 00954 double rhs_local_branching_constraint); 00955 00957 void switchToOriginalProblem(); 00958 00960 void round_and_check(double tolerance, 00961 OsiObject ** objects = 0, int nObjects = -1){ 00962 if(!problem_->check_solution(objects, nObjects)){ 00963 optimizationStatus_ = TNLPSolver::provenInfeasible; 00964 } 00965 } 00967 00972 enum OaMessagesTypes { 00973 CUT_NOT_VIOLATED_ENOUGH = 0, 00974 VIOLATED_OA_CUT_GENERATED, 00975 OA_CUT_GENERATED, 00976 OA_MESSAGES_DUMMY_END}; 00978 class OaMessages :public CoinMessages{ 00979 public: 00981 OaMessages(); 00982 }; 00984 class OaMessageHandler : public CoinMessageHandler{ 00985 public: 00987 OaMessageHandler():CoinMessageHandler(){ 00988 } 00990 OaMessageHandler(FILE * fp):CoinMessageHandler(fp){ 00991 } 00993 virtual ~OaMessageHandler(){ 00994 } 00996 OaMessageHandler(const OaMessageHandler &other): 00997 CoinMessageHandler(other){} 00999 OaMessageHandler(const CoinMessageHandler &other): 01000 CoinMessageHandler(other){} 01002 OaMessageHandler & operator=(const OaMessageHandler &rhs){ 01003 CoinMessageHandler::operator=(rhs); 01004 return *this;} 01006 virtual CoinMessageHandler* clone() const{ 01007 return new OaMessageHandler(*this);} 01009 void print(OsiRowCut &row); 01010 }; 01011 void setOaMessageHandler(const CoinMessageHandler &handler){ 01012 delete oaHandler_; 01013 oaHandler_ = new OaMessageHandler(handler); 01014 } 01016 01017 //----------------------------------------------------------------------- 01020 virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs, 01021 double effectivenessLb = 0.0){ 01022 freeCachedRowRim(); 01023 problem_->addCuts(cs); 01024 ApplyCutsReturnCode rc; 01025 return rc;} 01026 01028 virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts); 01029 01030 01032 virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts) 01033 { 01034 if(numberCuts) 01035 freeCachedRowRim(); 01036 problem_->addCuts(numberCuts, cuts); 01037 } 01038 01041 double getConstraintsViolation(const double * x, double & obj); 01042 01045 double getNonLinearitiesViolation(const double *x, const double obj); 01046 01047 //--------------------------------------------------------------------------- 01048 01049 void extractInterfaceParams(); 01050 01051 01053 virtual void setAppDefaultOptions(Ipopt::SmartPtr<Ipopt::OptionsList> Options); 01054 01056 static void registerOptions (Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions); 01057 01058 Ipopt::SmartPtr<Bonmin::RegisteredOptions> regOptions(){ 01059 if(IsValid(app_)) 01060 return app_->roptions(); 01061 else 01062 return NULL; 01063 } 01064 01067 01068 void SetStrongBrachingSolver(Ipopt::SmartPtr<StrongBranchingSolver> strong_branching_solver); 01071 virtual void markHotStart(); 01075 virtual void solveFromHotStart(); 01078 virtual void unmarkHotStart(); 01080 01082 void get_tolerances(double &tiny, double&very_tiny, double &infty){ 01083 tiny = tiny_; 01084 very_tiny = veryTiny_; 01085 infty = infty_; 01086 } 01087 01088 protected: 01089 01091 01092 enum RandomGenerationType{ 01093 uniform =0, perturb=1, perturb_suffix=2}; 01095 int initializeJacobianArrays(); 01096 01098 01099 virtual std::string appName() 01100 { 01101 return "bonmin"; 01102 } 01104 01105 01106 01108 void solveAndCheckErrors(bool doResolve, bool throwOnFailure, 01109 const char * whereFrom); 01110 01111 01114 virtual void applyRowCut( const OsiRowCut & rc ) 01115 { 01116 const OsiRowCut * cut = &rc; 01117 problem_->addCuts(1, &cut); 01118 } 01121 virtual void applyColCut( const OsiColCut & cc ) 01122 { 01123 throw SimpleError("Ipopt model does not implement this function.", 01124 "applyColCut"); 01125 } 01126 01127 // /** Read the name of the variables in an ampl .col file. */ 01128 // void readVarNames() const; 01129 01131 01135 Ipopt::SmartPtr<TMINLP> tminlp_; 01137 Ipopt::SmartPtr<TMINLP2TNLP> problem_; 01139 Ipopt::SmartPtr<Ipopt::TNLP> problem_to_optimize_; 01141 bool feasibility_mode_; 01143 Ipopt::SmartPtr<TNLPSolver> app_; 01144 01146 std::list<Ipopt::SmartPtr<TNLPSolver> > debug_apps_; 01148 bool testOthers_; 01150 01152 CoinWarmStart* warmstart_; 01153 01157 void freeCachedColRim(); 01159 void freeCachedRowRim(); 01161 void freeCachedData(); 01164 void extractSenseRhsAndRange() const; 01166 mutable char *rowsense_; 01167 01169 mutable double *rhs_; 01170 01172 mutable double *rowrange_; 01175 mutable double *reducedCosts_; 01177 double OsiDualObjectiveLimit_; 01179 mutable bool hasVarNamesFile_; 01181 01182 int nCallOptimizeTNLP_; 01184 double totalNlpSolveTime_; 01186 int totalIterations_; 01188 double maxRandomRadius_; 01190 int randomGenerationType_; 01192 double max_perturbation_; 01194 double pushValue_; 01196 int numRetryInitial_; 01198 int numRetryResolve_; 01200 int numRetryInfeasibles_; 01202 int numRetryUnsolved_; 01203 01204 01205 //Added by Claudia 01207 int dynamicCutOff_; 01209 double coeff_var_threshold_; 01211 double first_perc_for_cutoff_decr_; 01213 double second_perc_for_cutoff_decr_; 01214 01215 01217 Messages messages_; 01221 int pretendFailIsInfeasible_; 01222 01223 mutable int pretendSucceededNext_; 01224 01226 bool hasContinuedAfterNlpFailure_; 01229 int numIterationSuspect_ ; 01233 bool hasBeenOptimized_; 01237 mutable double * obj_; 01239 static bool hasPrintedOptions; 01240 01242 Ipopt::SmartPtr<TNLP2FPNLP> feasibilityProblem_; 01243 01244 01248 int * jRow_; 01250 int * jCol_; 01252 double * jValues_; 01254 int nnz_jac; 01256 01258 Ipopt::TNLP::LinearityType * constTypes_; 01261 int nNonLinear_; 01263 double tiny_; 01265 double veryTiny_; 01267 double infty_; 01269 TNLPSolver::ReturnStatus optimizationStatus_; 01271 WarmStartModes warmStartMode_; 01273 bool firstSolve_; 01275 SmartPtr<CutStrengthener> cutStrengthener_; 01276 01281 OaMessages oaMessages_; 01283 OaMessageHandler * oaHandler_; 01285 01286 double newCutoffDecr; 01287 protected: 01289 void createApplication(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions, 01290 Ipopt::SmartPtr<Ipopt::OptionsList> options, 01291 Ipopt::SmartPtr<Ipopt::Journalist> journalist, 01292 const std::string & prefix); 01294 OsiTMINLPInterface(Ipopt::SmartPtr<TNLPSolver> app); 01295 01297 bool internal_setWarmStart(const CoinWarmStart* ws); 01298 01300 CoinWarmStart* internal_getWarmStart() const; 01301 01303 CoinWarmStart* build_fake_basis() const; 01304 private: 01305 01307 SmartPtr<StrongBranchingSolver> strong_branching_solver_; 01309 TNLPSolver::ReturnStatus optimizationStatusBeforeHotStart_; 01310 static const char * OPT_SYMB; 01311 static const char * FAILED_SYMB; 01312 static const char * INFEAS_SYMB; 01313 static const char * TIME_SYMB; 01314 static const char * UNBOUND_SYMB; 01316 const char * statusAsString(TNLPSolver::ReturnStatus r){ 01317 if(r == TNLPSolver::solvedOptimal || r == TNLPSolver::solvedOptimalTol){ 01318 return OPT_SYMB;} 01319 else if(r == TNLPSolver::provenInfeasible){ 01320 return INFEAS_SYMB;} 01321 else if(r == TNLPSolver::unbounded){ 01322 return UNBOUND_SYMB;} 01323 else if(r == TNLPSolver::timeLimit){ 01324 return TIME_SYMB;} 01325 else return FAILED_SYMB; 01326 } 01327 const char * statusAsString(){ 01328 return statusAsString(optimizationStatus_);} 01329 }; 01330 } 01331 #endif