00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if defined(_MSC_VER)
00013
00014 # pragma warning(disable:4786)
00015 #endif
00016 #include <iomanip>
00017 #include <fstream>
00018
00019 #include <stdlib.h>
00020
00021 #include "CoinTime.hpp"
00022 #include "BonminConfig.h"
00023 #include "BonCouenneInterface.hpp"
00024 #include "BonIpoptSolver.hpp"
00025
00026 #include "BonCouenneSetup.hpp"
00027
00028 #include "BonCbc.hpp"
00029 #ifdef COIN_HAS_FILTERSQP
00030 #include "BonFilterSolver.hpp"
00031 #endif
00032
00033 #include "CbcCutGenerator.hpp"
00034 #include "CouenneProblem.hpp"
00035 #include "CouenneCutGenerator.hpp"
00036
00037 using namespace Bonmin;
00038
00039 int main (int argc, char *argv[])
00040 {
00041 using namespace Ipopt;
00042
00043 char * pbName = NULL;
00044 double time_start = CoinCpuTime();
00045
00046 try {
00047
00048 Bab bb;
00049 bb.setUsingCouenne (true);
00050
00051 CouenneSetup bonmin;
00052 bonmin.InitializeCouenne (argv);
00053
00054 #if 0
00055 CouenneFeasibility feasibility;
00056 bb.model().setProblemFeasibility (feasibility);
00057 #endif
00058
00060 double timeLimit = 0;
00061 bonmin.options () -> GetNumericValue ("time_limit", timeLimit, "bonmin.");
00062 bonmin.setDoubleParameter (BabSetupBase::MaxTime,
00063 timeLimit - (time_start = (CoinCpuTime () - time_start)));
00064
00066
00067 bb (bonmin);
00068
00070
00071 std::cout.precision (10);
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 if (bonmin.displayStats ()) {
00093
00095 int nr=-1, nt=-1;
00096 double st=-1;
00097
00098
00099
00100 CouenneCutGenerator *cg = NULL;
00101
00102 if (bb.model (). cutGenerators ())
00103 cg = dynamic_cast <CouenneCutGenerator *>
00104 (bb.model (). cutGenerators () [0] -> generator ());
00105
00106 if (cg) cg -> getStats (nr, nt, st);
00107 else printf ("Warning, could not get pointer to CouenneCutGenerator\n");
00108
00109 CouenneProblem *cp = cg ? cg -> Problem () : NULL;
00110
00111 if (cg && !cp) printf ("Warning, could not get pointer to problem\n");
00112 else
00113 printf ("Stats: %-15s %4d [var] %4d [int] %4d [con] %4d [aux] "
00114 "%6d [root] %8d [tot] %6g [sep] %8g [time] %8g [bb] "
00115 "%20e [lower] %20e [upper] %7d [nodes]\n",
00116 cp ? cp -> problemName ().c_str () : "unknown",
00117 (cp) ? cp -> nOrigVars () : -1,
00118 (cp) ? cp -> nOrigIntVars () : -1,
00119 (cp) ? cp -> nOrigCons () : -1,
00120 (cp) ? (cp -> nVars () -
00121 cp -> nOrigVars ()): -1,
00122 nr, nt, st,
00123 CoinCpuTime () - time_start,
00124 cg ? (CoinCpuTime () - cg -> rootTime ()) : CoinCpuTime (),
00125 bb.model (). getBestPossibleObjValue (),
00126 bb.model (). getObjValue (),
00127
00128
00129 bb.numNodes ());
00130
00131
00132
00133
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 }
00174
00175
00176 }
00177 catch(TNLPSolver::UnsolvedError *E) {
00178 E->writeDiffFiles();
00179 E->printError(std::cerr);
00180
00181
00182
00183
00184 }
00185 catch(OsiTMINLPInterface::SimpleError &E) {
00186 std::cerr<<E.className()<<"::"<<E.methodName()
00187 <<std::endl
00188 <<E.message()<<std::endl;
00189 }
00190 catch(CoinError &E) {
00191 std::cerr<<E.className()<<"::"<<E.methodName()
00192 <<std::endl
00193 <<E.message()<<std::endl;
00194 }
00195 catch (Ipopt::OPTION_INVALID &E)
00196 {
00197 std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00198 }
00199
00200
00201
00202
00203
00204
00205 delete [] pbName;
00206 return 0;
00207 }