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
00035
00036 using namespace Ipopt;
00037 using namespace Bonmin;
00038 SmartPtr<MyTMINLP> tminlp = new MyTMINLP;
00039
00040
00041 BonminSetup bonmin;
00042 bonmin.initializeOptionsAndJournalist();
00043
00044 bonmin.roptions()->AddStringOption2("print_solution","Do we print the solution or not?",
00045 "yes",
00046 "no", "No, we don't.",
00047 "yes", "Yes, we do.",
00048 "A longer comment can be put here");
00049
00050
00051
00052
00053 bonmin.options()->SetNumericValue("bonmin.time_limit", 5);
00054 bonmin.options()->SetStringValue("mu_oracle","loqo");
00055
00056
00057 bonmin.readOptionsFile("Mybonmin.opt");
00058 bonmin.readOptionsFile();
00059
00060
00061 bonmin.readOptionsString("bonmin.algorithm B-BB\n");
00062
00063
00064 int printSolution;
00065 bonmin.options()->GetEnumValue("print_solution", printSolution,"");
00066 if(printSolution == 1){
00067 tminlp->printSolutionAtEndOfAlgorithm();
00068 }
00069
00070
00071 bonmin.initialize(GetRawPtr(tminlp));
00072
00073
00074
00075
00076 double time1 = CoinCpuTime();
00077 try {
00078 Bab bb;
00079 bb(bonmin);
00080
00081
00082 }
00083 catch(TNLPSolver::UnsolvedError *E) {
00084
00085 std::cerr<<"Ipopt has failed to solve a problem"<<std::endl;
00086 }
00087 catch(OsiTMINLPInterface::SimpleError &E) {
00088 std::cerr<<E.className()<<"::"<<E.methodName()
00089 <<std::endl
00090 <<E.message()<<std::endl;
00091 }
00092 catch(CoinError &E) {
00093 std::cerr<<E.className()<<"::"<<E.methodName()
00094 <<std::endl
00095 <<E.message()<<std::endl;
00096 }
00097
00098
00099 return 0;
00100 }
00101