00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if defined(_MSC_VER)
00012
00013 # pragma warning(disable:4786)
00014 #endif
00015 #include <iomanip>
00016 #include <fstream>
00017
00018 #include "CoinTime.hpp"
00019 #include "CoinError.hpp"
00020
00021 #include "BonOsiTMINLPInterface.hpp"
00022 #include "BonIpoptSolver.hpp"
00023 #include "MyTMINLP.hpp"
00024 #include "BonCbc.hpp"
00025 #include "BonBonminSetup.hpp"
00026
00027 #include "BonOACutGenerator2.hpp"
00028 #include "BonEcpCuts.hpp"
00029 #include "BonOaNlpOptim.hpp"
00030
00031
00032 int main (int argc, char *argv[])
00033 {
00034 WindowsErrorPopupBlocker();
00035
00036 using namespace Ipopt;
00037 using namespace Bonmin;
00038 SmartPtr<MyTMINLP> tminlp = new MyTMINLP;
00039
00040 #ifdef REDIRECT
00041 FILE * fp = fopen("log.out","w");
00042 CoinMessageHandler handler(fp);
00043 BonminSetup bonmin(&handler);
00044 #else
00045 BonminSetup bonmin;
00046 #endif
00047 bonmin.initializeOptionsAndJournalist();
00048
00049 bonmin.roptions()->AddStringOption2("print_solution","Do we print the solution or not?",
00050 "yes",
00051 "no", "No, we don't.",
00052 "yes", "Yes, we do.",
00053 "A longer comment can be put here");
00054
00055
00056
00057
00058 bonmin.options()->SetNumericValue("bonmin.time_limit", 5);
00059 bonmin.options()->SetStringValue("mu_oracle","loqo");
00060
00061
00062 bonmin.readOptionsFile("Mybonmin.opt");
00063 bonmin.readOptionsFile();
00064
00065
00066 bonmin.readOptionsString("bonmin.algorithm B-BB\n");
00067
00068
00069 int printSolution;
00070 bonmin.options()->GetEnumValue("print_solution", printSolution,"");
00071 if(printSolution == 1){
00072 tminlp->printSolutionAtEndOfAlgorithm();
00073 }
00074
00075
00076 bonmin.initialize(GetRawPtr(tminlp));
00077
00078
00079
00080
00081 double time1 = CoinCpuTime();
00082 try {
00083 Bab bb;
00084 bb(bonmin);
00085
00086
00087 }
00088 catch(TNLPSolver::UnsolvedError *E) {
00089
00090 std::cerr<<"Ipopt has failed to solve a problem"<<std::endl;
00091 }
00092 catch(OsiTMINLPInterface::SimpleError &E) {
00093 std::cerr<<E.className()<<"::"<<E.methodName()
00094 <<std::endl
00095 <<E.message()<<std::endl;
00096 }
00097 catch(CoinError &E) {
00098 std::cerr<<E.className()<<"::"<<E.methodName()
00099 <<std::endl
00100 <<E.message()<<std::endl;
00101 }
00102
00103
00104 return 0;
00105 }
00106