00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "UtilParameters.h"
00017
00018 #include "OSDipApp.h"
00019
00020 #include "AlpsDecompModel.h"
00021
00022 #include "DecompAlgoC.h"
00023 #include "DecompAlgoPC.h"
00024 #include "DecompAlgoRC.h"
00025
00026 #include "UtilTimer.h"
00027 #include<map>
00028
00029
00030 int main(int argc, char ** argv){
00031 try{
00032
00033
00034
00035
00036 UtilParameters utilParam(argc, argv);
00037
00038 bool doCut = utilParam.GetSetting("doCut", false);
00039 bool doPriceCut = utilParam.GetSetting("doPriceCut", true);
00040 bool doDirect = utilParam.GetSetting("doDirect", false);
00041
00042
00043 UtilTimer timer;
00044 double timeSetupReal = 0.0;
00045 double timeSetupCpu = 0.0;
00046 double timeSolveReal = 0.0;
00047 double timeSolveCpu = 0.0;
00048
00049
00050
00051
00052 timer.start();
00053
00054
00055
00056
00057
00058 OSDipApp osdip( utilParam);
00059
00060
00061
00062
00063
00064
00065
00066 DecompAlgo *algo = NULL;
00067 assert(doCut + doPriceCut == 1);
00068
00069
00070
00071
00072 if(doCut)
00073 algo = new DecompAlgoC(&osdip, &utilParam);
00074
00075
00076
00077
00078 if(doPriceCut){
00079 std::cout << "CREATE NEW DecompAlgoPC" << std::endl;
00080 algo = new DecompAlgoPC(&osdip, &utilParam);
00081 std::cout << "DONE CREATE NEW DecompAlgoPC" << std::endl;
00082
00083
00084
00085 }
00086
00087 if(doCut && doDirect){
00088 timer.stop();
00089 timeSetupCpu = timer.getCpuTime();
00090 timeSetupReal = timer.getRealTime();
00091
00092
00093
00094
00095 timer.start();
00096
00097 algo->solveDirect();
00098 timer.stop();
00099 timeSolveCpu = timer.getCpuTime();
00100 timeSolveReal = timer.getRealTime();
00101 }
00102 else{
00103 timer.stop();
00104 timeSetupCpu = timer.getCpuTime();
00105 timeSetupReal = timer.getRealTime();
00106
00107
00108
00109
00110 int status = 0;
00111 AlpsDecompModel alpsModel(utilParam, algo);
00112
00113
00114
00115
00116 timer.start();
00117 std::cout << std::endl << std::endl << std::endl << std::endl;
00118 std::cout << "***************START SOLVE***************" << std::endl;
00119
00120
00121
00122 status = alpsModel.solve();
00123 std::cout << "FINISH SOLVE" << std::endl;
00124 timer.stop();
00125 timeSolveCpu = timer.getCpuTime();
00126 timeSolveReal = timer.getRealTime();
00127
00128
00129
00130
00131 cout << setiosflags(ios::fixed|ios::showpoint);
00132 cout << "Status= " << status
00133 << " BestLB= " << setw(10)
00134 << UtilDblToStr(alpsModel.getGlobalLB(),5)
00135 << " BestUB= " << setw(10)
00136 << UtilDblToStr(alpsModel.getGlobalUB(),5)
00137 << " Nodes= " << setw(6)
00138 << alpsModel.getNumNodesProcessed()
00139 << " SetupCPU= " << timeSetupCpu
00140 << " SolveCPU= " << timeSolveCpu
00141 << " TotalCPU= " << timeSetupCpu + timeSolveCpu
00142 << " SetupReal= " << timeSetupReal
00143 << " SetupReal= " << timeSolveReal
00144 << " TotalReal= " << timeSetupReal + timeSetupReal
00145 << endl;
00146
00147
00148 const DecompSolution * solution = alpsModel.getBestSolution();
00149 cout << "Optimal Solution" << endl;
00150 solution->print();
00151
00152 algo->getMasterOSI()->writeLp("finalRestrictedMaster", "lp", 1e-30, 5, 10);
00153
00154 }
00155
00156
00157
00158 delete algo;
00159
00160 }
00161 catch(const ErrorClass& eclass){
00162 std::cout << "Something went wrong:" << std::endl;
00163 std::cout << eclass.errormsg << std::endl;
00164
00165 return 1;
00166 }
00167 return 0;
00168 }
00169