1 | /* $Id: CbcSolver.cpp 2278 2016-05-19 10:50:22Z forrest $ */ |
---|
2 | // Copyright (C) 2007, International Business Machines |
---|
3 | // Corporation and others. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | /*! \file CbcSolver.cpp |
---|
7 | Â Â \brief Second level routines for the cbc stand-alone solver. |
---|
8 | */ |
---|
9 | |
---|
10 | #include "CbcConfig.h" |
---|
11 | #include "CoinPragma.hpp" |
---|
12 | |
---|
13 | #include <cassert> |
---|
14 | #include <cstdio> |
---|
15 | #include <cstdlib> |
---|
16 | #include <cmath> |
---|
17 | #include <cfloat> |
---|
18 | #include <cstring> |
---|
19 | #include <iostream> |
---|
20 | |
---|
21 | #include "CoinPragma.hpp" |
---|
22 | #include "CoinHelperFunctions.hpp" |
---|
23 | |
---|
24 | #include "CoinMpsIO.hpp" |
---|
25 | #include "CoinModel.hpp" |
---|
26 | |
---|
27 | #include "ClpFactorization.hpp" |
---|
28 | #include "ClpQuadraticObjective.hpp" |
---|
29 | #include "CoinTime.hpp" |
---|
30 | #include "ClpSimplex.hpp" |
---|
31 | #include "ClpSimplexOther.hpp" |
---|
32 | #include "ClpSolve.hpp" |
---|
33 | #include "ClpMessage.hpp" |
---|
34 | #include "ClpPackedMatrix.hpp" |
---|
35 | #include "ClpPlusMinusOneMatrix.hpp" |
---|
36 | #include "ClpNetworkMatrix.hpp" |
---|
37 | #include "ClpDualRowSteepest.hpp" |
---|
38 | #include "ClpDualRowDantzig.hpp" |
---|
39 | #include "ClpLinearObjective.hpp" |
---|
40 | #include "ClpPrimalColumnSteepest.hpp" |
---|
41 | #include "ClpPrimalColumnDantzig.hpp" |
---|
42 | |
---|
43 | #include "ClpPresolve.hpp" |
---|
44 | #ifndef COIN_HAS_CBC |
---|
45 | #define COIN_HAS_CBC |
---|
46 | #endif |
---|
47 | #include "CbcOrClpParam.hpp" |
---|
48 | #include "OsiRowCutDebugger.hpp" |
---|
49 | #include "OsiChooseVariable.hpp" |
---|
50 | #include "OsiAuxInfo.hpp" |
---|
51 | #include "CbcMipStartIO.hpp" |
---|
52 | // for printing |
---|
53 | #ifndef CLP_OUTPUT_FORMAT |
---|
54 | #define CLP_OUTPUT_FORMAT %15.8g |
---|
55 | #endif |
---|
56 | #define CLP_QUOTE(s) CLP_STRING(s) |
---|
57 | #define CLP_STRING(s) #s |
---|
58 | |
---|
59 | #include "CbcSolverHeuristics.hpp" |
---|
60 | #ifdef COIN_HAS_GLPK |
---|
61 | #include "glpk.h" |
---|
62 | extern glp_tran* cbc_glp_tran; |
---|
63 | extern glp_prob* cbc_glp_prob; |
---|
64 | #else |
---|
65 | #define GLP_UNDEF 1 |
---|
66 | #define GLP_FEAS 2 |
---|
67 | #define GLP_INFEAS 3 |
---|
68 | #define GLP_NOFEAS 4 |
---|
69 | #define GLP_OPT 5 |
---|
70 | #endif |
---|
71 | |
---|
72 | #ifndef CBC_QUIET |
---|
73 | #define CBC_QUIET 0 |
---|
74 | #endif |
---|
75 | |
---|
76 | //#define USER_HAS_FAKE_CLP |
---|
77 | //#define USER_HAS_FAKE_CBC |
---|
78 | |
---|
79 | //#define CLP_MALLOC_STATISTICS |
---|
80 | |
---|
81 | #ifdef CLP_MALLOC_STATISTICS |
---|
82 | #include <malloc.h> |
---|
83 | #include <exception> |
---|
84 | #include <new> |
---|
85 | #include "stolen_from_ekk_malloc.cpp" |
---|
86 | static double malloc_times = 0.0; |
---|
87 | static double malloc_total = 0.0; |
---|
88 | static int malloc_amount[] = {0, 32, 128, 256, 1024, 4096, 16384, 65536, 262144, INT_MAX}; |
---|
89 | static int malloc_n = 10; |
---|
90 | double malloc_counts[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
---|
91 | bool malloc_counts_on = true; |
---|
92 | void * operator new (size_t size) throw (std::bad_alloc) |
---|
93 | { |
---|
94 | Â Â malloc_times ++; |
---|
95 | Â Â malloc_total +=Â size; |
---|
96 |   int i; |
---|
97 |   for (i = 0; i < malloc_n; i++) { |
---|
98 |     if ((int) size <= malloc_amount[i]) { |
---|
99 | Â Â Â Â Â Â malloc_counts[i]++; |
---|
100 | Â Â Â Â Â Â break; |
---|
101 | Â Â Â Â } |
---|
102 | Â Â } |
---|
103 | # ifdef DEBUG_MALLOC |
---|
104 |   void *p; |
---|
105 |   if (malloc_counts_on) |
---|
106 | Â Â Â Â p =Â stolen_from_ekk_mallocBase(size); |
---|
107 | Â Â else |
---|
108 | Â Â Â Â p =Â malloc(size); |
---|
109 | # else |
---|
110 |   void * p = malloc(size); |
---|
111 | # endif |
---|
112 | Â Â //char * xx = (char *) p; |
---|
113 | Â Â //memset(xx,0,size); |
---|
114 | Â Â // Initialize random seed |
---|
115 | Â Â //CoinSeedRandom(987654321); |
---|
116 |   return p; |
---|
117 | } |
---|
118 | void operator delete (void *p) throw() |
---|
119 | { |
---|
120 | # ifdef DEBUG_MALLOC |
---|
121 |   if (malloc_counts_on) |
---|
122 | Â Â Â Â stolen_from_ekk_freeBase(p); |
---|
123 | Â Â else |
---|
124 | Â Â Â Â free(p); |
---|
125 | # else |
---|
126 | Â Â free(p); |
---|
127 | # endif |
---|
128 | } |
---|
129 | static void malloc_stats2() |
---|
130 | { |
---|
131 |   double average = malloc_total / malloc_times; |
---|
132 |   printf("count %g bytes %g - average %g\n", malloc_times, malloc_total, average); |
---|
133 |   for (int i = 0; i < malloc_n; i++) |
---|
134 |     printf("%g ", malloc_counts[i]); |
---|
135 | Â Â printf("\n"); |
---|
136 | Â Â malloc_times =Â 0.0; |
---|
137 | Â Â malloc_total =Â 0.0; |
---|
138 |   memset(malloc_counts, 0, sizeof(malloc_counts)); |
---|
139 | Â Â // print results |
---|
140 | } |
---|
141 | #else  //CLP_MALLOC_STATISTICS |
---|
142 | //void stolen_from_ekk_memory(void * dummy,int type) |
---|
143 | //{ |
---|
144 | //} |
---|
145 | //bool malloc_counts_on=false; |
---|
146 | #endif //CLP_MALLOC_STATISTICS |
---|
147 | |
---|
148 | //#define DMALLOC |
---|
149 | #ifdef DMALLOC |
---|
150 | #include "dmalloc.h" |
---|
151 | #endif |
---|
152 | |
---|
153 | #ifdef WSSMP_BARRIER |
---|
154 | #define FOREIGN_BARRIER |
---|
155 | #endif |
---|
156 | |
---|
157 | #ifdef UFL_BARRIER |
---|
158 | #define FOREIGN_BARRIER |
---|
159 | #endif |
---|
160 | |
---|
161 | #ifdef TAUCS_BARRIER |
---|
162 | #define FOREIGN_BARRIER |
---|
163 | #endif |
---|
164 | |
---|
165 | static int initialPumpTune = -1; |
---|
166 | #include "CoinWarmStartBasis.hpp" |
---|
167 | |
---|
168 | #include "OsiSolverInterface.hpp" |
---|
169 | #include "OsiCuts.hpp" |
---|
170 | #include "OsiRowCut.hpp" |
---|
171 | #include "OsiColCut.hpp" |
---|
172 | |
---|
173 | #ifndef COIN_HAS_LINK |
---|
174 | #define COIN_HAS_LINK |
---|
175 | #endif |
---|
176 | #ifdef COIN_HAS_LINK |
---|
177 | #include "CbcLinked.hpp" |
---|
178 | #endif |
---|
179 | |
---|
180 | #include "CglPreProcess.hpp" |
---|
181 | #include "CglCutGenerator.hpp" |
---|
182 | #include "CglGomory.hpp" |
---|
183 | #include "CglProbing.hpp" |
---|
184 | #include "CglKnapsackCover.hpp" |
---|
185 | #include "CglRedSplit.hpp" |
---|
186 | #include "CglRedSplit2.hpp" |
---|
187 | #include "CglGMI.hpp" |
---|
188 | #include "CglClique.hpp" |
---|
189 | #include "CglFlowCover.hpp" |
---|
190 | #include "CglMixedIntegerRounding2.hpp" |
---|
191 | #include "CglTwomir.hpp" |
---|
192 | #include "CglDuplicateRow.hpp" |
---|
193 | #include "CglStored.hpp" |
---|
194 | #include "CglLandP.hpp" |
---|
195 | #include "CglResidualCapacity.hpp" |
---|
196 | #include "CglZeroHalf.hpp" |
---|
197 | //#define CGL_WRITEMPS |
---|
198 | #ifdef CGL_WRITEMPS |
---|
199 | extern double * debugSolution; |
---|
200 | extern int debugNumberColumns; |
---|
201 | #endif |
---|
202 | #include "CbcModel.hpp" |
---|
203 | #include "CbcHeuristic.hpp" |
---|
204 | #include "CbcHeuristicLocal.hpp" |
---|
205 | #include "CbcHeuristicPivotAndFix.hpp" |
---|
206 | //#include "CbcHeuristicPivotAndComplement.hpp" |
---|
207 | #include "CbcHeuristicRandRound.hpp" |
---|
208 | #include "CbcHeuristicGreedy.hpp" |
---|
209 | #include "CbcHeuristicFPump.hpp" |
---|
210 | #include "CbcHeuristicRINS.hpp" |
---|
211 | #include "CbcHeuristicDiveCoefficient.hpp" |
---|
212 | #include "CbcHeuristicDiveFractional.hpp" |
---|
213 | #include "CbcHeuristicDiveGuided.hpp" |
---|
214 | #include "CbcHeuristicDiveVectorLength.hpp" |
---|
215 | #include "CbcHeuristicDivePseudoCost.hpp" |
---|
216 | #include "CbcHeuristicDiveLineSearch.hpp" |
---|
217 | #include "CbcTreeLocal.hpp" |
---|
218 | #include "CbcCompareActual.hpp" |
---|
219 | #include "CbcBranchActual.hpp" |
---|
220 | #include "CbcBranchLotsize.hpp" |
---|
221 | #include "CbcOrClpParam.hpp" |
---|
222 | #include "CbcCutGenerator.hpp" |
---|
223 | #include "CbcStrategy.hpp" |
---|
224 | #include "CbcBranchCut.hpp" |
---|
225 | |
---|
226 | #include "OsiClpSolverInterface.hpp" |
---|
227 | |
---|
228 | #include "CbcSolverAnalyze.hpp" |
---|
229 | #include "CbcSolverExpandKnapsack.hpp" |
---|
230 | |
---|
231 | #include "CbcSolver.hpp" |
---|
232 | |
---|
233 | //#define IN_BRANCH_AND_BOUND (0x01000000|262144) |
---|
234 | #define IN_BRANCH_AND_BOUND (0x01000000|262144|128|1024|2048) |
---|
235 | //#define IN_BRANCH_AND_BOUND (0x01000000|262144|128) |
---|
236 | |
---|
237 | /* |
---|
238 | Â CbcStopNow class definitions. |
---|
239 | */ |
---|
240 | |
---|
241 | CbcStopNow::CbcStopNow() |
---|
242 | { |
---|
243 | } |
---|
244 | CbcStopNow::~CbcStopNow() |
---|
245 | { |
---|
246 | } |
---|
247 | // Copy constructor |
---|
248 | CbcStopNow::CbcStopNow ( const CbcStopNow & ) |
---|
249 | { |
---|
250 | } |
---|
251 | // Assignment operator |
---|
252 | CbcStopNow & |
---|
253 | CbcStopNow::operator=(const CbcStopNow & rhs) |
---|
254 | { |
---|
255 |   if (this != &rhs) { |
---|
256 | Â Â } |
---|
257 |   return *this; |
---|
258 | } |
---|
259 | // Clone |
---|
260 | CbcStopNow * |
---|
261 | CbcStopNow::clone()Â const |
---|
262 | { |
---|
263 |   return new CbcStopNow(*this); |
---|
264 | } |
---|
265 | |
---|
266 | /* |
---|
267 | Â CbcUser class definitions. |
---|
268 | */ |
---|
269 | |
---|
270 | // User stuff (base class) |
---|
271 | CbcUser::CbcUser() |
---|
272 | Â Â Â Â :Â coinModel_(NULL), |
---|
273 | Â Â Â Â userName_("null") |
---|
274 | { |
---|
275 | } |
---|
276 | CbcUser::~CbcUser() |
---|
277 | { |
---|
278 |   delete coinModel_; |
---|
279 | } |
---|
280 | // Copy constructor |
---|
281 | CbcUser::CbcUser ( const CbcUser & rhs) |
---|
282 | { |
---|
283 |   if (rhs.coinModel_) |
---|
284 |     coinModel_ = new CoinModel(*rhs.coinModel_); |
---|
285 | Â Â else |
---|
286 | Â Â Â Â coinModel_ =Â NULL; |
---|
287 | Â Â userName_ =Â rhs.userName_; |
---|
288 | } |
---|
289 | // Assignment operator |
---|
290 | CbcUser & |
---|
291 | CbcUser::operator=(const CbcUser & rhs) |
---|
292 | { |
---|
293 |   if (this != &rhs) { |
---|
294 |     if (rhs.coinModel_) |
---|
295 |       coinModel_ = new CoinModel(*rhs.coinModel_); |
---|
296 | Â Â Â Â else |
---|
297 | Â Â Â Â Â Â coinModel_ =Â NULL; |
---|
298 | Â Â Â Â userName_ =Â rhs.userName_; |
---|
299 | Â Â } |
---|
300 |   return *this; |
---|
301 | } |
---|
302 | |
---|
303 | static void putBackOtherSolutions(CbcModel * presolvedModel, CbcModel * model, |
---|
304 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglPreProcess *Â preProcess) |
---|
305 | { |
---|
306 |  int numberSolutions=presolvedModel->numberSavedSolutions(); |
---|
307 |  int numberColumns=presolvedModel->getNumCols(); |
---|
308 |  if (numberSolutions>1) { |
---|
309 | Â Â model->deleteSolutions(); |
---|
310 |   double * bestSolution = CoinCopyOfArray(presolvedModel->bestSolution(),numberColumns); |
---|
311 | Â Â //double cutoff = presolvedModel->getCutoff(); |
---|
312 |   double objectiveValue=presolvedModel->getObjValue(); |
---|
313 | Â Â //model->createSpaceForSavedSolutions(numberSolutions-1); |
---|
314 |   for (int iSolution=numberSolutions-1;iSolution>=0;iSolution--) { |
---|
315 | Â Â Â presolvedModel->setCutoff(COIN_DBL_MAX); |
---|
316 | Â Â Â presolvedModel->solver()->setColSolution(presolvedModel->savedSolution(iSolution)); |
---|
317 | Â Â Â //presolvedModel->savedSolutionObjective(iSolution)); |
---|
318 | Â Â Â preProcess->postProcess(*presolvedModel->solver(),false); |
---|
319 | Â Â Â model->setBestSolution(preProcess->originalModel()->getColSolution(),model->solver()->getNumCols(), |
---|
320 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolvedModel->savedSolutionObjective(iSolution)); |
---|
321 | Â Â } |
---|
322 | Â Â presolvedModel->setBestObjectiveValue(objectiveValue); |
---|
323 | Â Â presolvedModel->solver()->setColSolution(bestSolution); |
---|
324 | Â Â //presolvedModel->setBestSolution(bestSolution,numberColumns,objectiveValue); |
---|
325 | Â } |
---|
326 | } |
---|
327 | |
---|
328 | /* |
---|
329 | Â CbcSolver class definitions |
---|
330 | */ |
---|
331 | |
---|
332 | CbcSolver::CbcSolver() |
---|
333 | Â Â Â Â :Â babModel_(NULL), |
---|
334 | Â Â Â Â userFunction_(NULL), |
---|
335 | Â Â Â Â statusUserFunction_(NULL), |
---|
336 | Â Â Â Â originalSolver_(NULL), |
---|
337 | Â Â Â Â originalCoinModel_(NULL), |
---|
338 | Â Â Â Â cutGenerator_(NULL), |
---|
339 | Â Â Â Â numberUserFunctions_(0), |
---|
340 | Â Â Â Â numberCutGenerators_(0), |
---|
341 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
342 | Â Â Â Â parameters_(NULL), |
---|
343 | Â Â Â Â numberParameters_(0), |
---|
344 | Â Â Â Â doMiplib_(false), |
---|
345 | Â Â Â Â noPrinting_(false), |
---|
346 | Â Â Â Â readMode_(1) |
---|
347 | { |
---|
348 |   callBack_ = new CbcStopNow(); |
---|
349 | Â Â fillParameters(); |
---|
350 | } |
---|
351 | CbcSolver::CbcSolver(const OsiClpSolverInterface & solver) |
---|
352 | Â Â Â Â :Â babModel_(NULL), |
---|
353 | Â Â Â Â userFunction_(NULL), |
---|
354 | Â Â Â Â statusUserFunction_(NULL), |
---|
355 | Â Â Â Â originalSolver_(NULL), |
---|
356 | Â Â Â Â originalCoinModel_(NULL), |
---|
357 | Â Â Â Â cutGenerator_(NULL), |
---|
358 | Â Â Â Â numberUserFunctions_(0), |
---|
359 | Â Â Â Â numberCutGenerators_(0), |
---|
360 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
361 | Â Â Â Â parameters_(NULL), |
---|
362 | Â Â Â Â numberParameters_(0), |
---|
363 | Â Â Â Â doMiplib_(false), |
---|
364 | Â Â Â Â noPrinting_(false), |
---|
365 | Â Â Â Â readMode_(1) |
---|
366 | { |
---|
367 |   callBack_ = new CbcStopNow(); |
---|
368 | Â Â model_ =Â CbcModel(solver); |
---|
369 | Â Â fillParameters(); |
---|
370 | } |
---|
371 | CbcSolver::CbcSolver(const CbcModel & solver) |
---|
372 | Â Â Â Â :Â babModel_(NULL), |
---|
373 | Â Â Â Â userFunction_(NULL), |
---|
374 | Â Â Â Â statusUserFunction_(NULL), |
---|
375 | Â Â Â Â originalSolver_(NULL), |
---|
376 | Â Â Â Â originalCoinModel_(NULL), |
---|
377 | Â Â Â Â cutGenerator_(NULL), |
---|
378 | Â Â Â Â numberUserFunctions_(0), |
---|
379 | Â Â Â Â numberCutGenerators_(0), |
---|
380 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
381 | Â Â Â Â parameters_(NULL), |
---|
382 | Â Â Â Â numberParameters_(0), |
---|
383 | Â Â Â Â doMiplib_(false), |
---|
384 | Â Â Â Â noPrinting_(false), |
---|
385 | Â Â Â Â readMode_(1) |
---|
386 | { |
---|
387 |   callBack_ = new CbcStopNow(); |
---|
388 | Â Â model_ =Â solver; |
---|
389 | Â Â fillParameters(); |
---|
390 | } |
---|
391 | CbcSolver::~CbcSolver() |
---|
392 | { |
---|
393 |   int i; |
---|
394 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
395 |     delete userFunction_[i]; |
---|
396 |   delete [] userFunction_; |
---|
397 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
398 |     delete cutGenerator_[i]; |
---|
399 |   delete [] cutGenerator_; |
---|
400 |   delete [] statusUserFunction_; |
---|
401 |   delete originalSolver_; |
---|
402 |   delete originalCoinModel_; |
---|
403 |   delete babModel_; |
---|
404 |   delete [] parameters_; |
---|
405 |   delete callBack_; |
---|
406 | } |
---|
407 | // Copy constructor |
---|
408 | CbcSolver::CbcSolver ( const CbcSolver & rhs) |
---|
409 | Â Â Â Â :Â model_(rhs.model_), |
---|
410 | Â Â Â Â babModel_(NULL), |
---|
411 | Â Â Â Â userFunction_(NULL), |
---|
412 | Â Â Â Â statusUserFunction_(NULL), |
---|
413 | Â Â Â Â numberUserFunctions_(rhs.numberUserFunctions_), |
---|
414 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
415 | Â Â Â Â parameters_(NULL), |
---|
416 | Â Â Â Â numberParameters_(rhs.numberParameters_), |
---|
417 | Â Â Â Â doMiplib_(rhs.doMiplib_), |
---|
418 | Â Â Â Â noPrinting_(rhs.noPrinting_), |
---|
419 | Â Â Â Â readMode_(rhs.readMode_) |
---|
420 | { |
---|
421 | Â Â fillParameters(); |
---|
422 |   if (rhs.babModel_) |
---|
423 |     babModel_ = new CbcModel(*rhs.babModel_); |
---|
424 |   userFunction_ = new CbcUser * [numberUserFunctions_]; |
---|
425 |   int i; |
---|
426 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
427 | Â Â Â Â userFunction_[i]Â =Â rhs.userFunction_[i]->clone(); |
---|
428 |   for (i = 0; i < numberParameters_; i++) |
---|
429 | Â Â Â Â parameters_[i]Â =Â rhs.parameters_[i]; |
---|
430 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
431 | Â Â Â Â cutGenerator_[i]Â =Â rhs.cutGenerator_[i]->clone(); |
---|
432 | Â Â callBack_ =Â rhs.callBack_->clone(); |
---|
433 | Â Â originalSolver_ =Â NULL; |
---|
434 |   if (rhs.originalSolver_) { |
---|
435 | Â Â Â Â OsiSolverInterface *Â temp =Â rhs.originalSolver_->clone(); |
---|
436 | Â Â Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
437 | Â Â Â Â assert (originalSolver_); |
---|
438 | Â Â } |
---|
439 | Â Â originalCoinModel_ =Â NULL; |
---|
440 |   if (rhs.originalCoinModel_) |
---|
441 |     originalCoinModel_ = new CoinModel(*rhs.originalCoinModel_); |
---|
442 | } |
---|
443 | // Assignment operator |
---|
444 | CbcSolver & |
---|
445 | CbcSolver::operator=(const CbcSolver & rhs) |
---|
446 | { |
---|
447 |   if (this != &rhs) { |
---|
448 |     int i; |
---|
449 |     for (i = 0; i < numberUserFunctions_; i++) |
---|
450 |       delete userFunction_[i]; |
---|
451 |     delete [] userFunction_; |
---|
452 |     for (i = 0; i < numberCutGenerators_; i++) |
---|
453 |       delete cutGenerator_[i]; |
---|
454 |     delete [] statusUserFunction_; |
---|
455 |     delete originalSolver_; |
---|
456 |     delete originalCoinModel_; |
---|
457 | Â Â Â Â statusUserFunction_ =Â NULL; |
---|
458 |     delete babModel_; |
---|
459 |     delete callBack_; |
---|
460 | Â Â Â Â numberUserFunctions_ =Â rhs.numberUserFunctions_; |
---|
461 | Â Â Â Â startTime_ =Â rhs.startTime_; |
---|
462 | Â Â Â Â numberParameters_ =Â rhs.numberParameters_; |
---|
463 |     for (i = 0; i < numberParameters_; i++) |
---|
464 | Â Â Â Â Â Â parameters_[i]Â =Â rhs.parameters_[i]; |
---|
465 |     for (i = 0; i < numberCutGenerators_; i++) |
---|
466 | Â Â Â Â Â Â cutGenerator_[i]Â =Â rhs.cutGenerator_[i]->clone(); |
---|
467 | Â Â Â Â noPrinting_ =Â rhs.noPrinting_; |
---|
468 | Â Â Â Â readMode_ =Â rhs.readMode_; |
---|
469 | Â Â Â Â doMiplib_ =Â rhs.doMiplib_; |
---|
470 | Â Â Â Â model_ =Â rhs.model_; |
---|
471 |     if (rhs.babModel_) |
---|
472 |       babModel_ = new CbcModel(*rhs.babModel_); |
---|
473 | Â Â Â Â else |
---|
474 | Â Â Â Â Â Â babModel_ =Â NULL; |
---|
475 |     userFunction_ = new CbcUser * [numberUserFunctions_]; |
---|
476 |     for (i = 0; i < numberUserFunctions_; i++) |
---|
477 | Â Â Â Â Â Â userFunction_[i]Â =Â rhs.userFunction_[i]->clone(); |
---|
478 | Â Â Â Â callBack_ =Â rhs.callBack_->clone(); |
---|
479 | Â Â Â Â originalSolver_ =Â NULL; |
---|
480 |     if (rhs.originalSolver_) { |
---|
481 | Â Â Â Â Â Â OsiSolverInterface *Â temp =Â rhs.originalSolver_->clone(); |
---|
482 | Â Â Â Â Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
483 | Â Â Â Â Â Â assert (originalSolver_); |
---|
484 | Â Â Â Â } |
---|
485 | Â Â Â Â originalCoinModel_ =Â NULL; |
---|
486 |     if (rhs.originalCoinModel_) |
---|
487 |       originalCoinModel_ = new CoinModel(*rhs.originalCoinModel_); |
---|
488 | Â Â } |
---|
489 |   return *this; |
---|
490 | } |
---|
491 | // Get int value |
---|
492 | int CbcSolver::intValue(CbcOrClpParameterType type) const |
---|
493 | { |
---|
494 |   return parameters_[whichParam(type, numberParameters_, parameters_)].intValue(); |
---|
495 | } |
---|
496 | // Set int value |
---|
497 | void CbcSolver::setIntValue(CbcOrClpParameterType type, int value) |
---|
498 | { |
---|
499 |   parameters_[whichParam(type, numberParameters_, parameters_)].setIntValue(value); |
---|
500 | } |
---|
501 | // Get double value |
---|
502 | double CbcSolver::doubleValue(CbcOrClpParameterType type) const |
---|
503 | { |
---|
504 |   return parameters_[whichParam(type, numberParameters_, parameters_)].doubleValue(); |
---|
505 | } |
---|
506 | // Set double value |
---|
507 | void CbcSolver::setDoubleValue(CbcOrClpParameterType type, double value) |
---|
508 | { |
---|
509 |   parameters_[whichParam(type, numberParameters_, parameters_)].setDoubleValue(value); |
---|
510 | } |
---|
511 | // User function (NULL if no match) |
---|
512 | CbcUser * CbcSolver::userFunction(const char * name) const |
---|
513 | { |
---|
514 |   int i; |
---|
515 |   for (i = 0; i < numberUserFunctions_; i++) { |
---|
516 |     if (!strcmp(name, userFunction_[i]->name().c_str())) |
---|
517 | Â Â Â Â Â Â break; |
---|
518 | Â Â } |
---|
519 |   if (i < numberUserFunctions_) |
---|
520 |     return userFunction_[i]; |
---|
521 | Â Â else |
---|
522 |     return NULL; |
---|
523 | } |
---|
524 | void CbcSolver::fillParameters() |
---|
525 | { |
---|
526 |   int maxParam = 200; |
---|
527 |   CbcOrClpParam * parameters = new CbcOrClpParam [maxParam]; |
---|
528 | Â Â numberParameters_ =Â 0Â ; |
---|
529 |   establishParams(numberParameters_, parameters) ; |
---|
530 | Â Â assert (numberParameters_ <=Â maxParam); |
---|
531 |   parameters_ = new CbcOrClpParam [numberParameters_]; |
---|
532 |   int i; |
---|
533 |   for (i = 0; i < numberParameters_; i++) |
---|
534 | Â Â Â Â parameters_[i]Â =Â parameters[i]; |
---|
535 |   delete [] parameters; |
---|
536 |   const char dirsep = CoinFindDirSeparator(); |
---|
537 | Â Â std::string directory; |
---|
538 | Â Â std::string dirSample; |
---|
539 | Â Â std::string dirNetlib; |
---|
540 | Â Â std::string dirMiplib; |
---|
541 |   if (dirsep == '/') { |
---|
542 | Â Â Â Â directory =Â "./"; |
---|
543 | Â Â Â Â dirSample =Â "../../Data/Sample/"; |
---|
544 | Â Â Â Â dirNetlib =Â "../../Data/Netlib/"; |
---|
545 | Â Â Â Â dirMiplib =Â "../../Data/miplib3/"; |
---|
546 |   } else { |
---|
547 | Â Â Â Â directory =Â ".\\"; |
---|
548 | Â Â Â Â dirSample =Â "..\\..\\..\\..\\Data\\Sample\\"; |
---|
549 | Â Â Â Â dirNetlib =Â "..\\..\\..\\..\\Data\\Netlib\\"; |
---|
550 | Â Â Â Â dirMiplib =Â "..\\..\\..\\..\\Data\\miplib3\\"; |
---|
551 | Â Â } |
---|
552 | Â Â std::string defaultDirectory =Â directory; |
---|
553 | Â Â std::string importFile =Â ""; |
---|
554 | Â Â std::string exportFile =Â "default.mps"; |
---|
555 | Â Â std::string importBasisFile =Â ""; |
---|
556 | Â Â std::string importPriorityFile =Â ""; |
---|
557 | Â Â std::string mipStartFile =Â ""; |
---|
558 | Â Â std::string debugFile =Â ""; |
---|
559 | Â Â std::string printMask =Â ""; |
---|
560 | Â Â std::string exportBasisFile =Â "default.bas"; |
---|
561 | Â Â std::string saveFile =Â "default.prob"; |
---|
562 | Â Â std::string restoreFile =Â "default.prob"; |
---|
563 | Â Â std::string solutionFile =Â "stdout"; |
---|
564 | Â Â std::string solutionSaveFile =Â "solution.file"; |
---|
565 |   int doIdiot = -1; |
---|
566 |   int outputFormat = 2; |
---|
567 |   int substitution = 3; |
---|
568 |   int dualize = 3; |
---|
569 |   int preSolve = 5; |
---|
570 |   int doSprint = -1; |
---|
571 |   int testOsiParameters = -1; |
---|
572 |   int createSolver = 0; |
---|
573 | Â Â ClpSimplex *Â lpSolver; |
---|
574 | Â Â OsiClpSolverInterface *Â clpSolver; |
---|
575 |   if (model_.solver()) { |
---|
576 | Â Â Â Â clpSolver =Â dynamic_cast<OsiClpSolverInterface *>Â (model_.solver()); |
---|
577 | Â Â Â Â assert (clpSolver); |
---|
578 | Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
579 | Â Â Â Â assert (lpSolver); |
---|
580 |   } else { |
---|
581 |     lpSolver = new ClpSimplex(); |
---|
582 |     clpSolver = new OsiClpSolverInterface(lpSolver, true); |
---|
583 | Â Â Â Â createSolver =Â 1Â ; |
---|
584 | Â Â } |
---|
585 |   parameters_[whichParam(CLP_PARAM_ACTION_BASISIN, numberParameters_, parameters_)].setStringValue(importBasisFile); |
---|
586 |   parameters_[whichParam(CBC_PARAM_ACTION_PRIORITYIN, numberParameters_, parameters_)].setStringValue(importPriorityFile); |
---|
587 |   parameters_[whichParam(CBC_PARAM_ACTION_MIPSTART, numberParameters_, parameters_)].setStringValue(mipStartFile); |
---|
588 |   parameters_[whichParam(CLP_PARAM_ACTION_BASISOUT, numberParameters_, parameters_)].setStringValue(exportBasisFile); |
---|
589 |   parameters_[whichParam(CLP_PARAM_ACTION_DEBUG, numberParameters_, parameters_)].setStringValue(debugFile); |
---|
590 |   parameters_[whichParam(CLP_PARAM_ACTION_PRINTMASK, numberParameters_, parameters_)].setStringValue(printMask); |
---|
591 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRECTORY, numberParameters_, parameters_)].setStringValue(directory); |
---|
592 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRSAMPLE, numberParameters_, parameters_)].setStringValue(dirSample); |
---|
593 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRNETLIB, numberParameters_, parameters_)].setStringValue(dirNetlib); |
---|
594 |   parameters_[whichParam(CBC_PARAM_ACTION_DIRMIPLIB, numberParameters_, parameters_)].setStringValue(dirMiplib); |
---|
595 |   parameters_[whichParam(CLP_PARAM_DBL_DUALBOUND, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualBound()); |
---|
596 |   parameters_[whichParam(CLP_PARAM_DBL_DUALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualTolerance()); |
---|
597 |   parameters_[whichParam(CLP_PARAM_ACTION_EXPORT, numberParameters_, parameters_)].setStringValue(exportFile); |
---|
598 |   parameters_[whichParam(CLP_PARAM_INT_IDIOT, numberParameters_, parameters_)].setIntValue(doIdiot); |
---|
599 |   parameters_[whichParam(CLP_PARAM_ACTION_IMPORT, numberParameters_, parameters_)].setStringValue(importFile); |
---|
600 |   parameters_[whichParam(CLP_PARAM_DBL_PRESOLVETOLERANCE, numberParameters_, parameters_)].setDoubleValue(1.0e-8); |
---|
601 |   int iParam = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
602 |   int value = 1; |
---|
603 | Â Â clpSolver->messageHandler()->setLogLevel(1)Â ; |
---|
604 | Â Â lpSolver->setLogLevel(1); |
---|
605 | Â Â parameters_[iParam].setIntValue(value); |
---|
606 |   iParam = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
607 | Â Â model_.messageHandler()->setLogLevel(value); |
---|
608 | Â Â parameters_[iParam].setIntValue(value); |
---|
609 |   parameters_[whichParam(CLP_PARAM_INT_MAXFACTOR, numberParameters_, parameters_)].setIntValue(lpSolver->factorizationFrequency()); |
---|
610 |   parameters_[whichParam(CLP_PARAM_INT_MAXITERATION, numberParameters_, parameters_)].setIntValue(lpSolver->maximumIterations()); |
---|
611 |   parameters_[whichParam(CLP_PARAM_INT_OUTPUTFORMAT, numberParameters_, parameters_)].setIntValue(outputFormat); |
---|
612 |   parameters_[whichParam(CLP_PARAM_INT_PRESOLVEPASS, numberParameters_, parameters_)].setIntValue(preSolve); |
---|
613 |   parameters_[whichParam(CLP_PARAM_INT_PERTVALUE, numberParameters_, parameters_)].setIntValue(lpSolver->perturbation()); |
---|
614 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->primalTolerance()); |
---|
615 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALWEIGHT, numberParameters_, parameters_)].setDoubleValue(lpSolver->infeasibilityCost()); |
---|
616 |   parameters_[whichParam(CLP_PARAM_ACTION_RESTORE, numberParameters_, parameters_)].setStringValue(restoreFile); |
---|
617 |   parameters_[whichParam(CLP_PARAM_ACTION_SAVE, numberParameters_, parameters_)].setStringValue(saveFile); |
---|
618 | Â Â //parameters_[whichParam(CLP_PARAM_DBL_TIMELIMIT,numberParameters_,parameters_)].setDoubleValue(1.0e8); |
---|
619 |   parameters_[whichParam(CBC_PARAM_DBL_TIMELIMIT_BAB, numberParameters_, parameters_)].setDoubleValue(1.0e8); |
---|
620 |   parameters_[whichParam(CLP_PARAM_ACTION_SOLUTION, numberParameters_, parameters_)].setStringValue(solutionFile); |
---|
621 |   parameters_[whichParam(CLP_PARAM_ACTION_NEXTBESTSOLUTION, numberParameters_, parameters_)].setStringValue(solutionFile); |
---|
622 |   parameters_[whichParam(CLP_PARAM_ACTION_SAVESOL, numberParameters_, parameters_)].setStringValue(solutionSaveFile); |
---|
623 |   parameters_[whichParam(CLP_PARAM_INT_SPRINT, numberParameters_, parameters_)].setIntValue(doSprint); |
---|
624 |   parameters_[whichParam(CLP_PARAM_INT_SUBSTITUTION, numberParameters_, parameters_)].setIntValue(substitution); |
---|
625 |   parameters_[whichParam(CLP_PARAM_INT_DUALIZE, numberParameters_, parameters_)].setIntValue(dualize); |
---|
626 |   parameters_[whichParam(CBC_PARAM_INT_NUMBERBEFORE, numberParameters_, parameters_)].setIntValue(model_.numberBeforeTrust()); |
---|
627 |   parameters_[whichParam(CBC_PARAM_INT_MAXNODES, numberParameters_, parameters_)].setIntValue(model_.getMaximumNodes()); |
---|
628 |   parameters_[whichParam(CBC_PARAM_INT_STRONGBRANCHING, numberParameters_, parameters_)].setIntValue(model_.numberStrong()); |
---|
629 |   parameters_[whichParam(CBC_PARAM_DBL_INFEASIBILITYWEIGHT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcInfeasibilityWeight)); |
---|
630 |   parameters_[whichParam(CBC_PARAM_DBL_INTEGERTOLERANCE, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcIntegerTolerance)); |
---|
631 |   parameters_[whichParam(CBC_PARAM_DBL_INCREMENT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcCutoffIncrement)); |
---|
632 |   parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(testOsiParameters); |
---|
633 |   parameters_[whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_)].setIntValue(1003); |
---|
634 | Â Â initialPumpTune =Â 1003; |
---|
635 | #ifdef CBC_THREAD |
---|
636 |   parameters_[whichParam(CBC_PARAM_INT_THREADS, numberParameters_, parameters_)].setIntValue(0); |
---|
637 | #endif |
---|
638 | Â Â // Set up likely cut generators and defaults |
---|
639 |   parameters_[whichParam(CBC_PARAM_STR_PREPROCESS, numberParameters_, parameters_)].setCurrentOption("sos"); |
---|
640 |   parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].setIntValue(1057); |
---|
641 |   parameters_[whichParam(CBC_PARAM_INT_CUTPASSINTREE, numberParameters_, parameters_)].setIntValue(1); |
---|
642 |   parameters_[whichParam(CBC_PARAM_INT_MOREMIPOPTIONS, numberParameters_, parameters_)].setIntValue(-1); |
---|
643 |   parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].setIntValue(100); |
---|
644 |   parameters_[whichParam(CBC_PARAM_STR_CUTSSTRATEGY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
645 |   parameters_[whichParam(CBC_PARAM_STR_HEURISTICSTRATEGY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
646 |   parameters_[whichParam(CBC_PARAM_STR_NODESTRATEGY, numberParameters_, parameters_)].setCurrentOption("fewest"); |
---|
647 |   parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
648 |   parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
649 |   parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
650 |   parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
651 |   parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
652 |   parameters_[whichParam(CBC_PARAM_STR_REDSPLIT2CUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
653 |   parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
654 |   parameters_[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
655 |   parameters_[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
656 |   parameters_[whichParam(CBC_PARAM_STR_FLOWCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
657 |   parameters_[whichParam(CBC_PARAM_STR_TWOMIRCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
658 |   parameters_[whichParam(CBC_PARAM_STR_LANDPCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
659 |   parameters_[whichParam(CBC_PARAM_STR_RESIDCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
660 |   parameters_[whichParam(CBC_PARAM_STR_ROUNDING, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
661 |   parameters_[whichParam(CBC_PARAM_STR_FPUMP, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
662 |   parameters_[whichParam(CBC_PARAM_STR_GREEDY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
663 |   parameters_[whichParam(CBC_PARAM_STR_COMBINE, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
664 |   parameters_[whichParam(CBC_PARAM_STR_CROSSOVER2, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
665 |   parameters_[whichParam(CBC_PARAM_STR_PIVOTANDCOMPLEMENT, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
666 |   parameters_[whichParam(CBC_PARAM_STR_PIVOTANDFIX, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
667 |   parameters_[whichParam(CBC_PARAM_STR_RANDROUND, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
668 |   parameters_[whichParam(CBC_PARAM_STR_NAIVE, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
669 |   parameters_[whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
670 |   parameters_[whichParam(CBC_PARAM_STR_DINS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
671 |   parameters_[whichParam(CBC_PARAM_STR_RENS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
672 |   parameters_[whichParam(CBC_PARAM_STR_LOCALTREE, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
673 |   parameters_[whichParam(CBC_PARAM_STR_COSTSTRATEGY, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
674 |   if (createSolver) |
---|
675 |     delete clpSolver; |
---|
676 | } |
---|
677 | |
---|
678 | /* |
---|
679 | Â Initialise a subset of the parameters prior to processing any input from |
---|
680 | Â the user. |
---|
681 | |
---|
682 | Â Why this choice of subset? |
---|
683 | */ |
---|
684 | /*! |
---|
685 | Â \todo Guard/replace clp-specific code |
---|
686 | */ |
---|
687 | void CbcSolver::fillValuesInSolver() |
---|
688 | { |
---|
689 | Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
690 | Â Â OsiClpSolverInterface *Â clpSolver = |
---|
691 | Â Â Â Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
692 | Â Â assert (clpSolver); |
---|
693 | Â Â ClpSimplex *Â lpSolver =Â clpSolver->getModelPtr(); |
---|
694 | |
---|
695 | Â Â /* |
---|
696 | Â Â Â Why are we reaching into the underlying solver(s) for these settings? |
---|
697 | Â Â Â Shouldn't CbcSolver have its own defaults, which are then imposed on the |
---|
698 | Â Â Â underlying solver? |
---|
699 | |
---|
700 | Â Â Â Coming at if from the other side, if CbcSolver had the capability to use |
---|
701 | Â Â Â multiple solvers then it definitely makes sense to acquire the defaults from |
---|
702 | Â Â Â the solver (on the assumption that we haven't processed command line |
---|
703 | Â Â Â parameters yet, which can then override the defaults). But then it's more of |
---|
704 | Â Â Â a challenge to avoid solver-specific coding here. |
---|
705 | Â Â */ |
---|
706 | Â Â noPrinting_ =Â (lpSolver->logLevel()Â ==Â 0); |
---|
707 | Â Â CoinMessageHandler *Â generalMessageHandler =Â clpSolver->messageHandler(); |
---|
708 | Â Â generalMessageHandler->setPrefix(true); |
---|
709 | |
---|
710 | Â Â lpSolver->setPerturbation(50); |
---|
711 | Â Â lpSolver->messageHandler()->setPrefix(false); |
---|
712 | |
---|
713 |   parameters_[whichParam(CLP_PARAM_DBL_DUALBOUND, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualBound()); |
---|
714 |   parameters_[whichParam(CLP_PARAM_DBL_DUALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualTolerance()); |
---|
715 | Â Â /* |
---|
716 | Â Â Â Why are we doing this? We read the log level from parameters_, set it into |
---|
717 | Â Â Â the message handlers for cbc and the underlying solver. Then we read the |
---|
718 | Â Â Â log level back from the handlers and use it to set the values in |
---|
719 | Â Â Â parameters_! |
---|
720 | Â Â */ |
---|
721 |   int iParam = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
722 |   int value = parameters_[iParam].intValue(); |
---|
723 | Â Â clpSolver->messageHandler()->setLogLevel(value)Â ; |
---|
724 | Â Â lpSolver->setLogLevel(value); |
---|
725 |   iParam = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
726 | Â Â value =Â parameters_[iParam].intValue(); |
---|
727 | Â Â model_.messageHandler()->setLogLevel(value); |
---|
728 |   parameters_[whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_)].setIntValue(model_.logLevel()); |
---|
729 |   parameters_[whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_)].setIntValue(lpSolver->logLevel()); |
---|
730 |   parameters_[whichParam(CLP_PARAM_INT_MAXFACTOR, numberParameters_, parameters_)].setIntValue(lpSolver->factorizationFrequency()); |
---|
731 |   parameters_[whichParam(CLP_PARAM_INT_MAXITERATION, numberParameters_, parameters_)].setIntValue(lpSolver->maximumIterations()); |
---|
732 |   parameters_[whichParam(CLP_PARAM_INT_PERTVALUE, numberParameters_, parameters_)].setIntValue(lpSolver->perturbation()); |
---|
733 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->primalTolerance()); |
---|
734 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALWEIGHT, numberParameters_, parameters_)].setDoubleValue(lpSolver->infeasibilityCost()); |
---|
735 |   parameters_[whichParam(CBC_PARAM_INT_NUMBERBEFORE, numberParameters_, parameters_)].setIntValue(model_.numberBeforeTrust()); |
---|
736 |   parameters_[whichParam(CBC_PARAM_INT_MAXNODES, numberParameters_, parameters_)].setIntValue(model_.getMaximumNodes()); |
---|
737 |   parameters_[whichParam(CBC_PARAM_INT_STRONGBRANCHING, numberParameters_, parameters_)].setIntValue(model_.numberStrong()); |
---|
738 |   parameters_[whichParam(CBC_PARAM_DBL_INFEASIBILITYWEIGHT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcInfeasibilityWeight)); |
---|
739 |   parameters_[whichParam(CBC_PARAM_DBL_INTEGERTOLERANCE, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcIntegerTolerance)); |
---|
740 |   parameters_[whichParam(CBC_PARAM_DBL_INCREMENT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcCutoffIncrement)); |
---|
741 | } |
---|
742 | // Add user function |
---|
743 | void |
---|
744 | CbcSolver::addUserFunction(CbcUser *Â function) |
---|
745 | { |
---|
746 |   CbcUser ** temp = new CbcUser * [numberUserFunctions_+1]; |
---|
747 |   int i; |
---|
748 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
749 | Â Â Â Â temp[i]Â =Â userFunction_[i]; |
---|
750 |   delete [] userFunction_; |
---|
751 | Â Â userFunction_ =Â temp; |
---|
752 | Â Â userFunction_[numberUserFunctions_++]Â =Â function->clone(); |
---|
753 |   delete [] statusUserFunction_; |
---|
754 | Â Â statusUserFunction_ =Â NULL; |
---|
755 | } |
---|
756 | // Set user call back |
---|
757 | void |
---|
758 | CbcSolver::setUserCallBack(CbcStopNow *Â function) |
---|
759 | { |
---|
760 |   delete callBack_; |
---|
761 | Â Â callBack_ =Â function->clone(); |
---|
762 | } |
---|
763 | // Copy of model on initial load (will contain output solutions) |
---|
764 | void |
---|
765 | CbcSolver::setOriginalSolver(OsiClpSolverInterface *Â originalSolver) |
---|
766 | { |
---|
767 |   delete originalSolver_; |
---|
768 | Â Â OsiSolverInterface *Â temp =Â originalSolver->clone(); |
---|
769 | Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
770 | Â Â assert (originalSolver_); |
---|
771 | |
---|
772 | } |
---|
773 | // Copy of model on initial load |
---|
774 | void |
---|
775 | CbcSolver::setOriginalCoinModel(CoinModel *Â originalCoinModel) |
---|
776 | { |
---|
777 |   delete originalCoinModel_; |
---|
778 |   originalCoinModel_ = new CoinModel(*originalCoinModel); |
---|
779 | } |
---|
780 | // Add cut generator |
---|
781 | void |
---|
782 | CbcSolver::addCutGenerator(CglCutGenerator *Â generator) |
---|
783 | { |
---|
784 |   CglCutGenerator ** temp = new CglCutGenerator * [numberCutGenerators_+1]; |
---|
785 |   int i; |
---|
786 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
787 | Â Â Â Â temp[i]Â =Â cutGenerator_[i]; |
---|
788 |   delete [] cutGenerator_; |
---|
789 | Â Â cutGenerator_ =Â temp; |
---|
790 | Â Â cutGenerator_[numberCutGenerators_++]Â =Â generator->clone(); |
---|
791 | } |
---|
792 | |
---|
793 | /* |
---|
794 | Â The only other solver that's ever been used is cplex, and the use is |
---|
795 | Â limited -- do the root with clp and all the cbc smarts, then give the |
---|
796 | Â problem over to cplex to finish. Although the defines can be read in some |
---|
797 | Â places to allow other options, nothing's been tested and success is |
---|
798 | Â unlikely. |
---|
799 | |
---|
800 | Â CBC_OTHER_SOLVER == 1 is cplex. |
---|
801 | */ |
---|
802 | |
---|
803 | #if CBC_OTHER_SOLVER==1 |
---|
804 | #Â ifndef COIN_HAS_CPX |
---|
805 | #Â Â error "Configuration did not detect cplex installation." |
---|
806 | #Â else |
---|
807 | #Â Â include "OsiCpxSolverInterface.hpp" |
---|
808 | #Â endif |
---|
809 | #endif |
---|
810 | |
---|
811 | #ifdef COIN_HAS_ASL |
---|
812 | #include "Cbc_ampl.h" |
---|
813 | #endif |
---|
814 | |
---|
815 | static void statistics(ClpSimplex * originalModel, ClpSimplex * model); |
---|
816 | static bool maskMatches(const int * starts, char ** masks, |
---|
817 | Â Â Â Â Â Â Â Â Â Â Â Â std::string &Â check); |
---|
818 | static void generateCode(CbcModel * model, const char * fileName, int type, int preProcess); |
---|
819 | |
---|
820 | // dummy fake main programs for UserClp and UserCbc |
---|
821 | void fakeMain (ClpSimplex & model, OsiSolverInterface & osiSolver, CbcModel & babSolver); |
---|
822 | void fakeMain2 (ClpSimplex & model, OsiClpSolverInterface & osiSolver, int options); |
---|
823 | |
---|
824 | // Allow for interrupts |
---|
825 | // But is this threadsafe? (so switched off by option) |
---|
826 | |
---|
827 | #include "CoinSignal.hpp" |
---|
828 | static CbcModel * currentBranchModel = NULL; |
---|
829 | |
---|
830 | extern "C" { |
---|
831 |   static void signal_handler(int whichSignal) { |
---|
832 |    if (currentBranchModel != NULL) { |
---|
833 | Â Â Â Â currentBranchModel->sayEventHappened();Â // say why stopped |
---|
834 |     if (currentBranchModel->heuristicModel()) |
---|
835 | Â Â Â Â Â currentBranchModel->heuristicModel()->sayEventHappened(); |
---|
836 | Â Â Â } |
---|
837 | Â Â Â Â return; |
---|
838 | Â Â } |
---|
839 | } |
---|
840 | |
---|
841 | //#define CBC_SIG_TRAP |
---|
842 | #ifdef CBC_SIG_TRAP |
---|
843 | #include <setjmp.h> |
---|
844 | static sigjmp_buf cbc_seg_buffer; |
---|
845 | extern "C" { |
---|
846 |   static void signal_handler_error(int whichSignal) { |
---|
847 |     siglongjmp(cbc_seg_buffer, 1); |
---|
848 | Â Â } |
---|
849 | } |
---|
850 | #endif |
---|
851 | |
---|
852 | |
---|
853 | /* |
---|
854 | Â Debug checks on special ordered sets. |
---|
855 | |
---|
856 | Â This is active only for debugging. The entire body of the routine becomes |
---|
857 | Â a noop when COIN_DEVELOP is not defined. To avoid compiler warnings, the |
---|
858 | Â formal parameters also need to go away. |
---|
859 | */ |
---|
860 | #ifdef COIN_DEVELOP |
---|
861 | void checkSOS(CbcModel * babModel, const OsiSolverInterface * solver) |
---|
862 | #else |
---|
863 | void checkSOS(CbcModel * /*babModel*/, const OsiSolverInterface * /*solver*/) |
---|
864 | #endif |
---|
865 | { |
---|
866 | #ifdef COIN_DEVELOP |
---|
867 |   if (!babModel->ownObjects()) |
---|
868 | Â Â Â Â return; |
---|
869 | #if COIN_DEVELOP>2 |
---|
870 | Â Â //const double *objective = solver->getObjCoefficients() ; |
---|
871 |   const double *columnLower = solver->getColLower() ; |
---|
872 |   const double * columnUpper = solver->getColUpper() ; |
---|
873 |   const double * solution = solver->getColSolution(); |
---|
874 | Â Â //int numberRows = solver->getNumRows(); |
---|
875 | Â Â //double direction = solver->getObjSense(); |
---|
876 | Â Â //int iRow,iColumn; |
---|
877 | #endif |
---|
878 | |
---|
879 | Â Â // Row copy |
---|
880 | Â Â CoinPackedMatrix matrixByRow(*solver->getMatrixByRow()); |
---|
881 | Â Â //const double * elementByRow = matrixByRow.getElements(); |
---|
882 | Â Â //const int * column = matrixByRow.getIndices(); |
---|
883 | Â Â //const CoinBigIndex * rowStart = matrixByRow.getVectorStarts(); |
---|
884 |   const int * rowLength = matrixByRow.getVectorLengths(); |
---|
885 | |
---|
886 | Â Â // Column copy |
---|
887 |   CoinPackedMatrix matrixByCol(*solver->getMatrixByCol()); |
---|
888 |   const double * element = matrixByCol.getElements(); |
---|
889 |   const int * row = matrixByCol.getIndices(); |
---|
890 |   const CoinBigIndex * columnStart = matrixByCol.getVectorStarts(); |
---|
891 |   const int * columnLength = matrixByCol.getVectorLengths(); |
---|
892 | |
---|
893 |   const double * rowLower = solver->getRowLower(); |
---|
894 |   const double * rowUpper = solver->getRowUpper(); |
---|
895 | Â Â OsiObject **Â objects =Â babModel->objects(); |
---|
896 |   int numberObjects = babModel->numberObjects(); |
---|
897 |   int numberColumns = solver->getNumCols() ; |
---|
898 |   for (int iObj = 0; iObj < numberObjects; iObj++) { |
---|
899 | Â Â Â Â CbcSOS *Â objSOS = |
---|
900 |       dynamic_cast <CbcSOS *>(objects[iObj]) ; |
---|
901 |     if (objSOS) { |
---|
902 |       int n = objSOS->numberMembers(); |
---|
903 |       const int * which = objSOS->members(); |
---|
904 | #if COIN_DEVELOP>2 |
---|
905 |       const double * weight = objSOS->weights(); |
---|
906 | #endif |
---|
907 |       int type = objSOS->sosType(); |
---|
908 | Â Â Â Â Â Â // convexity row? |
---|
909 |       int iColumn; |
---|
910 | Â Â Â Â Â Â iColumn =Â which[0]; |
---|
911 |       int j; |
---|
912 |       int convex = -1; |
---|
913 |       for (j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { |
---|
914 |         int iRow = row[j]; |
---|
915 |         double value = element[j]; |
---|
916 |         if (rowLower[iRow] == 1.0 && rowUpper[iRow] == 1.0 && |
---|
917 | Â Â Â Â Â Â Â Â Â Â Â Â value ==Â 1.0)Â { |
---|
918 | Â Â Â Â Â Â Â Â Â Â // possible |
---|
919 |           if (rowLength[iRow] == n) { |
---|
920 |             if (convex == -1) |
---|
921 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex =Â iRow; |
---|
922 | Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
923 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex =Â -2; |
---|
924 | Â Â Â Â Â Â Â Â Â Â } |
---|
925 | Â Â Â Â Â Â Â Â } |
---|
926 | Â Â Â Â Â Â } |
---|
927 | Â Â Â Â Â Â printf ("set %d of type %d has %d members - possible convexity row %d\n", |
---|
928 |           iObj, type, n, convex); |
---|
929 |       for (int i = 0; i < n; i++) { |
---|
930 | Â Â Â Â Â Â Â Â iColumn =Â which[i]; |
---|
931 | Â Â Â Â Â Â Â Â // Column may have been added |
---|
932 |         if (iColumn < numberColumns) { |
---|
933 |           int convex2 = -1; |
---|
934 |           for (j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { |
---|
935 |             int iRow = row[j]; |
---|
936 |             if (iRow == convex) { |
---|
937 |               double value = element[j]; |
---|
938 |               if (value == 1.0) { |
---|
939 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex2 =Â iRow; |
---|
940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
941 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
942 | Â Â Â Â Â Â Â Â Â Â } |
---|
943 |           if (convex2<0 && convex >= 0) { |
---|
944 | Â Â Â Â Â Â Â Â Â Â Â Â printf("odd convexity row\n"); |
---|
945 | Â Â Â Â Â Â Â Â Â Â Â Â convex =Â -2; |
---|
946 | Â Â Â Â Â Â Â Â Â Â } |
---|
947 | #if COIN_DEVELOP>2 |
---|
948 | Â Â Â Â Â Â Â Â Â Â printf("col %d has weight %g and value %g, bounds %g %g\n", |
---|
949 |               iColumn, weight[i], solution[iColumn], columnLower[iColumn], |
---|
950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â columnUpper[iColumn]); |
---|
951 | #endif |
---|
952 | Â Â Â Â Â Â Â Â } |
---|
953 | Â Â Â Â Â Â } |
---|
954 | Â Â Â Â } |
---|
955 | Â Â } |
---|
956 | #endif // COIN_DEVELOP |
---|
957 | } |
---|
958 | |
---|
959 | static int dummyCallBack(CbcModel * /*model*/, int /*whereFrom*/) |
---|
960 | { |
---|
961 |   return 0; |
---|
962 | } |
---|
963 | |
---|
964 | |
---|
965 | /* |
---|
966 | Â Global parameters for command processing. |
---|
967 | |
---|
968 | Â These will need to be moved into an object of some sort in order to make |
---|
969 | Â this set of calls thread-safe. |
---|
970 | */ |
---|
971 | |
---|
972 | int CbcOrClpRead_mode = 1; |
---|
973 | FILE *Â CbcOrClpReadCommand =Â stdin; |
---|
974 | extern int CbcOrClpEnvironmentIndex; |
---|
975 | |
---|
976 | int callCbc1(const char * input2, CbcModel & model, |
---|
977 |        int callBack(CbcModel * currentSolver, int whereFrom), |
---|
978 | Â Â Â Â Â Â Â CbcSolverUsefulData &Â parameterData); |
---|
979 | |
---|
980 | /* |
---|
981 | Â Wrappers for CbcMain0, CbcMain1. The various forms of callCbc will eventually |
---|
982 | Â resolve to a call to CbcMain0 followed by a call to callCbc1. |
---|
983 | */ |
---|
984 | /* |
---|
985 | Â Simplest calling form: supply just a string with the command options. The |
---|
986 | Â wrapper creates an OsiClpSolverInterface and calls the next wrapper. |
---|
987 | */ |
---|
988 | int callCbc(const std::string input2) |
---|
989 | { |
---|
990 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
991 | Â Â OsiClpSolverInterface solver1; |
---|
992 |   int returnCode = callCbc(input3, solver1); |
---|
993 | Â Â free(input3); |
---|
994 |   return returnCode; |
---|
995 | } |
---|
996 | |
---|
997 | int callCbc(const char * input2) |
---|
998 | { |
---|
999 | Â Â { |
---|
1000 | Â Â Â Â OsiClpSolverInterface solver1; |
---|
1001 |     return callCbc(input2, solver1); |
---|
1002 | Â Â } |
---|
1003 | } |
---|
1004 | |
---|
1005 | /* |
---|
1006 | Â Second calling form: supply the command line and an OsiClpSolverInterface. |
---|
1007 | Â the wrapper will create a CbcModel and call the next wrapper. |
---|
1008 | */ |
---|
1009 | |
---|
1010 | int callCbc(const std::string input2, OsiClpSolverInterface& solver1) |
---|
1011 | { |
---|
1012 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1013 |   int returnCode = callCbc(input3, solver1); |
---|
1014 | Â Â free(input3); |
---|
1015 |   return returnCode; |
---|
1016 | } |
---|
1017 | |
---|
1018 | int callCbc(const char * input2, OsiClpSolverInterface& solver1) |
---|
1019 | { |
---|
1020 | Â Â CbcModel model(solver1); |
---|
1021 |   return callCbc(input2, model); |
---|
1022 | } |
---|
1023 | |
---|
1024 | /* |
---|
1025 | Â Third calling form: supply the command line and a CbcModel. This wrapper will |
---|
1026 | Â actually call CbcMain0 and then call the next set of wrappers (callCbc1) to |
---|
1027 | Â handle the call to CbcMain1. |
---|
1028 | */ |
---|
1029 | int callCbc(const char * input2, CbcModel & babSolver) |
---|
1030 | { |
---|
1031 | Â CbcSolverUsefulData data; |
---|
1032 | #ifndef CBC_NO_INTERRUPT |
---|
1033 | Â Â data.useSignalHandler_=true; |
---|
1034 | #endif |
---|
1035 | #ifndef CBC_NO_PRINTING |
---|
1036 | Â Â data.noPrinting_ =Â false; |
---|
1037 | #endif |
---|
1038 |  CbcMain0(babSolver, data); |
---|
1039 |  return callCbc1(input2, babSolver, dummyCallBack, data); |
---|
1040 | } |
---|
1041 | |
---|
1042 | int callCbc(const std::string input2, CbcModel & babSolver) |
---|
1043 | { |
---|
1044 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1045 | Â Â CbcMain0(babSolver); |
---|
1046 |   int returnCode = callCbc1(input3, babSolver); |
---|
1047 | Â Â free(input3); |
---|
1048 |   return returnCode; |
---|
1049 | } |
---|
1050 | |
---|
1051 | |
---|
1052 | /* |
---|
1053 | Â Various overloads of callCbc1. The first pair accepts just a CbcModel and |
---|
1054 | Â supplements it with a dummy callback routine. The second pair allows the |
---|
1055 | Â user to supply a callback. See CbcMain1 for further explanation of the |
---|
1056 | Â callback. The various overloads of callCbc1 resolve to the final version, |
---|
1057 | Â which breaks the string into individual parameter strings (i.e., creates |
---|
1058 | Â something that looks like a standard argv vector). |
---|
1059 | */ |
---|
1060 | |
---|
1061 | int callCbc1(const std::string input2, CbcModel & babSolver) |
---|
1062 | { |
---|
1063 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1064 |   int returnCode = callCbc1(input3, babSolver); |
---|
1065 | Â Â free(input3); |
---|
1066 |   return returnCode; |
---|
1067 | } |
---|
1068 | |
---|
1069 | int callCbc1(const char * input2, CbcModel & model) |
---|
1070 | { |
---|
1071 |   return callCbc1(input2, model, dummyCallBack); |
---|
1072 | } |
---|
1073 | |
---|
1074 | int callCbc1(const std::string input2, CbcModel & babSolver, |
---|
1075 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1076 | { |
---|
1077 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1078 |   int returnCode = callCbc1(input3, babSolver, callBack); |
---|
1079 | Â Â free(input3); |
---|
1080 |   return returnCode; |
---|
1081 | } |
---|
1082 | int callCbc1(const char * input2, CbcModel & model, |
---|
1083 |        int callBack(CbcModel * currentSolver, int whereFrom), |
---|
1084 | Â Â Â Â Â Â Â CbcSolverUsefulData &Â parameterData) |
---|
1085 | { |
---|
1086 |   char * input = CoinStrdup(input2 ? input2 : "") ; |
---|
1087 | Â Â size_t length =Â strlen(input); |
---|
1088 |   bool blank = input[0] == ' '; |
---|
1089 |   int n = blank ? 0 : 1; |
---|
1090 |   for (size_t i = 0; i < length; i++) { |
---|
1091 |     if (blank) { |
---|
1092 | Â Â Â Â Â Â // look for next non blank |
---|
1093 |       if (input[i] == ' ') { |
---|
1094 | Â Â Â Â Â Â Â Â continue; |
---|
1095 |       } else { |
---|
1096 | Â Â Â Â Â Â Â Â n++; |
---|
1097 | Â Â Â Â Â Â Â Â blank =Â false; |
---|
1098 | Â Â Â Â Â Â } |
---|
1099 |     } else { |
---|
1100 | Â Â Â Â Â Â // look for next blank |
---|
1101 |       if (input[i] != ' ') { |
---|
1102 | Â Â Â Â Â Â Â Â continue; |
---|
1103 |       } else { |
---|
1104 | Â Â Â Â Â Â Â Â blank =Â true; |
---|
1105 | Â Â Â Â Â Â } |
---|
1106 | Â Â Â Â } |
---|
1107 | Â Â } |
---|
1108 |   char ** argv = new char * [n+2]; |
---|
1109 | Â Â argv[0]Â =Â CoinStrdup("cbc"); |
---|
1110 | Â Â size_t i =Â 0; |
---|
1111 |   while (input[i] == ' ') |
---|
1112 | Â Â Â Â i++; |
---|
1113 |   for (int j = 0; j < n; j++) { |
---|
1114 | Â Â Â Â size_t saveI =Â i; |
---|
1115 |     for (; i < length; i++) { |
---|
1116 | Â Â Â Â Â Â // look for next blank |
---|
1117 |       if (input[i] != ' ') { |
---|
1118 | Â Â Â Â Â Â Â Â continue; |
---|
1119 |       } else { |
---|
1120 | Â Â Â Â Â Â Â Â break; |
---|
1121 | Â Â Â Â Â Â } |
---|
1122 | Â Â Â Â } |
---|
1123 | Â Â Â Â input[i++]Â =Â '\0'; |
---|
1124 | Â Â Â Â argv[j+1]Â =Â CoinStrdup(input +Â saveI); |
---|
1125 |     while (input[i] == ' ') |
---|
1126 | Â Â Â Â Â Â i++; |
---|
1127 | Â Â } |
---|
1128 | Â Â argv[n+1]Â =Â CoinStrdup("-quit"); |
---|
1129 | Â Â free(input); |
---|
1130 | Â Â currentBranchModel =Â NULL; |
---|
1131 | Â Â CbcOrClpRead_mode =Â 1; |
---|
1132 | Â Â CbcOrClpReadCommand =Â stdin; |
---|
1133 |   int returnCode = CbcMain1(n + 2, const_cast<const char **>(argv), |
---|
1134 |                model, callBack,parameterData); |
---|
1135 |   for (int k = 0; k < n + 2; k++) |
---|
1136 | Â Â Â Â free(argv[k]); |
---|
1137 |   delete [] argv; |
---|
1138 |   return returnCode; |
---|
1139 | } |
---|
1140 | static CbcSolverUsefulData staticParameterData; |
---|
1141 | int callCbc1(const char * input2, CbcModel & model, |
---|
1142 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1143 | { |
---|
1144 | Â // allow interrupts and printing |
---|
1145 | #ifndef CBC_NO_INTERRUPT |
---|
1146 | Â staticParameterData.useSignalHandler_=true; |
---|
1147 | #endif |
---|
1148 | #ifndef CBC_NO_PRINTING |
---|
1149 | Â staticParameterData.noPrinting_ =Â false; |
---|
1150 | #endif |
---|
1151 |  return callCbc1(input2,model,callBack,staticParameterData); |
---|
1152 | } |
---|
1153 | |
---|
1154 | CglPreProcess *Â cbcPreProcessPointer=NULL; |
---|
1155 | |
---|
1156 | int CbcClpUnitTest (const CbcModel & saveModel, |
---|
1157 |           const std::string& dirMiplib, int testSwitch, |
---|
1158 |           const double * stuff); |
---|
1159 | |
---|
1160 | int CbcMain1 (int argc, const char *argv[], |
---|
1161 |        CbcModel & model) |
---|
1162 | { |
---|
1163 |   return CbcMain1(argc, argv, model, dummyCallBack); |
---|
1164 | } |
---|
1165 | |
---|
1166 | #ifdef CBC_THREAD_SAFE |
---|
1167 | // Copies of some input decoding |
---|
1168 | |
---|
1169 | static std::string |
---|
1170 | CoinReadGetCommand(int &whichArgument, int argc, const char *argv[]) |
---|
1171 | { |
---|
1172 | Â std::string field; |
---|
1173 |  if (whichArgument < argc) |
---|
1174 | Â Â field =Â argv[whichArgument++]; |
---|
1175 | Â else |
---|
1176 | Â Â field =Â "quit"; |
---|
1177 |  if (field[0] == '-') |
---|
1178 | Â Â field =Â field.substr(1); |
---|
1179 |  return field; |
---|
1180 | } |
---|
1181 | static std::string |
---|
1182 | CoinReadGetString(int &whichArgument, int argc, const char *argv[]) |
---|
1183 | { |
---|
1184 | Â std::string field; |
---|
1185 |  if (whichArgument < argc) |
---|
1186 | Â Â field =Â argv[whichArgument++]; |
---|
1187 | Â else |
---|
1188 | Â Â field =Â ""; |
---|
1189 |  return field; |
---|
1190 | } |
---|
1191 | // valid 0 - okay, 1 bad, 2 not there |
---|
1192 | static int |
---|
1193 | CoinReadGetIntField(int &whichArgument, int argc, const char *argv[], int * valid) |
---|
1194 | { |
---|
1195 | Â std::string field; |
---|
1196 |  if (whichArgument < argc) |
---|
1197 | Â Â field =Â argv[whichArgument++]; |
---|
1198 | Â else |
---|
1199 | Â Â field =Â "0"; |
---|
1200 |  long int value = 0; |
---|
1201 |  const char * start = field.c_str(); |
---|
1202 |  char * endPointer = NULL; |
---|
1203 | Â // check valid |
---|
1204 |  value = strtol(start, &endPointer, 10); |
---|
1205 |  if (*endPointer == '\0') { |
---|
1206 | Â Â *valid =Â 0; |
---|
1207 |  } else { |
---|
1208 | Â Â *valid =Â 1; |
---|
1209 | Â Â std::cout <<Â "String of "Â <<Â field; |
---|
1210 | Â } |
---|
1211 |  return static_cast<int>(value); |
---|
1212 | } |
---|
1213 | static double |
---|
1214 | CoinReadGetDoubleField(int &whichArgument, int argc, const char *argv[], int * valid) |
---|
1215 | { |
---|
1216 | Â std::string field; |
---|
1217 |  if (whichArgument < argc) |
---|
1218 | Â Â field =Â argv[whichArgument++]; |
---|
1219 | Â else |
---|
1220 | Â Â field =Â "0.0"; |
---|
1221 |  double value = 0.0; |
---|
1222 |  const char * start = field.c_str(); |
---|
1223 |  char * endPointer = NULL; |
---|
1224 | Â // check valid |
---|
1225 |  value = strtod(start, &endPointer); |
---|
1226 |  if (*endPointer == '\0') { |
---|
1227 | Â Â *valid =Â 0; |
---|
1228 |  } else { |
---|
1229 | Â Â *valid =Â 1; |
---|
1230 | Â Â std::cout <<Â "String of "Â <<Â field; |
---|
1231 | Â } |
---|
1232 |  return value; |
---|
1233 | } |
---|
1234 | // Redefine all |
---|
1235 | #define CoinReadGetCommand(x,y) CoinReadGetCommand(whichArgument,x,y) |
---|
1236 | #define CoinReadGetString(x,y) CoinReadGetString(whichArgument,x,y) |
---|
1237 | #define CoinReadGetIntField(x,y,z) CoinReadGetIntField(whichArgument,x,y,z) |
---|
1238 | #define CoinReadGetDoubleField(x,y,z) CoinReadGetDoubleField(whichArgument,x,y,z) |
---|
1239 | #endif |
---|
1240 | // Default Constructor |
---|
1241 | CbcSolverUsefulData::CbcSolverUsefulData() |
---|
1242 | { |
---|
1243 | Â totalTime_ =Â 0.0; |
---|
1244 | Â noPrinting_ =Â true; |
---|
1245 | Â useSignalHandler_ =Â false; |
---|
1246 | Â establishParams(numberParameters_,parameters_); |
---|
1247 | } |
---|
1248 | |
---|
1249 | /* Copy constructor . |
---|
1250 | Â */ |
---|
1251 | CbcSolverUsefulData::CbcSolverUsefulData(const CbcSolverUsefulData & rhs) |
---|
1252 | { |
---|
1253 | Â totalTime_ =Â rhs.totalTime_; |
---|
1254 | Â noPrinting_ =Â rhs.noPrinting_; |
---|
1255 | Â useSignalHandler_ =Â rhs.useSignalHandler_; |
---|
1256 | Â numberParameters_ =Â rhs.numberParameters_; |
---|
1257 | Â memcpy(parameters_,rhs.parameters_,sizeof(parameters_)); |
---|
1258 | } |
---|
1259 | |
---|
1260 | // Assignment operator |
---|
1261 | CbcSolverUsefulData & CbcSolverUsefulData::operator=(const CbcSolverUsefulData& rhs) |
---|
1262 | { |
---|
1263 |  if (this != &rhs) { |
---|
1264 | Â Â totalTime_ =Â rhs.totalTime_; |
---|
1265 | Â Â noPrinting_ =Â rhs.noPrinting_; |
---|
1266 | Â Â useSignalHandler_ =Â rhs.useSignalHandler_; |
---|
1267 | Â Â numberParameters_ =Â rhs.numberParameters_; |
---|
1268 | Â Â memcpy(parameters_,rhs.parameters_,sizeof(parameters_)); |
---|
1269 | Â } |
---|
1270 |  return *this; |
---|
1271 | } |
---|
1272 | |
---|
1273 | // Destructor |
---|
1274 | CbcSolverUsefulData::~CbcSolverUsefulData () |
---|
1275 | { |
---|
1276 | } |
---|
1277 | |
---|
1278 | /* |
---|
1279 | Â Meaning of whereFrom: |
---|
1280 | Â Â 1 after initial solve by dualsimplex etc |
---|
1281 | Â Â 2 after preprocessing |
---|
1282 | Â Â 3 just before branchAndBound (so user can override) |
---|
1283 | Â Â 4 just after branchAndBound (before postprocessing) |
---|
1284 | Â Â 5 after postprocessing |
---|
1285 | Â Â 6 after a user called heuristic phase |
---|
1286 | */ |
---|
1287 | |
---|
1288 | int CbcMain1 (int argc, const char *argv[], |
---|
1289 |        CbcModel & model, |
---|
1290 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1291 | { |
---|
1292 | Â // allow interrupts and printing |
---|
1293 | Â staticParameterData.noPrinting_ =Â false; |
---|
1294 | Â staticParameterData.useSignalHandler_=true; |
---|
1295 |  return CbcMain1(argc,argv,model,callBack,staticParameterData); |
---|
1296 | } |
---|
1297 | static void printGeneralMessage(CbcModel &model,const char * message); |
---|
1298 | /* |
---|
1299 | Â Meaning of whereFrom: |
---|
1300 | Â Â 1 after initial solve by dualsimplex etc |
---|
1301 | Â Â 2 after preprocessing |
---|
1302 | Â Â 3 just before branchAndBound (so user can override) |
---|
1303 | Â Â 4 just after branchAndBound (before postprocessing) |
---|
1304 | Â Â 5 after postprocessing |
---|
1305 | Â Â 6 after a user called heuristic phase |
---|
1306 | */ |
---|
1307 | int CbcMain1 (int argc, const char *argv[], |
---|
1308 |        CbcModel & model, |
---|
1309 |        int callBack(CbcModel * currentSolver, int whereFrom), |
---|
1310 | Â Â Â Â Â Â Â CbcSolverUsefulData &Â parameterData) |
---|
1311 | { |
---|
1312 | Â Â CbcOrClpParam *Â parameters_ =Â parameterData.parameters_; |
---|
1313 |   int numberParameters_ = parameterData.numberParameters_; |
---|
1314 |   double totalTime = parameterData.totalTime_; |
---|
1315 |   bool noPrinting = parameterData.noPrinting_; |
---|
1316 |   bool useSignalHandler = parameterData.useSignalHandler_; |
---|
1317 | Â Â CbcModel &Â model_ =Â model; |
---|
1318 | #ifdef CBC_THREAD_SAFE |
---|
1319 | Â Â // Initialize argument |
---|
1320 |   int whichArgument=1; |
---|
1321 | #endif |
---|
1322 | #ifdef CBC_USE_INITIAL_TIME |
---|
1323 |   if (model_.useElapsedTime()) |
---|
1324 |    model_.setDblParam(CbcModel::CbcStartSeconds, CoinGetTimeOfDay()); |
---|
1325 | Â Â else |
---|
1326 |    model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); |
---|
1327 | #endif |
---|
1328 | Â Â CbcModel *Â babModel_ =Â NULL; |
---|
1329 |   int returnMode = 1; |
---|
1330 | Â Â CbcOrClpRead_mode =Â 1; |
---|
1331 |   int statusUserFunction_[1]; |
---|
1332 |   int numberUserFunctions_ = 1; // to allow for ampl |
---|
1333 | Â Â // Statistics |
---|
1334 |   double statistics_seconds = 0.0, statistics_obj = 0.0; |
---|
1335 |   double statistics_sys_seconds = 0.0, statistics_elapsed_seconds = 0.0; |
---|
1336 | Â Â CoinWallclockTime(); |
---|
1337 |   double statistics_continuous = 0.0, statistics_tighter = 0.0; |
---|
1338 |   double statistics_cut_time = 0.0; |
---|
1339 |   int statistics_nodes = 0, statistics_iterations = 0; |
---|
1340 |   int statistics_nrows = 0, statistics_ncols = 0; |
---|
1341 |   int statistics_nprocessedrows = 0, statistics_nprocessedcols = 0; |
---|
1342 | Â Â std::string statistics_result; |
---|
1343 |   int * statistics_number_cuts = NULL; |
---|
1344 |   const char ** statistics_name_generators = NULL; |
---|
1345 |   int statistics_number_generators = 0; |
---|
1346 |   memset(statusUserFunction_, 0, numberUserFunctions_*sizeof(int)); |
---|
1347 | Â Â /* Note |
---|
1348 | Â Â Â Â This is meant as a stand-alone executable to do as much of coin as possible. |
---|
1349 | Â Â Â Â It should only have one solver known to it. |
---|
1350 | Â Â */ |
---|
1351 | Â Â CoinMessageHandler *Â generalMessageHandler =Â model_.messageHandler(); |
---|
1352 | Â Â generalMessageHandler->setPrefix(false); |
---|
1353 | #ifndef CBC_OTHER_SOLVER |
---|
1354 | Â Â OsiClpSolverInterface *Â originalSolver =Â dynamic_cast<OsiClpSolverInterface *>Â (model_.solver()); |
---|
1355 | Â Â assert (originalSolver); |
---|
1356 | Â Â // Move handler across if not default |
---|
1357 |   if (!originalSolver->defaultHandler() && originalSolver->getModelPtr()->defaultHandler()) |
---|
1358 | Â Â Â Â originalSolver->getModelPtr()->passInMessageHandler(originalSolver->messageHandler()); |
---|
1359 | Â Â CoinMessages generalMessages =Â originalSolver->getModelPtr()->messages(); |
---|
1360 |   char generalPrint[10000]; |
---|
1361 |   if (originalSolver->getModelPtr()->logLevel() == 0) |
---|
1362 | Â Â Â Â noPrinting =Â true; |
---|
1363 | #elif CBC_OTHER_SOLVER==1 |
---|
1364 | Â Â OsiCpxSolverInterface *Â originalSolver =Â dynamic_cast<OsiCpxSolverInterface *>Â (model_.solver()); |
---|
1365 | Â Â assert (originalSolver); |
---|
1366 | Â Â OsiClpSolverInterface dummySolver; |
---|
1367 | Â Â OsiCpxSolverInterface *Â clpSolver =Â originalSolver; |
---|
1368 | Â Â CoinMessages generalMessages =Â dummySolver.getModelPtr()->messages(); |
---|
1369 |   char generalPrint[10000]; |
---|
1370 | Â Â noPrinting =Â true; |
---|
1371 | #endif |
---|
1372 |   bool noPrinting_ = noPrinting; |
---|
1373 | Â Â // Say not in integer |
---|
1374 |   int integerStatus = -1; |
---|
1375 | Â Â // Say no resolve after cuts |
---|
1376 | Â Â model_.setResolveAfterTakeOffCuts(false); |
---|
1377 | Â Â // see if log in list |
---|
1378 |   for (int i = 1; i < argc; i++) { |
---|
1379 |     if (!strncmp(argv[i], "log", 3)) { |
---|
1380 |       const char * equals = strchr(argv[i], '='); |
---|
1381 |       if (equals && atoi(equals + 1) != 0) |
---|
1382 | Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1383 | Â Â Â Â Â Â else |
---|
1384 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1385 | Â Â Â Â Â Â break; |
---|
1386 |     } else if (!strncmp(argv[i], "-log", 4) && i < argc - 1) { |
---|
1387 |       if (atoi(argv[i+1]) != 0) |
---|
1388 | Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1389 | Â Â Â Â Â Â else |
---|
1390 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1391 | Â Â Â Â Â Â break; |
---|
1392 | Â Â Â Â } |
---|
1393 | Â Â } |
---|
1394 |   double time0; |
---|
1395 |   double time0Elapsed = CoinGetTimeOfDay(); |
---|
1396 | Â Â { |
---|
1397 |     double time1 = CoinCpuTime(), time2; |
---|
1398 | Â Â Â Â time0 =Â time1; |
---|
1399 |     double time1Elapsed = time0Elapsed; |
---|
1400 |     bool goodModel = (originalSolver->getNumCols()) ? true : false; |
---|
1401 | |
---|
1402 | Â Â Â Â // register signal handler |
---|
1403 | Â Â Â Â //CoinSighandler_t saveSignal=signal(SIGINT,signal_handler); |
---|
1404 | #if CBC_QUIET < 2 |
---|
1405 |     if (useSignalHandler) |
---|
1406 |      signal(SIGINT, signal_handler); |
---|
1407 | #endif |
---|
1408 | Â Â Â Â // Set up all non-standard stuff |
---|
1409 |     int cutPass = -1234567; |
---|
1410 |     int cutPassInTree = -1234567; |
---|
1411 |     int tunePreProcess = 0; |
---|
1412 |     int testOsiParameters = -1; |
---|
1413 | Â Â Â Â // 0 normal, 1 from ampl or MIQP etc (2 allows cuts) |
---|
1414 |     int complicatedInteger = 0; |
---|
1415 | Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
1416 |     if (noPrinting_) |
---|
1417 | Â Â Â Â Â Â setCbcOrClpPrinting(false); |
---|
1418 | #ifndef CBC_OTHER_SOLVER |
---|
1419 | Â Â Â Â OsiClpSolverInterface *Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
1420 | Â Â Â Â ClpSimplex *Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1421 |     if (noPrinting_) { |
---|
1422 | Â Â Â Â Â Â lpSolver->setLogLevel(0); |
---|
1423 | Â Â Â Â } |
---|
1424 | #else |
---|
1425 | Â Â Â Â ClpSimplex *Â lpSolver =Â NULL; |
---|
1426 | #endif |
---|
1427 | Â Â Â Â // For priorities etc |
---|
1428 |     int * priorities = NULL; |
---|
1429 |     int * branchDirection = NULL; |
---|
1430 |     double * pseudoDown = NULL; |
---|
1431 |     double * pseudoUp = NULL; |
---|
1432 |     double * solutionIn = NULL; |
---|
1433 |     int * prioritiesIn = NULL; |
---|
1434 |     std::vector< std::pair< std::string, double > > mipStart; |
---|
1435 |     std::vector< std::pair< std::string, double > > mipStartBefore; |
---|
1436 |     int numberSOS = 0; |
---|
1437 |     int * sosStart = NULL; |
---|
1438 |     int * sosIndices = NULL; |
---|
1439 |     char * sosType = NULL; |
---|
1440 |     double * sosReference = NULL; |
---|
1441 |     int * cut = NULL; |
---|
1442 |     int * sosPriority = NULL; |
---|
1443 | Â Â Â Â CglStored storedAmpl; |
---|
1444 | Â Â Â Â CoinModel *Â coinModel =Â NULL; |
---|
1445 | Â Â Â Â CoinModel saveCoinModel; |
---|
1446 | Â Â Â Â CoinModel saveTightenedModel; |
---|
1447 |     int * whichColumn = NULL; |
---|
1448 |     int * knapsackStart = NULL; |
---|
1449 |     int * knapsackRow = NULL; |
---|
1450 |     int numberKnapsack = 0; |
---|
1451 | #ifdef COIN_HAS_ASL |
---|
1452 | Â Â Â Â ampl_info info; |
---|
1453 | Â Â Â Â { |
---|
1454 |       memset(&info, 0, sizeof(info)); |
---|
1455 |       if (argc > 2 && !strcmp(argv[2], "-AMPL")) { |
---|
1456 | Â Â Â Â Â Â Â Â statusUserFunction_[0]Â =Â 1; |
---|
1457 | Â Â Â Â Â Â Â Â // see if log in list |
---|
1458 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1459 |         for (int i = 1; i < argc; i++) { |
---|
1460 |           if (!strncmp(argv[i], "log", 3)) { |
---|
1461 |             const char * equals = strchr(argv[i], '='); |
---|
1462 |             if (equals && atoi(equals + 1) > 0) { |
---|
1463 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.logLevel =Â atoi(equals +Â 1); |
---|
1465 |               int log = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
1466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[log].setIntValue(info.logLevel); |
---|
1467 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // mark so won't be overWritten |
---|
1468 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.numberRows =Â -1234567; |
---|
1469 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1470 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1471 | Â Â Â Â Â Â Â Â Â Â } |
---|
1472 | Â Â Â Â Â Â Â Â } |
---|
1473 | |
---|
1474 |         union { |
---|
1475 |           void * voidModel; |
---|
1476 | Â Â Â Â Â Â Â Â Â Â CoinModel *Â model; |
---|
1477 | Â Â Â Â Â Â Â Â }Â coinModelStart; |
---|
1478 | Â Â Â Â Â Â Â Â coinModelStart.model =Â NULL; |
---|
1479 |         int returnCode = readAmpl(&info, argc, const_cast<char **>(argv), & coinModelStart.voidModel); |
---|
1480 | Â Â Â Â Â Â Â Â coinModel =Â coinModelStart.model; |
---|
1481 |         if (returnCode) |
---|
1482 |           return returnCode; |
---|
1483 | Â Â Â Â Â Â Â Â CbcOrClpRead_mode =Â 2;Â // so will start with parameters |
---|
1484 | Â Â Â Â Â Â Â Â // see if log in list (including environment) |
---|
1485 |         for (int i = 1; i < info.numberArguments; i++) { |
---|
1486 |           if (!strcmp(info.arguments[i], "log")) { |
---|
1487 |             if (i < info.numberArguments - 1 && atoi(info.arguments[i+1]) > 0) |
---|
1488 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1489 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1490 | Â Â Â Â Â Â Â Â Â Â } |
---|
1491 | Â Â Â Â Â Â Â Â } |
---|
1492 |         if (noPrinting_) { |
---|
1493 | Â Â Â Â Â Â Â Â Â Â model_.messageHandler()->setLogLevel(0); |
---|
1494 | Â Â Â Â Â Â Â Â Â Â setCbcOrClpPrinting(false); |
---|
1495 | Â Â Â Â Â Â Â Â } |
---|
1496 |         if (!noPrinting_) |
---|
1497 | Â Â Â Â Â Â Â Â Â Â printf("%d rows, %d columns and %d elements\n", |
---|
1498 |               info.numberRows, info.numberColumns, info.numberElements); |
---|
1499 | #ifdef COIN_HAS_LINK |
---|
1500 |         if (!coinModel) { |
---|
1501 | #endif |
---|
1502 |           solver->loadProblem(info.numberColumns, info.numberRows, info.starts, |
---|
1503 |                     info.rows, info.elements, |
---|
1504 |                     info.columnLower, info.columnUpper, info.objective, |
---|
1505 |                     info.rowLower, info.rowUpper); |
---|
1506 | Â Â Â Â Â Â Â Â Â Â // take off cuts if ampl wants that |
---|
1507 |           if (info.cut && 0) { |
---|
1508 | Â Â Â Â Â Â Â Â Â Â Â Â printf("AMPL CUTS OFF until global cuts fixed\n"); |
---|
1509 | Â Â Â Â Â Â Â Â Â Â Â Â info.cut =Â NULL; |
---|
1510 | Â Â Â Â Â Â Â Â Â Â } |
---|
1511 |           if (info.cut) { |
---|
1512 |             int numberRows = info.numberRows; |
---|
1513 |             int * whichRow = new int [numberRows]; |
---|
1514 | Â Â Â Â Â Â Â Â Â Â Â Â // Row copy |
---|
1515 |             const CoinPackedMatrix * matrixByRow = solver->getMatrixByRow(); |
---|
1516 |             const double * elementByRow = matrixByRow->getElements(); |
---|
1517 |             const int * column = matrixByRow->getIndices(); |
---|
1518 |             const CoinBigIndex * rowStart = matrixByRow->getVectorStarts(); |
---|
1519 |             const int * rowLength = matrixByRow->getVectorLengths(); |
---|
1520 | |
---|
1521 |             const double * rowLower = solver->getRowLower(); |
---|
1522 |             const double * rowUpper = solver->getRowUpper(); |
---|
1523 |             int nDelete = 0; |
---|
1524 |             for (int iRow = 0; iRow < numberRows; iRow++) { |
---|
1525 |               if (info.cut[iRow]) { |
---|
1526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â whichRow[nDelete++]Â =Â iRow; |
---|
1527 |                 int start = rowStart[iRow]; |
---|
1528 |                 storedAmpl.addCut(rowLower[iRow], rowUpper[iRow], |
---|
1529 |                          rowLength[iRow], column + start, elementByRow + start); |
---|
1530 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1531 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1532 |             solver->deleteRows(nDelete, whichRow); |
---|
1533 |             delete [] whichRow; |
---|
1534 | Â Â Â Â Â Â Â Â Â Â } |
---|
1535 | #ifdef COIN_HAS_LINK |
---|
1536 |         } else { |
---|
1537 | #ifndef CBC_OTHER_SOLVER |
---|
1538 | Â Â Â Â Â Â Â Â Â Â // save |
---|
1539 | Â Â Â Â Â Â Â Â Â Â saveCoinModel =Â *coinModel; |
---|
1540 | Â Â Â Â Â Â Â Â Â Â // load from coin model |
---|
1541 | Â Â Â Â Â Â Â Â Â Â OsiSolverLink solver1; |
---|
1542 | Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2 =Â solver1.clone(); |
---|
1543 |           model_.assignSolver(solver2, false); |
---|
1544 | Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â si = |
---|
1545 | Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiSolverLink *>(model_.solver())Â ; |
---|
1546 | Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
1547 | Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(0.001); |
---|
1548 | Â Â Â Â Â Â Â Â Â Â // need some relative granularity |
---|
1549 | Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100.0); |
---|
1550 |           double dextra3 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
1551 |           if (dextra3) |
---|
1552 | Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(dextra3); |
---|
1553 | Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100000.0); |
---|
1554 | Â Â Â Â Â Â Â Â Â Â si->setIntegerPriority(1000); |
---|
1555 | Â Â Â Â Â Â Â Â Â Â si->setBiLinearPriority(10000); |
---|
1556 | Â Â Â Â Â Â Â Â Â Â CoinModel *Â model2 =Â reinterpret_cast<CoinModel *>Â (coinModel); |
---|
1557 |           int logLevel = parameters_[whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_)].intValue(); |
---|
1558 |           si->load(*model2, true, logLevel); |
---|
1559 | Â Â Â Â Â Â Â Â Â Â // redo |
---|
1560 | Â Â Â Â Â Â Â Â Â Â solver =Â model_.solver(); |
---|
1561 | Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
1562 | Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1563 | Â Â Â Â Â Â Â Â Â Â clpSolver->messageHandler()->setLogLevel(0)Â ; |
---|
1564 | Â Â Â Â Â Â Â Â Â Â testOsiParameters =Â 0; |
---|
1565 |           parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(0); |
---|
1566 | Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 1; |
---|
1567 |           if (info.cut) { |
---|
1568 | Â Â Â Â Â Â Â Â Â Â Â Â printf("Sorry - can't do cuts with LOS as ruins delicate row order\n"); |
---|
1569 | Â Â Â Â Â Â Â Â Â Â Â Â abort(); |
---|
1570 |             int numberRows = info.numberRows; |
---|
1571 |             int * whichRow = new int [numberRows]; |
---|
1572 | Â Â Â Â Â Â Â Â Â Â Â Â // Row copy |
---|
1573 |             const CoinPackedMatrix * matrixByRow = solver->getMatrixByRow(); |
---|
1574 |             const double * elementByRow = matrixByRow->getElements(); |
---|
1575 |             const int * column = matrixByRow->getIndices(); |
---|
1576 |             const CoinBigIndex * rowStart = matrixByRow->getVectorStarts(); |
---|
1577 |             const int * rowLength = matrixByRow->getVectorLengths(); |
---|
1578 | |
---|
1579 |             const double * rowLower = solver->getRowLower(); |
---|
1580 |             const double * rowUpper = solver->getRowUpper(); |
---|
1581 |             int nDelete = 0; |
---|
1582 |             for (int iRow = 0; iRow < numberRows; iRow++) { |
---|
1583 |               if (info.cut[iRow]) { |
---|
1584 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â whichRow[nDelete++]Â =Â iRow; |
---|
1585 |                 int start = rowStart[iRow]; |
---|
1586 |                 storedAmpl.addCut(rowLower[iRow], rowUpper[iRow], |
---|
1587 |                          rowLength[iRow], column + start, elementByRow + start); |
---|
1588 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1589 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1590 |             solver->deleteRows(nDelete, whichRow); |
---|
1591 | Â Â Â Â Â Â Â Â Â Â Â Â // and special matrix |
---|
1592 |             si->cleanMatrix()->deleteRows(nDelete, whichRow); |
---|
1593 |             delete [] whichRow; |
---|
1594 | Â Â Â Â Â Â Â Â Â Â } |
---|
1595 | #endif |
---|
1596 | Â Â Â Â Â Â Â Â } |
---|
1597 | #endif |
---|
1598 | Â Â Â Â Â Â Â Â // If we had a solution use it |
---|
1599 |         if (info.primalSolution) { |
---|
1600 | Â Â Â Â Â Â Â Â Â Â solver->setColSolution(info.primalSolution); |
---|
1601 | Â Â Â Â Â Â Â Â } |
---|
1602 | Â Â Â Â Â Â Â Â // status |
---|
1603 |         if (info.rowStatus) { |
---|
1604 |           unsigned char * statusArray = lpSolver->statusArray(); |
---|
1605 |           int i; |
---|
1606 |           for (i = 0; i < info.numberColumns; i++) |
---|
1607 |             statusArray[i] = static_cast<unsigned char>(info.columnStatus[i]); |
---|
1608 | Â Â Â Â Â Â Â Â Â Â statusArray +=Â info.numberColumns; |
---|
1609 |           for (i = 0; i < info.numberRows; i++) |
---|
1610 |             statusArray[i] = static_cast<unsigned char>(info.rowStatus[i]); |
---|
1611 | Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â lpSolver->getBasis(); |
---|
1612 | Â Â Â Â Â Â Â Â Â Â solver->setWarmStart(basis); |
---|
1613 |           delete basis; |
---|
1614 | Â Â Â Â Â Â Â Â } |
---|
1615 | Â Â Â Â Â Â Â Â freeArrays1(&info); |
---|
1616 | Â Â Â Â Â Â Â Â // modify objective if necessary |
---|
1617 | Â Â Â Â Â Â Â Â solver->setObjSense(info.direction); |
---|
1618 |         solver->setDblParam(OsiObjOffset, -info.offset); |
---|
1619 |         if (info.offset) { |
---|
1620 |           sprintf(generalPrint, "Ampl objective offset is %g", |
---|
1621 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.offset); |
---|
1622 |           generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1623 | Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
1624 | Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1625 | Â Â Â Â Â Â Â Â } |
---|
1626 | Â Â Â Â Â Â Â Â // Set integer variables (unless nonlinear when set) |
---|
1627 |         if (!info.nonLinear) { |
---|
1628 |           for (int i = info.numberColumns - info.numberIntegers; |
---|
1629 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â i <Â info.numberColumns;Â i++) |
---|
1630 | Â Â Â Â Â Â Â Â Â Â Â Â solver->setInteger(i); |
---|
1631 | Â Â Â Â Â Â Â Â } |
---|
1632 | Â Â Â Â Â Â Â Â goodModel =Â true; |
---|
1633 | Â Â Â Â Â Â Â Â // change argc etc |
---|
1634 | Â Â Â Â Â Â Â Â argc =Â info.numberArguments; |
---|
1635 |         argv = const_cast<const char **>(info.arguments); |
---|
1636 | Â Â Â Â Â Â } |
---|
1637 | Â Â Â Â } |
---|
1638 | #endif |
---|
1639 | Â Â Â Â // default action on import |
---|
1640 |     int allowImportErrors = 0; |
---|
1641 |     int keepImportNames = 1; |
---|
1642 |     int doIdiot = -1; |
---|
1643 |     int outputFormat = 2; |
---|
1644 |     int slpValue = -1; |
---|
1645 |     int cppValue = -1; |
---|
1646 |     int printOptions = 0; |
---|
1647 |     int printMode = 0; |
---|
1648 |     int presolveOptions = 0; |
---|
1649 |     int substitution = 3; |
---|
1650 |     int dualize = 3; |
---|
1651 |     int doCrash = 0; |
---|
1652 |     int doVector = 0; |
---|
1653 |     int doSprint = -1; |
---|
1654 |     int doScaling = 4; |
---|
1655 | Â Â Â Â // set reasonable defaults |
---|
1656 |     int preSolve = 5; |
---|
1657 |     int preProcess = 4; |
---|
1658 |     bool useStrategy = false; |
---|
1659 |     bool preSolveFile = false; |
---|
1660 |     bool strongChanged = false; |
---|
1661 |     bool pumpChanged = false; |
---|
1662 | |
---|
1663 |     double djFix = 1.0e100; |
---|
1664 |     double tightenFactor = 0.0; |
---|
1665 |     const char dirsep = CoinFindDirSeparator(); |
---|
1666 | Â Â Â Â std::string directory; |
---|
1667 | Â Â Â Â std::string dirSample; |
---|
1668 | Â Â Â Â std::string dirNetlib; |
---|
1669 | Â Â Â Â std::string dirMiplib; |
---|
1670 |     if (dirsep == '/') { |
---|
1671 | Â Â Â Â Â Â directory =Â "./"; |
---|
1672 | Â Â Â Â Â Â dirSample =Â "../../Data/Sample/"; |
---|
1673 | Â Â Â Â Â Â dirNetlib =Â "../../Data/Netlib/"; |
---|
1674 | Â Â Â Â Â Â dirMiplib =Â "../../Data/miplib3/"; |
---|
1675 |     } else { |
---|
1676 | Â Â Â Â Â Â directory =Â ".\\"; |
---|
1677 | Â Â Â Â Â Â dirSample =Â "..\\..\\..\\..\\Data\\Sample\\"; |
---|
1678 | Â Â Â Â Â Â dirNetlib =Â "..\\..\\..\\..\\Data\\Netlib\\"; |
---|
1679 | Â Â Â Â Â Â dirMiplib =Â "..\\..\\..\\..\\Data\\miplib3\\"; |
---|
1680 | Â Â Â Â } |
---|
1681 | Â Â Â Â std::string defaultDirectory =Â directory; |
---|
1682 | Â Â Â Â std::string importFile =Â ""; |
---|
1683 | Â Â Â Â std::string exportFile =Â "default.mps"; |
---|
1684 | Â Â Â Â std::string importBasisFile =Â ""; |
---|
1685 | Â Â Â Â std::string importPriorityFile =Â ""; |
---|
1686 | Â Â Â Â std::string debugFile =Â ""; |
---|
1687 | Â Â Â Â std::string printMask =Â ""; |
---|
1688 |     double * debugValues = NULL; |
---|
1689 |     int numberDebugValues = -1; |
---|
1690 |     int basisHasValues = 0; |
---|
1691 | Â Â Â Â std::string exportBasisFile =Â "default.bas"; |
---|
1692 | Â Â Â Â std::string saveFile =Â "default.prob"; |
---|
1693 | Â Â Â Â std::string restoreFile =Â "default.prob"; |
---|
1694 | Â Â Â Â std::string solutionFile =Â "stdout"; |
---|
1695 | Â Â Â Â std::string solutionSaveFile =Â "solution.file"; |
---|
1696 |     int slog = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
1697 |     int log = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
1698 | #ifndef CBC_OTHER_SOLVER |
---|
1699 |     double normalIncrement = model_.getCutoffIncrement();; |
---|
1700 | #endif |
---|
1701 |     if (testOsiParameters >= 0) { |
---|
1702 | Â Â Â Â Â Â // trying nonlinear - switch off some stuff |
---|
1703 | Â Â Â Â Â Â preProcess =Â 0; |
---|
1704 | Â Â Â Â } |
---|
1705 | Â Â Â Â // Set up likely cut generators and defaults |
---|
1706 |     int nodeStrategy = 0; |
---|
1707 |     bool dominatedCuts = false; |
---|
1708 |     int doSOS = 1; |
---|
1709 |     int verbose = 0; |
---|
1710 | Â Â Â Â CglGomory gomoryGen; |
---|
1711 | Â Â Â Â // try larger limit |
---|
1712 | Â Â Â Â gomoryGen.setLimitAtRoot(1000); |
---|
1713 | Â Â Â Â gomoryGen.setLimit(50); |
---|
1714 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1715 | #ifdef SWAP_GOMORY |
---|
1716 |     int gomoryAction = 0; |
---|
1717 | #else |
---|
1718 |     int gomoryAction = 3; |
---|
1719 | #endif |
---|
1720 | |
---|
1721 | Â Â Â Â CglProbing probingGen; |
---|
1722 | Â Â Â Â probingGen.setUsingObjective(1); |
---|
1723 | Â Â Â Â probingGen.setMaxPass(1); |
---|
1724 | Â Â Â Â probingGen.setMaxPassRoot(1); |
---|
1725 | Â Â Â Â // Number of unsatisfied variables to look at |
---|
1726 | Â Â Â Â probingGen.setMaxProbe(10); |
---|
1727 | Â Â Â Â probingGen.setMaxProbeRoot(50); |
---|
1728 | Â Â Â Â // How far to follow the consequences |
---|
1729 | Â Â Â Â probingGen.setMaxLook(10); |
---|
1730 | Â Â Â Â probingGen.setMaxLookRoot(50); |
---|
1731 | Â Â Â Â probingGen.setMaxLookRoot(10); |
---|
1732 | Â Â Â Â // Only look at rows with fewer than this number of elements |
---|
1733 | Â Â Â Â probingGen.setMaxElements(200); |
---|
1734 | Â Â Â Â probingGen.setMaxElementsRoot(300); |
---|
1735 | Â Â Â Â probingGen.setRowCuts(3); |
---|
1736 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1737 |     int probingAction = 1; |
---|
1738 | |
---|
1739 | Â Â Â Â CglKnapsackCover knapsackGen; |
---|
1740 | Â Â Â Â //knapsackGen.switchOnExpensive(); |
---|
1741 | Â Â Â Â //knapsackGen.setMaxInKnapsack(100); |
---|
1742 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1743 |     int knapsackAction = 3; |
---|
1744 | |
---|
1745 | Â Â Â Â CglRedSplit redsplitGen; |
---|
1746 | Â Â Â Â //redsplitGen.setLimit(100); |
---|
1747 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1748 | Â Â Â Â // Off as seems to give some bad cuts |
---|
1749 |     int redsplitAction = 0; |
---|
1750 | |
---|
1751 | Â Â Â Â CglRedSplit2 redsplit2Gen; |
---|
1752 | Â Â Â Â //redsplit2Gen.setLimit(100); |
---|
1753 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1754 | Â Â Â Â // Off |
---|
1755 |     int redsplit2Action = 0; |
---|
1756 | |
---|
1757 | Â Â Â Â CglGMI GMIGen; |
---|
1758 | Â Â Â Â //GMIGen.setLimit(100); |
---|
1759 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1760 | #ifdef SWAP_GOMORY |
---|
1761 |     int GMIAction = 3; |
---|
1762 | #else |
---|
1763 | Â Â Â Â // Off |
---|
1764 |     int GMIAction = 0; |
---|
1765 | #endif |
---|
1766 | |
---|
1767 |     CglFakeClique cliqueGen(NULL, false); |
---|
1768 | Â Â Â Â //CglClique cliqueGen(false,true); |
---|
1769 | Â Â Â Â cliqueGen.setStarCliqueReport(false); |
---|
1770 | Â Â Â Â cliqueGen.setRowCliqueReport(false); |
---|
1771 | Â Â Â Â cliqueGen.setMinViolation(0.1); |
---|
1772 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1773 |     int cliqueAction = 3; |
---|
1774 | |
---|
1775 | Â Â Â Â // maxaggr,multiply,criterion(1-3) |
---|
1776 |     CglMixedIntegerRounding2 mixedGen(1, true, 1); |
---|
1777 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1778 |     int mixedAction = 3; |
---|
1779 | Â Â Â Â mixedGen.setDoPreproc(1);Â // safer (and better) |
---|
1780 | |
---|
1781 | Â Â Â Â CglFlowCover flowGen; |
---|
1782 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1783 |     int flowAction = 3; |
---|
1784 | |
---|
1785 | Â Â Â Â CglTwomir twomirGen; |
---|
1786 | Â Â Â Â twomirGen.setMaxElements(250); |
---|
1787 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1788 |     int twomirAction = 3; |
---|
1789 | #ifndef DEBUG_MALLOC |
---|
1790 | Â Â Â Â CglLandP landpGen; |
---|
1791 | Â Â Â Â landpGen.validator().setMinViolation(1.0e-4); |
---|
1792 | #endif |
---|
1793 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1794 |     int landpAction = 0; |
---|
1795 | Â Â Â Â CglResidualCapacity residualCapacityGen; |
---|
1796 | Â Â Â Â residualCapacityGen.setDoPreproc(1);Â // always preprocess |
---|
1797 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1798 |     int residualCapacityAction = 0; |
---|
1799 | |
---|
1800 | Â Â Â Â CglZeroHalf zerohalfGen; |
---|
1801 | Â Â Â Â //zerohalfGen.switchOnExpensive(); |
---|
1802 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1803 |     int zerohalfAction = 0; |
---|
1804 | |
---|
1805 | Â Â Â Â // Stored cuts |
---|
1806 | Â Â Â Â //bool storedCuts = false; |
---|
1807 | |
---|
1808 |     int useCosts = 0; |
---|
1809 | Â Â Â Â // don't use input solution |
---|
1810 |     int useSolution = -1; |
---|
1811 | |
---|
1812 | Â Â Â Â // total number of commands read |
---|
1813 |     int numberGoodCommands = 0; |
---|
1814 | Â Â Â Â // Set false if user does anything advanced |
---|
1815 |     bool defaultSettings = true; |
---|
1816 | |
---|
1817 | Â Â Â Â // Hidden stuff for barrier |
---|
1818 |     int choleskyType = 0; |
---|
1819 |     int gamma = 0; |
---|
1820 |     int scaleBarrier = 0; |
---|
1821 |     int doKKT = 0; |
---|
1822 |     int crossover = 2; // do crossover unless quadratic |
---|
1823 |     bool biLinearProblem=false; |
---|
1824 | Â Â Â Â // For names |
---|
1825 |     int lengthName = 0; |
---|
1826 | Â Â Â Â std::vector<std::string>Â rowNames; |
---|
1827 | Â Â Â Â std::vector<std::string>Â columnNames; |
---|
1828 | Â Â Â Â // Default strategy stuff |
---|
1829 | Â Â Â Â { |
---|
1830 | Â Â Â Â Â Â // try changing tolerance at root |
---|
1831 | #define MORE_CUTS |
---|
1832 | #ifdef MORE_CUTS |
---|
1833 | Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.005); |
---|
1834 | Â Â Â Â Â Â twomirGen.setAwayAtRoot(0.005); |
---|
1835 | Â Â Â Â Â Â twomirGen.setAway(0.01); |
---|
1836 | Â Â Â Â Â Â //twomirGen.setMirScale(1,1); |
---|
1837 | Â Â Â Â Â Â //twomirGen.setTwomirScale(1,1); |
---|
1838 | Â Â Â Â Â Â //twomirGen.setAMax(2); |
---|
1839 | #else |
---|
1840 | Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.01); |
---|
1841 | Â Â Â Â Â Â twomirGen.setAwayAtRoot(0.01); |
---|
1842 | Â Â Â Â Â Â twomirGen.setAway(0.01); |
---|
1843 | #endif |
---|
1844 |       int iParam; |
---|
1845 |       iParam = whichParam(CBC_PARAM_INT_DIVEOPT, numberParameters_, parameters_); |
---|
1846 | Â Â Â Â Â Â parameters_[iParam].setIntValue(2); |
---|
1847 |       iParam = whichParam(CBC_PARAM_INT_FPUMPITS, numberParameters_, parameters_); |
---|
1848 | Â Â Â Â Â Â parameters_[iParam].setIntValue(30); |
---|
1849 |       iParam = whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_); |
---|
1850 | Â Â Â Â Â Â parameters_[iParam].setIntValue(1005043); |
---|
1851 | Â Â Â Â Â Â initialPumpTune =Â 1005043; |
---|
1852 |       iParam = whichParam(CLP_PARAM_INT_PROCESSTUNE, numberParameters_, parameters_); |
---|
1853 | Â Â Â Â Â Â parameters_[iParam].setIntValue(6); |
---|
1854 | Â Â Â Â Â Â tunePreProcess =Â 6; |
---|
1855 |       iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
1856 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1857 |       iParam = whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_); |
---|
1858 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1859 |       iParam = whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_); |
---|
1860 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1861 | Â Â Â Â Â Â probingAction =Â 3; |
---|
1862 | Â Â Â Â Â Â //parameters_[iParam].setCurrentOption("forceOnStrong"); |
---|
1863 | Â Â Â Â Â Â //probingAction = 8; |
---|
1864 | Â Â Â Â } |
---|
1865 | Â Â Â Â std::string field; |
---|
1866 | #if CBC_QUIET == 0 |
---|
1867 |     if (!noPrinting_) { |
---|
1868 | Â Â Â Â Â Â sprintf(generalPrint, |
---|
1869 | Â Â Â Â Â Â Â Â Â Â "Welcome to the CBC MILP Solver \n"); |
---|
1870 |       if (strcmp(CBC_VERSION, "trunk")){ |
---|
1871 | Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1872 |             "Version: %s \n", CBC_VERSION); |
---|
1873 | Â Â Â Â Â Â }else{ |
---|
1874 | Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1875 | Â Â Â Â Â Â Â Â Â Â Â Â "Version: Trunk (unstable) \n"); |
---|
1876 | Â Â Â Â Â Â } |
---|
1877 | Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1878 |           "Build Date: %s \n", __DATE__); |
---|
1879 | #ifdef CBC_SVN_REV |
---|
1880 | Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1881 |           "Revision Number: %d \n", CBC_SVN_REV); |
---|
1882 | #endif |
---|
1883 |       generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1884 | Â Â Â Â Â Â <<Â generalPrint |
---|
1885 | Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1886 | Â Â Â Â Â Â // Print command line |
---|
1887 |       if (argc > 1) { |
---|
1888 |         bool foundStrategy = false; |
---|
1889 |         sprintf(generalPrint, "command line - "); |
---|
1890 |         for (int i = 0; i < argc; i++) { |
---|
1891 |           if (!argv[i]) |
---|
1892 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1893 |           if (strstr(argv[i], "strat")) |
---|
1894 | Â Â Â Â Â Â Â Â Â Â Â Â foundStrategy =Â true; |
---|
1895 |           sprintf(generalPrint + strlen(generalPrint), "%s ", argv[i]); |
---|
1896 | Â Â Â Â Â Â Â Â } |
---|
1897 |         if (!foundStrategy) |
---|
1898 |           sprintf(generalPrint + strlen(generalPrint), "(default strategy 1)"); |
---|
1899 |         generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1900 | Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
1901 | Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1902 | Â Â Â Â Â Â } |
---|
1903 | Â Â Â Â } |
---|
1904 | #endif |
---|
1905 |     while (1) { |
---|
1906 | Â Â Â Â Â Â // next command |
---|
1907 |       field = CoinReadGetCommand(argc, argv); |
---|
1908 | Â Â Â Â Â Â // Reset time |
---|
1909 | Â Â Â Â Â Â time1 =Â CoinCpuTime(); |
---|
1910 | Â Â Â Â Â Â time1Elapsed =Â CoinGetTimeOfDay(); |
---|
1911 | Â Â Â Â Â Â // adjust field if has odd trailing characters |
---|
1912 |       char temp [200]; |
---|
1913 |       strcpy(temp, field.c_str()); |
---|
1914 |       int length = static_cast<int>(strlen(temp)); |
---|
1915 |       for (int k = length - 1; k >= 0; k--) { |
---|
1916 |         if (temp[k] < ' ') |
---|
1917 | Â Â Â Â Â Â Â Â Â Â length--; |
---|
1918 | Â Â Â Â Â Â Â Â else |
---|
1919 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1920 | Â Â Â Â Â Â } |
---|
1921 | Â Â Â Â Â Â temp[length]Â =Â '\0'; |
---|
1922 | Â Â Â Â Â Â field =Â temp; |
---|
1923 | Â Â Â Â Â Â // exit if null or similar |
---|
1924 |       if (!field.length()) { |
---|
1925 |         if (numberGoodCommands == 1 && goodModel) { |
---|
1926 | Â Â Â Â Â Â Â Â Â Â // we just had file name - do branch and bound |
---|
1927 | Â Â Â Â Â Â Â Â Â Â field =Â "branch"; |
---|
1928 |         } else if (!numberGoodCommands) { |
---|
1929 | Â Â Â Â Â Â Â Â Â Â // let's give the sucker a hint |
---|
1930 | Â Â Â Â Â Â Â Â Â Â std::cout |
---|
1931 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â "CoinSolver takes input from arguments ( - switches to stdin)" |
---|
1932 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â std::endl |
---|
1933 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â "Enter ? for list of commands or help"Â <<Â std::endl; |
---|
1934 | Â Â Â Â Â Â Â Â Â Â field =Â "-"; |
---|
1935 |         } else { |
---|
1936 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1937 | Â Â Â Â Â Â Â Â } |
---|
1938 | Â Â Â Â Â Â } |
---|
1939 | |
---|
1940 | Â Â Â Â Â Â // see if ? at end |
---|
1941 | Â Â Â Â Â Â size_t numberQuery =Â 0; |
---|
1942 |       if (field != "?" && field != "???") { |
---|
1943 | Â Â Â Â Â Â Â Â size_t length =Â field.length(); |
---|
1944 | Â Â Â Â Â Â Â Â size_t i; |
---|
1945 |         for (i = length - 1; i > 0; i--) { |
---|
1946 |           if (field[i] == '?') |
---|
1947 | Â Â Â Â Â Â Â Â Â Â Â Â numberQuery++; |
---|
1948 | Â Â Â Â Â Â Â Â Â Â else |
---|
1949 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1950 | Â Â Â Â Â Â Â Â } |
---|
1951 |         field = field.substr(0, length - numberQuery); |
---|
1952 | Â Â Â Â Â Â } |
---|
1953 | Â Â Â Â Â Â // find out if valid command |
---|
1954 |       int iParam; |
---|
1955 |       int numberMatches = 0; |
---|
1956 |       int firstMatch = -1; |
---|
1957 |       for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
1958 |         int match = parameters_[iParam].matches(field); |
---|
1959 |         if (match == 1) { |
---|
1960 | Â Â Â Â Â Â Â Â Â Â numberMatches =Â 1; |
---|
1961 | Â Â Â Â Â Â Â Â Â Â firstMatch =Â iParam; |
---|
1962 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1963 |         } else { |
---|
1964 |           if (match && firstMatch < 0) |
---|
1965 | Â Â Â Â Â Â Â Â Â Â Â Â firstMatch =Â iParam; |
---|
1966 | Â Â Â Â Â Â Â Â Â Â numberMatches +=Â match >>Â 1; |
---|
1967 | Â Â Â Â Â Â Â Â } |
---|
1968 | Â Â Â Â Â Â } |
---|
1969 |       if (iParam < numberParameters_ && !numberQuery) { |
---|
1970 | Â Â Â Â Â Â Â Â // found |
---|
1971 | Â Â Â Â Â Â Â Â CbcOrClpParam found =Â parameters_[iParam]; |
---|
1972 | Â Â Â Â Â Â Â Â CbcOrClpParameterType type =Â found.type(); |
---|
1973 |         int valid; |
---|
1974 | Â Â Â Â Â Â Â Â numberGoodCommands++; |
---|
1975 |         if (type == CBC_PARAM_ACTION_BAB && goodModel) { |
---|
1976 | #ifndef CBC_USE_INITIAL_TIME |
---|
1977 |          if (model_.useElapsedTime()) |
---|
1978 |           model_.setDblParam(CbcModel::CbcStartSeconds, CoinGetTimeOfDay()); |
---|
1979 | Â Â Â Â Â Â Â Â Â else |
---|
1980 |           model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); |
---|
1981 | #endif |
---|
1982 | Â Â Â Â Â Â Â Â Â biLinearProblem=false; |
---|
1983 | Â Â Â Â Â Â Â Â Â Â // check if any integers |
---|
1984 | #ifndef CBC_OTHER_SOLVER |
---|
1985 | #ifdef COIN_HAS_ASL |
---|
1986 |           if (info.numberSos && doSOS && statusUserFunction_[0]) { |
---|
1987 | Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
1988 | Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â info.numberSos; |
---|
1989 | Â Â Â Â Â Â Â Â Â Â } |
---|
1990 | #endif |
---|
1991 | Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1992 |           if (!lpSolver->integerInformation() && !numberSOS && |
---|
1993 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â !clpSolver->numberSOS()Â &&Â !model_.numberObjects()Â &&Â !clpSolver->numberObjects()) |
---|
1994 | Â Â Â Â Â Â Â Â Â Â Â Â type =Â CLP_PARAM_ACTION_DUALSIMPLEX; |
---|
1995 | #endif |
---|
1996 | Â Â Â Â Â Â Â Â } |
---|
1997 |         if (type == CBC_PARAM_GENERALQUERY) { |
---|
1998 |           bool evenHidden = false; |
---|
1999 |           int printLevel = |
---|
2000 | Â Â Â Â Â Â Â Â Â Â Â Â parameters_[whichParam(CLP_PARAM_STR_ALLCOMMANDS, |
---|
2001 |                         numberParameters_, parameters_)].currentOptionAsInteger(); |
---|
2002 |           int convertP[] = {2, 1, 0}; |
---|
2003 | Â Â Â Â Â Â Â Â Â Â printLevel =Â convertP[printLevel]; |
---|
2004 |           if ((verbose&8) != 0) { |
---|
2005 | Â Â Â Â Â Â Â Â Â Â Â Â // even hidden |
---|
2006 | Â Â Â Â Â Â Â Â Â Â Â Â evenHidden =Â true; |
---|
2007 | Â Â Â Â Â Â Â Â Â Â Â Â verbose &=Â ~8; |
---|
2008 | Â Â Â Â Â Â Â Â Â Â } |
---|
2009 | #ifdef COIN_HAS_ASL |
---|
2010 |           if (verbose < 4 && statusUserFunction_[0]) |
---|
2011 | Â Â Â Â Â Â Â Â Â Â Â Â verbose +=Â 4; |
---|
2012 | #endif |
---|
2013 |           if (verbose < 4) { |
---|
2014 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "In argument list keywords have leading - " |
---|
2015 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ", -stdin or just - switches to stdin"Â <<Â std::endl; |
---|
2016 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "One command per line (and no -)"Â <<Â std::endl; |
---|
2017 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd? gives list of possibilities, if only one + explanation"Â <<Â std::endl; |
---|
2018 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd?? adds explanation, if only one fuller help"Â <<Â std::endl; |
---|
2019 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd without value (where expected) gives current value"Â <<Â std::endl; |
---|
2020 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd value sets value"Â <<Â std::endl; |
---|
2021 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Commands are:"Â <<Â std::endl; |
---|
2022 |           } else { |
---|
2023 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Cbc options are set within AMPL with commands like:"Â <<Â std::endl <<Â std::endl; |
---|
2024 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Â Â Â Â Â option cbc_options \"cuts=root log=2 feas=on slog=1\""Â <<Â std::endl <<Â std::endl; |
---|
2025 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "only maximize, dual, primal, help and quit are recognized without ="Â <<Â std::endl; |
---|
2026 | Â Â Â Â Â Â Â Â Â Â } |
---|
2027 |           int maxAcross = 10; |
---|
2028 |           if ((verbose % 4) != 0) |
---|
2029 | Â Â Â Â Â Â Â Â Â Â Â Â maxAcross =Â 1; |
---|
2030 |           int limits[] = {1, 51, 101, 151, 201, 251, 301, 351, 401}; |
---|
2031 | Â Â Â Â Â Â Â Â Â Â std::vector<std::string>Â types; |
---|
2032 | Â Â Â Â Â Â Â Â Â Â types.push_back("Double parameters:"); |
---|
2033 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut double parameters:"); |
---|
2034 | Â Â Â Â Â Â Â Â Â Â types.push_back("Integer parameters:"); |
---|
2035 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut integer parameters:"); |
---|
2036 | Â Â Â Â Â Â Â Â Â Â types.push_back("Keyword parameters:"); |
---|
2037 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut keyword parameters:"); |
---|
2038 | Â Â Â Â Â Â Â Â Â Â types.push_back("Actions or string parameters:"); |
---|
2039 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut actions:"); |
---|
2040 |           int iType; |
---|
2041 |           for (iType = 0; iType < 8; iType++) { |
---|
2042 |             int across = 0; |
---|
2043 |             int lengthLine = 0; |
---|
2044 |             if ((verbose % 4) != 0) |
---|
2045 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2046 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â types[iType]Â <<Â std::endl; |
---|
2047 |             if ((verbose&2) != 0) |
---|
2048 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2049 |             for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
2050 |               int type = parameters_[iParam].type(); |
---|
2051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //printf("%d type %d limits %d %d display %d\n",iParam, |
---|
2052 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â type,limits[iType],limits[iType+1],parameters_[iParam].displayThis()); |
---|
2053 |               if ((parameters_[iParam].displayThis() >= printLevel || evenHidden) && |
---|
2054 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type >=Â limits[iType] |
---|
2055 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â type <Â limits[iType+1])Â { |
---|
2056 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // but skip if not useful for ampl (and in ampl mode) |
---|
2057 |                 if (verbose >= 4 && (parameters_[iParam].whereUsed()&4) == 0) |
---|
2058 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue; |
---|
2059 |                 if (!across) { |
---|
2060 |                   if ((verbose&2) != 0) |
---|
2061 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Command "; |
---|
2062 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2063 |                 int length = parameters_[iParam].lengthMatchName() + 1; |
---|
2064 |                 if (lengthLine + length > 80) { |
---|
2065 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2066 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
2067 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lengthLine =Â 0; |
---|
2068 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2069 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " "Â <<Â parameters_[iParam].matchName(); |
---|
2070 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lengthLine +=Â length; |
---|
2071 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across++; |
---|
2072 |                 if (across == maxAcross) { |
---|
2073 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
2074 |                   if ((verbose % 4) != 0) { |
---|
2075 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put out description as well |
---|
2076 |                     if ((verbose&1) != 0) |
---|
2077 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " "Â <<Â parameters_[iParam].shortHelp(); |
---|
2078 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2079 |                     if ((verbose&2) != 0) { |
---|
2080 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "---- description"Â <<Â std::endl; |
---|
2081 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].printLongHelp(); |
---|
2082 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "----"Â <<Â std::endl <<Â std::endl; |
---|
2083 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2084 |                   } else { |
---|
2085 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2086 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2087 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2088 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2089 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2090 |             if (across) |
---|
2091 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2092 | Â Â Â Â Â Â Â Â Â Â } |
---|
2093 |         } else if (type == CBC_PARAM_FULLGENERALQUERY) { |
---|
2094 | Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Full list of commands is:"Â <<Â std::endl; |
---|
2095 |           int maxAcross = 5; |
---|
2096 |           int limits[] = {1, 51, 101, 151, 201, 251, 301, 351, 401}; |
---|
2097 | Â Â Â Â Â Â Â Â Â Â std::vector<std::string>Â types; |
---|
2098 | Â Â Â Â Â Â Â Â Â Â types.push_back("Double parameters:"); |
---|
2099 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut double parameters:"); |
---|
2100 | Â Â Â Â Â Â Â Â Â Â types.push_back("Integer parameters:"); |
---|
2101 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut integer parameters:"); |
---|
2102 | Â Â Â Â Â Â Â Â Â Â types.push_back("Keyword parameters:"); |
---|
2103 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut keyword parameters:"); |
---|
2104 | Â Â Â Â Â Â Â Â Â Â types.push_back("Actions or string parameters:"); |
---|
2105 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut actions:"); |
---|
2106 |           int iType; |
---|
2107 |           for (iType = 0; iType < 8; iType++) { |
---|
2108 |             int across = 0; |
---|
2109 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â types[iType]Â <<Â "Â "; |
---|
2110 |             for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
2111 |               int type = parameters_[iParam].type(); |
---|
2112 |               if (type >= limits[iType] |
---|
2113 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â type <Â limits[iType+1])Â { |
---|
2114 |                 if (!across) |
---|
2115 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Â "; |
---|
2116 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].matchName()Â <<Â "Â "; |
---|
2117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across++; |
---|
2118 |                 if (across == maxAcross) { |
---|
2119 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
2121 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2122 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2123 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2124 |             if (across) |
---|
2125 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
2126 | Â Â Â Â Â Â Â Â Â Â } |
---|
2127 |         } else if (type < 101) { |
---|
2128 | Â Â Â Â Â Â Â Â Â Â // get next field as double |
---|
2129 |           double value = CoinReadGetDoubleField(argc, argv, &valid); |
---|
2130 |           if (!valid) { |
---|
2131 |             if (type < 51) { |
---|
2132 |               int returnCode; |
---|
2133 |               const char * message = |
---|
2134 |                 parameters_[iParam].setDoubleParameterWithMessage(lpSolver, value, returnCode); |
---|
2135 |               if (!noPrinting_ && strlen(message)) { |
---|
2136 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2137 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2138 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2139 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2140 |             } else if (type < 81) { |
---|
2141 |               int returnCode; |
---|
2142 |               const char * message = |
---|
2143 |                 parameters_[iParam].setDoubleParameterWithMessage(model_, value, returnCode); |
---|
2144 |               if (!noPrinting_ && strlen(message)) { |
---|
2145 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2146 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2147 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2148 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2149 |             } else { |
---|
2150 |               int returnCode; |
---|
2151 |               const char * message = |
---|
2152 |                 parameters_[iParam].setDoubleParameterWithMessage(lpSolver, value, returnCode); |
---|
2153 |               if (!noPrinting_ && strlen(message)) { |
---|
2154 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2155 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2156 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2158 |               switch (type) { |
---|
2159 |               case CBC_PARAM_DBL_DJFIX: |
---|
2160 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â djFix =Â value; |
---|
2161 | #ifndef CBC_OTHER_SOLVER |
---|
2162 |                 if (goodModel && djFix < 1.0e20) { |
---|
2163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // do some fixing |
---|
2164 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (model_.solver()); |
---|
2165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->initialSolve(); |
---|
2166 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
2167 |                   int numberColumns = lpSolver->numberColumns(); |
---|
2168 |                   int i; |
---|
2169 |                   const char * type = lpSolver->integerInformation(); |
---|
2170 |                   double * lower = lpSolver->columnLower(); |
---|
2171 |                   double * upper = lpSolver->columnUpper(); |
---|
2172 |                   double * solution = lpSolver->primalColumnSolution(); |
---|
2173 |                   double * dj = lpSolver->dualColumnSolution(); |
---|
2174 |                   int numberFixed = 0; |
---|
2175 |                   double dextra4 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA4, numberParameters_, parameters_)].doubleValue(); |
---|
2176 |                   if (dextra4) |
---|
2177 |                     printf("Multiple for continuous dj fixing is %g\n", dextra4); |
---|
2178 |                   for (i = 0; i < numberColumns; i++) { |
---|
2179 |                     double djValue = dj[i]; |
---|
2180 |                     if (!type[i]) |
---|
2181 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â djValue *=Â dextra4; |
---|
2182 |                     if (type[i] || dextra4) { |
---|
2183 |                       double value = solution[i]; |
---|
2184 |                       if (value < lower[i] + 1.0e-5 && djValue > djFix) { |
---|
2185 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution[i]Â =Â lower[i]; |
---|
2186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upper[i]Â =Â lower[i]; |
---|
2187 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberFixed++; |
---|
2188 |                       } else if (value > upper[i] - 1.0e-5 && djValue < -djFix) { |
---|
2189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution[i]Â =Â upper[i]; |
---|
2190 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lower[i]Â =Â upper[i]; |
---|
2191 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberFixed++; |
---|
2192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2193 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2194 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2195 |                   sprintf(generalPrint, "%d columns fixed\n", numberFixed); |
---|
2196 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2199 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2200 | #endif |
---|
2201 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2202 |               case CBC_PARAM_DBL_TIGHTENFACTOR: |
---|
2203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tightenFactor =Â value; |
---|
2204 |                 if (!complicatedInteger) |
---|
2205 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2206 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2207 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â default: |
---|
2208 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2209 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2210 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2211 |           } else if (valid == 1) { |
---|
2212 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " is illegal for double parameter "Â <<Â parameters_[iParam].name()Â <<Â " value remains "Â << |
---|
2213 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].doubleValue()Â <<Â std::endl; |
---|
2214 |           } else { |
---|
2215 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2216 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].doubleValue()Â <<Â std::endl; |
---|
2217 | Â Â Â Â Â Â Â Â Â Â } |
---|
2218 |         } else if (type < 201) { |
---|
2219 | Â Â Â Â Â Â Â Â Â Â // get next field as int |
---|
2220 |           int value = CoinReadGetIntField(argc, argv, &valid); |
---|
2221 |           if (!valid) { |
---|
2222 |             if (type < 151) { |
---|
2223 |               if (parameters_[iParam].type() == CLP_PARAM_INT_PRESOLVEPASS) |
---|
2224 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â value; |
---|
2225 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_IDIOT) |
---|
2226 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doIdiot =Â value; |
---|
2227 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SPRINT) |
---|
2228 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSprint =Â value; |
---|
2229 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_OUTPUTFORMAT) |
---|
2230 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â outputFormat =Â value; |
---|
2231 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SLPVALUE) |
---|
2232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â slpValue =Â value; |
---|
2233 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_CPP) |
---|
2234 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cppValue =Â value; |
---|
2235 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PRESOLVEOPTIONS) |
---|
2236 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveOptions =Â value; |
---|
2237 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PRINTOPTIONS) |
---|
2238 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printOptions =Â value; |
---|
2239 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SUBSTITUTION) |
---|
2240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â substitution =Â value; |
---|
2241 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_DUALIZE) |
---|
2242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â value; |
---|
2243 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PROCESSTUNE) |
---|
2244 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â value; |
---|
2245 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_USESOLUTION) |
---|
2246 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â useSolution =Â value; |
---|
2247 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_VERBOSE) |
---|
2248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â verbose =Â value; |
---|
2249 |               int returnCode; |
---|
2250 |               const char * message = |
---|
2251 |                 parameters_[iParam].setIntParameterWithMessage(lpSolver, value, returnCode); |
---|
2252 |               if (!noPrinting_ && strlen(message)) { |
---|
2253 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2254 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2257 |             } else { |
---|
2258 |               if (parameters_[iParam].type() == CBC_PARAM_INT_CUTPASS) |
---|
2259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPass =Â value; |
---|
2260 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_CUTPASSINTREE) |
---|
2261 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPassInTree =Â value; |
---|
2262 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_STRONGBRANCHING || |
---|
2263 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_NUMBERBEFORE) |
---|
2264 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â strongChanged =Â true; |
---|
2265 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_FPUMPTUNE || |
---|
2266 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_FPUMPTUNE2 || |
---|
2267 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_FPUMPITS) |
---|
2268 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pumpChanged =Â true; |
---|
2269 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_EXPERIMENT) { |
---|
2270 |                 int addFlags=0; |
---|
2271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // switch on some later features if >999 |
---|
2272 |                 if (value>999) { |
---|
2273 |                  int switchValue=value/1000; |
---|
2274 |                  const char * message = NULL; |
---|
2275 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value -=Â 1000*switchValue; |
---|
2276 |                  parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters_, parameters_)].setIntValue(0/*value*/); |
---|
2277 |                  switch (switchValue) { |
---|
2278 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â default: |
---|
2279 |                  case 4: |
---|
2280 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // hotstart 500, -200 cut passes |
---|
2281 |                   message=parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].setIntValueWithMessage(500); |
---|
2282 |                   if (!noPrinting_&&message) |
---|
2283 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2284 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2285 |                   message=parameters_[whichParam(CBC_PARAM_INT_CUTPASS, numberParameters_, parameters_)].setIntValueWithMessage(-200); |
---|
2286 |                   if (!noPrinting_&&message) |
---|
2287 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2288 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2289 |                  case 3: |
---|
2290 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // multiple 4 |
---|
2291 |                   message=parameters_[whichParam(CBC_PARAM_INT_MULTIPLEROOTS, numberParameters_, parameters_)].setIntValueWithMessage(4); |
---|
2292 |                   if (!noPrinting_&&message) |
---|
2293 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2294 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2295 |                  case 2: |
---|
2296 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // rens plus all diving at root |
---|
2297 |                   message=parameters_[whichParam(CBC_PARAM_INT_DIVEOPT, numberParameters_, parameters_)].setIntValueWithMessage(16); |
---|
2298 |                   if (!noPrinting_&&message) |
---|
2299 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2300 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2301 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setNumberAnalyzeIterations(-value); |
---|
2302 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // -tune 7 zero,lagomory,gmi at root - probing on |
---|
2303 |                  case 1: |
---|
2304 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess=7; |
---|
2305 |                   message=parameters_[whichParam(CLP_PARAM_INT_PROCESSTUNE, numberParameters_, parameters_)].setIntValueWithMessage(7); |
---|
2306 |                   if (!noPrinting_&&message) |
---|
2307 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2308 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2309 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //message = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].setIntValueWithMessage(1025); |
---|
2310 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (!noPrinting_&&message) |
---|
2311 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2312 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â << message << CoinMessageEol; |
---|
2313 |                   message=parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOptionWithMessage("on"); |
---|
2314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 1; |
---|
2315 |                   if (!noPrinting_&&message) |
---|
2316 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2317 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2318 |                   message=parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOptionWithMessage("root"); |
---|
2319 |                   if (!noPrinting_&&message) |
---|
2320 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2321 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2322 |                   message=parameters_[whichParam(CBC_PARAM_STR_LAGOMORYCUTS, numberParameters_, parameters_)].setCurrentOptionWithMessage("root"); |
---|
2323 |                   if (!noPrinting_&&message) |
---|
2324 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2325 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2326 | #ifdef SWAP_GOMORY |
---|
2327 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â GMIAction =Â 3; |
---|
2328 |                   message=parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOptionWithMessage("ifmove"); |
---|
2329 | #else |
---|
2330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â GMIAction =Â 2; |
---|
2331 |                   message=parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOptionWithMessage("root"); |
---|
2332 | #endif |
---|
2333 |                   if (!noPrinting_&&message) |
---|
2334 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2335 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message <<Â CoinMessageEol; |
---|
2336 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value =Â 0; |
---|
2338 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2339 |                 if (value>=10) { |
---|
2340 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â addFlags =Â 1048576*(value/10); |
---|
2341 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value =Â value %Â 10; |
---|
2342 |                  parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters_, parameters_)].setIntValue(value); |
---|
2343 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2344 |                 if (value >= 1) { |
---|
2345 |                   int values[]={24003,280003,792003,24003,24003}; |
---|
2346 |                   if (value>=2&&value<=3) { |
---|
2347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // swap default diving |
---|
2348 |                    int iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
2349 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2350 |                    iParam = whichParam(CBC_PARAM_STR_DIVINGP, numberParameters_, parameters_); |
---|
2351 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
2352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2353 |                   int extra4 = values[value-1]+addFlags; |
---|
2354 |                   parameters_[whichParam(CBC_PARAM_INT_EXTRA4, numberParameters_, parameters_)].setIntValue(extra4); |
---|
2355 |                   if (!noPrinting_) { |
---|
2356 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2357 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "switching on global root cuts for gomory and knapsack" |
---|
2358 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2359 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2360 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "using OSL factorization" |
---|
2361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2362 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2363 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "extra options - -rens on -extra4 " |
---|
2364 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<extra4<<" -passc 1000!" |
---|
2365 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2366 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2367 |                   parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOption("forceOnStrong"); |
---|
2368 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 8; |
---|
2369 |                   parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption("onGlobal"); |
---|
2370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â 5; |
---|
2371 |                   parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption("onGlobal"); |
---|
2372 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â 5; |
---|
2373 |                   parameters_[whichParam(CLP_PARAM_STR_FACTORIZATION, numberParameters_, parameters_)].setCurrentOption("osl"); |
---|
2374 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->forceOtherFactorization(3); |
---|
2375 |                   parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].setIntValue(100); |
---|
2376 |                   parameters_[whichParam(CBC_PARAM_INT_CUTPASS, numberParameters_, parameters_)].setIntValue(1000); |
---|
2377 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPass =Â 1000; |
---|
2378 |                   parameters_[whichParam(CBC_PARAM_STR_RENS, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
2379 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2380 |               } else if (parameters_[iParam].type() == CBC_PARAM_INT_STRATEGY) { |
---|
2381 |                 if (value == 0) { |
---|
2382 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.05); |
---|
2383 |                   int iParam; |
---|
2384 |                   iParam = whichParam(CBC_PARAM_INT_DIVEOPT, numberParameters_, parameters_); |
---|
2385 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(-1); |
---|
2386 |                   iParam = whichParam(CBC_PARAM_INT_FPUMPITS, numberParameters_, parameters_); |
---|
2387 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(20); |
---|
2388 |                   iParam = whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_); |
---|
2389 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(1003); |
---|
2390 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â initialPumpTune =Â 1003; |
---|
2391 |                   iParam = whichParam(CLP_PARAM_INT_PROCESSTUNE, numberParameters_, parameters_); |
---|
2392 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(0); |
---|
2393 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â 0; |
---|
2394 |                   iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
2395 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2396 |                   iParam = whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_); |
---|
2397 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2398 |                   iParam = whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_); |
---|
2399 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // but not if cuts off |
---|
2400 |                   int jParam = whichParam(CBC_PARAM_STR_CUTSSTRATEGY, numberParameters_, parameters_); |
---|
2401 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2402 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â jParam =Â parameters_[jParam].currentOptionAsInteger(); |
---|
2403 |                   if (jParam) { |
---|
2404 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
2405 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 1; |
---|
2406 |                   } else { |
---|
2407 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2408 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 0; |
---|
2409 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2410 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2411 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2412 |               int returnCode; |
---|
2413 |               const char * message = |
---|
2414 |                 parameters_[iParam].setIntParameterWithMessage(model_, value, returnCode); |
---|
2415 |               if (!noPrinting_ && strlen(message)) { |
---|
2416 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2417 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2418 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2419 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2420 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2421 |           } else if (valid == 1) { |
---|
2422 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " is illegal for integer parameter "Â <<Â parameters_[iParam].name()Â <<Â " value remains "Â << |
---|
2423 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].intValue()Â <<Â std::endl; |
---|
2424 |           } else { |
---|
2425 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].intValue()Â <<Â std::endl; |
---|
2427 | Â Â Â Â Â Â Â Â Â Â } |
---|
2428 |         } else if (type < 301) { |
---|
2429 | Â Â Â Â Â Â Â Â Â Â // one of several strings |
---|
2430 |           std::string value = CoinReadGetString(argc, argv); |
---|
2431 |           int action = parameters_[iParam].parameterOption(value); |
---|
2432 |           if (action < 0) { |
---|
2433 |             if (value != "EOL") { |
---|
2434 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // no match |
---|
2435 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].printOptions(); |
---|
2436 |             } else { |
---|
2437 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // print current value |
---|
2438 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2439 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].currentOption()Â <<Â std::endl; |
---|
2440 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2441 |           } else { |
---|
2442 |             const char * message = |
---|
2443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOptionWithMessage(action); |
---|
2444 |             if (!noPrinting_ && strlen(message)) { |
---|
2445 |               generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2446 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2447 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2448 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2449 | Â Â Â Â Â Â Â Â Â Â Â Â // for now hard wired |
---|
2450 |             switch (type) { |
---|
2451 |             case CLP_PARAM_STR_DIRECTION: |
---|
2452 |               if (action == 0) |
---|
2453 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(1); |
---|
2454 |               else if (action == 1) |
---|
2455 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(-1); |
---|
2456 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2457 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(0); |
---|
2458 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2459 |             case CLP_PARAM_STR_DUALPIVOT: |
---|
2460 |               if (action == 0) { |
---|
2461 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep(3); |
---|
2462 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2463 |               } else if (action == 1) { |
---|
2464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowDantzig dantzig; |
---|
2465 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //ClpDualRowSteepest dantzig(5); |
---|
2466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(dantzig); |
---|
2467 |               } else if (action == 2) { |
---|
2468 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // partial steep |
---|
2469 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep(2); |
---|
2470 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2471 |               } else { |
---|
2472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep; |
---|
2473 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2474 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2475 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2476 |             case CLP_PARAM_STR_PRIMALPIVOT: |
---|
2477 |               if (action == 0) { |
---|
2478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(3); |
---|
2479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2480 |               } else if (action == 1) { |
---|
2481 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(0); |
---|
2482 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2483 |               } else if (action == 2) { |
---|
2484 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnDantzig dantzig; |
---|
2485 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(dantzig); |
---|
2486 |               } else if (action == 3) { |
---|
2487 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(4); |
---|
2488 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2489 |               } else if (action == 4) { |
---|
2490 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(1); |
---|
2491 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2492 |               } else if (action == 5) { |
---|
2493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(2); |
---|
2494 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2495 |               } else if (action == 6) { |
---|
2496 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(10); |
---|
2497 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2498 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2499 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2500 |             case CLP_PARAM_STR_SCALING: |
---|
2501 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->scaling(action); |
---|
2502 |               solver->setHintParam(OsiDoScale, action != 0, OsiHintTry); |
---|
2503 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doScaling =Â action; |
---|
2504 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2505 |             case CLP_PARAM_STR_AUTOSCALE: |
---|
2506 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setAutomaticScaling(action !=Â 0); |
---|
2507 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2508 |             case CLP_PARAM_STR_SPARSEFACTOR: |
---|
2509 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setSparseFactorization((1Â -Â action)Â !=Â 0); |
---|
2510 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2511 |             case CLP_PARAM_STR_BIASLU: |
---|
2512 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->setBiasLU(action); |
---|
2513 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2514 |             case CLP_PARAM_STR_PERTURBATION: |
---|
2515 |               if (action == 0) |
---|
2516 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPerturbation(50); |
---|
2517 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2518 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPerturbation(100); |
---|
2519 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2520 |             case CLP_PARAM_STR_ERRORSALLOWED: |
---|
2521 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â allowImportErrors =Â action; |
---|
2522 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2523 |             case CLP_PARAM_STR_INTPRINT: |
---|
2524 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â printMode =Â action; |
---|
2525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //case CLP_PARAM_NOTUSED_ALGORITHM: |
---|
2527 |               //algorithm = action; |
---|
2528 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //defaultSettings=false; // user knows what she is doing |
---|
2529 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //abort(); |
---|
2530 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //break; |
---|
2531 |             case CLP_PARAM_STR_KEEPNAMES: |
---|
2532 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â keepImportNames =Â 1Â -Â action; |
---|
2533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2534 |             case CLP_PARAM_STR_PRESOLVE: |
---|
2535 |               if (action == 0) |
---|
2536 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 5; |
---|
2537 |               else if (action == 1) |
---|
2538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 0; |
---|
2539 |               else if (action == 2) |
---|
2540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 10; |
---|
2541 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolveFile =Â true; |
---|
2543 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2544 |             case CLP_PARAM_STR_PFI: |
---|
2545 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->setForrestTomlin(action ==Â 0); |
---|
2546 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2547 |             case CLP_PARAM_STR_FACTORIZATION: |
---|
2548 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->forceOtherFactorization(action); |
---|
2549 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2550 |             case CLP_PARAM_STR_CRASH: |
---|
2551 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doCrash =Â action; |
---|
2552 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2553 |             case CLP_PARAM_STR_VECTOR: |
---|
2554 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doVector =Â action; |
---|
2555 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2556 |             case CLP_PARAM_STR_MESSAGES: |
---|
2557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->messageHandler()->setPrefix(action !=Â 0); |
---|
2558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2559 |             case CLP_PARAM_STR_CHOLESKY: |
---|
2560 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choleskyType =Â action; |
---|
2561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2562 |             case CLP_PARAM_STR_GAMMA: |
---|
2563 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gamma =Â action; |
---|
2564 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2565 |             case CLP_PARAM_STR_BARRIERSCALE: |
---|
2566 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â scaleBarrier =Â action; |
---|
2567 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2568 |             case CLP_PARAM_STR_KKT: |
---|
2569 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doKKT =Â action; |
---|
2570 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2571 |             case CLP_PARAM_STR_CROSSOVER: |
---|
2572 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â crossover =Â action; |
---|
2573 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2574 |             case CLP_PARAM_STR_TIME_MODE: |
---|
2575 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setUseElapsedTime(action!=0); |
---|
2576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2577 |             case CBC_PARAM_STR_SOS: |
---|
2578 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSOS =Â action; |
---|
2579 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2580 |             case CBC_PARAM_STR_GOMORYCUTS: |
---|
2581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2582 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â action; |
---|
2583 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2584 |             case CBC_PARAM_STR_PROBINGCUTS: |
---|
2585 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2586 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â action; |
---|
2587 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2588 |             case CBC_PARAM_STR_KNAPSACKCUTS: |
---|
2589 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2590 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â action; |
---|
2591 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2592 |             case CBC_PARAM_STR_REDSPLITCUTS: |
---|
2593 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplitAction =Â action; |
---|
2595 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2596 |             case CBC_PARAM_STR_REDSPLIT2CUTS: |
---|
2597 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2598 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplit2Action =Â action; |
---|
2599 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2600 |             case CBC_PARAM_STR_GMICUTS: |
---|
2601 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2602 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â GMIAction =Â action; |
---|
2603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2604 |             case CBC_PARAM_STR_CLIQUECUTS: |
---|
2605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2606 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â cliqueAction =Â action; |
---|
2607 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2608 |             case CBC_PARAM_STR_FLOWCUTS: |
---|
2609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2610 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â flowAction =Â action; |
---|
2611 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2612 |             case CBC_PARAM_STR_MIXEDCUTS: |
---|
2613 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2614 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â mixedAction =Â action; |
---|
2615 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2616 |             case CBC_PARAM_STR_TWOMIRCUTS: |
---|
2617 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2618 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirAction =Â action; |
---|
2619 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2620 |             case CBC_PARAM_STR_LANDPCUTS: |
---|
2621 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2622 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â landpAction =Â action; |
---|
2623 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2624 |             case CBC_PARAM_STR_RESIDCUTS: |
---|
2625 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2626 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â residualCapacityAction =Â action; |
---|
2627 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2628 |             case CBC_PARAM_STR_ZEROHALFCUTS: |
---|
2629 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2630 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â zerohalfAction =Â action; |
---|
2631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2632 |             case CBC_PARAM_STR_ROUNDING: |
---|
2633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2634 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2635 |             case CBC_PARAM_STR_FPUMP: |
---|
2636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2637 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2638 |             case CBC_PARAM_STR_RINS: |
---|
2639 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2640 |             case CBC_PARAM_STR_DINS: |
---|
2641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2642 |             case CBC_PARAM_STR_RENS: |
---|
2643 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2644 |             case CBC_PARAM_STR_CUTSSTRATEGY: |
---|
2645 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â action; |
---|
2646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â action; |
---|
2647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â action; |
---|
2648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â cliqueAction =Â action; |
---|
2649 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â flowAction =Â action; |
---|
2650 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â mixedAction =Â action; |
---|
2651 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirAction =Â action; |
---|
2652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //landpAction = action; |
---|
2653 |               parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2654 |               parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2655 |               parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2656 |               parameters_[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2657 |               parameters_[whichParam(CBC_PARAM_STR_FLOWCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2658 |               parameters_[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2659 |               parameters_[whichParam(CBC_PARAM_STR_TWOMIRCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2660 |               if (!action) { |
---|
2661 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â zerohalfAction =Â action; |
---|
2662 |                 parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2663 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplitAction =Â action; |
---|
2664 |                 parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2665 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplit2Action =Â action; |
---|
2666 |                 parameters_[whichParam(CBC_PARAM_STR_REDSPLIT2CUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2667 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â GMIAction =Â action; |
---|
2668 |                 parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â landpAction =Â action; |
---|
2670 |                 parameters_[whichParam(CBC_PARAM_STR_LANDPCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â residualCapacityAction =Â action; |
---|
2672 |                 parameters_[whichParam(CBC_PARAM_STR_RESIDCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2673 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2674 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2675 |             case CBC_PARAM_STR_HEURISTICSTRATEGY: |
---|
2676 |               parameters_[whichParam(CBC_PARAM_STR_ROUNDING, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2677 |               parameters_[whichParam(CBC_PARAM_STR_GREEDY, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2678 |               parameters_[whichParam(CBC_PARAM_STR_COMBINE, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2679 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //parameters_[whichParam(CBC_PARAM_STR_LOCALTREE,numberParameters_,parameters_)].setCurrentOption(action); |
---|
2680 |               parameters_[whichParam(CBC_PARAM_STR_FPUMP, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2681 |               parameters_[whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2682 |               parameters_[whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2684 |             case CBC_PARAM_STR_GREEDY: |
---|
2685 |             case CBC_PARAM_STR_DIVINGS: |
---|
2686 |             case CBC_PARAM_STR_DIVINGC: |
---|
2687 |             case CBC_PARAM_STR_DIVINGF: |
---|
2688 |             case CBC_PARAM_STR_DIVINGG: |
---|
2689 |             case CBC_PARAM_STR_DIVINGL: |
---|
2690 |             case CBC_PARAM_STR_DIVINGP: |
---|
2691 |             case CBC_PARAM_STR_DIVINGV: |
---|
2692 |             case CBC_PARAM_STR_COMBINE: |
---|
2693 |             case CBC_PARAM_STR_PIVOTANDCOMPLEMENT: |
---|
2694 |             case CBC_PARAM_STR_PIVOTANDFIX: |
---|
2695 |             case CBC_PARAM_STR_RANDROUND: |
---|
2696 |             case CBC_PARAM_STR_LOCALTREE: |
---|
2697 |             case CBC_PARAM_STR_NAIVE: |
---|
2698 |             case CBC_PARAM_STR_CPX: |
---|
2699 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2700 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2701 |             case CBC_PARAM_STR_COSTSTRATEGY: |
---|
2702 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â useCosts =Â action; |
---|
2703 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2704 |             case CBC_PARAM_STR_NODESTRATEGY: |
---|
2705 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â nodeStrategy =Â action; |
---|
2706 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2707 |             case CBC_PARAM_STR_PREPROCESS: |
---|
2708 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â action; |
---|
2709 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2710 | Â Â Â Â Â Â Â Â Â Â Â Â default: |
---|
2711 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //abort(); |
---|
2712 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2713 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2714 | Â Â Â Â Â Â Â Â Â Â } |
---|
2715 |         } else { |
---|
2716 | Â Â Â Â Â Â Â Â Â Â // action |
---|
2717 |           if (type == CLP_PARAM_ACTION_EXIT) { |
---|
2718 | #ifdef COIN_HAS_ASL |
---|
2719 |             if (statusUserFunction_[0]) { |
---|
2720 |               if (info.numberIntegers || info.numberBinary) { |
---|
2721 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // integer |
---|
2722 |               } else { |
---|
2723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // linear |
---|
2724 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2725 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â writeAmpl(&info); |
---|
2726 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â freeArrays2(&info); |
---|
2727 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â freeArgs(&info); |
---|
2728 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2729 | #endif |
---|
2730 | Â Â Â Â Â Â Â Â Â Â Â Â break;Â // stop all |
---|
2731 | Â Â Â Â Â Â Â Â Â Â } |
---|
2732 |           switch (type) { |
---|
2733 |           case CLP_PARAM_ACTION_DUALSIMPLEX: |
---|
2734 |           case CLP_PARAM_ACTION_PRIMALSIMPLEX: |
---|
2735 |           case CLP_PARAM_ACTION_SOLVECONTINUOUS: |
---|
2736 |           case CLP_PARAM_ACTION_BARRIER: |
---|
2737 |             if (goodModel) { |
---|
2738 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Say not in integer |
---|
2739 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â -1; |
---|
2740 |               double objScale = |
---|
2741 |                 parameters_[whichParam(CLP_PARAM_DBL_OBJSCALE2, numberParameters_, parameters_)].doubleValue(); |
---|
2742 |               if (objScale != 1.0) { |
---|
2743 |                 int iColumn; |
---|
2744 |                 int numberColumns = lpSolver->numberColumns(); |
---|
2745 |                 double * dualColumnSolution = |
---|
2746 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->dualColumnSolution(); |
---|
2747 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpObjective *Â obj =Â lpSolver->objectiveAsObject(); |
---|
2748 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert(dynamic_cast<ClpLinearObjective *>Â (obj)); |
---|
2749 |                 double offset; |
---|
2750 |                 double * objective = obj->gradient(NULL, NULL, offset, true); |
---|
2751 |                 for (iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
2752 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualColumnSolution[iColumn]Â *=Â objScale; |
---|
2753 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objective[iColumn]Â *=Â objScale;; |
---|
2754 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2755 |                 int iRow; |
---|
2756 |                 int numberRows = lpSolver->numberRows(); |
---|
2757 |                 double * dualRowSolution = |
---|
2758 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->dualRowSolution(); |
---|
2759 |                 for (iRow = 0; iRow < numberRows; iRow++) |
---|
2760 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualRowSolution[iRow]Â *=Â objScale; |
---|
2761 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setObjectiveOffset(objScale*lpSolver->objectiveOffset()); |
---|
2762 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2763 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::SolveType method; |
---|
2764 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::PresolveType presolveType; |
---|
2765 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â model2 =Â lpSolver; |
---|
2766 |               if (dualize) { |
---|
2767 |                 bool tryIt = true; |
---|
2768 |                 double fractionColumn = 1.0; |
---|
2769 |                 double fractionRow = 1.0; |
---|
2770 |                 if (dualize == 3) { |
---|
2771 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 1; |
---|
2772 |                   int numberColumns = lpSolver->numberColumns(); |
---|
2773 |                   int numberRows = lpSolver->numberRows(); |
---|
2774 |                   if (numberRows < 50000 || 5*numberColumns > numberRows) { |
---|
2775 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tryIt =Â false; |
---|
2776 |                   } else { |
---|
2777 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fractionColumn =Â 0.1; |
---|
2778 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fractionRow =Â 0.1; |
---|
2779 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2780 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2781 |                 if (tryIt) { |
---|
2782 |                   model2 = static_cast<ClpSimplexOther *> (model2)->dualOfModel(fractionRow, fractionColumn); |
---|
2783 |                   if (model2) { |
---|
2784 |                     sprintf(generalPrint, "Dual of model has %d rows and %d columns", |
---|
2785 |                         model2->numberRows(), model2->numberColumns()); |
---|
2786 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2787 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2788 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2789 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setOptimizationDirection(1.0); |
---|
2790 |                   } else { |
---|
2791 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
2792 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 0; |
---|
2793 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2794 |                 } else { |
---|
2795 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 0; |
---|
2796 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2797 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2798 |               if (noPrinting_) |
---|
2799 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setLogLevel(0); |
---|
2800 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve solveOptions; |
---|
2801 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setPresolveActions(presolveOptions); |
---|
2802 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setSubstitution(substitution); |
---|
2803 |               if (preSolve != 5 && preSolve) { |
---|
2804 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumber; |
---|
2805 |                 if (preSolve < 0) { |
---|
2806 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â -Â preSolve; |
---|
2807 |                   if (preSolve <= 100) { |
---|
2808 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumber; |
---|
2809 |                     sprintf(generalPrint, "Doing %d presolve passes - picking up non-costed slacks", |
---|
2810 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve); |
---|
2811 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2812 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2813 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2814 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setDoSingletonColumn(true); |
---|
2815 |                   } else { |
---|
2816 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve -=Â 100; |
---|
2817 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumberCost; |
---|
2818 |                     sprintf(generalPrint, "Doing %d presolve passes - picking up costed slacks", |
---|
2819 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve); |
---|
2820 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2821 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2822 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2823 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2824 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2825 |               } else if (preSolve) { |
---|
2826 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOn; |
---|
2827 |               } else { |
---|
2828 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOff; |
---|
2829 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2830 |               solveOptions.setPresolveType(presolveType, preSolve); |
---|
2831 |               if (type == CLP_PARAM_ACTION_DUALSIMPLEX || |
---|
2832 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type ==Â CLP_PARAM_ACTION_SOLVECONTINUOUS)Â { |
---|
2833 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useDual; |
---|
2834 |               } else if (type == CLP_PARAM_ACTION_PRIMALSIMPLEX) { |
---|
2835 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::usePrimalorSprint; |
---|
2836 |               } else { |
---|
2837 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrier; |
---|
2838 |                 if (crossover == 1) { |
---|
2839 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrierNoCross; |
---|
2840 |                 } else if (crossover == 2) { |
---|
2841 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpObjective *Â obj =Â lpSolver->objectiveAsObject(); |
---|
2842 |                   if (obj->type() > 1) { |
---|
2843 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrierNoCross; |
---|
2844 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOff; |
---|
2845 |                     solveOptions.setPresolveType(presolveType, preSolve); |
---|
2846 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2847 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2848 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2849 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setSolveType(method); |
---|
2850 |               if (preSolveFile) |
---|
2851 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveOptions |=Â 0x40000000; |
---|
2852 |               solveOptions.setSpecialOption(4, presolveOptions); |
---|
2853 |               solveOptions.setSpecialOption(5, printOptions); |
---|
2854 |               if (doVector) { |
---|
2855 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â matrix =Â lpSolver->clpMatrix(); |
---|
2856 |                 if (dynamic_cast< ClpPackedMatrix*>(matrix)) { |
---|
2857 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix *Â clpMatrix =Â dynamic_cast<Â ClpPackedMatrix*>(matrix); |
---|
2858 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpMatrix->makeSpecialColumnCopy(); |
---|
2859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2860 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2861 |               if (method == ClpSolve::useDual) { |
---|
2862 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // dual |
---|
2863 |                 if (doCrash) |
---|
2864 |                   solveOptions.setSpecialOption(0, 1, doCrash); // crash |
---|
2865 |                 else if (doIdiot) |
---|
2866 |                   solveOptions.setSpecialOption(0, 2, doIdiot); // possible idiot |
---|
2867 |               } else if (method == ClpSolve::usePrimalorSprint) { |
---|
2868 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // primal |
---|
2869 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // if slp turn everything off |
---|
2870 |                 if (slpValue > 0) { |
---|
2871 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doCrash =Â false; |
---|
2872 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSprint =Â 0; |
---|
2873 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doIdiot =Â -1; |
---|
2874 |                   solveOptions.setSpecialOption(1, 10, slpValue); // slp |
---|
2875 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::usePrimal; |
---|
2876 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2877 |                 if (doCrash) { |
---|
2878 |                   solveOptions.setSpecialOption(1, 1, doCrash); // crash |
---|
2879 |                 } else if (doSprint > 0) { |
---|
2880 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // sprint overrides idiot |
---|
2881 |                   solveOptions.setSpecialOption(1, 3, doSprint); // sprint |
---|
2882 |                 } else if (doIdiot > 0) { |
---|
2883 |                   solveOptions.setSpecialOption(1, 2, doIdiot); // idiot |
---|
2884 |                 } else if (slpValue <= 0) { |
---|
2885 |                   if (doIdiot == 0) { |
---|
2886 |                     if (doSprint == 0) |
---|
2887 |                       solveOptions.setSpecialOption(1, 4); // all slack |
---|
2888 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2889 |                       solveOptions.setSpecialOption(1, 9); // all slack or sprint |
---|
2890 |                   } else { |
---|
2891 |                     if (doSprint == 0) |
---|
2892 |                       solveOptions.setSpecialOption(1, 8); // all slack or idiot |
---|
2893 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2894 |                       solveOptions.setSpecialOption(1, 7); // initiative |
---|
2895 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2896 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2897 |                 if (basisHasValues == -1) |
---|
2898 |                   solveOptions.setSpecialOption(1, 11); // switch off values |
---|
2899 |               } else if (method == ClpSolve::useBarrier || method == ClpSolve::useBarrierNoCross) { |
---|
2900 |                 int barrierOptions = choleskyType; |
---|
2901 |                 if (scaleBarrier) |
---|
2902 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 8; |
---|
2903 |                 if (doKKT) |
---|
2904 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 16; |
---|
2905 |                 if (gamma) |
---|
2906 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 32Â *Â gamma; |
---|
2907 |                 if (crossover == 3) |
---|
2908 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 256;Â // try presolve in crossover |
---|
2909 |                 solveOptions.setSpecialOption(4, barrierOptions); |
---|
2910 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2911 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setMaximumSeconds(model_.getMaximumSeconds()); |
---|
2912 | #ifdef COIN_HAS_LINK |
---|
2913 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â coinSolver =Â model_.solver(); |
---|
2914 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â linkSolver =Â dynamic_cast<Â OsiSolverLink*>Â (coinSolver); |
---|
2915 |               if (!linkSolver) { |
---|
2916 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->initialSolve(solveOptions); |
---|
2917 |               } else { |
---|
2918 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // special solver |
---|
2919 |                 int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
2920 |                 double * solution = NULL; |
---|
2921 |                 if (testOsiOptions < 10) { |
---|
2922 |                   solution = linkSolver->nonlinearSLP(slpValue > 0 ? slpValue : 20 , 1.0e-5); |
---|
2923 |                 } else if (testOsiOptions >= 10) { |
---|
2924 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinModel coinModel =Â *linkSolver->coinModel(); |
---|
2925 |                   ClpSimplex * tempModel = approximateSolution(coinModel, slpValue > 0 ? slpValue : 50 , 1.0e-5, 0); |
---|
2926 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (tempModel); |
---|
2927 |                   solution = CoinCopyOfArray(tempModel->primalColumnSolution(), coinModel.numberColumns()); |
---|
2928 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setObjectiveValue(tempModel->objectiveValue()); |
---|
2929 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setProblemStatus(tempModel->problemStatus()); |
---|
2930 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setSecondaryStatus(tempModel->secondaryStatus()); |
---|
2931 |                   delete tempModel; |
---|
2932 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2933 |                 if (solution) { |
---|
2934 |                   memcpy(model2->primalColumnSolution(), solution, |
---|
2935 |                       CoinMin(model2->numberColumns(), linkSolver->coinModel()->numberColumns())*sizeof(double)); |
---|
2936 |                   delete [] solution; |
---|
2937 |                 } else { |
---|
2938 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("No nonlinear solution\n"); |
---|
2939 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2941 | #else |
---|
2942 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->initialSolve(solveOptions); |
---|
2943 | #endif |
---|
2944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
2945 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // map states |
---|
2946 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* clp status |
---|
2947 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 - unknown e.g. before solve or if postSolve says not optimal |
---|
2948 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 - optimal |
---|
2949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - primal infeasible |
---|
2950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - dual infeasible |
---|
2951 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 - stopped on iterations or time |
---|
2952 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - stopped due to errors |
---|
2953 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 - stopped by event handler (virtual int ClpEventHandler::event()) */ |
---|
2954 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* cbc status |
---|
2955 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 before branchAndBound |
---|
2956 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found |
---|
2957 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (or check value of best solution) |
---|
2958 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 stopped - on maxnodes, maxsols, maxtime |
---|
2959 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 difficulties so run was abandoned |
---|
2960 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (5 event user programmed event occurred) */ |
---|
2961 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* clp secondary status of problem - may get extended |
---|
2962 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 - none |
---|
2963 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - primal infeasible because dual limit reached OR probably primal |
---|
2964 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â infeasible but can't prove it (main status 4) |
---|
2965 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - scaled problem optimal - unscaled problem has primal infeasibilities |
---|
2966 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 - scaled problem optimal - unscaled problem has dual infeasibilities |
---|
2967 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - scaled problem optimal - unscaled problem has primal and dual infeasibilities |
---|
2968 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 - giving up in primal with flagged variables |
---|
2969 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 6 - failed due to empty problem check |
---|
2970 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7 - postSolve says not optimal |
---|
2971 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8 - failed due to bad element check |
---|
2972 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 9 - status was 3 and stopped on time |
---|
2973 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 100 up - translation of enum from ClpEventHandler |
---|
2974 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
2975 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* cbc secondary status of problem |
---|
2976 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 unset (status_ will also be -1) |
---|
2977 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 search completed with solution |
---|
2978 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 linear relaxation not feasible (or worse than cutoff) |
---|
2979 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 stopped on gap |
---|
2980 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 stopped on nodes |
---|
2981 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 stopped on time |
---|
2982 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 stopped on user event |
---|
2983 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 6 stopped on solutions |
---|
2984 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7 linear relaxation unbounded |
---|
2985 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8 stopped on iterations limit |
---|
2986 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
2987 |                 int iStatus = model2->status(); |
---|
2988 |                 int iStatus2 = model2->secondaryStatus(); |
---|
2989 |                 if (iStatus == 0) { |
---|
2990 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
2991 |                   if (found.type() == CBC_PARAM_ACTION_BAB) { |
---|
2992 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // set best solution in model as no integers |
---|
2993 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setBestSolution(model2->primalColumnSolution(), |
---|
2994 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->numberColumns(), |
---|
2995 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getObjValue()* |
---|
2996 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getObjSense()); |
---|
2997 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2998 |                 } else if (iStatus == 1) { |
---|
2999 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3000 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 1;Â // say infeasible |
---|
3001 |                 } else if (iStatus == 2) { |
---|
3002 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3003 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 7;Â // say unbounded |
---|
3004 |                 } else if (iStatus == 3) { |
---|
3005 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 1; |
---|
3006 |                   if (iStatus2 == 9) // what does 9 mean ????????????? |
---|
3007 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 4; |
---|
3008 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3009 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 3;Â // Use nodes - as closer than solutions |
---|
3010 |                 } else if (iStatus == 4) { |
---|
3011 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 2;Â // difficulties |
---|
3012 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
3013 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3014 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(iStatus); |
---|
3015 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(iStatus2); |
---|
3016 |                 if ((iStatus == 2 || iStatus2 > 0) && |
---|
3017 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â !noPrinting_)Â { |
---|
3018 |                   std::string statusName[] = {"", "Stopped on ", "Run abandoned", "", "", "User ctrl-c"}; |
---|
3019 |                   std::string minor[] = {"Optimal solution found", "Linear relaxation infeasible", "Optimal solution found (within gap tolerance)", "node limit", "time limit", "user ctrl-c", "solution limit", "Linear relaxation unbounded", "iterations limit", "Problem proven infeasible"}; |
---|
3020 |                   sprintf(generalPrint, "\nResult - %s%s\n\n", |
---|
3021 |                       statusName[iStatus].c_str(), |
---|
3022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â minor[iStatus2].c_str()); |
---|
3023 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
3024 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Enumerated nodes:Â Â Â Â Â Â 0\n"); |
---|
3025 |                   sprintf(generalPrint + strlen(generalPrint), |
---|
3026 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Total iterations:Â Â Â Â Â Â 0\n"); |
---|
3027 | #if CBC_QUIET == 0 |
---|
3028 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
3029 |                       "Time (CPU seconds):     %.2f\n", |
---|
3030 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinCpuTime()Â -Â time0); |
---|
3031 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
3032 |                       "Time (Wallclock Seconds):  %.2f\n", |
---|
3033 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinGetTimeOfDay()-time0Elapsed); |
---|
3034 | #endif |
---|
3035 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3036 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3037 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3038 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3039 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //assert (lpSolver==clpSolver->getModelPtr()); |
---|
3040 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (clpSolver ==Â model_.solver()); |
---|
3041 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->setWarmStart(NULL); |
---|
3042 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3043 |                 if (babModel_) { |
---|
3044 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(iStatus); |
---|
3045 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(iStatus2); |
---|
3046 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3047 |                 int returnCode = callBack(&model, 1); |
---|
3048 |                 if (returnCode) { |
---|
3049 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3050 |                   delete babModel_; |
---|
3051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3052 |                   return returnCode; |
---|
3053 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3054 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3055 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â basisHasValues =Â 1; |
---|
3056 |               if (dualize) { |
---|
3057 |                 int returnCode = static_cast<ClpSimplexOther *> (lpSolver)->restoreFromDual(model2); |
---|
3058 |                 if (model2->status() == 3) |
---|
3059 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â returnCode =Â 0; |
---|
3060 |                 delete model2; |
---|
3061 |                 if (returnCode && dualize != 2) |
---|
3062 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->primal(1); |
---|
3063 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
3064 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3065 | #ifdef COIN_HAS_ASL |
---|
3066 |               if (statusUserFunction_[0]) { |
---|
3067 |                 double value = model2->getObjValue(); |
---|
3068 |                 char buf[300]; |
---|
3069 |                 int pos = 0; |
---|
3070 |                 int iStat = model2->status(); |
---|
3071 |                 if (iStat == 0) { |
---|
3072 |                   pos += sprintf(buf + pos, "optimal," ); |
---|
3073 |                 } else if (iStat == 1) { |
---|
3074 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // infeasible |
---|
3075 |                   pos += sprintf(buf + pos, "infeasible,"); |
---|
3076 |                 } else if (iStat == 2) { |
---|
3077 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // unbounded |
---|
3078 |                   pos += sprintf(buf + pos, "unbounded,"); |
---|
3079 |                 } else if (iStat == 3) { |
---|
3080 |                   pos += sprintf(buf + pos, "stopped on iterations or time,"); |
---|
3081 |                 } else if (iStat == 4) { |
---|
3082 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 7; |
---|
3083 |                   pos += sprintf(buf + pos, "stopped on difficulties,"); |
---|
3084 |                 } else if (iStat == 5) { |
---|
3085 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 3; |
---|
3086 |                   pos += sprintf(buf + pos, "stopped on ctrl-c,"); |
---|
3087 |                 } else if (iStat == 6) { |
---|
3088 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // bab infeasible |
---|
3089 |                   pos += sprintf(buf + pos, "integer infeasible,"); |
---|
3090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 1; |
---|
3091 |                 } else { |
---|
3092 |                   pos += sprintf(buf + pos, "status unknown,"); |
---|
3093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 6; |
---|
3094 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3095 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â iStat; |
---|
3096 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â value; |
---|
3097 |                 pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), |
---|
3098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value); |
---|
3099 |                 sprintf(buf + pos, "\n%d iterations", |
---|
3100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getIterationCount()); |
---|
3101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.primalSolution); |
---|
3102 |                 int numberColumns = model2->numberColumns(); |
---|
3103 |                 info.primalSolution = reinterpret_cast<double *> (malloc(numberColumns * sizeof(double))); |
---|
3104 |                 CoinCopyN(model2->primalColumnSolution(), numberColumns, info.primalSolution); |
---|
3105 |                 int numberRows = model2->numberRows(); |
---|
3106 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.dualSolution); |
---|
3107 |                 info.dualSolution = reinterpret_cast<double *> (malloc(numberRows * sizeof(double))); |
---|
3108 |                 CoinCopyN(model2->dualRowSolution(), numberRows, info.dualSolution); |
---|
3109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â model2->getBasis(); |
---|
3110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.rowStatus); |
---|
3111 |                 info.rowStatus = reinterpret_cast<int *> (malloc(numberRows * sizeof(int))); |
---|
3112 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.columnStatus); |
---|
3113 |                 info.columnStatus = reinterpret_cast<int *> (malloc(numberColumns * sizeof(int))); |
---|
3114 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Put basis in |
---|
3115 |                 int i; |
---|
3116 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // free,basic,ub,lb are 0,1,2,3 |
---|
3117 |                 for (i = 0; i < numberRows; i++) { |
---|
3118 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getArtifStatus(i); |
---|
3119 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.rowStatus[i]Â =Â status; |
---|
3120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3121 |                 for (i = 0; i < numberColumns; i++) { |
---|
3122 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getStructStatus(i); |
---|
3123 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.columnStatus[i]Â =Â status; |
---|
3124 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3125 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put buffer into info |
---|
3126 |                 strcpy(info.buffer, buf); |
---|
3127 |                 delete basis; |
---|
3128 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3129 | #endif |
---|
3130 |             } else { |
---|
3131 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3132 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3133 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3134 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3135 |           case CLP_PARAM_ACTION_STATISTICS: |
---|
3136 |             if (goodModel) { |
---|
3137 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If presolve on look at presolved |
---|
3138 |               bool deleteModel2 = false; |
---|
3139 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â model2 =Â lpSolver; |
---|
3140 |               if (preSolve) { |
---|
3141 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPresolve pinfo; |
---|
3142 |                 int presolveOptions2 = presolveOptions&~0x40000000; |
---|
3143 |                 if ((presolveOptions2&0xffff) != 0) |
---|
3144 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.setPresolveActions(presolveOptions2); |
---|
3145 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.setSubstitution(substitution); |
---|
3146 |                 if ((printOptions&1) != 0) |
---|
3147 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.statistics(); |
---|
3148 |                 double presolveTolerance = |
---|
3149 |                   parameters_[whichParam(CLP_PARAM_DBL_PRESOLVETOLERANCE, numberParameters_, parameters_)].doubleValue(); |
---|
3150 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 = |
---|
3151 |                   pinfo.presolvedModel(*lpSolver, presolveTolerance, |
---|
3152 |                              true, preSolve); |
---|
3153 |                 if (model2) { |
---|
3154 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Statistics for presolved model\n"); |
---|
3155 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â deleteModel2 =Â true; |
---|
3156 |                 } else { |
---|
3157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Presolved model looks infeasible - will use unpresolved\n"); |
---|
3158 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
3159 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3160 |               } else { |
---|
3161 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Statistics for unpresolved model\n"); |
---|
3162 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
3163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3164 |               statistics(lpSolver, model2); |
---|
3165 |               if (deleteModel2) |
---|
3166 |                 delete model2; |
---|
3167 |             } else { |
---|
3168 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3169 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3170 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3171 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3172 |           case CLP_PARAM_ACTION_TIGHTEN: |
---|
3173 |             if (goodModel) { |
---|
3174 |               int numberInfeasibilities = lpSolver->tightenPrimalBounds(); |
---|
3175 |               if (numberInfeasibilities) { |
---|
3176 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"** Analysis indicates model infeasible"); |
---|
3177 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3178 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3179 |             } else { |
---|
3180 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3181 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3182 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3183 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3184 |           case CLP_PARAM_ACTION_PLUSMINUS: |
---|
3185 |             if (goodModel) { |
---|
3186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â saveMatrix =Â lpSolver->clpMatrix(); |
---|
3187 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix*Â clpMatrix = |
---|
3188 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<Â ClpPackedMatrix*>(saveMatrix); |
---|
3189 |               if (clpMatrix) { |
---|
3190 |                 ClpPlusMinusOneMatrix * newMatrix = new ClpPlusMinusOneMatrix(*(clpMatrix->matrix())); |
---|
3191 |                 if (newMatrix->getIndices()) { |
---|
3192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->replaceMatrix(newMatrix); |
---|
3193 |                   delete saveMatrix; |
---|
3194 |                   sprintf(generalPrint, "Matrix converted to +- one matrix"); |
---|
3195 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3196 |                 } else { |
---|
3197 |                  sprintf(generalPrint, "Matrix can not be converted to +- 1 matrix"); |
---|
3198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3199 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3200 |               } else { |
---|
3201 |                sprintf(generalPrint, "Matrix not a ClpPackedMatrix"); |
---|
3202 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3204 |             } else { |
---|
3205 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3206 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3207 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3208 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3209 |           case CLP_PARAM_ACTION_OUTDUPROWS: |
---|
3210 | Â Â Â Â Â Â Â Â Â Â Â Â dominatedCuts =Â true; |
---|
3211 | #ifdef JJF_ZERO |
---|
3212 |             if (goodModel) { |
---|
3213 |               int numberRows = clpSolver->getNumRows(); |
---|
3214 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //int nOut = outDupRow(clpSolver); |
---|
3215 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglDuplicateRow dupcuts(clpSolver); |
---|
3216 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â storedCuts =Â dupcuts.outDuplicates(clpSolver)Â !=Â 0; |
---|
3217 |               int nOut = numberRows - clpSolver->getNumRows(); |
---|
3218 |               if (nOut && !noPrinting_) |
---|
3219 |                 sprintf(generalPrint, "%d rows eliminated", nOut); |
---|
3220 |               generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3221 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3222 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3223 |             } else { |
---|
3224 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3225 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3226 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3227 | #endif |
---|
3228 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3229 |           case CLP_PARAM_ACTION_NETWORK: |
---|
3230 |             if (goodModel) { |
---|
3231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â saveMatrix =Â lpSolver->clpMatrix(); |
---|
3232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix*Â clpMatrix = |
---|
3233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<Â ClpPackedMatrix*>(saveMatrix); |
---|
3234 |               if (clpMatrix) { |
---|
3235 |                 ClpNetworkMatrix * newMatrix = new ClpNetworkMatrix(*(clpMatrix->matrix())); |
---|
3236 |                 if (newMatrix->getIndices()) { |
---|
3237 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->replaceMatrix(newMatrix); |
---|
3238 |                   delete saveMatrix; |
---|
3239 |                   sprintf(generalPrint, "Matrix converted to network matrix"); |
---|
3240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3241 |                 } else { |
---|
3242 |                  sprintf(generalPrint, "Matrix can not be converted to network matrix"); |
---|
3243 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3244 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3245 |               } else { |
---|
3246 |                sprintf(generalPrint, "Matrix not a ClpPackedMatrix"); |
---|
3247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3249 |             } else { |
---|
3250 |              sprintf(generalPrint, "** Current model not valid"); |
---|
3251 | Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3252 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3253 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3254 |           case CBC_PARAM_ACTION_DOHEURISTIC: |
---|
3255 |             if (goodModel) { |
---|
3256 | #ifndef CBC_USE_INITIAL_TIME |
---|
3257 |              if (model_.useElapsedTime()) |
---|
3258 |               model_.setDblParam(CbcModel::CbcStartSeconds, CoinGetTimeOfDay()); |
---|
3259 | Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3260 |               model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); |
---|
3261 | #endif |
---|
3262 |               int vubAction = parameters_[whichParam(CBC_PARAM_INT_VUBTRY, numberParameters_, parameters_)].intValue(); |
---|
3263 |               if (vubAction != -1) { |
---|
3264 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // look at vubs |
---|
3265 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // extra1 is number of ints to leave free |
---|
3266 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Just ones which affect >= extra3 |
---|
3267 |                 int extra3 = parameters_[whichParam(CBC_PARAM_INT_EXTRA3, numberParameters_, parameters_)].intValue(); |
---|
3268 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* 2 is cost above which to fix if feasible |
---|
3269 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 is fraction of integer variables fixed if relaxing (0.97) |
---|
3270 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 is fraction of all variables fixed if relaxing (0.0) |
---|
3271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
3272 |                 double dextra[6]; |
---|
3273 |                 int extra[5]; |
---|
3274 |                 extra[1] = parameters_[whichParam(CBC_PARAM_INT_EXTRA1, numberParameters_, parameters_)].intValue(); |
---|
3275 |                 int exp1 = parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters_, |
---|
3276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_)].intValue(); |
---|
3277 |                 if (exp1 == 4 && extra[1] == -1) |
---|
3278 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra[1]Â =Â 999998; |
---|
3279 |                 dextra[1] = parameters_[whichParam(CBC_PARAM_DBL_FAKEINCREMENT, numberParameters_, parameters_)].doubleValue(); |
---|
3280 |                 dextra[2] = parameters_[whichParam(CBC_PARAM_DBL_FAKECUTOFF, numberParameters_, parameters_)].doubleValue(); |
---|
3281 |                 dextra[3] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
3282 |                 dextra[4] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA4, numberParameters_, parameters_)].doubleValue(); |
---|
3283 |                 dextra[5] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA5, numberParameters_, parameters_)].doubleValue(); |
---|
3284 |                 if (!dextra[3]) |
---|
3285 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dextra[3]Â =Â 0.97; |
---|
3286 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //OsiClpSolverInterface * newSolver = |
---|
3287 |                 fixVubs(model_, extra3, vubAction, generalMessageHandler, |
---|
3288 |                     debugValues, dextra, extra); |
---|
3289 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //assert (!newSolver); |
---|
3290 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3291 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Actually do heuristics |
---|
3292 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // may need to flip objective |
---|
3293 |               bool needFlip = model_.solver()->getObjSense()<0.0; |
---|
3294 |               if (needFlip) |
---|
3295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.flipModel();Â |
---|
3296 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if we do then - fix priorities in clonebutmodel_.convertToDynamic(); |
---|
3297 |               bool objectsExist = model_.objects() != NULL; |
---|
3298 |               if (!objectsExist) { |
---|
3299 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.findIntegers(false); |
---|
3300 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.convertToDynamic(); |
---|
3301 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3302 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // set priorities etc |
---|
3303 |               if (priorities) { |
---|
3304 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â objects =Â model_.objects(); |
---|
3305 |                int numberObjects = model_.numberObjects(); |
---|
3306 |                for (int iObj = 0; iObj < numberObjects; iObj++) { |
---|
3307 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleInteger *Â obj = |
---|
3308 |                  dynamic_cast <CbcSimpleInteger *>(objects[iObj]) ; |
---|
3309 |                 if (!obj) |
---|
3310 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue; |
---|
3311 |                 int iColumn = obj->columnNumber(); |
---|
3312 |                 if (branchDirection) { |
---|
3313 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setPreferredWay(branchDirection[iColumn]); |
---|
3314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3315 |                 if (priorities) { |
---|
3316 |                  int iPriority = priorities[iColumn]; |
---|
3317 |                  if (iPriority > 0) |
---|
3318 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setPriority(iPriority); |
---|
3319 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3320 |                 if (pseudoUp && pseudoUp[iColumn]) { |
---|
3321 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleIntegerPseudoCost *Â obj1a = |
---|
3322 |                   dynamic_cast <CbcSimpleIntegerPseudoCost *>(objects[iObj]) ; |
---|
3323 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (obj1a); |
---|
3324 |                  if (pseudoDown[iColumn] > 0.0) |
---|
3325 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj1a->setDownPseudoCost(pseudoDown[iColumn]); |
---|
3326 |                  if (pseudoUp[iColumn] > 0.0) |
---|
3327 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj1a->setUpPseudoCost(pseudoUp[iColumn]); |
---|
3328 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3329 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3331 |               doHeuristics(&model_, 2, parameters_, |
---|
3332 |                      numberParameters_, noPrinting_, initialPumpTune); |
---|
3333 |               if (!objectsExist) { |
---|
3334 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.deleteObjects(false); |
---|
3335 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3336 |               if (needFlip) |
---|
3337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.flipModel(); |
---|
3338 |               if (model_.bestSolution()) { |
---|
3339 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(1); |
---|
3340 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(6); |
---|
3341 | #ifdef COIN_HAS_ASL |
---|
3342 |                 if (statusUserFunction_[0]) { |
---|
3343 |                   double value = model_.getObjValue(); |
---|
3344 |                   char buf[300]; |
---|
3345 |                   int pos = 0; |
---|
3346 |                   pos += sprintf(buf + pos, "feasible,"); |
---|
3347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â 0; |
---|
3348 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â value; |
---|
3349 |                   pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), |
---|
3350 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value); |
---|
3351 |                   sprintf(buf + pos, "\n0 iterations"); |
---|
3352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.primalSolution); |
---|
3353 |                   int numberColumns = lpSolver->numberColumns(); |
---|
3354 |                   info.primalSolution = reinterpret_cast<double *> (malloc(numberColumns * sizeof(double))); |
---|
3355 |                   CoinCopyN(model_.bestSolution(), numberColumns, info.primalSolution); |
---|
3356 |                   int numberRows = lpSolver->numberRows(); |
---|
3357 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.dualSolution); |
---|
3358 |                   info.dualSolution = reinterpret_cast<double *> (malloc(numberRows * sizeof(double))); |
---|
3359 |                   CoinZeroN(info.dualSolution, numberRows); |
---|
3360 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â lpSolver->getBasis(); |
---|
3361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.rowStatus); |
---|
3362 |                   info.rowStatus = reinterpret_cast<int *> (malloc(numberRows * sizeof(int))); |
---|
3363 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.columnStatus); |
---|
3364 |                   info.columnStatus = reinterpret_cast<int *> (malloc(numberColumns * sizeof(int))); |
---|
3365 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Put basis in |
---|
3366 |                   int i; |
---|
3367 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // free,basic,ub,lb are 0,1,2,3 |
---|
3368 |                   for (i = 0; i < numberRows; i++) { |
---|
3369 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getArtifStatus(i); |
---|
3370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.rowStatus[i]Â =Â status; |
---|
3371 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3372 |                   for (i = 0; i < numberColumns; i++) { |
---|
3373 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getStructStatus(i); |
---|
3374 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.columnStatus[i]Â =Â status; |
---|
3375 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3376 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put buffer into info |
---|
3377 |                   strcpy(info.buffer, buf); |
---|
3378 |                   delete basis; |
---|
3379 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3380 | #endif |
---|
3381 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3382 |               int returnCode = callBack(&model, 6); |
---|
3383 |               if (returnCode) { |
---|
3384 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3385 |                 delete babModel_; |
---|
3386 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3387 |                 return returnCode; |
---|
3388 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3389 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3390 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3391 |           case CBC_PARAM_ACTION_MIPLIB: |
---|
3392 | Â Â Â Â Â Â Â Â Â Â Â Â // User can set options - main difference is lack of model and CglPreProcess |
---|
3393 | Â Â Â Â Â Â Â Â Â Â Â Â goodModel =Â true; |
---|
3394 |             parameters_[whichParam(CBC_PARAM_INT_MULTIPLEROOTS, numberParameters_, parameters_)].setIntValue(0); |
---|
3395 | Â Â Â Â Â Â Â Â Â Â Â Â /* |
---|
3396 | Â Â Â Â Â Â Â Â Â Â Â Â Â Run branch-and-cut. First set a few options -- node comparison, scaling. |
---|
3397 | Â Â Â Â Â Â Â Â Â Â Â Â Â Print elapsed time at the end. |
---|
3398 | Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
3399 |           case CBC_PARAM_ACTION_BAB: // branchAndBound |
---|
3400 | Â Â Â Â Â Â Â Â Â Â Â Â // obsolete case STRENGTHEN: |
---|
3401 |             if (goodModel) { |
---|
3402 |               bool miplib = type == CBC_PARAM_ACTION_MIPLIB; |
---|
3403 |               int logLevel = parameters_[slog].intValue(); |
---|
3404 |               int truncateColumns=COIN_INT_MAX; |
---|
3405 |               int truncateRows=-1; |
---|
3406 |               double * truncatedRhsLower=NULL; |
---|
3407 |               double * truncatedRhsUpper=NULL; |
---|
3408 |               int * newPriorities=NULL; |
---|
3409 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Reduce printout |
---|
3410 |               if (logLevel <= 1) { |
---|
3411 |                 model_.solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3412 |               } else { |
---|
3413 |                 model_.solver()->setHintParam(OsiDoReducePrint, false, OsiHintTry); |
---|
3414 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3415 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3416 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3417 | #ifndef CBC_OTHER_SOLVER |
---|
3418 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3419 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3421 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->getModelPtr()->scaling(doScaling); |
---|
3422 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lpSolver =Â si->getModelPtr(); |
---|
3423 |                 if (doVector) { |
---|
3424 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â matrix =Â lpSolver->clpMatrix(); |
---|
3425 |                   if (dynamic_cast< ClpPackedMatrix*>(matrix)) { |
---|
3426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix *Â clpMatrix =Â dynamic_cast<Â ClpPackedMatrix*>(matrix); |
---|
3427 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpMatrix->makeSpecialColumnCopy(); |
---|
3428 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3429 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3430 | #elif CBC_OTHER_SOLVER==1 |
---|
3431 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiCpxSolverInterface *Â si = |
---|
3432 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiCpxSolverInterface *>(solver)Â ; |
---|
3433 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3434 | #endif |
---|
3435 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nrows =Â si->getNumRows(); |
---|
3436 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_ncols =Â si->getNumCols(); |
---|
3437 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedrows =Â si->getNumRows(); |
---|
3438 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedcols =Â si->getNumCols(); |
---|
3439 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if quadratic |
---|
3440 | #ifndef CBC_OTHER_SOLVER |
---|
3441 | #ifdef COIN_HAS_LINK |
---|
3442 |                 if (!complicatedInteger) { |
---|
3443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpQuadraticObjective *Â obj =Â (dynamic_cast<Â ClpQuadraticObjective*>(lpSolver->objectiveAsObject())); |
---|
3444 |                   if (obj) { |
---|
3445 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3446 |                     int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
3447 |                     parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(CoinMax(0, testOsiOptions)); |
---|
3448 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // create coin model |
---|
3449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â coinModel =Â lpSolver->createCoinModel(); |
---|
3450 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (coinModel); |
---|
3451 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // load from coin model |
---|
3452 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink solver1; |
---|
3453 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2 =Â solver1.clone(); |
---|
3454 |                     model_.assignSolver(solver2, false); |
---|
3455 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â si = |
---|
3456 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiSolverLink *>(model_.solver())Â ; |
---|
3457 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3458 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(0.001); |
---|
3459 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // need some relative granularity |
---|
3460 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100.0); |
---|
3461 |                     double dextra3 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
3462 |                     if (dextra3) |
---|
3463 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(dextra3); |
---|
3464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(1000.0); |
---|
3465 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setIntegerPriority(1000); |
---|
3466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setBiLinearPriority(10000); |
---|
3467 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â biLinearProblem=true; |
---|
3468 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions2(2Â +Â 4Â +Â 8); |
---|
3469 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinModel *Â model2 =Â coinModel; |
---|
3470 |                     si->load(*model2, true, parameters_[log].intValue()); |
---|
3471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // redo |
---|
3472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver =Â model_.solver(); |
---|
3473 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
3474 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
3475 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->messageHandler()->setLogLevel(0)Â ; |
---|
3476 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â testOsiParameters =Â 0; |
---|
3477 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 2;Â // allow cuts |
---|
3478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â coinSolver =Â model_.solver(); |
---|
3479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â linkSolver =Â dynamic_cast<Â OsiSolverLink*>Â (coinSolver); |
---|
3480 |                     if (linkSolver->quadraticModel()) { |
---|
3481 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â qp =Â linkSolver->quadraticModel(); |
---|
3482 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); |
---|
3483 |                       qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); |
---|
3484 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â qp->primal(1); |
---|
3485 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLinearizedQuadratic solver2(qp); |
---|
3486 |                       const double * solution = NULL; |
---|
3487 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Reduce printout |
---|
3488 |                       solver2.setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3489 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcModel model2(solver2); |
---|
3490 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Now do requested saves and modifications |
---|
3491 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcModel *Â cbcModel =Â &Â model2; |
---|
3492 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â osiModel =Â model2.solver(); |
---|
3493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclpModel =Â dynamic_cast<Â OsiClpSolverInterface*>Â (osiModel); |
---|
3494 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â clpModel =Â osiclpModel->getModelPtr(); |
---|
3495 | |
---|
3496 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Set changed values |
---|
3497 | |
---|
3498 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglProbing probing; |
---|
3499 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxProbe(10); |
---|
3500 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxLook(10); |
---|
3501 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxElements(200); |
---|
3502 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxProbeRoot(50); |
---|
3503 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxLookRoot(10); |
---|
3504 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setRowCuts(3); |
---|
3505 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setUsingObjective(true); |
---|
3506 |                       cbcModel->addCutGenerator(&probing, -1, "Probing", true, false, false, -100, -1, -1); |
---|
3507 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(0)->setTiming(true); |
---|
3508 | |
---|
3509 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglGomory gomory; |
---|
3510 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomory.setLimitAtRoot(512); |
---|
3511 |                       cbcModel->addCutGenerator(&gomory, -98, "Gomory", true, false, false, -100, -1, -1); |
---|
3512 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(1)->setTiming(true); |
---|
3513 | |
---|
3514 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglKnapsackCover knapsackCover; |
---|
3515 |                       cbcModel->addCutGenerator(&knapsackCover, -98, "KnapsackCover", true, false, false, -100, -1, -1); |
---|
3516 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(2)->setTiming(true); |
---|
3517 | |
---|
3518 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglRedSplit redSplit; |
---|
3519 |                       cbcModel->addCutGenerator(&redSplit, -99, "RedSplit", true, false, false, -100, -1, -1); |
---|
3520 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(3)->setTiming(true); |
---|
3521 | |
---|
3522 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglClique clique; |
---|
3523 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setStarCliqueReport(false); |
---|
3524 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setRowCliqueReport(false); |
---|
3525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setMinViolation(0.1); |
---|
3526 |                       cbcModel->addCutGenerator(&clique, -98, "Clique", true, false, false, -100, -1, -1); |
---|
3527 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(4)->setTiming(true); |
---|
3528 | |
---|
3529 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglMixedIntegerRounding2 mixedIntegerRounding2; |
---|
3530 |                       cbcModel->addCutGenerator(&mixedIntegerRounding2, -98, "MixedIntegerRounding2", true, false, false, -100, -1, -1); |
---|
3531 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(5)->setTiming(true); |
---|
3532 | |
---|
3533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglFlowCover flowCover; |
---|
3534 |                       cbcModel->addCutGenerator(&flowCover, -98, "FlowCover", true, false, false, -100, -1, -1); |
---|
3535 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(6)->setTiming(true); |
---|
3536 | |
---|
3537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglTwomir twomir; |
---|
3538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomir.setMaxElements(250); |
---|
3539 |                       cbcModel->addCutGenerator(&twomir, -99, "Twomir", true, false, false, -100, -1, -1); |
---|
3540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(7)->setTiming(true); |
---|
3541 | |
---|
3542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicFPump heuristicFPump(*cbcModel); |
---|
3543 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setWhen(13); |
---|
3544 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setMaximumPasses(20); |
---|
3545 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setMaximumRetries(7); |
---|
3546 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setHeuristicName("feasibility pump"); |
---|
3547 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setInitialWeight(1); |
---|
3548 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setFractionSmall(0.6); |
---|
3549 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicFPump); |
---|
3550 | |
---|
3551 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcRounding rounding(*cbcModel); |
---|
3552 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rounding.setHeuristicName("rounding"); |
---|
3553 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&rounding); |
---|
3554 | |
---|
3555 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicLocal heuristicLocal(*cbcModel); |
---|
3556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setHeuristicName("combine solutions"); |
---|
3557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setSearchType(1); |
---|
3558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setFractionSmall(0.6); |
---|
3559 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicLocal); |
---|
3560 | |
---|
3561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicGreedyCover heuristicGreedyCover(*cbcModel); |
---|
3562 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicGreedyCover.setHeuristicName("greedy cover"); |
---|
3563 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicGreedyCover); |
---|
3564 | |
---|
3565 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicGreedyEquality heuristicGreedyEquality(*cbcModel); |
---|
3566 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicGreedyEquality.setHeuristicName("greedy equality"); |
---|
3567 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicGreedyEquality); |
---|
3568 | |
---|
3569 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcCompareDefault compare; |
---|
3570 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNodeComparison(compare); |
---|
3571 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNumberBeforeTrust(5); |
---|
3572 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setSpecialOptions(2); |
---|
3573 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->messageHandler()->setLogLevel(1); |
---|
3574 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMaximumCutPassesAtRoot(-100); |
---|
3575 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMaximumCutPasses(1); |
---|
3576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMinimumDrop(0.05); |
---|
3577 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // For branchAndBound this may help |
---|
3578 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->defaultFactorizationFrequency(); |
---|
3579 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->setDualBound(1.0001e+08); |
---|
3580 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->setPerturbation(50); |
---|
3581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclpModel->setSpecialOptions(193); |
---|
3582 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclpModel->messageHandler()->setLogLevel(0); |
---|
3583 |                       osiclpModel->setIntParam(OsiMaxNumIterationHotStart, 100); |
---|
3584 |                       osiclpModel->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3585 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // You can save some time by switching off message building |
---|
3586 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // clpModel->messagesPointer()->setDetailMessages(100,10000,(int *) NULL); |
---|
3587 | |
---|
3588 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Solve |
---|
3589 | |
---|
3590 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->initialSolve(); |
---|
3591 |                       if (clpModel->tightenPrimalBounds() != 0) { |
---|
3592 |                        sprintf(generalPrint, "Problem is infeasible - tightenPrimalBounds!"); |
---|
3593 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3595 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3596 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->dual();Â // clean up |
---|
3597 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->initialSolve(); |
---|
3598 | #ifdef CBC_THREAD |
---|
3599 |                       int numberThreads = parameters_[whichParam(CBC_PARAM_INT_THREADS, numberParameters_, parameters_)].intValue(); |
---|
3600 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNumberThreads(numberThreads %Â 100); |
---|
3601 |                       cbcModel->setThreadMode(CoinMin(numberThreads / 100, 7)); |
---|
3602 | #endif |
---|
3603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //setCutAndHeuristicOptions(*cbcModel); |
---|
3604 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->branchAndBound(); |
---|
3605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLinearizedQuadratic *Â solver3 =Â dynamic_cast<OsiSolverLinearizedQuadratic *>Â (model2.solver()); |
---|
3606 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (solver3); |
---|
3607 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution =Â solver3->bestSolution(); |
---|
3608 |                       double bestObjectiveValue = solver3->bestObjectiveValue(); |
---|
3609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â linkSolver->setBestObjectiveValue(bestObjectiveValue); |
---|
3610 |                       if (solution) { |
---|
3611 |                        linkSolver->setBestSolution(solution, solver3->getNumCols()); |
---|
3612 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3613 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicDynamic3 dynamic(model_); |
---|
3614 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic.setHeuristicName("dynamic pass thru"); |
---|
3615 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.addHeuristic(&dynamic); |
---|
3616 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // if convex |
---|
3617 |                       if ((linkSolver->specialOptions2()&4) != 0 && solution) { |
---|
3618 |                         int numberColumns = coinModel->numberColumns(); |
---|
3619 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (linkSolver->objectiveVariable()Â ==Â numberColumns); |
---|
3620 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // add OA cut |
---|
3621 |                         double offset; |
---|
3622 |                         double * gradient = new double [numberColumns+1]; |
---|
3623 |                         memcpy(gradient, qp->objectiveAsObject()->gradient(qp, solution, offset, true, 2), |
---|
3624 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberColumns*sizeof(double)); |
---|
3625 |                         double rhs = 0.0; |
---|
3626 |                         int * column = new int[numberColumns+1]; |
---|
3627 |                         int n = 0; |
---|
3628 |                         for (int i = 0; i < numberColumns; i++) { |
---|
3629 |                           double value = gradient[i]; |
---|
3630 |                           if (fabs(value) > 1.0e-12) { |
---|
3631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gradient[n]Â =Â value; |
---|
3632 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rhs +=Â value *Â solution[i]; |
---|
3633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â column[n++]Â =Â i; |
---|
3634 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3635 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gradient[n]Â =Â -1.0; |
---|
3637 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â column[n++]Â =Â numberColumns; |
---|
3638 |                         storedAmpl.addCut(-COIN_DBL_MAX, offset + 1.0e-7, n, column, gradient); |
---|
3639 |                         delete [] gradient; |
---|
3640 |                         delete [] column; |
---|
3641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3642 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // could do three way branching round a) continuous b) best solution |
---|
3643 |                       printf("obj %g\n", bestObjectiveValue); |
---|
3644 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â linkSolver->initialSolve(); |
---|
3645 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3648 | #endif |
---|
3649 | #endif |
---|
3650 |                 if (logLevel <= 1) |
---|
3651 |                   si->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3652 | #ifndef CBC_OTHER_SOLVER |
---|
3653 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions(0x40000000); |
---|
3654 | #endif |
---|
3655 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3656 |               if (!miplib) { |
---|
3657 |                 if (!preSolve) { |
---|
3658 |                   model_.solver()->setHintParam(OsiDoPresolveInInitial, false, OsiHintTry); |
---|
3659 |                   model_.solver()->setHintParam(OsiDoPresolveInResolve, false, OsiHintTry); |
---|
3660 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3661 |                 double time1a = CoinCpuTime(); |
---|
3662 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3663 | #ifndef CBC_OTHER_SOLVER |
---|
3664 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3665 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3666 |                 if (si) |
---|
3667 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions(si->specialOptions()Â |Â 1024); |
---|
3668 | #endif |
---|
3669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.initialSolve(); |
---|
3670 | #ifndef CBC_OTHER_SOLVER |
---|
3671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â clpSolver =Â si->getModelPtr(); |
---|
3672 |                 int iStatus = clpSolver->status(); |
---|
3673 |                 int iStatus2 = clpSolver->secondaryStatus(); |
---|
3674 |                 if (iStatus == 0) { |
---|
3675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
3676 |                 } else if (iStatus == 1) { |
---|
3677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 1;Â // say infeasible |
---|
3679 |                 } else if (iStatus == 2) { |
---|
3680 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3681 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 7;Â // say unbounded |
---|
3682 |                 } else if (iStatus == 3) { |
---|
3683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 1; |
---|
3684 |                   if (iStatus2 == 9) |
---|
3685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 4; |
---|
3686 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3687 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 3;Â // Use nodes - as closer than solutions |
---|
3688 |                 } else if (iStatus == 4) { |
---|
3689 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 2;Â // difficulties |
---|
3690 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
3691 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3692 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(iStatus); |
---|
3693 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(iStatus2); |
---|
3694 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setWarmStart(NULL); |
---|
3695 |                 int returnCode = callBack(&model_, 1); |
---|
3696 |                 if (returnCode) { |
---|
3697 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3698 |                   delete babModel_; |
---|
3699 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3700 |                   return returnCode; |
---|
3701 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3702 |                 if (clpSolver->status() > 0) { |
---|
3703 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3704 |                   if (babModel_) { |
---|
3705 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(iStatus); |
---|
3706 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(iStatus2); |
---|
3707 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3708 |                   if (!noPrinting_) { |
---|
3709 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â clpSolver->status(); |
---|
3710 |                     const char * msg[] = {"infeasible", "unbounded", "stopped", |
---|
3711 |                                "difficulties", "other" |
---|
3712 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }; |
---|
3713 |                     sprintf(generalPrint, "Problem is %s - %.2f seconds", |
---|
3714 |                         msg[iStatus-1], CoinCpuTime() - time1a); |
---|
3715 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3716 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3717 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3718 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3719 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3720 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3721 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->setSpecialOptions(clpSolver->specialOptions()Â |Â IN_BRANCH_AND_BOUND);Â // say is Cbc (and in branch and bound) |
---|
3722 | #elif CBC_OTHER_SOLVER==1 |
---|
3723 | #endif |
---|
3724 |                 if (!noPrinting_) { |
---|
3725 |                   sprintf(generalPrint, "Continuous objective value is %g - %.2f seconds", |
---|
3726 |                       solver->getObjValue(), CoinCpuTime() - time1a); |
---|
3727 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3728 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3729 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3730 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3731 |                 if (model_.getMaximumNodes() == -987654321) { |
---|
3732 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if No objective! |
---|
3733 |                   int numberColumns = clpSolver->getNumCols(); |
---|
3734 |                   const double * obj = clpSolver->getObjCoefficients(); |
---|
3735 |                   const double * lower = clpSolver->getColLower(); |
---|
3736 |                   const double * upper = clpSolver->getColUpper(); |
---|
3737 |                   int nObj = 0; |
---|
3738 |                   for (int i = 0; i < numberColumns; i++) { |
---|
3739 |                     if (upper[i] > lower[i] && obj[i]) |
---|
3740 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nObj++; |
---|
3741 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3742 |                   if (!nObj) { |
---|
3743 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("************No objective!!\n"); |
---|
3744 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setMaximumSolutions(1); |
---|
3745 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Column copy |
---|
3746 |                     CoinPackedMatrix matrixByCol(*model_.solver()->getMatrixByCol()); |
---|
3747 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const double * element = matrixByCol.getElements(); |
---|
3748 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const int * row = matrixByCol.getIndices(); |
---|
3749 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const CoinBigIndex * columnStart = matrixByCol.getVectorStarts(); |
---|
3750 |                     const int * columnLength = matrixByCol.getVectorLengths(); |
---|
3751 |                     for (int i = 0; i < numberColumns; i++) { |
---|
3752 |                       double value = (CoinDrand48() + 0.5) * 10000; |
---|
3753 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value =Â 10; |
---|
3754 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value *=Â columnLength[i]; |
---|
3755 |                       int iValue = static_cast<int> (value) / 10; |
---|
3756 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //iValue=1; |
---|
3757 |                       clpSolver->setObjCoeff(i, iValue); |
---|
3758 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3759 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3760 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3761 | #ifndef CBC_OTHER_SOLVER |
---|
3762 |                 if (!complicatedInteger && preProcess == 0 && clpSolver->tightenPrimalBounds(0.0, 0, true) != 0) { |
---|
3763 |                  sprintf(generalPrint, "Problem is infeasible - tightenPrimalBounds!"); |
---|
3764 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3765 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3766 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3767 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say infeasible for solution |
---|
3768 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â 6; |
---|
3769 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3770 |                   if (babModel_) { |
---|
3771 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3772 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3773 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3774 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3775 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3776 |                 if (clpSolver->dualBound() == 1.0e10) { |
---|
3777 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex temp =Â *clpSolver; |
---|
3778 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â temp.setLogLevel(0); |
---|
3779 |                   temp.dual(0, 7); |
---|
3780 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // user did not set - so modify |
---|
3781 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get largest scaled away from bound |
---|
3782 |                   double largest = 1.0e-12; |
---|
3783 |                   double largestScaled = 1.0e-12; |
---|
3784 |                   int numberRows = temp.numberRows(); |
---|
3785 |                   const double * rowPrimal = temp.primalRowSolution(); |
---|
3786 |                   const double * rowLower = temp.rowLower(); |
---|
3787 |                   const double * rowUpper = temp.rowUpper(); |
---|
3788 |                   const double * rowScale = temp.rowScale(); |
---|
3789 |                   int iRow; |
---|
3790 |                   for (iRow = 0; iRow < numberRows; iRow++) { |
---|
3791 |                     double value = rowPrimal[iRow]; |
---|
3792 |                     double above = value - rowLower[iRow]; |
---|
3793 |                     double below = rowUpper[iRow] - value; |
---|
3794 |                     if (above < 1.0e12) { |
---|
3795 |                       largest = CoinMax(largest, above); |
---|
3796 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3797 |                     if (below < 1.0e12) { |
---|
3798 |                       largest = CoinMax(largest, below); |
---|
3799 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3800 |                     if (rowScale) { |
---|
3801 |                       double multiplier = rowScale[iRow]; |
---|
3802 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â above *=Â multiplier; |
---|
3803 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â below *=Â multiplier; |
---|
3804 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3805 |                     if (above < 1.0e12) { |
---|
3806 |                       largestScaled = CoinMax(largestScaled, above); |
---|
3807 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3808 |                     if (below < 1.0e12) { |
---|
3809 |                       largestScaled = CoinMax(largestScaled, below); |
---|
3810 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3811 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3812 | |
---|
3813 |                   int numberColumns = temp.numberColumns(); |
---|
3814 |                   const double * columnPrimal = temp.primalColumnSolution(); |
---|
3815 |                   const double * columnLower = temp.columnLower(); |
---|
3816 |                   const double * columnUpper = temp.columnUpper(); |
---|
3817 |                   const double * columnScale = temp.columnScale(); |
---|
3818 |                   int iColumn; |
---|
3819 |                   for (iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
3820 |                     double value = columnPrimal[iColumn]; |
---|
3821 |                     double above = value - columnLower[iColumn]; |
---|
3822 |                     double below = columnUpper[iColumn] - value; |
---|
3823 |                     if (above < 1.0e12) { |
---|
3824 |                       largest = CoinMax(largest, above); |
---|
3825 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3826 |                     if (below < 1.0e12) { |
---|
3827 |                       largest = CoinMax(largest, below); |
---|
3828 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3829 |                     if (columnScale) { |
---|
3830 |                       double multiplier = 1.0 / columnScale[iColumn]; |
---|
3831 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â above *=Â multiplier; |
---|
3832 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â below *=Â multiplier; |
---|
3833 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3834 |                     if (above < 1.0e12) { |
---|
3835 |                       largestScaled = CoinMax(largestScaled, above); |
---|
3836 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3837 |                     if (below < 1.0e12) { |
---|
3838 |                       largestScaled = CoinMax(largestScaled, below); |
---|
3839 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3840 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3841 | #ifdef COIN_DEVELOP |
---|
3842 |                   if (!noPrinting_) |
---|
3843 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Largest (scaled) away from bound "Â <<Â largestScaled |
---|
3844 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â " unscaled "Â <<Â largest <<Â std::endl; |
---|
3845 | #endif |
---|
3846 |                   clpSolver->setDualBound(CoinMax(1.0001e8, CoinMin(100.0*largest, 1.00001e10))); |
---|
3847 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3848 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->resolve();Â // clean up |
---|
3849 | #endif |
---|
3850 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3851 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If user made settings then use them |
---|
3852 |               if (!defaultSettings) { |
---|
3853 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3854 |                 if (!doScaling) |
---|
3855 |                   solver->setHintParam(OsiDoScale, false, OsiHintTry); |
---|
3856 | #ifndef CBC_OTHER_SOLVER |
---|
3857 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3858 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3860 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get clp itself |
---|
3861 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â modelC =Â si->getModelPtr(); |
---|
3862 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (modelC->tightenPrimalBounds()!=0) { |
---|
3863 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //std::cout<<"Problem is infeasible!"<<std::endl; |
---|
3864 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //break; |
---|
3865 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //} |
---|
3866 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // bounds based on continuous |
---|
3867 |                 if (tightenFactor && !complicatedInteger) { |
---|
3868 |                   if (modelC->tightenPrimalBounds(tightenFactor) != 0) { |
---|
3869 |                    sprintf(generalPrint, "Problem is infeasible!"); |
---|
3870 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
3871 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3872 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3873 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3874 |                     if (babModel_) { |
---|
3875 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3876 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3877 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3878 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3879 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3880 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3881 | #endif |
---|
3882 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3883 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if we want preprocessing |
---|
3884 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â saveSolver =Â NULL; |
---|
3885 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglPreProcess process; |
---|
3886 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Say integers in sync |
---|
3887 |               bool integersOK = true; |
---|
3888 |               delete babModel_; |
---|
3889 |               babModel_ = new CbcModel(model_); |
---|
3890 | #ifndef CBC_OTHER_SOLVER |
---|
3891 |               int numberChanged = 0; |
---|
3892 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver3 =Â clpSolver->clone(); |
---|
3893 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver3); |
---|
3894 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â clpSolver2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (babModel_->solver()); |
---|
3895 |               if (clpSolver2->messageHandler()->logLevel()) |
---|
3896 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver2->messageHandler()->setLogLevel(1); |
---|
3897 |               if (logLevel > -1) |
---|
3898 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver2->messageHandler()->setLogLevel(logLevel); |
---|
3899 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver2->getModelPtr(); |
---|
3900 |               if (lpSolver->factorizationFrequency() == 200 && !miplib) { |
---|
3901 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // User did not touch preset |
---|
3902 |                 int numberRows = lpSolver->numberRows(); |
---|
3903 |                 const int cutoff1 = 10000; |
---|
3904 |                 const int cutoff2 = 100000; |
---|
3905 |                 const int base = 75; |
---|
3906 |                 const int freq0 = 50; |
---|
3907 |                 const int freq1 = 200; |
---|
3908 |                 const int freq2 = 400; |
---|
3909 |                 const int maximum = 1000; |
---|
3910 |                 int frequency; |
---|
3911 |                 if (numberRows < cutoff1) |
---|
3912 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â numberRows /Â freq0; |
---|
3913 |                 else if (numberRows < cutoff2) |
---|
3914 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â cutoff1 /Â freq0 +Â (numberRows -Â cutoff1)Â /Â freq1; |
---|
3915 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3916 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â cutoff1 /Â freq0 +Â (cutoff2 -Â cutoff1)Â /Â freq1 +Â (numberRows -Â cutoff2)Â /Â freq2; |
---|
3917 |                 lpSolver->setFactorizationFrequency(CoinMin(maximum, frequency)); |
---|
3918 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3919 | #elif CBC_OTHER_SOLVER==1 |
---|
3920 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver3 =Â model_.solver()->clone(); |
---|
3921 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver3); |
---|
3922 | #endif |
---|
3923 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â time2 =Â CoinCpuTime(); |
---|
3924 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â totalTime +=Â time2 -Â time1; |
---|
3925 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //time1 = time2; |
---|
3926 |               double timeLeft = babModel_->getMaximumSeconds(); |
---|
3927 |               int numberOriginalColumns = babModel_->solver()->getNumCols(); |
---|
3928 |               if (preProcess == 7) { |
---|
3929 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // use strategy instead |
---|
3930 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3931 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â useStrategy =Â true; |
---|
3932 | #ifdef COIN_HAS_LINK |
---|
3933 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // empty out any cuts |
---|
3934 |                 if (storedAmpl.sizeRowCuts()) { |
---|
3935 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Emptying ampl stored cuts as internal preprocessing\n"); |
---|
3936 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglStored temp; |
---|
3937 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â storedAmpl =Â temp; |
---|
3938 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3939 | #endif |
---|
3940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3941 |               if (preProcess && type == CBC_PARAM_ACTION_BAB) { |
---|
3942 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // see whether to switch off preprocessing |
---|
3943 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // only allow SOS and integer |
---|
3944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â objects =Â babModel_->objects(); |
---|
3945 |                int numberObjects = babModel_->numberObjects(); |
---|
3946 |                for (int iObj = 0; iObj < numberObjects; iObj++) { |
---|
3947 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSOS *Â objSOS = |
---|
3948 |                  dynamic_cast <CbcSOS *>(objects[iObj]) ; |
---|
3949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleInteger *Â objSimpleInteger = |
---|
3950 |                  dynamic_cast <CbcSimpleInteger *>(objects[iObj]) ; |
---|
3951 |                 if (!objSimpleInteger&&!objSOS) { |
---|
3952 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // find all integers anyway |
---|
3953 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->findIntegers(true); |
---|
3954 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess=0; |
---|
3955 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3956 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3957 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3958 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3959 |               if (type == CBC_PARAM_ACTION_BAB) { |
---|
3960 |                 double limit; |
---|
3961 |                 clpSolver->getDblParam(OsiDualObjectiveLimit, limit); |
---|
3962 |                 if (clpSolver->getObjValue()*clpSolver->getObjSense() >= |
---|
3963 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â limit*clpSolver->getObjSense()) |
---|
3964 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3965 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3966 |               if (mipStartBefore.size()) |
---|
3967 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3968 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcModel tempModel=*babModel_; |
---|
3969 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (babModel_->getNumCols()==model_.getNumCols()); |
---|
3970 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::vector<Â std::string >Â colNames; |
---|
3971 |                 for ( int i=0 ; (i<model_.solver()->getNumCols()) ; ++i ) |
---|
3972 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â colNames.push_back(Â model_.solver()->getColName(i)Â ); |
---|
3973 |                 std::vector< double > x( model_.getNumCols(), 0.0 ); |
---|
3974 |                 double obj; |
---|
3975 |                 int status = computeCompleteSolution( &tempModel, colNames, mipStartBefore, &x[0], obj ); |
---|
3976 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // set cutoff |
---|
3977 |                 if (!status) { |
---|
3978 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setCutoff(CoinMin(babModel_->getCutoff(),obj+1.0e-4)); |
---|
3979 |                  babModel_->setBestSolution( &x[0], static_cast<int>(x.size()), obj, false ); |
---|
3980 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSolutionCount(1); |
---|
3981 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setCutoff(CoinMin(model_.getCutoff(),obj+1.0e-4)); |
---|
3982 |                  model_.setBestSolution( &x[0], static_cast<int>(x.size()), obj, false ); |
---|
3983 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSolutionCount(1); |
---|
3984 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3985 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3986 |               if (preProcess && type == CBC_PARAM_ACTION_BAB) { |
---|
3987 | #ifndef CBC_OTHER_SOLVER |
---|
3988 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if sos from mps file |
---|
3989 |                 if (numberSOS == 0 && clpSolver->numberSOS() && doSOS) { |
---|
3990 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
3991 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â clpSolver->numberSOS(); |
---|
3992 |                   const CoinSet * setInfo = clpSolver->setInfo(); |
---|
3993 |                   sosStart = new int [numberSOS+1]; |
---|
3994 |                   sosType = new char [numberSOS]; |
---|
3995 |                   int i; |
---|
3996 |                   int nTotal = 0; |
---|
3997 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart[0]Â =Â 0; |
---|
3998 |                   for ( i = 0; i < numberSOS; i++) { |
---|
3999 |                     int type = setInfo[i].setType(); |
---|
4000 |                     int n = setInfo[i].numberEntries(); |
---|
4001 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosType[i]Â =Â static_cast<char>(type); |
---|
4002 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nTotal +=Â n; |
---|
4003 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart[i+1]Â =Â nTotal; |
---|
4004 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4005 |                   sosIndices = new int[nTotal]; |
---|
4006 |                   sosReference = new double [nTotal]; |
---|
4007 |                   for (i = 0; i < numberSOS; i++) { |
---|
4008 |                     int n = setInfo[i].numberEntries(); |
---|
4009 |                     const int * which = setInfo[i].which(); |
---|
4010 |                     const double * weights = setInfo[i].weights(); |
---|
4011 |                     int base = sosStart[i]; |
---|
4012 |                     for (int j = 0; j < n; j++) { |
---|
4013 |                       int k = which[j]; |
---|
4014 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices[j+base]Â =Â k; |
---|
4015 |                       sosReference[j+base] = weights ? weights[j] : static_cast<double> (j); |
---|
4016 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4017 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4018 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4019 | #endif |
---|
4020 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveSolver =Â babModel_->solver()->clone(); |
---|
4021 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Do not try and produce equality cliques and |
---|
4022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â do up to 10 passes */ |
---|
4023 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2; |
---|
4024 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4025 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Tell solver we are in Branch and Cut |
---|
4026 |                   saveSolver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo) ; |
---|
4027 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Default set of cut generators |
---|
4028 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglProbing generator1; |
---|
4029 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setUsingObjective(1); |
---|
4030 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPass(1); |
---|
4031 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPassRoot(1); |
---|
4032 |                   generator1.setMaxProbeRoot(CoinMin(3000, saveSolver->getNumCols())); |
---|
4033 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElements(100); |
---|
4034 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElementsRoot(200); |
---|
4035 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxLookRoot(50); |
---|
4036 |                   if (saveSolver->getNumCols() > 3000) |
---|
4037 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxProbeRoot(123); |
---|
4038 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setRowCuts(3); |
---|
4039 |                   if ((tunePreProcess&1) != 0) { |
---|
4040 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // heavy probing |
---|
4041 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPassRoot(2); |
---|
4042 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElements(1000); |
---|
4043 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxProbeRoot(saveSolver->getNumCols()); |
---|
4044 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxLookRoot(saveSolver->getNumCols()); |
---|
4045 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4046 |                   if ((babModel_->specialOptions()&65536) != 0) |
---|
4047 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.setOptions(1); |
---|
4048 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Add in generators |
---|
4049 |                   if ((model_.moreSpecialOptions()&65536)==0) |
---|
4050 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.addCutGenerator(&generator1); |
---|
4051 |                   int translate[] = {9999, 0, 0, -3, 2, 3, -2, 9999, 4, 5}; |
---|
4052 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.passInMessageHandler(babModel_->messageHandler()); |
---|
4053 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //process.messageHandler()->setLogLevel(babModel_->logLevel()); |
---|
4054 | #ifdef COIN_HAS_ASL |
---|
4055 |                   if (info.numberSos && doSOS && statusUserFunction_[0]) { |
---|
4056 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
4057 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â info.numberSos; |
---|
4058 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart =Â info.sosStart; |
---|
4059 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices =Â info.sosIndices; |
---|
4060 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4061 | #endif |
---|
4062 |                   if (numberSOS && doSOS) { |
---|
4063 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
4064 |                     int numberColumns = saveSolver->getNumCols(); |
---|
4065 |                     char * prohibited = new char[numberColumns]; |
---|
4066 |                     memset(prohibited, 0, numberColumns); |
---|
4067 |                     int n = sosStart[numberSOS]; |
---|
4068 |                     for (int i = 0; i < n; i++) { |
---|
4069 |                       int iColumn = sosIndices[i]; |
---|
4070 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
4071 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4072 |                     process.passInProhibited(prohibited, numberColumns); |
---|
4073 |                     delete [] prohibited; |
---|
4074 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4075 |                   if (0) { |
---|
4076 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
4077 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Special integers |
---|
4078 |                    int numberColumns = saveSolver->getNumCols(); |
---|
4079 |                    char * prohibited = new char[numberColumns]; |
---|
4080 |                    memset(prohibited, 0, numberColumns); |
---|
4081 |                    const CoinPackedMatrix * matrix = saveSolver->getMatrixByCol(); |
---|
4082 |                    const int * columnLength = matrix->getVectorLengths(); |
---|
4083 |                    int numberProhibited=0; |
---|
4084 |                    for (int iColumn = numberColumns-1; iColumn >=0; iColumn--) { |
---|
4085 |                     if (!saveSolver->isInteger(iColumn)|| |
---|
4086 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â columnLength[iColumn]>1) |
---|
4087 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4088 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberProhibited++; |
---|
4089 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
4090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4091 |                    if (numberProhibited) { |
---|
4092 |                     process.passInProhibited(prohibited, numberColumns); |
---|
4093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("**** Treating last %d integers as special - give high priority?\n",numberProhibited); |
---|
4094 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4095 |                    delete [] prohibited; |
---|
4096 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4097 |                   if (!model_.numberObjects() && true) { |
---|
4098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* model may not have created objects |
---|
4099 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If none then create |
---|
4100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
4101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.findIntegers(true); |
---|
4102 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4103 |                   if (model_.numberObjects()) { |
---|
4104 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â oldObjects =Â babModel_->objects(); |
---|
4105 |                     int numberOldObjects = babModel_->numberObjects(); |
---|
4106 |                     if (!numberOldObjects) { |
---|
4107 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldObjects =Â model_.objects(); |
---|
4108 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberOldObjects =Â model_.numberObjects(); |
---|
4109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
4111 |                     int numberColumns = saveSolver->getNumCols(); |
---|
4112 |                     char * prohibited = new char[numberColumns]; |
---|
4113 |                     memset(prohibited, 0, numberColumns); |
---|
4114 |                     int numberProhibited = 0; |
---|
4115 |                     for (int iObj = 0; iObj < numberOldObjects; iObj++) { |
---|
4116 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSOS *Â obj = |
---|
4117 |                         dynamic_cast <CbcSOS *>(oldObjects[iObj]) ; |
---|
4118 |                       if (obj) { |
---|
4119 |                         int n = obj->numberMembers(); |
---|
4120 |                         const int * which = obj->members(); |
---|
4121 |                         for (int i = 0; i < n; i++) { |
---|
4122 |                           int iColumn = which[i]; |
---|
4123 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
4124 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberProhibited++; |
---|
4125 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4126 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4127 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcLotsize *Â obj2 = |
---|
4128 |                         dynamic_cast <CbcLotsize *>(oldObjects[iObj]) ; |
---|
4129 |                       if (obj2) { |
---|
4130 |                         int iColumn = obj2->columnNumber(); |
---|
4131 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
4132 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberProhibited++; |
---|
4133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4134 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4135 |                     if (numberProhibited) |
---|
4136 |                       process.passInProhibited(prohibited, numberColumns); |
---|
4137 |                     delete [] prohibited; |
---|
4138 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4139 |                   int numberPasses = 10; |
---|
4140 | #ifndef CBC_OTHER_SOLVER |
---|
4141 |                   if (doSprint > 0) { |
---|
4142 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Sprint for primal solves |
---|
4143 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::SolveType method =Â ClpSolve::usePrimalorSprint; |
---|
4144 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::PresolveType presolveType =Â ClpSolve::presolveOff; |
---|
4145 |                     int numberPasses = 5; |
---|
4146 |                     int options[] = {0, 3, 0, 0, 0, 0}; |
---|
4147 |                     int extraInfo[] = { -1, 20, -1, -1, -1, -1}; |
---|
4148 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extraInfo[1]Â =Â doSprint; |
---|
4149 |                     int independentOptions[] = {0, 0, 3}; |
---|
4150 |                     ClpSolve clpSolve(method, presolveType, numberPasses, |
---|
4151 |                              options, extraInfo, independentOptions); |
---|
4152 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say use in OsiClp |
---|
4153 |                     clpSolve.setSpecialOption(6, 1); |
---|
4154 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
4155 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSolveOptions(clpSolve); |
---|
4156 |                     osiclp->setHintParam(OsiDoDualInResolve, false); |
---|
4157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // switch off row copy |
---|
4158 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setSpecialOptions(osiclp->getModelPtr()->specialOptions()Â |Â 256); |
---|
4159 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setInfeasibilityCost(1.0e11); |
---|
4160 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4161 | #endif |
---|
4162 | #ifndef CBC_OTHER_SOLVER |
---|
4163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4164 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
4165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSpecialOptions(osiclp->specialOptions()Â |Â 1024); |
---|
4166 |                     int savePerturbation = osiclp->getModelPtr()->perturbation(); |
---|
4167 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //#define CBC_TEMP1 |
---|
4168 | #ifdef CBC_TEMP1 |
---|
4169 |                     if (savePerturbation == 50) |
---|
4170 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setPerturbation(52);Â // try less |
---|
4171 | #endif |
---|
4172 |                     if ((model_.moreSpecialOptions()&65536)!=0) |
---|
4173 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.setOptions(2+4+8);Â // no cuts |
---|
4174 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcPreProcessPointer =Â &Â process; |
---|
4175 |                     int saveOptions = osiclp->getModelPtr()->moreSpecialOptions(); |
---|
4176 |                     if ((model_.specialOptions()&16777216)!=0&& |
---|
4177 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.getCutoff()>1.0e30)Â { |
---|
4178 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setMoreSpecialOptions(saveOptions|262144); |
---|
4179 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4180 |                     solver2 = process.preProcessNonDefault(*saveSolver, translate[preProcess], numberPasses, |
---|
4181 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess); |
---|
4182 |                     if (solver2) { |
---|
4183 |                      model_.setOriginalColumns( process.originalColumns(), solver2->getNumCols() ); |
---|
4184 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setPerturbation(savePerturbation); |
---|
4185 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setMoreSpecialOptions(saveOptions); |
---|
4186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4187 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4188 | #elif CBC_OTHER_SOLVER==1 |
---|
4189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcPreProcessPointer =Â &Â process; |
---|
4190 |                   solver2 = process.preProcessNonDefault(*saveSolver, translate[preProcess], numberPasses, |
---|
4191 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess); |
---|
4192 | #endif |
---|
4193 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integersOK =Â false;Â // We need to redo if CbcObjects exist |
---|
4194 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Tell solver we are not in Branch and Cut |
---|
4195 |                   saveSolver->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; |
---|
4196 |                   if (solver2) |
---|
4197 |                     solver2->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; |
---|
4198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4199 | #ifdef COIN_HAS_ASL |
---|
4200 |                 if (!solver2 && statusUserFunction_[0]) { |
---|
4201 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // infeasible |
---|
4202 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â 1; |
---|
4203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â 1.0e100; |
---|
4204 |                   sprintf(info.buffer, "infeasible/unbounded by pre-processing"); |
---|
4205 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.primalSolution =Â NULL; |
---|
4206 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.dualSolution =Â NULL; |
---|
4207 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4208 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4209 | #endif |
---|
4210 |                 if (!noPrinting_) { |
---|
4211 |                   if (!solver2) { |
---|
4212 |                     sprintf(generalPrint, "Pre-processing says infeasible or unbounded"); |
---|
4213 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4214 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4215 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4216 |                   } else { |
---|
4217 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //printf("processed model has %d rows, %d columns and %d elements\n", |
---|
4218 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â solver2->getNumRows(),solver2->getNumCols(),solver2->getNumElements()); |
---|
4219 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4220 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4221 |                 if (!solver2) { |
---|
4222 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say infeasible for solution |
---|
4223 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â 6; |
---|
4224 |                   delete saveSolver; |
---|
4225 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveSolver=NULL; |
---|
4226 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
4227 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
4228 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
4229 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
4230 |                 } else { |
---|
4231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedrows =Â solver2->getNumRows(); |
---|
4232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedcols =Â solver2->getNumCols(); |
---|
4233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(-1); |
---|
4234 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(-1); |
---|
4235 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4236 |                 int returnCode = callBack(babModel_, 2); |
---|
4237 |                 if (returnCode) { |
---|
4238 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
4239 |                   delete babModel_; |
---|
4240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
4241 |                   return returnCode; |
---|
4242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4243 |                 if (!solver2) |
---|
4244 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4245 |                 if (model_.bestSolution()) { |
---|
4246 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // need to redo - in case no better found in BAB |
---|
4247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // just get integer part right |
---|
4248 |                   const int * originalColumns = process.originalColumns(); |
---|
4249 |                   int numberColumns = solver2->getNumCols(); |
---|
4250 |                   double * bestSolution = babModel_->bestSolution(); |
---|
4251 |                   const double * oldBestSolution = model_.bestSolution(); |
---|
4252 |                   for (int i = 0; i < numberColumns; i++) { |
---|
4253 |                     int jColumn = originalColumns[i]; |
---|
4254 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bestSolution[i]Â =Â oldBestSolution[jColumn]; |
---|
4255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4257 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //solver2->resolve(); |
---|
4258 |                 if (preProcess == 2) { |
---|
4259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â clpSolver2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver2); |
---|
4260 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lpSolver =Â clpSolver2->getModelPtr(); |
---|
4261 |                   lpSolver->writeMps("presolved.mps", 2, 1, lpSolver->optimizationDirection()); |
---|
4262 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Preprocessed model (minimization) on presolved.mps\n"); |
---|
4263 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4264 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4265 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // look at new integers |
---|
4266 |                   int numberOriginalColumns = |
---|
4267 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.originalModel()->getNumCols(); |
---|
4268 |                   const int * originalColumns = process.originalColumns(); |
---|
4269 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver2); |
---|
4270 |                   int numberColumns = osiclp2->getNumCols(); |
---|
4271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
4272 |                   for (int i = 0; i < numberColumns; i++) { |
---|
4273 |                     int iColumn = originalColumns[i]; |
---|
4274 |                     if (iColumn < numberOriginalColumns) { |
---|
4275 |                       if (osiclp2->isInteger(i) && !osiclp->isInteger(iColumn)) |
---|
4276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp2->setOptionalInteger(i);Â // say optional |
---|
4277 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4278 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4279 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4280 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // we have to keep solver2 so pass clone |
---|
4281 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2 =Â solver2->clone(); |
---|
4282 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // see if extra variables wanted |
---|
4283 |                 int threshold = |
---|
4284 |                  parameters_[whichParam(CBC_PARAM_INT_EXTRA_VARIABLES, numberParameters_, parameters_)].intValue(); |
---|
4285 |                 int more2 = parameters_[whichParam(CBC_PARAM_INT_MOREMOREMIPOPTIONS, numberParameters_, parameters_)].intValue(); |
---|
4286 |                 if (threshold || (more2&(512|1024)) != 0) { |
---|
4287 |                  int numberColumns = solver2->getNumCols(); |
---|
4288 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â truncateRows =Â solver2->getNumRows(); |
---|
4289 |                  bool modifiedModel=false; |
---|
4290 |                  int highPriority=0; |
---|
4291 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* |
---|
4292 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â normal - no priorities |
---|
4293 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â >10000 equal high priority |
---|
4294 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â >20000 higher priority for higher cost |
---|
4295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
4296 |                  if (threshold>10000) { |
---|
4297 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â highPriority=threshold/10000; |
---|
4298 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â threshold -=Â 10000*highPriority; |
---|
4299 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4300 |                  const double * columnLower = solver2->getColLower(); |
---|
4301 |                  const double * columnUpper = solver2->getColUpper(); |
---|
4302 |                  const double * objective = solver2->getObjCoefficients(); |
---|
4303 |                  int numberIntegers = 0; |
---|
4304 |                  int numberBinary = 0; |
---|
4305 |                  int numberTotalIntegers=0; |
---|
4306 |                  double * obj = new double [numberColumns]; |
---|
4307 |                  int * which = new int [numberColumns]; |
---|
4308 |                  for (int iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
4309 |                   if (solver2->isInteger(iColumn)) { |
---|
4310 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberTotalIntegers++; |
---|
4311 |                    if (columnUpper[iColumn] > columnLower[iColumn]) { |
---|
4312 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberIntegers++; |
---|
4313 |                     if (columnLower[iColumn] == 0.0 && columnUpper[iColumn] == 1) |
---|
4314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberBinary++; |
---|
4315 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4316 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4317 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4318 |                  int numberSort=0; |
---|
4319 |                  int numberZero=0; |
---|
4320 |                  int numberZeroContinuous=0; |
---|
4321 |                  int numberDifferentObj=0; |
---|
4322 |                  int numberContinuous=0; |
---|
4323 |                  for (int iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
4324 |                   if (columnUpper[iColumn] > columnLower[iColumn]) { |
---|
4325 |                    if (solver2->isInteger(iColumn)) { |
---|
4326 |                     if (!objective[iColumn]) { |
---|
4327 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberZero++; |
---|
4328 |                     } else { |
---|
4329 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj[numberSort]=Â fabs(objective[iColumn]); |
---|
4330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â which[numberSort++]=iColumn; |
---|
4331 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4332 |                    } else if (objective[iColumn]) { |
---|
4333 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberContinuous++; |
---|
4334 |                    } else { |
---|
4335 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberZeroContinuous++; |
---|
4336 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4338 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4339 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinSort_2(obj,obj+numberSort,which); |
---|
4340 |                  double last=obj[0]; |
---|
4341 |                  for (int jColumn = 1; jColumn < numberSort; jColumn++) { |
---|
4342 |                   if (fabs(obj[jColumn]-last)>1.0e-12) { |
---|
4343 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberDifferentObj++; |
---|
4344 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last=obj[jColumn]; |
---|
4345 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4346 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberDifferentObj++; |
---|
4348 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"Problem has %d integers (%d of which binary) and %d continuous", |
---|
4349 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberIntegers,numberBinary,numberColumns-numberIntegers); |
---|
4350 |                  generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4351 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4353 |                  if (numberColumns>numberIntegers) { |
---|
4354 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"%d continuous have nonzero objective, %d have zero objective", |
---|
4355 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberContinuous,numberZeroContinuous); |
---|
4356 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4357 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4358 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4359 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4360 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"%d integer have nonzero objective, %d have zero objective, %d different nonzero (taking abs)", |
---|
4361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSort,numberZero,numberDifferentObj); |
---|
4362 |                  generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4363 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4364 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4365 |                  if (numberDifferentObj<=threshold + (numberZero) ? 1 : 0 && numberDifferentObj) { |
---|
4366 |                   int * backward=NULL; |
---|
4367 |                   if (highPriority) { |
---|
4368 |                    newPriorities = new int [numberTotalIntegers+numberDifferentObj+numberColumns]; |
---|
4369 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â backward=newPriorities+numberTotalIntegers+numberDifferentObj; |
---|
4370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberTotalIntegers=0; |
---|
4371 |                    for (int iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
4372 |                     if (solver2->isInteger(iColumn)) { |
---|
4373 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â backward[iColumn]=numberTotalIntegers; |
---|
4374 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newPriorities[numberTotalIntegers++]=10000; |
---|
4375 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4376 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4377 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4378 |                   int iLast=0; |
---|
4379 |                   double last=obj[0]; |
---|
4380 |                   for (int jColumn = 1; jColumn < numberSort; jColumn++) { |
---|
4381 |                    if (fabs(obj[jColumn]-last)>1.0e-12) { |
---|
4382 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"%d variables have objective of %g", |
---|
4383 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â jColumn-iLast,last); |
---|
4384 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4385 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4386 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4387 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLast=jColumn; |
---|
4388 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last=obj[jColumn]; |
---|
4389 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4390 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4391 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"%d variables have objective of %g", |
---|
4392 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSort-iLast,last); |
---|
4393 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4394 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4395 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4396 |                   int spaceNeeded=numberSort+numberDifferentObj; |
---|
4397 |                   int * columnAdd = new int[spaceNeeded+numberDifferentObj+1]; |
---|
4398 |                   double * elementAdd = new double[spaceNeeded]; |
---|
4399 |                   int * rowAdd = new int[numberDifferentObj+1]; |
---|
4400 |                   double * objectiveNew = new double[3*numberDifferentObj]; |
---|
4401 |                   double * lowerNew = objectiveNew+numberDifferentObj; |
---|
4402 |                   double * upperNew = lowerNew+numberDifferentObj; |
---|
4403 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â memset(columnAdd+spaceNeeded,0, |
---|
4404 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (numberDifferentObj+1)*sizeof(int)); |
---|
4405 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLast=0; |
---|
4406 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last=obj[0]; |
---|
4407 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberDifferentObj=0; |
---|
4408 |                   int priorityLevel=9999; |
---|
4409 |                   int numberElements=0; |
---|
4410 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rowAdd[0]=0; |
---|
4411 |                   for (int jColumn = 1; jColumn < numberSort+1; jColumn++) { |
---|
4412 |                    if (jColumn==numberSort||fabs(obj[jColumn]-last)>1.0e-12) { |
---|
4413 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // not if just one |
---|
4414 |                     if (jColumn-iLast>1) { |
---|
4415 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // do priority |
---|
4416 |                      if (highPriority==1) { |
---|
4417 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newPriorities[numberTotalIntegers+numberDifferentObj] |
---|
4418 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â =Â 500; |
---|
4419 |                      } else if (highPriority==2) { |
---|
4420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newPriorities[numberTotalIntegers+numberDifferentObj] |
---|
4421 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â =Â priorityLevel; |
---|
4422 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â priorityLevel--; |
---|
4423 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4424 |                      int iColumn=which[iLast]; |
---|
4425 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objectiveNew[numberDifferentObj]=objective[iColumn]; |
---|
4426 |                      double lower=0.0; |
---|
4427 |                      double upper=0.0; |
---|
4428 |                      for (int kColumn=iLast;kColumn<jColumn;kColumn++) { |
---|
4429 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iColumn=which[kColumn]; |
---|
4430 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setObjCoeff(iColumn,0.0); |
---|
4431 |                       double lowerValue=columnLower[iColumn]; |
---|
4432 |                       double upperValue=columnUpper[iColumn]; |
---|
4433 |                       double elementValue=-1.0; |
---|
4434 |                       if (objectiveNew[numberDifferentObj]*objective[iColumn]<0.0) { |
---|
4435 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lowerValue=-columnUpper[iColumn]; |
---|
4436 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upperValue=-columnLower[iColumn]; |
---|
4437 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â elementValue=1.0; |
---|
4438 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4439 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â columnAdd[numberElements]=iColumn; |
---|
4440 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â elementAdd[numberElements++]=elementValue; |
---|
4441 |                       if (lower!=-COIN_DBL_MAX) { |
---|
4442 |                        if (lowerValue!=-COIN_DBL_MAX) |
---|
4443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lower +=Â lowerValue; |
---|
4444 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4445 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lower=-COIN_DBL_MAX; |
---|
4446 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4447 |                       if (upper!=COIN_DBL_MAX) { |
---|
4448 |                        if (upperValue!=COIN_DBL_MAX) |
---|
4449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upper +=Â upperValue; |
---|
4450 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4451 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upper=COIN_DBL_MAX; |
---|
4452 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4453 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4454 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â columnAdd[numberElements]=numberColumns+numberDifferentObj; |
---|
4455 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â elementAdd[numberElements++]=1.0; |
---|
4456 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lowerNew[numberDifferentObj]=lower; |
---|
4457 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upperNew[numberDifferentObj]=upper; |
---|
4458 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberDifferentObj++; |
---|
4459 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rowAdd[numberDifferentObj]=numberElements; |
---|
4460 |                     } else if (highPriority) { |
---|
4461 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // just one |
---|
4462 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // do priority |
---|
4463 |                      int iColumn=which[iLast]; |
---|
4464 |                      int iInt=backward[iColumn]; |
---|
4465 |                      if (highPriority==1) { |
---|
4466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newPriorities[iInt]Â =Â 500; |
---|
4467 |                      } else { |
---|
4468 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newPriorities[iInt]Â =Â priorityLevel; |
---|
4469 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â priorityLevel--; |
---|
4470 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4472 |                     if (jColumn<numberSort) { |
---|
4473 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLast=jColumn; |
---|
4474 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last=obj[jColumn]; |
---|
4475 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4476 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4477 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4478 |                   if (numberDifferentObj) { |
---|
4479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // add columns |
---|
4480 |                    solver2->addCols(numberDifferentObj, |
---|
4481 |                             columnAdd+spaceNeeded, NULL, NULL, |
---|
4482 |                             lowerNew, upperNew,objectiveNew); |
---|
4483 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // add constraints and make integer if all integer in group |
---|
4484 |                    for (int iObj=0; iObj < numberDifferentObj; iObj++) { |
---|
4485 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lowerNew[iObj]=0.0; |
---|
4486 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upperNew[iObj]=0.0; |
---|
4487 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setInteger(numberColumns+iObj); |
---|
4488 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4489 |                    solver2->addRows(numberDifferentObj, |
---|
4490 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rowAdd,columnAdd,elementAdd, |
---|
4491 |                             lowerNew, upperNew); |
---|
4492 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"Replacing model - %d new variables",numberDifferentObj); |
---|
4493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â modifiedModel=true; |
---|
4494 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4495 |                   delete [] columnAdd; |
---|
4496 |                   delete [] elementAdd; |
---|
4497 |                   delete [] rowAdd; |
---|
4498 |                   delete [] objectiveNew; |
---|
4499 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4500 |                  delete [] which; |
---|
4501 |                  delete [] obj; |
---|
4502 |                  if ((more2&(512|1024)) != 0) { |
---|
4503 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try for row slacks etc |
---|
4504 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // later do row branching |
---|
4505 |                   int iRow, iColumn; |
---|
4506 |                   int numberColumns = solver2->getNumCols(); |
---|
4507 |                   int numberRows = solver2->getNumRows(); |
---|
4508 |                   int fudgeObjective = more2&512; |
---|
4509 |                   int addSlacks = more2&1024; |
---|
4510 |                   if (fudgeObjective) { |
---|
4511 |                    bool moveObj = false; |
---|
4512 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fudgeObjective =Â 0; |
---|
4513 |                    const double * objective = solver2->getObjCoefficients(); |
---|
4514 |                    const double * columnLower = solver2->getColLower(); |
---|
4515 |                    const double * columnUpper = solver2->getColUpper(); |
---|
4516 |                    double * newValues = new double [numberColumns+1]; |
---|
4517 |                    int * newColumn = new int [numberColumns+1]; |
---|
4518 |                    bool allInteger=true; |
---|
4519 |                    int n=0; |
---|
4520 |                    double newLower = 0.0; |
---|
4521 |                    double newUpper = 0.0; |
---|
4522 |                    for (iColumn=0;iColumn<numberColumns;iColumn++) { |
---|
4523 |                     if (objective[iColumn]) { |
---|
4524 |                      if (!solver2->isInteger(iColumn)) { |
---|
4525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â allInteger=false; |
---|
4526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4527 |                      } else { |
---|
4528 |                       double value = objective[iColumn]; |
---|
4529 |                       double nearest = floor(value+0.5); |
---|
4530 |                       if (fabs(value-nearest)>1.0e-8) { |
---|
4531 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â allInteger=false; |
---|
4532 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4533 |                       } else { |
---|
4534 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newValues[n]=nearest; |
---|
4535 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumn[n++]=iColumn; |
---|
4536 |                        if (nearest>0.0) { |
---|
4537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newLower +=Â CoinMax(columnLower[iColumn],-1.0e20)*nearest; |
---|
4538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newUpper +=Â CoinMin(columnUpper[iColumn],1.0e20)*nearest; |
---|
4539 |                        } else { |
---|
4540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newUpper +=Â CoinMax(columnLower[iColumn],-1.0e20)*nearest; |
---|
4541 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newLower +=Â CoinMin(columnUpper[iColumn],1.0e20)*nearest; |
---|
4542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4543 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4544 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4545 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4546 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4547 |                    if (allInteger && n) { |
---|
4548 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fudgeObjective =Â n; |
---|
4549 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->addCol(0,NULL,NULL,newLower,newUpper,0.0,"obj_col"); |
---|
4550 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setInteger(numberColumns); |
---|
4551 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newValues[n]=-1.0; |
---|
4552 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumn[n++]=numberColumns; |
---|
4553 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->addRow(n,newColumn,newValues,0.0,0.0); |
---|
4554 |                     if (moveObj) { |
---|
4555 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â memset(newValues,0,numberColumns*sizeof(double)); |
---|
4556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newValues[numberColumns]=1.0; |
---|
4557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setObjective(newValues); |
---|
4558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4559 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberRows++; |
---|
4560 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberColumns++; |
---|
4561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4562 |                    delete [] newValues; |
---|
4563 |                    delete [] newColumn; |
---|
4564 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4565 |                   if (addSlacks) { |
---|
4566 |                    bool moveObj = false; |
---|
4567 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â addSlacks=0; |
---|
4568 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get row copy |
---|
4569 |                    const CoinPackedMatrix * matrix = solver2->getMatrixByRow(); |
---|
4570 |                    const double * element = matrix->getElements(); |
---|
4571 |                    const int * column = matrix->getIndices(); |
---|
4572 |                    const CoinBigIndex * rowStart = matrix->getVectorStarts(); |
---|
4573 |                    const int * rowLength = matrix->getVectorLengths(); |
---|
4574 |                    const double * rowLower = solver2->getRowLower(); |
---|
4575 |                    const double * rowUpper = solver2->getRowUpper(); |
---|
4576 |                    const double * columnLower = solver2->getColLower(); |
---|
4577 |                    const double * columnUpper = solver2->getColUpper(); |
---|
4578 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
4579 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // maximum space for additional columns |
---|
4580 |                    CoinBigIndex * newColumnStart = new CoinBigIndex[numberRows+1]; |
---|
4581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumnStart[0]=0; |
---|
4582 |                    int * newRow = new int [numberRows]; |
---|
4583 |                    double * newElement = new double [numberRows]; |
---|
4584 |                    double * newObjective = new double [numberRows]; |
---|
4585 |                    double * newColumnLower = new double [numberRows]; |
---|
4586 |                    double * newColumnUpper = new double [numberRows]; |
---|
4587 |                    double * oldObjective = CoinCopyOfArray(solver2->getObjCoefficients(), |
---|
4588 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberColumns); |
---|
4589 |                    for (iRow=0;iRow<numberRows;iRow++) { |
---|
4590 |                     if (rowLower[iRow]!=rowUpper[iRow]) { |
---|
4591 |                      bool allInteger=true; |
---|
4592 |                      double newLower = 0.0; |
---|
4593 |                      double newUpper = 0.0; |
---|
4594 |                      double constantObjective=0.0; |
---|
4595 |                      for (int j=rowStart[iRow];j<rowStart[iRow]+rowLength[iRow];j++) { |
---|
4596 |                       int iColumn = column[j]; |
---|
4597 |                       if (!solver2->isInteger(iColumn)) { |
---|
4598 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â allInteger=false; |
---|
4599 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4600 |                       } else { |
---|
4601 |                        double value = element[j]; |
---|
4602 |                        double nearest = floor(value+0.5); |
---|
4603 |                        if (fabs(value-nearest)>1.0e-8) { |
---|
4604 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â allInteger=false; |
---|
4605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4606 |                        } else { |
---|
4607 |                         if (!oldObjective[iColumn]) |
---|
4608 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=COIN_DBL_MAX; |
---|
4609 |                         if (!constantObjective) { |
---|
4610 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=oldObjective[iColumn]/nearest; |
---|
4611 |                         } else if (constantObjective!=COIN_DBL_MAX) { |
---|
4612 |                          double newConstant=oldObjective[iColumn]/nearest; |
---|
4613 |                          if (constantObjective>0.0) { |
---|
4614 |                           if (newConstant<=0.0) |
---|
4615 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=COIN_DBL_MAX; |
---|
4616 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4617 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=CoinMin(constantObjective,newConstant); |
---|
4618 |                          } else { |
---|
4619 |                           if (newConstant>=0.0) |
---|
4620 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=COIN_DBL_MAX; |
---|
4621 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4622 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â constantObjective=CoinMax(constantObjective,newConstant); |
---|
4623 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4624 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4625 |                         if (nearest>0.0) { |
---|
4626 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newLower +=Â CoinMax(columnLower[iColumn],-1.0e20)*nearest; |
---|
4627 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newUpper +=Â CoinMin(columnUpper[iColumn],1.0e20)*nearest; |
---|
4628 |                         } else { |
---|
4629 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newUpper +=Â CoinMax(columnLower[iColumn],-1.0e20)*nearest; |
---|
4630 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newLower +=Â CoinMin(columnUpper[iColumn],1.0e20)*nearest; |
---|
4631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4632 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4634 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4635 |                      if (allInteger) { |
---|
4636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumnStart[addSlacks+1]=addSlacks+1; |
---|
4637 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newRow[addSlacks]=iRow; |
---|
4638 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newElement[addSlacks]=-1.0; |
---|
4639 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newObjective[addSlacks]Â =Â 0.0; |
---|
4640 |                       if (moveObj && constantObjective != COIN_DBL_MAX) { |
---|
4641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // move some of objective here if looks constant |
---|
4642 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newObjective[addSlacks]=constantObjective; |
---|
4643 |                        for (int j=rowStart[iRow];j<rowStart[iRow]+rowLength[iRow];j++) { |
---|
4644 |                         int iColumn = column[j]; |
---|
4645 |                         double value = element[j]; |
---|
4646 |                         double nearest = floor(value+0.5); |
---|
4647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldObjective[iColumn]Â -=Â nearest*constantObjective; |
---|
4648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4649 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4650 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumnLower[addSlacks]Â =Â CoinMax(newLower,ceil(rowLower[iRow]));; |
---|
4651 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumnUpper[addSlacks]Â =Â CoinMin(newUpper,floor(rowUpper[iRow])); |
---|
4652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â addSlacks++; |
---|
4653 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4654 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4655 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4656 |                    if (addSlacks) { |
---|
4657 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setObjective(oldObjective); |
---|
4658 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->addCols(addSlacks,newColumnStart,newRow,newElement, |
---|
4659 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumnLower,newColumnUpper,newObjective); |
---|
4660 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â truncatedRhsLower =Â CoinCopyOfArray(solver2->getRowLower(),numberRows); |
---|
4661 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â truncatedRhsUpper =Â CoinCopyOfArray(solver2->getRowUpper(),numberRows); |
---|
4662 |                     for (int j=0;j<addSlacks;j++) { |
---|
4663 |                      int iRow = newRow[j]; |
---|
4664 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setRowLower(iRow,0.0); |
---|
4665 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setRowUpper(iRow,0.0); |
---|
4666 |                      int iColumn = j+numberColumns; |
---|
4667 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setInteger(iColumn); |
---|
4668 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::string name =Â solver2->getRowName(iRow); |
---|
4669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â name +=Â "_int"; |
---|
4670 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2->setColName(iColumn,name); |
---|
4671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4672 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4673 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4674 |                   if (fudgeObjective||addSlacks) { |
---|
4675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â modifiedModel=true; |
---|
4676 |                    if (fudgeObjective && addSlacks) { |
---|
4677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"Objective integer added with %d elements and %d Integer slacks added", |
---|
4678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fudgeObjective,addSlacks); |
---|
4679 |                    } else if (fudgeObjective) { |
---|
4680 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // just objective |
---|
4681 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"Objective integer added with %d elements", |
---|
4682 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fudgeObjective); |
---|
4683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â more2 &=Â ~1024; |
---|
4684 |                    } else { |
---|
4685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // just slacks |
---|
4686 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint,"%d Integer slacks added",addSlacks); |
---|
4687 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â more2 &=Â ~512; |
---|
4688 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4689 |                   } else { |
---|
4690 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â more2 &=Â ~(512|1024); |
---|
4691 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4692 |                   parameters_[whichParam(CBC_PARAM_INT_MOREMOREMIPOPTIONS, numberParameters_, parameters_)].setIntValue(more2); |
---|
4693 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4694 |                  if (modifiedModel) { |
---|
4695 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4696 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4697 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4698 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â truncateColumns=numberColumns; |
---|
4699 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4700 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4701 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver2); |
---|
4702 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setOriginalColumns(process.originalColumns(), |
---|
4703 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â truncateColumns); |
---|
4704 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->initialSolve(); |
---|
4705 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumSeconds(timeLeft -Â (CoinCpuTime()Â -Â time2)); |
---|
4706 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4707 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // now tighten bounds |
---|
4708 |               if (!miplib) { |
---|
4709 | #ifndef CBC_OTHER_SOLVER |
---|
4710 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
4711 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(babModel_->solver())Â ; |
---|
4712 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
4713 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get clp itself |
---|
4714 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â modelC =Â si->getModelPtr(); |
---|
4715 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (noPrinting_) |
---|
4716 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //modelC->setLogLevel(0); |
---|
4717 |                 if (!complicatedInteger && modelC->tightenPrimalBounds() != 0) { |
---|
4718 |                  sprintf(generalPrint, "Problem is infeasible!"); |
---|
4719 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printGeneralMessage(model_,generalPrint); |
---|
4720 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
4721 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
4722 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say infeasible for solution |
---|
4723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â 6; |
---|
4724 |                   delete saveSolver; |
---|
4725 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveSolver=NULL; |
---|
4726 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel_ if exists |
---|
4727 |                   if (babModel_) { |
---|
4728 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
4729 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
4730 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4731 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
4732 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4733 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->resolve(); |
---|
4734 | #elif CBC_OTHER_SOLVER==1 |
---|
4735 | #endif |
---|
4736 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4737 |               if (debugValues) { |
---|
4738 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // for debug |
---|
4739 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::string problemName ; |
---|
4740 |                 babModel_->solver()->getStrParam(OsiProbName, problemName) ; |
---|
4741 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->activateRowCutDebugger(problemName.c_str())Â ; |
---|
4742 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirGen.probname_ =Â CoinStrdup(problemName.c_str()); |
---|
4743 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // checking seems odd |
---|
4744 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //redsplitGen.set_given_optsol(babModel_->solver()->getRowCutDebuggerAlways()->optimalSolution(), |
---|
4745 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->getNumCols()); |
---|
4746 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4747 |               int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
4748 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //#ifdef COIN_HAS_ASL |
---|
4749 | #ifndef JJF_ONE |
---|
4750 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If linked then see if expansion wanted |
---|
4751 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4752 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â solver3 =Â dynamic_cast<OsiSolverLink *>Â (babModel_->solver()); |
---|
4753 |                 int options = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].intValue() / 10000; |
---|
4754 |                 if (solver3 || (options&16) != 0) { |
---|
4755 |                   if (options) { |
---|
4756 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* |
---|
4757 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - force mini branch and bound |
---|
4758 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - set priorities high on continuous |
---|
4759 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - try adding OA cuts |
---|
4760 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8 - try doing quadratic linearization |
---|
4761 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 16 - try expanding knapsacks |
---|
4762 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
4763 |                     if ((options&16)) { |
---|
4764 |                       int numberColumns = saveCoinModel.numberColumns(); |
---|
4765 |                       int numberRows = saveCoinModel.numberRows(); |
---|
4766 |                       whichColumn = new int[numberColumns]; |
---|
4767 |                       knapsackStart = new int[numberRows+1]; |
---|
4768 |                       knapsackRow = new int[numberRows]; |
---|
4769 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberKnapsack =Â 10000; |
---|
4770 |                       int extra1 = parameters_[whichParam(CBC_PARAM_INT_EXTRA1, numberParameters_, parameters_)].intValue(); |
---|
4771 |                       int extra2 = parameters_[whichParam(CBC_PARAM_INT_EXTRA2, numberParameters_, parameters_)].intValue(); |
---|
4772 |                       int logLevel = parameters_[log].intValue(); |
---|
4773 |                       OsiSolverInterface * solver = expandKnapsack(saveCoinModel, whichColumn, knapsackStart, |
---|
4774 |                                      knapsackRow, numberKnapsack, |
---|
4775 |                                      storedAmpl, logLevel, extra1, extra2, |
---|
4776 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveTightenedModel); |
---|
4777 |                       if (solver) { |
---|
4778 | #ifndef CBC_OTHER_SOLVER |
---|
4779 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
4780 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (clpSolver); |
---|
4781 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
4782 | #endif |
---|
4783 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver); |
---|
4784 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â testOsiOptions =Â 0; |
---|
4785 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // allow gomory |
---|
4786 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 0; |
---|
4787 | #ifdef COIN_HAS_ASL |
---|
4788 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Priorities already done |
---|
4789 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.priorities); |
---|
4790 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.priorities =Â NULL; |
---|
4791 | #endif |
---|
4792 |                       } else { |
---|
4793 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberKnapsack =Â 0; |
---|
4794 |                         delete [] whichColumn; |
---|
4795 |                         delete [] |
---|