1 | /* $Id: CbcSolver.cpp 1240 2009-10-02 18:41:44Z 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 | |
---|
52 | #include "CbcSolverHeuristics.hpp" |
---|
53 | #ifdef COIN_HAS_GLPK |
---|
54 | #include "glpk.h" |
---|
55 | extern glp_tran* cbc_glp_tran; |
---|
56 | extern glp_prob* cbc_glp_prob; |
---|
57 | #else |
---|
58 | #define GLP_UNDEF 1 |
---|
59 | #define GLP_FEAS 2 |
---|
60 | #define GLP_INFEAS 3 |
---|
61 | #define GLP_NOFEAS 4 |
---|
62 | #define GLP_OPT 5 |
---|
63 | #endif |
---|
64 | |
---|
65 | //#define USER_HAS_FAKE_CLP |
---|
66 | //#define USER_HAS_FAKE_CBC |
---|
67 | |
---|
68 | //#define CLP_MALLOC_STATISTICS |
---|
69 | |
---|
70 | #ifdef CLP_MALLOC_STATISTICS |
---|
71 | #include <malloc.h> |
---|
72 | #include <exception> |
---|
73 | #include <new> |
---|
74 | #include "stolen_from_ekk_malloc.cpp" |
---|
75 | static double malloc_times = 0.0; |
---|
76 | static double malloc_total = 0.0; |
---|
77 | static int malloc_amount[] = {0, 32, 128, 256, 1024, 4096, 16384, 65536, 262144, INT_MAX}; |
---|
78 | static int malloc_n = 10; |
---|
79 | double malloc_counts[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
---|
80 | bool malloc_counts_on = true; |
---|
81 | void * operator new (size_t size) throw (std::bad_alloc) |
---|
82 | { |
---|
83 | Â Â malloc_times ++; |
---|
84 | Â Â malloc_total +=Â size; |
---|
85 |   int i; |
---|
86 |   for (i = 0; i < malloc_n; i++) { |
---|
87 |     if ((int) size <= malloc_amount[i]) { |
---|
88 | Â Â Â Â Â Â malloc_counts[i]++; |
---|
89 | Â Â Â Â Â Â break; |
---|
90 | Â Â Â Â } |
---|
91 | Â Â } |
---|
92 | # ifdef DEBUG_MALLOC |
---|
93 |   void *p; |
---|
94 |   if (malloc_counts_on) |
---|
95 | Â Â Â Â p =Â stolen_from_ekk_mallocBase(size); |
---|
96 | Â Â else |
---|
97 | Â Â Â Â p =Â malloc(size); |
---|
98 | # else |
---|
99 |   void * p = malloc(size); |
---|
100 | # endif |
---|
101 | Â Â //char * xx = (char *) p; |
---|
102 | Â Â //memset(xx,0,size); |
---|
103 | Â Â // Initialize random seed |
---|
104 | Â Â //CoinSeedRandom(987654321); |
---|
105 |   return p; |
---|
106 | } |
---|
107 | void operator delete (void *p) throw() |
---|
108 | { |
---|
109 | # ifdef DEBUG_MALLOC |
---|
110 |   if (malloc_counts_on) |
---|
111 | Â Â Â Â stolen_from_ekk_freeBase(p); |
---|
112 | Â Â else |
---|
113 | Â Â Â Â free(p); |
---|
114 | # else |
---|
115 | Â Â free(p); |
---|
116 | # endif |
---|
117 | } |
---|
118 | static void malloc_stats2() |
---|
119 | { |
---|
120 |   double average = malloc_total / malloc_times; |
---|
121 |   printf("count %g bytes %g - average %g\n", malloc_times, malloc_total, average); |
---|
122 |   for (int i = 0; i < malloc_n; i++) |
---|
123 |     printf("%g ", malloc_counts[i]); |
---|
124 | Â Â printf("\n"); |
---|
125 | Â Â malloc_times =Â 0.0; |
---|
126 | Â Â malloc_total =Â 0.0; |
---|
127 |   memset(malloc_counts, 0, sizeof(malloc_counts)); |
---|
128 | Â Â // print results |
---|
129 | } |
---|
130 | #else  //CLP_MALLOC_STATISTICS |
---|
131 | //void stolen_from_ekk_memory(void * dummy,int type) |
---|
132 | //{ |
---|
133 | //} |
---|
134 | //bool malloc_counts_on=false; |
---|
135 | #endif //CLP_MALLOC_STATISTICS |
---|
136 | |
---|
137 | //#define DMALLOC |
---|
138 | #ifdef DMALLOC |
---|
139 | #include "dmalloc.h" |
---|
140 | #endif |
---|
141 | |
---|
142 | #ifdef WSSMP_BARRIER |
---|
143 | #define FOREIGN_BARRIER |
---|
144 | #endif |
---|
145 | |
---|
146 | #ifdef UFL_BARRIER |
---|
147 | #define FOREIGN_BARRIER |
---|
148 | #endif |
---|
149 | |
---|
150 | #ifdef TAUCS_BARRIER |
---|
151 | #define FOREIGN_BARRIER |
---|
152 | #endif |
---|
153 | |
---|
154 | static int initialPumpTune = -1; |
---|
155 | #include "CoinWarmStartBasis.hpp" |
---|
156 | |
---|
157 | #include "OsiSolverInterface.hpp" |
---|
158 | #include "OsiCuts.hpp" |
---|
159 | #include "OsiRowCut.hpp" |
---|
160 | #include "OsiColCut.hpp" |
---|
161 | |
---|
162 | #ifndef COIN_HAS_LINK |
---|
163 | #define COIN_HAS_LINK |
---|
164 | #endif |
---|
165 | #ifdef COIN_HAS_LINK |
---|
166 | #include "CbcLinked.hpp" |
---|
167 | #endif |
---|
168 | |
---|
169 | #include "CglPreProcess.hpp" |
---|
170 | #include "CglCutGenerator.hpp" |
---|
171 | #include "CglGomory.hpp" |
---|
172 | #include "CglProbing.hpp" |
---|
173 | #include "CglKnapsackCover.hpp" |
---|
174 | #include "CglRedSplit.hpp" |
---|
175 | #include "CglClique.hpp" |
---|
176 | #include "CglFlowCover.hpp" |
---|
177 | #include "CglMixedIntegerRounding2.hpp" |
---|
178 | #include "CglTwomir.hpp" |
---|
179 | #include "CglDuplicateRow.hpp" |
---|
180 | #include "CglStored.hpp" |
---|
181 | #include "CglLandP.hpp" |
---|
182 | #include "CglResidualCapacity.hpp" |
---|
183 | |
---|
184 | #ifdef ZERO_HALF_CUTS |
---|
185 | #include "CglZeroHalf.hpp" |
---|
186 | #endif |
---|
187 | //#define CGL_WRITEMPS |
---|
188 | #ifdef CGL_WRITEMPS |
---|
189 | extern double * debugSolution; |
---|
190 | extern int debugNumberColumns; |
---|
191 | #endif |
---|
192 | #include "CbcModel.hpp" |
---|
193 | #include "CbcHeuristic.hpp" |
---|
194 | #include "CbcHeuristicLocal.hpp" |
---|
195 | #include "CbcHeuristicPivotAndFix.hpp" |
---|
196 | //#include "CbcHeuristicPivotAndComplement.hpp" |
---|
197 | #include "CbcHeuristicRandRound.hpp" |
---|
198 | #include "CbcHeuristicGreedy.hpp" |
---|
199 | #include "CbcHeuristicFPump.hpp" |
---|
200 | #include "CbcHeuristicRINS.hpp" |
---|
201 | #include "CbcHeuristicDiveCoefficient.hpp" |
---|
202 | #include "CbcHeuristicDiveFractional.hpp" |
---|
203 | #include "CbcHeuristicDiveGuided.hpp" |
---|
204 | #include "CbcHeuristicDiveVectorLength.hpp" |
---|
205 | #include "CbcHeuristicDivePseudoCost.hpp" |
---|
206 | #include "CbcHeuristicDiveLineSearch.hpp" |
---|
207 | #include "CbcTreeLocal.hpp" |
---|
208 | #include "CbcCompareActual.hpp" |
---|
209 | #include "CbcBranchActual.hpp" |
---|
210 | #include "CbcBranchLotsize.hpp" |
---|
211 | #include "CbcOrClpParam.hpp" |
---|
212 | #include "CbcCutGenerator.hpp" |
---|
213 | #include "CbcStrategy.hpp" |
---|
214 | #include "CbcBranchCut.hpp" |
---|
215 | |
---|
216 | #include "OsiClpSolverInterface.hpp" |
---|
217 | |
---|
218 | #include "CbcSolverAnalyze.hpp" |
---|
219 | #include "CbcSolverExpandKnapsack.hpp" |
---|
220 | |
---|
221 | #include "CbcSolver.hpp" |
---|
222 | |
---|
223 | //#define IN_BRANCH_AND_BOUND (0x01000000|262144) |
---|
224 | #define IN_BRANCH_AND_BOUND (0x01000000|262144|128|1024|2048) |
---|
225 | //#define IN_BRANCH_AND_BOUND (0x01000000|262144|128) |
---|
226 | |
---|
227 | /* |
---|
228 | Â CbcStopNow class definitions. |
---|
229 | */ |
---|
230 | |
---|
231 | CbcStopNow::CbcStopNow() |
---|
232 | { |
---|
233 | } |
---|
234 | CbcStopNow::~CbcStopNow() |
---|
235 | { |
---|
236 | } |
---|
237 | // Copy constructor |
---|
238 | CbcStopNow::CbcStopNow ( const CbcStopNow & ) |
---|
239 | { |
---|
240 | } |
---|
241 | // Assignment operator |
---|
242 | CbcStopNow & |
---|
243 | CbcStopNow::operator=(const CbcStopNow & rhs) |
---|
244 | { |
---|
245 |   if (this != &rhs) { |
---|
246 | Â Â } |
---|
247 |   return *this; |
---|
248 | } |
---|
249 | // Clone |
---|
250 | CbcStopNow * |
---|
251 | CbcStopNow::clone()Â const |
---|
252 | { |
---|
253 |   return new CbcStopNow(*this); |
---|
254 | } |
---|
255 | |
---|
256 | /* |
---|
257 | Â CbcUser class definitions. |
---|
258 | */ |
---|
259 | |
---|
260 | // User stuff (base class) |
---|
261 | CbcUser::CbcUser() |
---|
262 | Â Â Â Â :Â coinModel_(NULL), |
---|
263 | Â Â Â Â userName_("null") |
---|
264 | { |
---|
265 | } |
---|
266 | CbcUser::~CbcUser() |
---|
267 | { |
---|
268 |   delete coinModel_; |
---|
269 | } |
---|
270 | // Copy constructor |
---|
271 | CbcUser::CbcUser ( const CbcUser & rhs) |
---|
272 | { |
---|
273 |   if (rhs.coinModel_) |
---|
274 |     coinModel_ = new CoinModel(*rhs.coinModel_); |
---|
275 | Â Â else |
---|
276 | Â Â Â Â coinModel_ =Â NULL; |
---|
277 | Â Â userName_ =Â rhs.userName_; |
---|
278 | } |
---|
279 | // Assignment operator |
---|
280 | CbcUser & |
---|
281 | CbcUser::operator=(const CbcUser & rhs) |
---|
282 | { |
---|
283 |   if (this != &rhs) { |
---|
284 |     if (rhs.coinModel_) |
---|
285 |       coinModel_ = new CoinModel(*rhs.coinModel_); |
---|
286 | Â Â Â Â else |
---|
287 | Â Â Â Â Â Â coinModel_ =Â NULL; |
---|
288 | Â Â Â Â userName_ =Â rhs.userName_; |
---|
289 | Â Â } |
---|
290 |   return *this; |
---|
291 | } |
---|
292 | |
---|
293 | /* |
---|
294 | Â CbcSolver class definitions |
---|
295 | */ |
---|
296 | |
---|
297 | CbcSolver::CbcSolver() |
---|
298 | Â Â Â Â :Â babModel_(NULL), |
---|
299 | Â Â Â Â userFunction_(NULL), |
---|
300 | Â Â Â Â statusUserFunction_(NULL), |
---|
301 | Â Â Â Â originalSolver_(NULL), |
---|
302 | Â Â Â Â originalCoinModel_(NULL), |
---|
303 | Â Â Â Â cutGenerator_(NULL), |
---|
304 | Â Â Â Â numberUserFunctions_(0), |
---|
305 | Â Â Â Â numberCutGenerators_(0), |
---|
306 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
307 | Â Â Â Â parameters_(NULL), |
---|
308 | Â Â Â Â numberParameters_(0), |
---|
309 | Â Â Â Â doMiplib_(false), |
---|
310 | Â Â Â Â noPrinting_(false), |
---|
311 | Â Â Â Â readMode_(1) |
---|
312 | { |
---|
313 |   callBack_ = new CbcStopNow(); |
---|
314 | Â Â fillParameters(); |
---|
315 | } |
---|
316 | CbcSolver::CbcSolver(const OsiClpSolverInterface & solver) |
---|
317 | Â Â Â Â :Â babModel_(NULL), |
---|
318 | Â Â Â Â userFunction_(NULL), |
---|
319 | Â Â Â Â statusUserFunction_(NULL), |
---|
320 | Â Â Â Â originalSolver_(NULL), |
---|
321 | Â Â Â Â originalCoinModel_(NULL), |
---|
322 | Â Â Â Â cutGenerator_(NULL), |
---|
323 | Â Â Â Â numberUserFunctions_(0), |
---|
324 | Â Â Â Â numberCutGenerators_(0), |
---|
325 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
326 | Â Â Â Â parameters_(NULL), |
---|
327 | Â Â Â Â numberParameters_(0), |
---|
328 | Â Â Â Â doMiplib_(false), |
---|
329 | Â Â Â Â noPrinting_(false), |
---|
330 | Â Â Â Â readMode_(1) |
---|
331 | { |
---|
332 |   callBack_ = new CbcStopNow(); |
---|
333 | Â Â model_ =Â CbcModel(solver); |
---|
334 | Â Â fillParameters(); |
---|
335 | } |
---|
336 | CbcSolver::CbcSolver(const CbcModel & solver) |
---|
337 | Â Â Â Â :Â babModel_(NULL), |
---|
338 | Â Â Â Â userFunction_(NULL), |
---|
339 | Â Â Â Â statusUserFunction_(NULL), |
---|
340 | Â Â Â Â originalSolver_(NULL), |
---|
341 | Â Â Â Â originalCoinModel_(NULL), |
---|
342 | Â Â Â Â cutGenerator_(NULL), |
---|
343 | Â Â Â Â numberUserFunctions_(0), |
---|
344 | Â Â Â Â numberCutGenerators_(0), |
---|
345 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
346 | Â Â Â Â parameters_(NULL), |
---|
347 | Â Â Â Â numberParameters_(0), |
---|
348 | Â Â Â Â doMiplib_(false), |
---|
349 | Â Â Â Â noPrinting_(false), |
---|
350 | Â Â Â Â readMode_(1) |
---|
351 | { |
---|
352 |   callBack_ = new CbcStopNow(); |
---|
353 | Â Â model_ =Â solver; |
---|
354 | Â Â fillParameters(); |
---|
355 | } |
---|
356 | CbcSolver::~CbcSolver() |
---|
357 | { |
---|
358 |   int i; |
---|
359 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
360 |     delete userFunction_[i]; |
---|
361 |   delete [] userFunction_; |
---|
362 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
363 |     delete cutGenerator_[i]; |
---|
364 |   delete [] cutGenerator_; |
---|
365 |   delete [] statusUserFunction_; |
---|
366 |   delete originalSolver_; |
---|
367 |   delete originalCoinModel_; |
---|
368 |   delete babModel_; |
---|
369 |   delete [] parameters_; |
---|
370 |   delete callBack_; |
---|
371 | } |
---|
372 | // Copy constructor |
---|
373 | CbcSolver::CbcSolver ( const CbcSolver & rhs) |
---|
374 | Â Â Â Â :Â model_(rhs.model_), |
---|
375 | Â Â Â Â babModel_(NULL), |
---|
376 | Â Â Â Â userFunction_(NULL), |
---|
377 | Â Â Â Â statusUserFunction_(NULL), |
---|
378 | Â Â Â Â numberUserFunctions_(rhs.numberUserFunctions_), |
---|
379 | Â Â Â Â startTime_(CoinCpuTime()), |
---|
380 | Â Â Â Â parameters_(NULL), |
---|
381 | Â Â Â Â numberParameters_(rhs.numberParameters_), |
---|
382 | Â Â Â Â doMiplib_(rhs.doMiplib_), |
---|
383 | Â Â Â Â noPrinting_(rhs.noPrinting_), |
---|
384 | Â Â Â Â readMode_(rhs.readMode_) |
---|
385 | { |
---|
386 | Â Â fillParameters(); |
---|
387 |   if (rhs.babModel_) |
---|
388 |     babModel_ = new CbcModel(*rhs.babModel_); |
---|
389 |   userFunction_ = new CbcUser * [numberUserFunctions_]; |
---|
390 |   int i; |
---|
391 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
392 | Â Â Â Â userFunction_[i]Â =Â rhs.userFunction_[i]->clone(); |
---|
393 |   for (i = 0; i < numberParameters_; i++) |
---|
394 | Â Â Â Â parameters_[i]Â =Â rhs.parameters_[i]; |
---|
395 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
396 | Â Â Â Â cutGenerator_[i]Â =Â rhs.cutGenerator_[i]->clone(); |
---|
397 | Â Â callBack_ =Â rhs.callBack_->clone(); |
---|
398 | Â Â originalSolver_ =Â NULL; |
---|
399 |   if (rhs.originalSolver_) { |
---|
400 | Â Â Â Â OsiSolverInterface *Â temp =Â rhs.originalSolver_->clone(); |
---|
401 | Â Â Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
402 | Â Â Â Â assert (originalSolver_); |
---|
403 | Â Â } |
---|
404 | Â Â originalCoinModel_ =Â NULL; |
---|
405 |   if (rhs.originalCoinModel_) |
---|
406 |     originalCoinModel_ = new CoinModel(*rhs.originalCoinModel_); |
---|
407 | } |
---|
408 | // Assignment operator |
---|
409 | CbcSolver & |
---|
410 | CbcSolver::operator=(const CbcSolver & rhs) |
---|
411 | { |
---|
412 |   if (this != &rhs) { |
---|
413 |     int i; |
---|
414 |     for (i = 0; i < numberUserFunctions_; i++) |
---|
415 |       delete userFunction_[i]; |
---|
416 |     delete [] userFunction_; |
---|
417 |     for (i = 0; i < numberCutGenerators_; i++) |
---|
418 |       delete cutGenerator_[i]; |
---|
419 |     delete [] cutGenerator_; |
---|
420 |     delete [] statusUserFunction_; |
---|
421 |     delete originalSolver_; |
---|
422 |     delete originalCoinModel_; |
---|
423 | Â Â Â Â statusUserFunction_ =Â NULL; |
---|
424 |     delete babModel_; |
---|
425 |     delete [] parameters_; |
---|
426 |     delete callBack_; |
---|
427 | Â Â Â Â numberUserFunctions_ =Â rhs.numberUserFunctions_; |
---|
428 | Â Â Â Â startTime_ =Â rhs.startTime_; |
---|
429 | Â Â Â Â numberParameters_ =Â rhs.numberParameters_; |
---|
430 |     for (i = 0; i < numberParameters_; i++) |
---|
431 | Â Â Â Â Â Â parameters_[i]Â =Â rhs.parameters_[i]; |
---|
432 |     for (i = 0; i < numberCutGenerators_; i++) |
---|
433 | Â Â Â Â Â Â cutGenerator_[i]Â =Â rhs.cutGenerator_[i]->clone(); |
---|
434 | Â Â Â Â noPrinting_ =Â rhs.noPrinting_; |
---|
435 | Â Â Â Â readMode_ =Â rhs.readMode_; |
---|
436 | Â Â Â Â doMiplib_ =Â rhs.doMiplib_; |
---|
437 | Â Â Â Â model_ =Â rhs.model_; |
---|
438 |     if (rhs.babModel_) |
---|
439 |       babModel_ = new CbcModel(*rhs.babModel_); |
---|
440 | Â Â Â Â else |
---|
441 | Â Â Â Â Â Â babModel_ =Â NULL; |
---|
442 |     userFunction_ = new CbcUser * [numberUserFunctions_]; |
---|
443 |     for (i = 0; i < numberUserFunctions_; i++) |
---|
444 | Â Â Â Â Â Â userFunction_[i]Â =Â rhs.userFunction_[i]->clone(); |
---|
445 | Â Â Â Â callBack_ =Â rhs.callBack_->clone(); |
---|
446 | Â Â Â Â originalSolver_ =Â NULL; |
---|
447 |     if (rhs.originalSolver_) { |
---|
448 | Â Â Â Â Â Â OsiSolverInterface *Â temp =Â rhs.originalSolver_->clone(); |
---|
449 | Â Â Â Â Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
450 | Â Â Â Â Â Â assert (originalSolver_); |
---|
451 | Â Â Â Â } |
---|
452 | Â Â Â Â originalCoinModel_ =Â NULL; |
---|
453 |     if (rhs.originalCoinModel_) |
---|
454 |       originalCoinModel_ = new CoinModel(*rhs.originalCoinModel_); |
---|
455 | Â Â } |
---|
456 |   return *this; |
---|
457 | } |
---|
458 | // Get int value |
---|
459 | int CbcSolver::intValue(CbcOrClpParameterType type) const |
---|
460 | { |
---|
461 |   return parameters_[whichParam(type, numberParameters_, parameters_)].intValue(); |
---|
462 | } |
---|
463 | // Set int value |
---|
464 | void CbcSolver::setIntValue(CbcOrClpParameterType type, int value) |
---|
465 | { |
---|
466 |   parameters_[whichParam(type, numberParameters_, parameters_)].setIntValue(value); |
---|
467 | } |
---|
468 | // Get double value |
---|
469 | double CbcSolver::doubleValue(CbcOrClpParameterType type) const |
---|
470 | { |
---|
471 |   return parameters_[whichParam(type, numberParameters_, parameters_)].doubleValue(); |
---|
472 | } |
---|
473 | // Set double value |
---|
474 | void CbcSolver::setDoubleValue(CbcOrClpParameterType type, double value) |
---|
475 | { |
---|
476 |   parameters_[whichParam(type, numberParameters_, parameters_)].setDoubleValue(value); |
---|
477 | } |
---|
478 | // User function (NULL if no match) |
---|
479 | CbcUser * CbcSolver::userFunction(const char * name) const |
---|
480 | { |
---|
481 |   int i; |
---|
482 |   for (i = 0; i < numberUserFunctions_; i++) { |
---|
483 |     if (!strcmp(name, userFunction_[i]->name().c_str())) |
---|
484 | Â Â Â Â Â Â break; |
---|
485 | Â Â } |
---|
486 |   if (i < numberUserFunctions_) |
---|
487 |     return userFunction_[i]; |
---|
488 | Â Â else |
---|
489 |     return NULL; |
---|
490 | } |
---|
491 | void CbcSolver::fillParameters() |
---|
492 | { |
---|
493 |   int maxParam = 200; |
---|
494 |   CbcOrClpParam * parameters = new CbcOrClpParam [maxParam]; |
---|
495 | Â Â numberParameters_ =Â 0Â ; |
---|
496 |   establishParams(numberParameters_, parameters) ; |
---|
497 | Â Â assert (numberParameters_ <=Â maxParam); |
---|
498 |   parameters_ = new CbcOrClpParam [numberParameters_]; |
---|
499 |   int i; |
---|
500 |   for (i = 0; i < numberParameters_; i++) |
---|
501 | Â Â Â Â parameters_[i]Â =Â parameters[i]; |
---|
502 |   delete [] parameters; |
---|
503 |   const char dirsep = CoinFindDirSeparator(); |
---|
504 | Â Â std::string directory; |
---|
505 | Â Â std::string dirSample; |
---|
506 | Â Â std::string dirNetlib; |
---|
507 | Â Â std::string dirMiplib; |
---|
508 |   if (dirsep == '/') { |
---|
509 | Â Â Â Â directory =Â "./"; |
---|
510 | Â Â Â Â dirSample =Â "../../Data/Sample/"; |
---|
511 | Â Â Â Â dirNetlib =Â "../../Data/Netlib/"; |
---|
512 | Â Â Â Â dirMiplib =Â "../../Data/miplib3/"; |
---|
513 |   } else { |
---|
514 | Â Â Â Â directory =Â ".\\"; |
---|
515 | Â Â Â Â dirSample =Â "..\\..\\..\\..\\Data\\Sample\\"; |
---|
516 | Â Â Â Â dirNetlib =Â "..\\..\\..\\..\\Data\\Netlib\\"; |
---|
517 | Â Â Â Â dirMiplib =Â "..\\..\\..\\..\\Data\\miplib3\\"; |
---|
518 | Â Â } |
---|
519 | Â Â std::string defaultDirectory =Â directory; |
---|
520 | Â Â std::string importFile =Â ""; |
---|
521 | Â Â std::string exportFile =Â "default.mps"; |
---|
522 | Â Â std::string importBasisFile =Â ""; |
---|
523 | Â Â std::string importPriorityFile =Â ""; |
---|
524 | Â Â std::string debugFile =Â ""; |
---|
525 | Â Â std::string printMask =Â ""; |
---|
526 | Â Â std::string exportBasisFile =Â "default.bas"; |
---|
527 | Â Â std::string saveFile =Â "default.prob"; |
---|
528 | Â Â std::string restoreFile =Â "default.prob"; |
---|
529 | Â Â std::string solutionFile =Â "stdout"; |
---|
530 | Â Â std::string solutionSaveFile =Â "solution.file"; |
---|
531 |   int doIdiot = -1; |
---|
532 |   int outputFormat = 2; |
---|
533 |   int substitution = 3; |
---|
534 |   int dualize = 3; |
---|
535 |   int preSolve = 5; |
---|
536 |   int doSprint = -1; |
---|
537 |   int testOsiParameters = -1; |
---|
538 |   int createSolver = 0; |
---|
539 | Â Â ClpSimplex *Â lpSolver; |
---|
540 | Â Â OsiClpSolverInterface *Â clpSolver; |
---|
541 |   if (model_.solver()) { |
---|
542 | Â Â Â Â clpSolver =Â dynamic_cast<OsiClpSolverInterface *>Â (model_.solver()); |
---|
543 | Â Â Â Â assert (clpSolver); |
---|
544 | Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
545 | Â Â Â Â assert (lpSolver); |
---|
546 |   } else { |
---|
547 |     lpSolver = new ClpSimplex(); |
---|
548 |     clpSolver = new OsiClpSolverInterface(lpSolver, true); |
---|
549 | Â Â Â Â createSolver =Â 1Â ; |
---|
550 | Â Â } |
---|
551 |   parameters_[whichParam(CLP_PARAM_ACTION_BASISIN, numberParameters_, parameters_)].setStringValue(importBasisFile); |
---|
552 |   parameters_[whichParam(CBC_PARAM_ACTION_PRIORITYIN, numberParameters_, parameters_)].setStringValue(importPriorityFile); |
---|
553 |   parameters_[whichParam(CLP_PARAM_ACTION_BASISOUT, numberParameters_, parameters_)].setStringValue(exportBasisFile); |
---|
554 |   parameters_[whichParam(CLP_PARAM_ACTION_DEBUG, numberParameters_, parameters_)].setStringValue(debugFile); |
---|
555 |   parameters_[whichParam(CLP_PARAM_ACTION_PRINTMASK, numberParameters_, parameters_)].setStringValue(printMask); |
---|
556 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRECTORY, numberParameters_, parameters_)].setStringValue(directory); |
---|
557 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRSAMPLE, numberParameters_, parameters_)].setStringValue(dirSample); |
---|
558 |   parameters_[whichParam(CLP_PARAM_ACTION_DIRNETLIB, numberParameters_, parameters_)].setStringValue(dirNetlib); |
---|
559 |   parameters_[whichParam(CBC_PARAM_ACTION_DIRMIPLIB, numberParameters_, parameters_)].setStringValue(dirMiplib); |
---|
560 |   parameters_[whichParam(CLP_PARAM_DBL_DUALBOUND, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualBound()); |
---|
561 |   parameters_[whichParam(CLP_PARAM_DBL_DUALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualTolerance()); |
---|
562 |   parameters_[whichParam(CLP_PARAM_ACTION_EXPORT, numberParameters_, parameters_)].setStringValue(exportFile); |
---|
563 |   parameters_[whichParam(CLP_PARAM_INT_IDIOT, numberParameters_, parameters_)].setIntValue(doIdiot); |
---|
564 |   parameters_[whichParam(CLP_PARAM_ACTION_IMPORT, numberParameters_, parameters_)].setStringValue(importFile); |
---|
565 |   parameters_[whichParam(CLP_PARAM_DBL_PRESOLVETOLERANCE, numberParameters_, parameters_)].setDoubleValue(1.0e-8); |
---|
566 |   int iParam = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
567 |   int value = 1; |
---|
568 | Â Â clpSolver->messageHandler()->setLogLevel(1)Â ; |
---|
569 | Â Â lpSolver->setLogLevel(1); |
---|
570 | Â Â parameters_[iParam].setIntValue(value); |
---|
571 |   iParam = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
572 | Â Â model_.messageHandler()->setLogLevel(value); |
---|
573 | Â Â parameters_[iParam].setIntValue(value); |
---|
574 |   parameters_[whichParam(CLP_PARAM_INT_MAXFACTOR, numberParameters_, parameters_)].setIntValue(lpSolver->factorizationFrequency()); |
---|
575 |   parameters_[whichParam(CLP_PARAM_INT_MAXITERATION, numberParameters_, parameters_)].setIntValue(lpSolver->maximumIterations()); |
---|
576 |   parameters_[whichParam(CLP_PARAM_INT_OUTPUTFORMAT, numberParameters_, parameters_)].setIntValue(outputFormat); |
---|
577 |   parameters_[whichParam(CLP_PARAM_INT_PRESOLVEPASS, numberParameters_, parameters_)].setIntValue(preSolve); |
---|
578 |   parameters_[whichParam(CLP_PARAM_INT_PERTVALUE, numberParameters_, parameters_)].setIntValue(lpSolver->perturbation()); |
---|
579 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->primalTolerance()); |
---|
580 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALWEIGHT, numberParameters_, parameters_)].setDoubleValue(lpSolver->infeasibilityCost()); |
---|
581 |   parameters_[whichParam(CLP_PARAM_ACTION_RESTORE, numberParameters_, parameters_)].setStringValue(restoreFile); |
---|
582 |   parameters_[whichParam(CLP_PARAM_ACTION_SAVE, numberParameters_, parameters_)].setStringValue(saveFile); |
---|
583 | Â Â //parameters_[whichParam(CLP_PARAM_DBL_TIMELIMIT,numberParameters_,parameters_)].setDoubleValue(1.0e8); |
---|
584 |   parameters_[whichParam(CBC_PARAM_DBL_TIMELIMIT_BAB, numberParameters_, parameters_)].setDoubleValue(1.0e8); |
---|
585 |   parameters_[whichParam(CLP_PARAM_ACTION_SOLUTION, numberParameters_, parameters_)].setStringValue(solutionFile); |
---|
586 |   parameters_[whichParam(CLP_PARAM_ACTION_SAVESOL, numberParameters_, parameters_)].setStringValue(solutionSaveFile); |
---|
587 |   parameters_[whichParam(CLP_PARAM_INT_SPRINT, numberParameters_, parameters_)].setIntValue(doSprint); |
---|
588 |   parameters_[whichParam(CLP_PARAM_INT_SUBSTITUTION, numberParameters_, parameters_)].setIntValue(substitution); |
---|
589 |   parameters_[whichParam(CLP_PARAM_INT_DUALIZE, numberParameters_, parameters_)].setIntValue(dualize); |
---|
590 |   parameters_[whichParam(CBC_PARAM_INT_NUMBERBEFORE, numberParameters_, parameters_)].setIntValue(model_.numberBeforeTrust()); |
---|
591 |   parameters_[whichParam(CBC_PARAM_INT_MAXNODES, numberParameters_, parameters_)].setIntValue(model_.getMaximumNodes()); |
---|
592 |   parameters_[whichParam(CBC_PARAM_INT_STRONGBRANCHING, numberParameters_, parameters_)].setIntValue(model_.numberStrong()); |
---|
593 |   parameters_[whichParam(CBC_PARAM_DBL_INFEASIBILITYWEIGHT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcInfeasibilityWeight)); |
---|
594 |   parameters_[whichParam(CBC_PARAM_DBL_INTEGERTOLERANCE, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcIntegerTolerance)); |
---|
595 |   parameters_[whichParam(CBC_PARAM_DBL_INCREMENT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcCutoffIncrement)); |
---|
596 |   parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(testOsiParameters); |
---|
597 |   parameters_[whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_)].setIntValue(1003); |
---|
598 | Â Â initialPumpTune =Â 1003; |
---|
599 | #ifdef CBC_THREAD |
---|
600 |   parameters_[whichParam(CBC_PARAM_INT_THREADS, numberParameters_, parameters_)].setIntValue(0); |
---|
601 | #endif |
---|
602 | Â Â // Set up likely cut generators and defaults |
---|
603 |   parameters_[whichParam(CBC_PARAM_STR_PREPROCESS, numberParameters_, parameters_)].setCurrentOption("sos"); |
---|
604 |   parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].setIntValue(1057); |
---|
605 |   parameters_[whichParam(CBC_PARAM_INT_CUTPASSINTREE, numberParameters_, parameters_)].setIntValue(1); |
---|
606 |   parameters_[whichParam(CBC_PARAM_INT_MOREMIPOPTIONS, numberParameters_, parameters_)].setIntValue(-1); |
---|
607 |   parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].setIntValue(100); |
---|
608 |   parameters_[whichParam(CBC_PARAM_STR_CUTSSTRATEGY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
609 |   parameters_[whichParam(CBC_PARAM_STR_HEURISTICSTRATEGY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
610 |   parameters_[whichParam(CBC_PARAM_STR_NODESTRATEGY, numberParameters_, parameters_)].setCurrentOption("fewest"); |
---|
611 |   parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
612 |   parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
613 |   parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
614 | #ifdef ZERO_HALF_CUTS |
---|
615 |   parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
616 | #endif |
---|
617 |   parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
618 |   parameters_[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
619 |   parameters_[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
620 |   parameters_[whichParam(CBC_PARAM_STR_FLOWCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); |
---|
621 |   parameters_[whichParam(CBC_PARAM_STR_TWOMIRCUTS, numberParameters_, parameters_)].setCurrentOption("root"); |
---|
622 |   parameters_[whichParam(CBC_PARAM_STR_LANDPCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
623 |   parameters_[whichParam(CBC_PARAM_STR_RESIDCUTS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
624 |   parameters_[whichParam(CBC_PARAM_STR_ROUNDING, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
625 |   parameters_[whichParam(CBC_PARAM_STR_FPUMP, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
626 |   parameters_[whichParam(CBC_PARAM_STR_GREEDY, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
627 |   parameters_[whichParam(CBC_PARAM_STR_COMBINE, numberParameters_, parameters_)].setCurrentOption("on"); |
---|
628 |   parameters_[whichParam(CBC_PARAM_STR_CROSSOVER2, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
629 |   parameters_[whichParam(CBC_PARAM_STR_PIVOTANDCOMPLEMENT, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
630 |   parameters_[whichParam(CBC_PARAM_STR_PIVOTANDFIX, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
631 |   parameters_[whichParam(CBC_PARAM_STR_RANDROUND, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
632 |   parameters_[whichParam(CBC_PARAM_STR_NAIVE, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
633 |   parameters_[whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
634 |   parameters_[whichParam(CBC_PARAM_STR_DINS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
635 |   parameters_[whichParam(CBC_PARAM_STR_RENS, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
636 |   parameters_[whichParam(CBC_PARAM_STR_LOCALTREE, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
637 |   parameters_[whichParam(CBC_PARAM_STR_COSTSTRATEGY, numberParameters_, parameters_)].setCurrentOption("off"); |
---|
638 |   if (createSolver) |
---|
639 |     delete clpSolver; |
---|
640 | } |
---|
641 | |
---|
642 | /* |
---|
643 | Â Initialise a subset of the parameters prior to processing any input from |
---|
644 | Â the user. |
---|
645 | |
---|
646 | Â Why this choice of subset? |
---|
647 | */ |
---|
648 | /*! |
---|
649 | Â \todo Guard/replace clp-specific code |
---|
650 | */ |
---|
651 | void CbcSolver::fillValuesInSolver() |
---|
652 | { |
---|
653 | Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
654 | Â Â OsiClpSolverInterface *Â clpSolver = |
---|
655 | Â Â Â Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
656 | Â Â assert (clpSolver); |
---|
657 | Â Â ClpSimplex *Â lpSolver =Â clpSolver->getModelPtr(); |
---|
658 | |
---|
659 | Â Â /* |
---|
660 | Â Â Â Why are we reaching into the underlying solver(s) for these settings? |
---|
661 | Â Â Â Shouldn't CbcSolver have its own defaults, which are then imposed on the |
---|
662 | Â Â Â underlying solver? |
---|
663 | |
---|
664 | Â Â Â Coming at if from the other side, if CbcSolver had the capability to use |
---|
665 | Â Â Â multiple solvers then it definitely makes sense to acquire the defaults from |
---|
666 | Â Â Â the solver (on the assumption that we haven't processed command line |
---|
667 | Â Â Â parameters yet, which can then override the defaults). But then it's more of |
---|
668 | Â Â Â a challenge to avoid solver-specific coding here. |
---|
669 | Â Â */ |
---|
670 | Â Â noPrinting_ =Â (lpSolver->logLevel()Â ==Â 0); |
---|
671 | Â Â CoinMessageHandler *Â generalMessageHandler =Â clpSolver->messageHandler(); |
---|
672 | Â Â generalMessageHandler->setPrefix(true); |
---|
673 | |
---|
674 | Â Â lpSolver->setPerturbation(50); |
---|
675 | Â Â lpSolver->messageHandler()->setPrefix(false); |
---|
676 | |
---|
677 |   parameters_[whichParam(CLP_PARAM_DBL_DUALBOUND, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualBound()); |
---|
678 |   parameters_[whichParam(CLP_PARAM_DBL_DUALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->dualTolerance()); |
---|
679 | Â Â /* |
---|
680 | Â Â Â Why are we doing this? We read the log level from parameters_, set it into |
---|
681 | Â Â Â the message handlers for cbc and the underlying solver. Then we read the |
---|
682 | Â Â Â log level back from the handlers and use it to set the values in |
---|
683 | Â Â Â parameters_! |
---|
684 | Â Â */ |
---|
685 |   int iParam = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
686 |   int value = parameters_[iParam].intValue(); |
---|
687 | Â Â clpSolver->messageHandler()->setLogLevel(value)Â ; |
---|
688 | Â Â lpSolver->setLogLevel(value); |
---|
689 |   iParam = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
690 | Â Â value =Â parameters_[iParam].intValue(); |
---|
691 | Â Â model_.messageHandler()->setLogLevel(value); |
---|
692 |   parameters_[whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_)].setIntValue(model_.logLevel()); |
---|
693 |   parameters_[whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_)].setIntValue(lpSolver->logLevel()); |
---|
694 |   parameters_[whichParam(CLP_PARAM_INT_MAXFACTOR, numberParameters_, parameters_)].setIntValue(lpSolver->factorizationFrequency()); |
---|
695 |   parameters_[whichParam(CLP_PARAM_INT_MAXITERATION, numberParameters_, parameters_)].setIntValue(lpSolver->maximumIterations()); |
---|
696 |   parameters_[whichParam(CLP_PARAM_INT_PERTVALUE, numberParameters_, parameters_)].setIntValue(lpSolver->perturbation()); |
---|
697 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALTOLERANCE, numberParameters_, parameters_)].setDoubleValue(lpSolver->primalTolerance()); |
---|
698 |   parameters_[whichParam(CLP_PARAM_DBL_PRIMALWEIGHT, numberParameters_, parameters_)].setDoubleValue(lpSolver->infeasibilityCost()); |
---|
699 |   parameters_[whichParam(CBC_PARAM_INT_NUMBERBEFORE, numberParameters_, parameters_)].setIntValue(model_.numberBeforeTrust()); |
---|
700 |   parameters_[whichParam(CBC_PARAM_INT_MAXNODES, numberParameters_, parameters_)].setIntValue(model_.getMaximumNodes()); |
---|
701 |   parameters_[whichParam(CBC_PARAM_INT_STRONGBRANCHING, numberParameters_, parameters_)].setIntValue(model_.numberStrong()); |
---|
702 |   parameters_[whichParam(CBC_PARAM_DBL_INFEASIBILITYWEIGHT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcInfeasibilityWeight)); |
---|
703 |   parameters_[whichParam(CBC_PARAM_DBL_INTEGERTOLERANCE, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcIntegerTolerance)); |
---|
704 |   parameters_[whichParam(CBC_PARAM_DBL_INCREMENT, numberParameters_, parameters_)].setDoubleValue(model_.getDblParam(CbcModel::CbcCutoffIncrement)); |
---|
705 | } |
---|
706 | // Add user function |
---|
707 | void |
---|
708 | CbcSolver::addUserFunction(CbcUser *Â function) |
---|
709 | { |
---|
710 |   CbcUser ** temp = new CbcUser * [numberUserFunctions_+1]; |
---|
711 |   int i; |
---|
712 |   for (i = 0; i < numberUserFunctions_; i++) |
---|
713 | Â Â Â Â temp[i]Â =Â userFunction_[i]; |
---|
714 |   delete [] userFunction_; |
---|
715 | Â Â userFunction_ =Â temp; |
---|
716 | Â Â userFunction_[numberUserFunctions_++]Â =Â function->clone(); |
---|
717 |   delete [] statusUserFunction_; |
---|
718 | Â Â statusUserFunction_ =Â NULL; |
---|
719 | } |
---|
720 | // Set user call back |
---|
721 | void |
---|
722 | CbcSolver::setUserCallBack(CbcStopNow *Â function) |
---|
723 | { |
---|
724 |   delete callBack_; |
---|
725 | Â Â callBack_ =Â function->clone(); |
---|
726 | } |
---|
727 | // Copy of model on initial load (will contain output solutions) |
---|
728 | void |
---|
729 | CbcSolver::setOriginalSolver(OsiClpSolverInterface *Â originalSolver) |
---|
730 | { |
---|
731 |   delete originalSolver_; |
---|
732 | Â Â OsiSolverInterface *Â temp =Â originalSolver->clone(); |
---|
733 | Â Â originalSolver_ =Â dynamic_cast<OsiClpSolverInterface *>Â (temp); |
---|
734 | Â Â assert (originalSolver_); |
---|
735 | |
---|
736 | } |
---|
737 | // Copy of model on initial load |
---|
738 | void |
---|
739 | CbcSolver::setOriginalCoinModel(CoinModel *Â originalCoinModel) |
---|
740 | { |
---|
741 |   delete originalCoinModel_; |
---|
742 |   originalCoinModel_ = new CoinModel(*originalCoinModel); |
---|
743 | } |
---|
744 | // Add cut generator |
---|
745 | void |
---|
746 | CbcSolver::addCutGenerator(CglCutGenerator *Â generator) |
---|
747 | { |
---|
748 |   CglCutGenerator ** temp = new CglCutGenerator * [numberCutGenerators_+1]; |
---|
749 |   int i; |
---|
750 |   for (i = 0; i < numberCutGenerators_; i++) |
---|
751 | Â Â Â Â temp[i]Â =Â cutGenerator_[i]; |
---|
752 |   delete [] cutGenerator_; |
---|
753 | Â Â cutGenerator_ =Â temp; |
---|
754 | Â Â cutGenerator_[numberCutGenerators_++]Â =Â generator->clone(); |
---|
755 | } |
---|
756 | |
---|
757 | /* |
---|
758 | Â The only other solver that's ever been used is cplex, and the use is |
---|
759 | Â limited -- do the root with clp and all the cbc smarts, then give the |
---|
760 | Â problem over to cplex to finish. Although the defines can be read in some |
---|
761 | Â places to allow other options, nothing's been tested and success is |
---|
762 | Â unlikely. |
---|
763 | |
---|
764 | Â CBC_OTHER_SOLVER == 1 is cplex. |
---|
765 | */ |
---|
766 | |
---|
767 | #if CBC_OTHER_SOLVER==1 |
---|
768 | #Â ifndef COIN_HAS_CPX |
---|
769 | #Â Â error "Configuration did not detect cplex installation." |
---|
770 | #Â else |
---|
771 | #Â Â include "OsiCpxSolverInterface.hpp" |
---|
772 | #Â endif |
---|
773 | #endif |
---|
774 | |
---|
775 | #ifdef COIN_HAS_ASL |
---|
776 | #include "Cbc_ampl.h" |
---|
777 | #endif |
---|
778 | |
---|
779 | static double totalTime = 0.0; |
---|
780 | static void statistics(ClpSimplex * originalModel, ClpSimplex * model); |
---|
781 | static bool maskMatches(const int * starts, char ** masks, |
---|
782 | Â Â Â Â Â Â Â Â Â Â Â Â std::string &Â check); |
---|
783 | static void generateCode(CbcModel * model, const char * fileName, int type, int preProcess); |
---|
784 | |
---|
785 | // dummy fake main programs for UserClp and UserCbc |
---|
786 | void fakeMain (ClpSimplex & model, OsiSolverInterface & osiSolver, CbcModel & babSolver); |
---|
787 | void fakeMain2 (ClpSimplex & model, OsiClpSolverInterface & osiSolver, int options); |
---|
788 | |
---|
789 | // Allow for interrupts |
---|
790 | // But is this threadsafe? (so switched off by option) |
---|
791 | |
---|
792 | #include "CoinSignal.hpp" |
---|
793 | static CbcModel * currentBranchModel = NULL; |
---|
794 | |
---|
795 | extern "C" { |
---|
796 |   static void signal_handler(int /*whichSignal*/) { |
---|
797 |     if (currentBranchModel != NULL) { |
---|
798 | Â Â Â Â Â Â currentBranchModel->setMaximumNodes(0);Â // stop at next node |
---|
799 | Â Â Â Â Â Â currentBranchModel->setMaximumSeconds(0.0);Â // stop |
---|
800 | Â Â Â Â } |
---|
801 | Â Â Â Â return; |
---|
802 | Â Â } |
---|
803 | } |
---|
804 | |
---|
805 | //#define CBC_SIG_TRAP |
---|
806 | #ifdef CBC_SIG_TRAP |
---|
807 | #include <setjmp.h> |
---|
808 | static sigjmp_buf cbc_seg_buffer; |
---|
809 | extern "C" { |
---|
810 |   static void signal_handler_error(int whichSignal) { |
---|
811 |     siglongjmp(cbc_seg_buffer, 1); |
---|
812 | Â Â } |
---|
813 | } |
---|
814 | #endif |
---|
815 | |
---|
816 | |
---|
817 | /* |
---|
818 | Â Debug checks on special ordered sets. |
---|
819 | |
---|
820 | Â This is active only for debugging. The entire body of the routine becomes |
---|
821 | Â a noop when COIN_DEVELOP is not defined. To avoid compiler warnings, the |
---|
822 | Â formal parameters also need to go away. |
---|
823 | */ |
---|
824 | #ifdef COIN_DEVELOP |
---|
825 | void checkSOS(CbcModel * babModel, const OsiSolverInterface * solver) |
---|
826 | #else |
---|
827 | void checkSOS(CbcModel * /*babModel*/, const OsiSolverInterface * /*solver*/) |
---|
828 | #endif |
---|
829 | { |
---|
830 | #ifdef COIN_DEVELOP |
---|
831 |   if (!babModel->ownObjects()) |
---|
832 | Â Â Â Â return; |
---|
833 | #if COIN_DEVELOP>2 |
---|
834 | Â Â //const double *objective = solver->getObjCoefficients() ; |
---|
835 |   const double *columnLower = solver->getColLower() ; |
---|
836 |   const double * columnUpper = solver->getColUpper() ; |
---|
837 |   const double * solution = solver->getColSolution(); |
---|
838 | Â Â //int numberRows = solver->getNumRows(); |
---|
839 | Â Â //double direction = solver->getObjSense(); |
---|
840 | Â Â //int iRow,iColumn; |
---|
841 | #endif |
---|
842 | |
---|
843 | Â Â // Row copy |
---|
844 | Â Â CoinPackedMatrix matrixByRow(*solver->getMatrixByRow()); |
---|
845 | Â Â //const double * elementByRow = matrixByRow.getElements(); |
---|
846 | Â Â //const int * column = matrixByRow.getIndices(); |
---|
847 | Â Â //const CoinBigIndex * rowStart = matrixByRow.getVectorStarts(); |
---|
848 |   const int * rowLength = matrixByRow.getVectorLengths(); |
---|
849 | |
---|
850 | Â Â // Column copy |
---|
851 |   CoinPackedMatrix matrixByCol(*solver->getMatrixByCol()); |
---|
852 |   const double * element = matrixByCol.getElements(); |
---|
853 |   const int * row = matrixByCol.getIndices(); |
---|
854 |   const CoinBigIndex * columnStart = matrixByCol.getVectorStarts(); |
---|
855 |   const int * columnLength = matrixByCol.getVectorLengths(); |
---|
856 | |
---|
857 |   const double * rowLower = solver->getRowLower(); |
---|
858 |   const double * rowUpper = solver->getRowUpper(); |
---|
859 | Â Â OsiObject **Â objects =Â babModel->objects(); |
---|
860 |   int numberObjects = babModel->numberObjects(); |
---|
861 |   int numberColumns = solver->getNumCols() ; |
---|
862 |   for (int iObj = 0; iObj < numberObjects; iObj++) { |
---|
863 | Â Â Â Â CbcSOS *Â objSOS = |
---|
864 |       dynamic_cast <CbcSOS *>(objects[iObj]) ; |
---|
865 |     if (objSOS) { |
---|
866 |       int n = objSOS->numberMembers(); |
---|
867 |       const int * which = objSOS->members(); |
---|
868 | #if COIN_DEVELOP>2 |
---|
869 |       const double * weight = objSOS->weights(); |
---|
870 | #endif |
---|
871 |       int type = objSOS->sosType(); |
---|
872 | Â Â Â Â Â Â // convexity row? |
---|
873 |       int iColumn; |
---|
874 | Â Â Â Â Â Â iColumn =Â which[0]; |
---|
875 |       int j; |
---|
876 |       int convex = -1; |
---|
877 |       for (j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { |
---|
878 |         int iRow = row[j]; |
---|
879 |         double value = element[j]; |
---|
880 |         if (rowLower[iRow] == 1.0 && rowUpper[iRow] == 1.0 && |
---|
881 | Â Â Â Â Â Â Â Â Â Â Â Â value ==Â 1.0)Â { |
---|
882 | Â Â Â Â Â Â Â Â Â Â // possible |
---|
883 |           if (rowLength[iRow] == n) { |
---|
884 |             if (convex == -1) |
---|
885 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex =Â iRow; |
---|
886 | Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
887 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex =Â -2; |
---|
888 | Â Â Â Â Â Â Â Â Â Â } |
---|
889 | Â Â Â Â Â Â Â Â } |
---|
890 | Â Â Â Â Â Â } |
---|
891 | Â Â Â Â Â Â printf ("set %d of type %d has %d members - possible convexity row %d\n", |
---|
892 |           iObj, type, n, convex); |
---|
893 |       for (int i = 0; i < n; i++) { |
---|
894 | Â Â Â Â Â Â Â Â iColumn =Â which[i]; |
---|
895 | Â Â Â Â Â Â Â Â // Column may have been added |
---|
896 |         if (iColumn < numberColumns) { |
---|
897 |           int convex2 = -1; |
---|
898 |           for (j = columnStart[iColumn]; j < columnStart[iColumn] + columnLength[iColumn]; j++) { |
---|
899 |             int iRow = row[j]; |
---|
900 |             if (iRow == convex) { |
---|
901 |               double value = element[j]; |
---|
902 |               if (value == 1.0) { |
---|
903 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â convex2 =Â iRow; |
---|
904 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
905 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
906 | Â Â Â Â Â Â Â Â Â Â } |
---|
907 |           if (convex2<0 && convex >= 0) { |
---|
908 | Â Â Â Â Â Â Â Â Â Â Â Â printf("odd convexity row\n"); |
---|
909 | Â Â Â Â Â Â Â Â Â Â Â Â convex =Â -2; |
---|
910 | Â Â Â Â Â Â Â Â Â Â } |
---|
911 | #if COIN_DEVELOP>2 |
---|
912 | Â Â Â Â Â Â Â Â Â Â printf("col %d has weight %g and value %g, bounds %g %g\n", |
---|
913 |               iColumn, weight[i], solution[iColumn], columnLower[iColumn], |
---|
914 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â columnUpper[iColumn]); |
---|
915 | #endif |
---|
916 | Â Â Â Â Â Â Â Â } |
---|
917 | Â Â Â Â Â Â } |
---|
918 | Â Â Â Â } |
---|
919 | Â Â } |
---|
920 | #endif // COIN_DEVELOP |
---|
921 | } |
---|
922 | |
---|
923 | static int dummyCallBack(CbcModel * /*model*/, int /*whereFrom*/) |
---|
924 | { |
---|
925 |   return 0; |
---|
926 | } |
---|
927 | |
---|
928 | |
---|
929 | /* |
---|
930 | Â Global parameters for command processing. |
---|
931 | |
---|
932 | Â These will need to be moved into an object of some sort in order to make |
---|
933 | Â this set of calls thread-safe. |
---|
934 | */ |
---|
935 | |
---|
936 | int CbcOrClpRead_mode = 1; |
---|
937 | FILE *Â CbcOrClpReadCommand =Â stdin; |
---|
938 | extern int CbcOrClpEnvironmentIndex; |
---|
939 | static bool noPrinting = false; |
---|
940 | |
---|
941 | |
---|
942 | |
---|
943 | /* |
---|
944 | Â Wrappers for CbcMain0, CbcMain1. The various forms of callCbc will eventually |
---|
945 | Â resolve to a call to CbcMain0 followed by a call to callCbc1. |
---|
946 | */ |
---|
947 | /* |
---|
948 | Â Simplest calling form: supply just a string with the command options. The |
---|
949 | Â wrapper creates an OsiClpSolverInterface and calls the next wrapper. |
---|
950 | */ |
---|
951 | int callCbc(const std::string input2) |
---|
952 | { |
---|
953 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
954 | Â Â OsiClpSolverInterface solver1; |
---|
955 |   int returnCode = callCbc(input3, solver1); |
---|
956 | Â Â free(input3); |
---|
957 |   return returnCode; |
---|
958 | } |
---|
959 | |
---|
960 | int callCbc(const char * input2) |
---|
961 | { |
---|
962 | Â Â { |
---|
963 | Â Â Â Â OsiClpSolverInterface solver1; |
---|
964 |     return callCbc(input2, solver1); |
---|
965 | Â Â } |
---|
966 | } |
---|
967 | |
---|
968 | /* |
---|
969 | Â Second calling form: supply the command line and an OsiClpSolverInterface. |
---|
970 | Â the wrapper will create a CbcModel and call the next wrapper. |
---|
971 | */ |
---|
972 | |
---|
973 | int callCbc(const std::string input2, OsiClpSolverInterface& solver1) |
---|
974 | { |
---|
975 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
976 |   int returnCode = callCbc(input3, solver1); |
---|
977 | Â Â free(input3); |
---|
978 |   return returnCode; |
---|
979 | } |
---|
980 | |
---|
981 | int callCbc(const char * input2, OsiClpSolverInterface& solver1) |
---|
982 | { |
---|
983 | Â Â CbcModel model(solver1); |
---|
984 |   return callCbc(input2, model); |
---|
985 | } |
---|
986 | |
---|
987 | /* |
---|
988 | Â Third calling form: supply the command line and a CbcModel. This wrapper will |
---|
989 | Â actually call CbcMain0 and then call the next set of wrappers (callCbc1) to |
---|
990 | Â handle the call to CbcMain1. |
---|
991 | */ |
---|
992 | int callCbc(const char * input2, CbcModel & babSolver) |
---|
993 | { |
---|
994 | Â Â CbcMain0(babSolver); |
---|
995 |   return callCbc1(input2, babSolver); |
---|
996 | } |
---|
997 | |
---|
998 | int callCbc(const std::string input2, CbcModel & babSolver) |
---|
999 | { |
---|
1000 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1001 | Â Â CbcMain0(babSolver); |
---|
1002 |   int returnCode = callCbc1(input3, babSolver); |
---|
1003 | Â Â free(input3); |
---|
1004 |   return returnCode; |
---|
1005 | } |
---|
1006 | |
---|
1007 | |
---|
1008 | /* |
---|
1009 | Â Various overloads of callCbc1. The first pair accepts just a CbcModel and |
---|
1010 | Â supplements it with a dummy callback routine. The second pair allows the |
---|
1011 | Â user to supply a callback. See CbcMain1 for further explanation of the |
---|
1012 | Â callback. The various overloads of callCbc1 resolve to the final version, |
---|
1013 | Â which breaks the string into individual parameter strings (i.e., creates |
---|
1014 | Â something that looks like a standard argv vector). |
---|
1015 | */ |
---|
1016 | |
---|
1017 | int callCbc1(const std::string input2, CbcModel & babSolver) |
---|
1018 | { |
---|
1019 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1020 |   int returnCode = callCbc1(input3, babSolver); |
---|
1021 | Â Â free(input3); |
---|
1022 |   return returnCode; |
---|
1023 | } |
---|
1024 | |
---|
1025 | int callCbc1(const char * input2, CbcModel & model) |
---|
1026 | { |
---|
1027 |   return callCbc1(input2, model, dummyCallBack); |
---|
1028 | } |
---|
1029 | |
---|
1030 | int callCbc1(const std::string input2, CbcModel & babSolver, |
---|
1031 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1032 | { |
---|
1033 |   char * input3 = CoinStrdup(input2.c_str()); |
---|
1034 |   int returnCode = callCbc1(input3, babSolver, callBack); |
---|
1035 | Â Â free(input3); |
---|
1036 |   return returnCode; |
---|
1037 | } |
---|
1038 | |
---|
1039 | int callCbc1(const char * input2, CbcModel & model, |
---|
1040 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1041 | { |
---|
1042 |   char * input = CoinStrdup(input2); |
---|
1043 | Â Â size_t length =Â strlen(input); |
---|
1044 |   bool blank = input[0] == '0'; |
---|
1045 |   int n = blank ? 0 : 1; |
---|
1046 |   for (size_t i = 0; i < length; i++) { |
---|
1047 |     if (blank) { |
---|
1048 | Â Â Â Â Â Â // look for next non blank |
---|
1049 |       if (input[i] == ' ') { |
---|
1050 | Â Â Â Â Â Â Â Â continue; |
---|
1051 |       } else { |
---|
1052 | Â Â Â Â Â Â Â Â n++; |
---|
1053 | Â Â Â Â Â Â Â Â blank =Â false; |
---|
1054 | Â Â Â Â Â Â } |
---|
1055 |     } else { |
---|
1056 | Â Â Â Â Â Â // look for next blank |
---|
1057 |       if (input[i] != ' ') { |
---|
1058 | Â Â Â Â Â Â Â Â continue; |
---|
1059 |       } else { |
---|
1060 | Â Â Â Â Â Â Â Â blank =Â true; |
---|
1061 | Â Â Â Â Â Â } |
---|
1062 | Â Â Â Â } |
---|
1063 | Â Â } |
---|
1064 |   char ** argv = new char * [n+2]; |
---|
1065 | Â Â argv[0]Â =Â CoinStrdup("cbc"); |
---|
1066 | Â Â size_t i =Â 0; |
---|
1067 |   while (input[i] == ' ') |
---|
1068 | Â Â Â Â i++; |
---|
1069 |   for (int j = 0; j < n; j++) { |
---|
1070 | Â Â Â Â size_t saveI =Â i; |
---|
1071 |     for (; i < length; i++) { |
---|
1072 | Â Â Â Â Â Â // look for next blank |
---|
1073 |       if (input[i] != ' ') { |
---|
1074 | Â Â Â Â Â Â Â Â continue; |
---|
1075 |       } else { |
---|
1076 | Â Â Â Â Â Â Â Â break; |
---|
1077 | Â Â Â Â Â Â } |
---|
1078 | Â Â Â Â } |
---|
1079 | Â Â Â Â input[i]Â =Â '\0'; |
---|
1080 | Â Â Â Â argv[j+1]Â =Â CoinStrdup(input +Â saveI); |
---|
1081 |     while (input[i] == ' ') |
---|
1082 | Â Â Â Â Â Â i++; |
---|
1083 | Â Â } |
---|
1084 | Â Â argv[n+1]Â =Â CoinStrdup("-quit"); |
---|
1085 | Â Â free(input); |
---|
1086 | Â Â totalTime =Â 0.0; |
---|
1087 | Â Â currentBranchModel =Â NULL; |
---|
1088 | Â Â CbcOrClpRead_mode =Â 1; |
---|
1089 | Â Â CbcOrClpReadCommand =Â stdin; |
---|
1090 | Â Â noPrinting =Â false; |
---|
1091 |   int returnCode = CbcMain1(n + 2, const_cast<const char **>(argv), |
---|
1092 |                model, callBack); |
---|
1093 |   for (int k = 0; k < n + 2; k++) |
---|
1094 | Â Â Â Â free(argv[k]); |
---|
1095 |   delete [] argv; |
---|
1096 |   return returnCode; |
---|
1097 | } |
---|
1098 | |
---|
1099 | #define CBCMAXPARAMETERS 200 |
---|
1100 | static CbcOrClpParam parameters[CBCMAXPARAMETERS]; |
---|
1101 | static int numberParameters = 0 ; |
---|
1102 | CglPreProcess *Â cbcPreProcessPointer=NULL; |
---|
1103 | |
---|
1104 | int CbcClpUnitTest (const CbcModel & saveModel, |
---|
1105 |           const std::string& dirMiplib, int testSwitch, |
---|
1106 |           const double * stuff); |
---|
1107 | |
---|
1108 | int CbcMain1 (int argc, const char *argv[], |
---|
1109 |        CbcModel & model) |
---|
1110 | { |
---|
1111 |   return CbcMain1(argc, argv, model, dummyCallBack); |
---|
1112 | } |
---|
1113 | |
---|
1114 | |
---|
1115 | /* |
---|
1116 | Â Meaning of whereFrom: |
---|
1117 | Â Â 1 after initial solve by dualsimplex etc |
---|
1118 | Â Â 2 after preprocessing |
---|
1119 | Â Â 3 just before branchAndBound (so user can override) |
---|
1120 | Â Â 4 just after branchAndBound (before postprocessing) |
---|
1121 | Â Â 5 after postprocessing |
---|
1122 | Â Â 6 after a user called heuristic phase |
---|
1123 | */ |
---|
1124 | |
---|
1125 | int CbcMain1 (int argc, const char *argv[], |
---|
1126 |        CbcModel & model, |
---|
1127 |        int callBack(CbcModel * currentSolver, int whereFrom)) |
---|
1128 | { |
---|
1129 | Â Â CbcOrClpParam *Â parameters_ =Â parameters; |
---|
1130 |   int numberParameters_ = numberParameters; |
---|
1131 | Â Â CbcModel &Â model_ =Â model; |
---|
1132 | #ifdef CBC_USE_INITIAL_TIME |
---|
1133 |   if (model_.useElapsedTime()) |
---|
1134 |    model_.setDblParam(CbcModel::CbcStartSeconds, CoinGetTimeOfDay()); |
---|
1135 | Â Â else |
---|
1136 |    model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); |
---|
1137 | #endif |
---|
1138 | Â Â CbcModel *Â babModel_ =Â NULL; |
---|
1139 |   int returnMode = 1; |
---|
1140 | Â Â CbcOrClpRead_mode =Â 1; |
---|
1141 |   int statusUserFunction_[1]; |
---|
1142 |   int numberUserFunctions_ = 1; // to allow for ampl |
---|
1143 | Â Â // Statistics |
---|
1144 |   double statistics_seconds = 0.0, statistics_obj = 0.0; |
---|
1145 |   double statistics_sys_seconds = 0.0, statistics_elapsed_seconds = 0.0; |
---|
1146 | Â Â CoinWallclockTime(); |
---|
1147 |   double statistics_continuous = 0.0, statistics_tighter = 0.0; |
---|
1148 |   double statistics_cut_time = 0.0; |
---|
1149 |   int statistics_nodes = 0, statistics_iterations = 0; |
---|
1150 |   int statistics_nrows = 0, statistics_ncols = 0; |
---|
1151 |   int statistics_nprocessedrows = 0, statistics_nprocessedcols = 0; |
---|
1152 | Â Â std::string statistics_result; |
---|
1153 |   int * statistics_number_cuts = NULL; |
---|
1154 |   const char ** statistics_name_generators = NULL; |
---|
1155 |   int statistics_number_generators = 0; |
---|
1156 |   memset(statusUserFunction_, 0, numberUserFunctions_*sizeof(int)); |
---|
1157 | Â Â /* Note |
---|
1158 | Â Â Â Â This is meant as a stand-alone executable to do as much of coin as possible. |
---|
1159 | Â Â Â Â It should only have one solver known to it. |
---|
1160 | Â Â */ |
---|
1161 | Â Â CoinMessageHandler *Â generalMessageHandler =Â model_.messageHandler(); |
---|
1162 | Â Â generalMessageHandler->setPrefix(false); |
---|
1163 | #ifndef CBC_OTHER_SOLVER |
---|
1164 | Â Â OsiClpSolverInterface *Â originalSolver =Â dynamic_cast<OsiClpSolverInterface *>Â (model_.solver()); |
---|
1165 | Â Â assert (originalSolver); |
---|
1166 | Â Â // Move handler across if not default |
---|
1167 |   if (!originalSolver->defaultHandler() && originalSolver->getModelPtr()->defaultHandler()) |
---|
1168 | Â Â Â Â originalSolver->getModelPtr()->passInMessageHandler(originalSolver->messageHandler()); |
---|
1169 | Â Â CoinMessages generalMessages =Â originalSolver->getModelPtr()->messages(); |
---|
1170 |   char generalPrint[10000]; |
---|
1171 |   if (originalSolver->getModelPtr()->logLevel() == 0) |
---|
1172 | Â Â Â Â noPrinting =Â true; |
---|
1173 | #elif CBC_OTHER_SOLVER==1 |
---|
1174 | Â Â OsiCpxSolverInterface *Â originalSolver =Â dynamic_cast<OsiCpxSolverInterface *>Â (model_.solver()); |
---|
1175 | Â Â assert (originalSolver); |
---|
1176 | Â Â OsiClpSolverInterface dummySolver; |
---|
1177 | Â Â OsiCpxSolverInterface *Â clpSolver =Â originalSolver; |
---|
1178 | Â Â CoinMessages generalMessages =Â dummySolver.getModelPtr()->messages(); |
---|
1179 |   char generalPrint[10000]; |
---|
1180 | Â Â noPrinting =Â true; |
---|
1181 | #endif |
---|
1182 |   bool noPrinting_ = noPrinting; |
---|
1183 | Â Â // Say not in integer |
---|
1184 |   int integerStatus = -1; |
---|
1185 | Â Â // Say no resolve after cuts |
---|
1186 | Â Â model_.setResolveAfterTakeOffCuts(false); |
---|
1187 | Â Â // see if log in list |
---|
1188 |   for (int i = 1; i < argc; i++) { |
---|
1189 |     if (!strncmp(argv[i], "log", 3)) { |
---|
1190 |       const char * equals = strchr(argv[i], '='); |
---|
1191 |       if (equals && atoi(equals + 1) != 0) |
---|
1192 | Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1193 | Â Â Â Â Â Â else |
---|
1194 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1195 | Â Â Â Â Â Â break; |
---|
1196 |     } else if (!strncmp(argv[i], "-log", 4) && i < argc - 1) { |
---|
1197 |       if (atoi(argv[i+1]) != 0) |
---|
1198 | Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1199 | Â Â Â Â Â Â else |
---|
1200 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1201 | Â Â Â Â Â Â break; |
---|
1202 | Â Â Â Â } |
---|
1203 | Â Â } |
---|
1204 |   double time0; |
---|
1205 |   double time0Elapsed = CoinGetTimeOfDay(); |
---|
1206 | Â Â { |
---|
1207 |     double time1 = CoinCpuTime(), time2; |
---|
1208 | Â Â Â Â time0 =Â time1; |
---|
1209 |     double time1Elapsed = time0Elapsed; |
---|
1210 |     bool goodModel = (originalSolver->getNumCols()) ? true : false; |
---|
1211 | |
---|
1212 | Â Â Â Â // register signal handler |
---|
1213 | Â Â Â Â //CoinSighandler_t saveSignal=signal(SIGINT,signal_handler); |
---|
1214 | #ifndef CBC_QUIET |
---|
1215 |     signal(SIGINT, signal_handler); |
---|
1216 | #endif |
---|
1217 | Â Â Â Â // Set up all non-standard stuff |
---|
1218 |     int cutPass = -1234567; |
---|
1219 |     int cutPassInTree = -1234567; |
---|
1220 |     int tunePreProcess = 0; |
---|
1221 |     int testOsiParameters = -1; |
---|
1222 | Â Â Â Â // 0 normal, 1 from ampl or MIQP etc (2 allows cuts) |
---|
1223 |     int complicatedInteger = 0; |
---|
1224 | Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
1225 |     if (noPrinting_) |
---|
1226 | Â Â Â Â Â Â setCbcOrClpPrinting(false); |
---|
1227 | #ifndef CBC_OTHER_SOLVER |
---|
1228 | Â Â Â Â OsiClpSolverInterface *Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
1229 | Â Â Â Â ClpSimplex *Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1230 |     if (noPrinting_) { |
---|
1231 | Â Â Â Â Â Â lpSolver->setLogLevel(0); |
---|
1232 | Â Â Â Â } |
---|
1233 | #else |
---|
1234 | Â Â Â Â ClpSimplex *Â lpSolver =Â NULL; |
---|
1235 | #endif |
---|
1236 | Â Â Â Â // For priorities etc |
---|
1237 |     int * priorities = NULL; |
---|
1238 |     int * branchDirection = NULL; |
---|
1239 |     double * pseudoDown = NULL; |
---|
1240 |     double * pseudoUp = NULL; |
---|
1241 |     double * solutionIn = NULL; |
---|
1242 |     int * prioritiesIn = NULL; |
---|
1243 |     int numberSOS = 0; |
---|
1244 |     int * sosStart = NULL; |
---|
1245 |     int * sosIndices = NULL; |
---|
1246 |     char * sosType = NULL; |
---|
1247 |     double * sosReference = NULL; |
---|
1248 |     int * cut = NULL; |
---|
1249 |     int * sosPriority = NULL; |
---|
1250 | Â Â Â Â CglStored storedAmpl; |
---|
1251 | Â Â Â Â CoinModel *Â coinModel =Â NULL; |
---|
1252 | Â Â Â Â CoinModel saveCoinModel; |
---|
1253 | Â Â Â Â CoinModel saveTightenedModel; |
---|
1254 |     int * whichColumn = NULL; |
---|
1255 |     int * knapsackStart = NULL; |
---|
1256 |     int * knapsackRow = NULL; |
---|
1257 |     int numberKnapsack = 0; |
---|
1258 | #ifdef COIN_HAS_ASL |
---|
1259 | Â Â Â Â ampl_info info; |
---|
1260 | Â Â Â Â { |
---|
1261 |       memset(&info, 0, sizeof(info)); |
---|
1262 |       if (argc > 2 && !strcmp(argv[2], "-AMPL")) { |
---|
1263 | Â Â Â Â Â Â Â Â statusUserFunction_[0]Â =Â 1; |
---|
1264 | Â Â Â Â Â Â Â Â // see if log in list |
---|
1265 | Â Â Â Â Â Â Â Â noPrinting_ =Â true; |
---|
1266 |         for (int i = 1; i < argc; i++) { |
---|
1267 |           if (!strncmp(argv[i], "log", 3)) { |
---|
1268 |             const char * equals = strchr(argv[i], '='); |
---|
1269 |             if (equals && atoi(equals + 1) > 0) { |
---|
1270 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.logLevel =Â atoi(equals +Â 1); |
---|
1272 |               int log = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
1273 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[log].setIntValue(info.logLevel); |
---|
1274 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // mark so won't be overWritten |
---|
1275 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.numberRows =Â -1234567; |
---|
1276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1277 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1278 | Â Â Â Â Â Â Â Â Â Â } |
---|
1279 | Â Â Â Â Â Â Â Â } |
---|
1280 | |
---|
1281 |         union { |
---|
1282 |           void * voidModel; |
---|
1283 | Â Â Â Â Â Â Â Â Â Â CoinModel *Â model; |
---|
1284 | Â Â Â Â Â Â Â Â }Â coinModelStart; |
---|
1285 | Â Â Â Â Â Â Â Â coinModelStart.model =Â NULL; |
---|
1286 |         int returnCode = readAmpl(&info, argc, const_cast<char **>(argv), & coinModelStart.voidModel); |
---|
1287 | Â Â Â Â Â Â Â Â coinModel =Â coinModelStart.model; |
---|
1288 |         if (returnCode) |
---|
1289 |           return returnCode; |
---|
1290 | Â Â Â Â Â Â Â Â CbcOrClpRead_mode =Â 2;Â // so will start with parameters |
---|
1291 | Â Â Â Â Â Â Â Â // see if log in list (including environment) |
---|
1292 |         for (int i = 1; i < info.numberArguments; i++) { |
---|
1293 |           if (!strcmp(info.arguments[i], "log")) { |
---|
1294 |             if (i < info.numberArguments - 1 && atoi(info.arguments[i+1]) > 0) |
---|
1295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â noPrinting_ =Â false; |
---|
1296 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1297 | Â Â Â Â Â Â Â Â Â Â } |
---|
1298 | Â Â Â Â Â Â Â Â } |
---|
1299 |         if (noPrinting_) { |
---|
1300 | Â Â Â Â Â Â Â Â Â Â model_.messageHandler()->setLogLevel(0); |
---|
1301 | Â Â Â Â Â Â Â Â Â Â setCbcOrClpPrinting(false); |
---|
1302 | Â Â Â Â Â Â Â Â } |
---|
1303 |         if (!noPrinting_) |
---|
1304 | Â Â Â Â Â Â Â Â Â Â printf("%d rows, %d columns and %d elements\n", |
---|
1305 |               info.numberRows, info.numberColumns, info.numberElements); |
---|
1306 | #ifdef COIN_HAS_LINK |
---|
1307 |         if (!coinModel) { |
---|
1308 | #endif |
---|
1309 |           solver->loadProblem(info.numberColumns, info.numberRows, info.starts, |
---|
1310 |                     info.rows, info.elements, |
---|
1311 |                     info.columnLower, info.columnUpper, info.objective, |
---|
1312 |                     info.rowLower, info.rowUpper); |
---|
1313 | Â Â Â Â Â Â Â Â Â Â // take off cuts if ampl wants that |
---|
1314 |           if (info.cut && 0) { |
---|
1315 | Â Â Â Â Â Â Â Â Â Â Â Â printf("AMPL CUTS OFF until global cuts fixed\n"); |
---|
1316 | Â Â Â Â Â Â Â Â Â Â Â Â info.cut =Â NULL; |
---|
1317 | Â Â Â Â Â Â Â Â Â Â } |
---|
1318 |           if (info.cut) { |
---|
1319 |             int numberRows = info.numberRows; |
---|
1320 |             int * whichRow = new int [numberRows]; |
---|
1321 | Â Â Â Â Â Â Â Â Â Â Â Â // Row copy |
---|
1322 |             const CoinPackedMatrix * matrixByRow = solver->getMatrixByRow(); |
---|
1323 |             const double * elementByRow = matrixByRow->getElements(); |
---|
1324 |             const int * column = matrixByRow->getIndices(); |
---|
1325 |             const CoinBigIndex * rowStart = matrixByRow->getVectorStarts(); |
---|
1326 |             const int * rowLength = matrixByRow->getVectorLengths(); |
---|
1327 | |
---|
1328 |             const double * rowLower = solver->getRowLower(); |
---|
1329 |             const double * rowUpper = solver->getRowUpper(); |
---|
1330 |             int nDelete = 0; |
---|
1331 |             for (int iRow = 0; iRow < numberRows; iRow++) { |
---|
1332 |               if (info.cut[iRow]) { |
---|
1333 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â whichRow[nDelete++]Â =Â iRow; |
---|
1334 |                 int start = rowStart[iRow]; |
---|
1335 |                 storedAmpl.addCut(rowLower[iRow], rowUpper[iRow], |
---|
1336 |                          rowLength[iRow], column + start, elementByRow + start); |
---|
1337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1338 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1339 |             solver->deleteRows(nDelete, whichRow); |
---|
1340 |             delete [] whichRow; |
---|
1341 | Â Â Â Â Â Â Â Â Â Â } |
---|
1342 | #ifdef COIN_HAS_LINK |
---|
1343 |         } else { |
---|
1344 | #ifndef CBC_OTHER_SOLVER |
---|
1345 | Â Â Â Â Â Â Â Â Â Â // save |
---|
1346 | Â Â Â Â Â Â Â Â Â Â saveCoinModel =Â *coinModel; |
---|
1347 | Â Â Â Â Â Â Â Â Â Â // load from coin model |
---|
1348 | Â Â Â Â Â Â Â Â Â Â OsiSolverLink solver1; |
---|
1349 | Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2 =Â solver1.clone(); |
---|
1350 |           model_.assignSolver(solver2, false); |
---|
1351 | Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â si = |
---|
1352 | Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiSolverLink *>(model_.solver())Â ; |
---|
1353 | Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
1354 | Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(0.001); |
---|
1355 | Â Â Â Â Â Â Â Â Â Â // need some relative granularity |
---|
1356 | Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100.0); |
---|
1357 |           double dextra3 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
1358 |           if (dextra3) |
---|
1359 | Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(dextra3); |
---|
1360 | Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100000.0); |
---|
1361 | Â Â Â Â Â Â Â Â Â Â si->setIntegerPriority(1000); |
---|
1362 | Â Â Â Â Â Â Â Â Â Â si->setBiLinearPriority(10000); |
---|
1363 | Â Â Â Â Â Â Â Â Â Â CoinModel *Â model2 =Â reinterpret_cast<CoinModel *>Â (coinModel); |
---|
1364 |           int logLevel = parameters_[whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_)].intValue(); |
---|
1365 |           si->load(*model2, true, logLevel); |
---|
1366 | Â Â Â Â Â Â Â Â Â Â // redo |
---|
1367 | Â Â Â Â Â Â Â Â Â Â solver =Â model_.solver(); |
---|
1368 | Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
1369 | Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1370 | Â Â Â Â Â Â Â Â Â Â clpSolver->messageHandler()->setLogLevel(0)Â ; |
---|
1371 | Â Â Â Â Â Â Â Â Â Â testOsiParameters =Â 0; |
---|
1372 |           parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(0); |
---|
1373 | Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 1; |
---|
1374 |           if (info.cut) { |
---|
1375 | Â Â Â Â Â Â Â Â Â Â Â Â printf("Sorry - can't do cuts with LOS as ruins delicate row order\n"); |
---|
1376 | Â Â Â Â Â Â Â Â Â Â Â Â abort(); |
---|
1377 |             int numberRows = info.numberRows; |
---|
1378 |             int * whichRow = new int [numberRows]; |
---|
1379 | Â Â Â Â Â Â Â Â Â Â Â Â // Row copy |
---|
1380 |             const CoinPackedMatrix * matrixByRow = solver->getMatrixByRow(); |
---|
1381 |             const double * elementByRow = matrixByRow->getElements(); |
---|
1382 |             const int * column = matrixByRow->getIndices(); |
---|
1383 |             const CoinBigIndex * rowStart = matrixByRow->getVectorStarts(); |
---|
1384 |             const int * rowLength = matrixByRow->getVectorLengths(); |
---|
1385 | |
---|
1386 |             const double * rowLower = solver->getRowLower(); |
---|
1387 |             const double * rowUpper = solver->getRowUpper(); |
---|
1388 |             int nDelete = 0; |
---|
1389 |             for (int iRow = 0; iRow < numberRows; iRow++) { |
---|
1390 |               if (info.cut[iRow]) { |
---|
1391 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â whichRow[nDelete++]Â =Â iRow; |
---|
1392 |                 int start = rowStart[iRow]; |
---|
1393 |                 storedAmpl.addCut(rowLower[iRow], rowUpper[iRow], |
---|
1394 |                          rowLength[iRow], column + start, elementByRow + start); |
---|
1395 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1396 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1397 |             solver->deleteRows(nDelete, whichRow); |
---|
1398 | Â Â Â Â Â Â Â Â Â Â Â Â // and special matrix |
---|
1399 |             si->cleanMatrix()->deleteRows(nDelete, whichRow); |
---|
1400 |             delete [] whichRow; |
---|
1401 | Â Â Â Â Â Â Â Â Â Â } |
---|
1402 | #endif |
---|
1403 | Â Â Â Â Â Â Â Â } |
---|
1404 | #endif |
---|
1405 | Â Â Â Â Â Â Â Â // If we had a solution use it |
---|
1406 |         if (info.primalSolution) { |
---|
1407 | Â Â Â Â Â Â Â Â Â Â solver->setColSolution(info.primalSolution); |
---|
1408 | Â Â Â Â Â Â Â Â } |
---|
1409 | Â Â Â Â Â Â Â Â // status |
---|
1410 |         if (info.rowStatus) { |
---|
1411 |           unsigned char * statusArray = lpSolver->statusArray(); |
---|
1412 |           int i; |
---|
1413 |           for (i = 0; i < info.numberColumns; i++) |
---|
1414 |             statusArray[i] = static_cast<unsigned char>(info.columnStatus[i]); |
---|
1415 | Â Â Â Â Â Â Â Â Â Â statusArray +=Â info.numberColumns; |
---|
1416 |           for (i = 0; i < info.numberRows; i++) |
---|
1417 |             statusArray[i] = static_cast<unsigned char>(info.rowStatus[i]); |
---|
1418 | Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â lpSolver->getBasis(); |
---|
1419 | Â Â Â Â Â Â Â Â Â Â solver->setWarmStart(basis); |
---|
1420 |           delete basis; |
---|
1421 | Â Â Â Â Â Â Â Â } |
---|
1422 | Â Â Â Â Â Â Â Â freeArrays1(&info); |
---|
1423 | Â Â Â Â Â Â Â Â // modify objective if necessary |
---|
1424 | Â Â Â Â Â Â Â Â solver->setObjSense(info.direction); |
---|
1425 |         solver->setDblParam(OsiObjOffset, info.offset); |
---|
1426 |         if (info.offset) { |
---|
1427 |           sprintf(generalPrint, "Ampl objective offset is %g", |
---|
1428 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.offset); |
---|
1429 |           generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1430 | Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
1431 | Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1432 | Â Â Â Â Â Â Â Â } |
---|
1433 | Â Â Â Â Â Â Â Â // Set integer variables (unless nonlinear when set) |
---|
1434 |         if (!info.nonLinear) { |
---|
1435 |           for (int i = info.numberColumns - info.numberIntegers; |
---|
1436 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â i <Â info.numberColumns;Â i++) |
---|
1437 | Â Â Â Â Â Â Â Â Â Â Â Â solver->setInteger(i); |
---|
1438 | Â Â Â Â Â Â Â Â } |
---|
1439 | Â Â Â Â Â Â Â Â goodModel =Â true; |
---|
1440 | Â Â Â Â Â Â Â Â // change argc etc |
---|
1441 | Â Â Â Â Â Â Â Â argc =Â info.numberArguments; |
---|
1442 |         argv = const_cast<const char **>(info.arguments); |
---|
1443 | Â Â Â Â Â Â } |
---|
1444 | Â Â Â Â } |
---|
1445 | #endif |
---|
1446 | Â Â Â Â // default action on import |
---|
1447 |     int allowImportErrors = 0; |
---|
1448 |     int keepImportNames = 1; |
---|
1449 |     int doIdiot = -1; |
---|
1450 |     int outputFormat = 2; |
---|
1451 |     int slpValue = -1; |
---|
1452 |     int cppValue = -1; |
---|
1453 |     int printOptions = 0; |
---|
1454 |     int printMode = 0; |
---|
1455 |     int presolveOptions = 0; |
---|
1456 |     int substitution = 3; |
---|
1457 |     int dualize = 3; |
---|
1458 |     int doCrash = 0; |
---|
1459 |     int doVector = 0; |
---|
1460 |     int doSprint = -1; |
---|
1461 |     int doScaling = 4; |
---|
1462 | Â Â Â Â // set reasonable defaults |
---|
1463 |     int preSolve = 5; |
---|
1464 |     int preProcess = 4; |
---|
1465 |     bool useStrategy = false; |
---|
1466 |     bool preSolveFile = false; |
---|
1467 |     bool strongChanged = false; |
---|
1468 |     bool pumpChanged = false; |
---|
1469 | |
---|
1470 |     double djFix = 1.0e100; |
---|
1471 |     double tightenFactor = 0.0; |
---|
1472 |     const char dirsep = CoinFindDirSeparator(); |
---|
1473 | Â Â Â Â std::string directory; |
---|
1474 | Â Â Â Â std::string dirSample; |
---|
1475 | Â Â Â Â std::string dirNetlib; |
---|
1476 | Â Â Â Â std::string dirMiplib; |
---|
1477 |     if (dirsep == '/') { |
---|
1478 | Â Â Â Â Â Â directory =Â "./"; |
---|
1479 | Â Â Â Â Â Â dirSample =Â "../../Data/Sample/"; |
---|
1480 | Â Â Â Â Â Â dirNetlib =Â "../../Data/Netlib/"; |
---|
1481 | Â Â Â Â Â Â dirMiplib =Â "../../Data/miplib3/"; |
---|
1482 |     } else { |
---|
1483 | Â Â Â Â Â Â directory =Â ".\\"; |
---|
1484 | Â Â Â Â Â Â dirSample =Â "..\\..\\..\\..\\Data\\Sample\\"; |
---|
1485 | Â Â Â Â Â Â dirNetlib =Â "..\\..\\..\\..\\Data\\Netlib\\"; |
---|
1486 | Â Â Â Â Â Â dirMiplib =Â "..\\..\\..\\..\\Data\\miplib3\\"; |
---|
1487 | Â Â Â Â } |
---|
1488 | Â Â Â Â std::string defaultDirectory =Â directory; |
---|
1489 | Â Â Â Â std::string importFile =Â ""; |
---|
1490 | Â Â Â Â std::string exportFile =Â "default.mps"; |
---|
1491 | Â Â Â Â std::string importBasisFile =Â ""; |
---|
1492 | Â Â Â Â std::string importPriorityFile =Â ""; |
---|
1493 | Â Â Â Â std::string debugFile =Â ""; |
---|
1494 | Â Â Â Â std::string printMask =Â ""; |
---|
1495 |     double * debugValues = NULL; |
---|
1496 |     int numberDebugValues = -1; |
---|
1497 |     int basisHasValues = 0; |
---|
1498 | Â Â Â Â std::string exportBasisFile =Â "default.bas"; |
---|
1499 | Â Â Â Â std::string saveFile =Â "default.prob"; |
---|
1500 | Â Â Â Â std::string restoreFile =Â "default.prob"; |
---|
1501 | Â Â Â Â std::string solutionFile =Â "stdout"; |
---|
1502 | Â Â Â Â std::string solutionSaveFile =Â "solution.file"; |
---|
1503 |     int slog = whichParam(CLP_PARAM_INT_SOLVERLOGLEVEL, numberParameters_, parameters_); |
---|
1504 |     int log = whichParam(CLP_PARAM_INT_LOGLEVEL, numberParameters_, parameters_); |
---|
1505 | #ifndef CBC_OTHER_SOLVER |
---|
1506 |     double normalIncrement = model_.getCutoffIncrement();; |
---|
1507 | #endif |
---|
1508 |     if (testOsiParameters >= 0) { |
---|
1509 | Â Â Â Â Â Â // trying nonlinear - switch off some stuff |
---|
1510 | Â Â Â Â Â Â preProcess =Â 0; |
---|
1511 | Â Â Â Â } |
---|
1512 | Â Â Â Â // Set up likely cut generators and defaults |
---|
1513 |     int nodeStrategy = 0; |
---|
1514 |     bool dominatedCuts = false; |
---|
1515 |     int doSOS = 1; |
---|
1516 |     int verbose = 0; |
---|
1517 | Â Â Â Â CglGomory gomoryGen; |
---|
1518 | Â Â Â Â // try larger limit |
---|
1519 | Â Â Â Â gomoryGen.setLimitAtRoot(1000); |
---|
1520 | Â Â Â Â gomoryGen.setLimit(50); |
---|
1521 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1522 |     int gomoryAction = 3; |
---|
1523 | |
---|
1524 | Â Â Â Â CglProbing probingGen; |
---|
1525 | Â Â Â Â probingGen.setUsingObjective(1); |
---|
1526 | Â Â Â Â probingGen.setMaxPass(1); |
---|
1527 | Â Â Â Â probingGen.setMaxPassRoot(1); |
---|
1528 | Â Â Â Â // Number of unsatisfied variables to look at |
---|
1529 | Â Â Â Â probingGen.setMaxProbe(10); |
---|
1530 | Â Â Â Â probingGen.setMaxProbeRoot(50); |
---|
1531 | Â Â Â Â // How far to follow the consequences |
---|
1532 | Â Â Â Â probingGen.setMaxLook(10); |
---|
1533 | Â Â Â Â probingGen.setMaxLookRoot(50); |
---|
1534 | Â Â Â Â probingGen.setMaxLookRoot(10); |
---|
1535 | Â Â Â Â // Only look at rows with fewer than this number of elements |
---|
1536 | Â Â Â Â probingGen.setMaxElements(200); |
---|
1537 | Â Â Â Â probingGen.setMaxElementsRoot(300); |
---|
1538 | Â Â Â Â probingGen.setRowCuts(3); |
---|
1539 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1540 |     int probingAction = 1; |
---|
1541 | |
---|
1542 | Â Â Â Â CglKnapsackCover knapsackGen; |
---|
1543 | Â Â Â Â //knapsackGen.switchOnExpensive(); |
---|
1544 | Â Â Â Â //knapsackGen.setMaxInKnapsack(100); |
---|
1545 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1546 |     int knapsackAction = 3; |
---|
1547 | |
---|
1548 | Â Â Â Â CglRedSplit redsplitGen; |
---|
1549 | Â Â Â Â //redsplitGen.setLimit(100); |
---|
1550 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1551 | Â Â Â Â // Off as seems to give some bad cuts |
---|
1552 |     int redsplitAction = 0; |
---|
1553 | |
---|
1554 |     CglFakeClique cliqueGen(NULL, false); |
---|
1555 | Â Â Â Â //CglClique cliqueGen(false,true); |
---|
1556 | Â Â Â Â cliqueGen.setStarCliqueReport(false); |
---|
1557 | Â Â Â Â cliqueGen.setRowCliqueReport(false); |
---|
1558 | Â Â Â Â cliqueGen.setMinViolation(0.1); |
---|
1559 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1560 |     int cliqueAction = 3; |
---|
1561 | |
---|
1562 | Â Â Â Â // maxaggr,multiply,criterion(1-3) |
---|
1563 |     CglMixedIntegerRounding2 mixedGen(1, true, 1); |
---|
1564 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1565 |     int mixedAction = 3; |
---|
1566 | |
---|
1567 | Â Â Â Â CglFlowCover flowGen; |
---|
1568 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1569 |     int flowAction = 3; |
---|
1570 | |
---|
1571 | Â Â Â Â CglTwomir twomirGen; |
---|
1572 | Â Â Â Â twomirGen.setMaxElements(250); |
---|
1573 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1574 |     int twomirAction = 2; |
---|
1575 | #ifndef DEBUG_MALLOC |
---|
1576 | Â Â Â Â CglLandP landpGen; |
---|
1577 | #endif |
---|
1578 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1579 |     int landpAction = 0; |
---|
1580 | Â Â Â Â CglResidualCapacity residualCapacityGen; |
---|
1581 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1582 |     int residualCapacityAction = 0; |
---|
1583 | |
---|
1584 | #ifdef ZERO_HALF_CUTS |
---|
1585 | Â Â Â Â CglZeroHalf zerohalfGen; |
---|
1586 | Â Â Â Â //zerohalfGen.switchOnExpensive(); |
---|
1587 | Â Â Â Â // set default action (0=off,1=on,2=root) |
---|
1588 |     int zerohalfAction = 0; |
---|
1589 | #endif |
---|
1590 | |
---|
1591 | Â Â Â Â // Stored cuts |
---|
1592 | Â Â Â Â //bool storedCuts = false; |
---|
1593 | |
---|
1594 |     int useCosts = 0; |
---|
1595 | Â Â Â Â // don't use input solution |
---|
1596 |     int useSolution = -1; |
---|
1597 | |
---|
1598 | Â Â Â Â // total number of commands read |
---|
1599 |     int numberGoodCommands = 0; |
---|
1600 | Â Â Â Â // Set false if user does anything advanced |
---|
1601 |     bool defaultSettings = true; |
---|
1602 | |
---|
1603 | Â Â Â Â // Hidden stuff for barrier |
---|
1604 |     int choleskyType = 0; |
---|
1605 |     int gamma = 0; |
---|
1606 |     int scaleBarrier = 0; |
---|
1607 |     int doKKT = 0; |
---|
1608 |     int crossover = 2; // do crossover unless quadratic |
---|
1609 | Â Â Â Â // For names |
---|
1610 |     int lengthName = 0; |
---|
1611 | Â Â Â Â std::vector<std::string>Â rowNames; |
---|
1612 | Â Â Â Â std::vector<std::string>Â columnNames; |
---|
1613 | Â Â Â Â // Default strategy stuff |
---|
1614 | Â Â Â Â { |
---|
1615 | Â Â Â Â Â Â // try changing tolerance at root |
---|
1616 | #define MORE_CUTS |
---|
1617 | #ifdef MORE_CUTS |
---|
1618 | Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.005); |
---|
1619 | Â Â Â Â Â Â twomirGen.setAwayAtRoot(0.005); |
---|
1620 | Â Â Â Â Â Â twomirGen.setAway(0.01); |
---|
1621 | Â Â Â Â Â Â //twomirGen.setMirScale(1,1); |
---|
1622 | Â Â Â Â Â Â //twomirGen.setTwomirScale(1,1); |
---|
1623 | Â Â Â Â Â Â //twomirGen.setAMax(2); |
---|
1624 | #else |
---|
1625 | Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.01); |
---|
1626 | Â Â Â Â Â Â twomirGen.setAwayAtRoot(0.01); |
---|
1627 | Â Â Â Â Â Â twomirGen.setAway(0.01); |
---|
1628 | #endif |
---|
1629 |       int iParam; |
---|
1630 |       iParam = whichParam(CBC_PARAM_INT_DIVEOPT, numberParameters_, parameters_); |
---|
1631 | Â Â Â Â Â Â parameters_[iParam].setIntValue(3); |
---|
1632 |       iParam = whichParam(CBC_PARAM_INT_FPUMPITS, numberParameters_, parameters_); |
---|
1633 | Â Â Â Â Â Â parameters_[iParam].setIntValue(30); |
---|
1634 |       iParam = whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_); |
---|
1635 | Â Â Â Â Â Â parameters_[iParam].setIntValue(1005043); |
---|
1636 | Â Â Â Â Â Â initialPumpTune =Â 1005043; |
---|
1637 |       iParam = whichParam(CLP_PARAM_INT_PROCESSTUNE, numberParameters_, parameters_); |
---|
1638 | Â Â Â Â Â Â parameters_[iParam].setIntValue(6); |
---|
1639 | Â Â Â Â Â Â tunePreProcess =Â 6; |
---|
1640 |       iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
1641 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1642 |       iParam = whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_); |
---|
1643 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1644 |       iParam = whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_); |
---|
1645 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
1646 | Â Â Â Â Â Â probingAction =Â 1; |
---|
1647 | Â Â Â Â Â Â parameters_[iParam].setCurrentOption("forceOnStrong"); |
---|
1648 | Â Â Â Â Â Â probingAction =Â 8; |
---|
1649 | Â Â Â Â } |
---|
1650 | Â Â Â Â std::string field; |
---|
1651 | #ifndef CBC_QUIET |
---|
1652 |     if (!noPrinting_) { |
---|
1653 | Â Â Â Â Â Â sprintf(generalPrint, |
---|
1654 | Â Â Â Â Â Â Â Â Â Â "Welcome to the CBC MILP Solver \n"); |
---|
1655 |       if (strcmp(CBC_VERSION, "trunk")){ |
---|
1656 | Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1657 |             "Version: %s \n", CBC_VERSION); |
---|
1658 | Â Â Â Â Â Â }else{ |
---|
1659 | Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1660 | Â Â Â Â Â Â Â Â Â Â Â Â "Version: Trunk (unstable) \n"); |
---|
1661 | Â Â Â Â Â Â } |
---|
1662 | Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1663 |           "Build Date: %s \n", __DATE__); |
---|
1664 | #ifdef CBC_SVN_REV |
---|
1665 | Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
1666 |           "Revision Number: %d \n", CBC_SVN_REV); |
---|
1667 | #endif |
---|
1668 |       generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1669 | Â Â Â Â Â Â <<Â generalPrint |
---|
1670 | Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1671 | Â Â Â Â Â Â // Print command line |
---|
1672 |       if (argc > 1) { |
---|
1673 |         bool foundStrategy = false; |
---|
1674 |         sprintf(generalPrint, "command line - "); |
---|
1675 |         for (int i = 0; i < argc; i++) { |
---|
1676 |           if (!argv[i]) |
---|
1677 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1678 |           if (strstr(argv[i], "strat")) |
---|
1679 | Â Â Â Â Â Â Â Â Â Â Â Â foundStrategy =Â true; |
---|
1680 |           sprintf(generalPrint + strlen(generalPrint), "%s ", argv[i]); |
---|
1681 | Â Â Â Â Â Â Â Â } |
---|
1682 |         if (!foundStrategy) |
---|
1683 |           sprintf(generalPrint + strlen(generalPrint), "(default strategy 1)"); |
---|
1684 |         generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1685 | Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
1686 | Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1687 | Â Â Â Â Â Â } |
---|
1688 | Â Â Â Â } |
---|
1689 | #endif |
---|
1690 |     while (1) { |
---|
1691 | Â Â Â Â Â Â // next command |
---|
1692 |       field = CoinReadGetCommand(argc, argv); |
---|
1693 | Â Â Â Â Â Â // Reset time |
---|
1694 | Â Â Â Â Â Â time1 =Â CoinCpuTime(); |
---|
1695 | Â Â Â Â Â Â time1Elapsed =Â CoinGetTimeOfDay(); |
---|
1696 | Â Â Â Â Â Â // adjust field if has odd trailing characters |
---|
1697 |       char temp [200]; |
---|
1698 |       strcpy(temp, field.c_str()); |
---|
1699 |       int length = static_cast<int>(strlen(temp)); |
---|
1700 |       for (int k = length - 1; k >= 0; k--) { |
---|
1701 |         if (temp[k] < ' ') |
---|
1702 | Â Â Â Â Â Â Â Â Â Â length--; |
---|
1703 | Â Â Â Â Â Â Â Â else |
---|
1704 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1705 | Â Â Â Â Â Â } |
---|
1706 | Â Â Â Â Â Â temp[length]Â =Â '\0'; |
---|
1707 | Â Â Â Â Â Â field =Â temp; |
---|
1708 | Â Â Â Â Â Â // exit if null or similar |
---|
1709 |       if (!field.length()) { |
---|
1710 |         if (numberGoodCommands == 1 && goodModel) { |
---|
1711 | Â Â Â Â Â Â Â Â Â Â // we just had file name - do branch and bound |
---|
1712 | Â Â Â Â Â Â Â Â Â Â field =Â "branch"; |
---|
1713 |         } else if (!numberGoodCommands) { |
---|
1714 | Â Â Â Â Â Â Â Â Â Â // let's give the sucker a hint |
---|
1715 | Â Â Â Â Â Â Â Â Â Â std::cout |
---|
1716 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â "CoinSolver takes input from arguments ( - switches to stdin)" |
---|
1717 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â std::endl |
---|
1718 | Â Â Â Â Â Â Â Â Â Â Â Â <<Â "Enter ? for list of commands or help"Â <<Â std::endl; |
---|
1719 | Â Â Â Â Â Â Â Â Â Â field =Â "-"; |
---|
1720 |         } else { |
---|
1721 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1722 | Â Â Â Â Â Â Â Â } |
---|
1723 | Â Â Â Â Â Â } |
---|
1724 | |
---|
1725 | Â Â Â Â Â Â // see if ? at end |
---|
1726 | Â Â Â Â Â Â size_t numberQuery =Â 0; |
---|
1727 |       if (field != "?" && field != "???") { |
---|
1728 | Â Â Â Â Â Â Â Â size_t length =Â field.length(); |
---|
1729 | Â Â Â Â Â Â Â Â size_t i; |
---|
1730 |         for (i = length - 1; i > 0; i--) { |
---|
1731 |           if (field[i] == '?') |
---|
1732 | Â Â Â Â Â Â Â Â Â Â Â Â numberQuery++; |
---|
1733 | Â Â Â Â Â Â Â Â Â Â else |
---|
1734 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1735 | Â Â Â Â Â Â Â Â } |
---|
1736 |         field = field.substr(0, length - numberQuery); |
---|
1737 | Â Â Â Â Â Â } |
---|
1738 | Â Â Â Â Â Â // find out if valid command |
---|
1739 |       int iParam; |
---|
1740 |       int numberMatches = 0; |
---|
1741 |       int firstMatch = -1; |
---|
1742 |       for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
1743 |         int match = parameters_[iParam].matches(field); |
---|
1744 |         if (match == 1) { |
---|
1745 | Â Â Â Â Â Â Â Â Â Â numberMatches =Â 1; |
---|
1746 | Â Â Â Â Â Â Â Â Â Â firstMatch =Â iParam; |
---|
1747 | Â Â Â Â Â Â Â Â Â Â break; |
---|
1748 |         } else { |
---|
1749 |           if (match && firstMatch < 0) |
---|
1750 | Â Â Â Â Â Â Â Â Â Â Â Â firstMatch =Â iParam; |
---|
1751 | Â Â Â Â Â Â Â Â Â Â numberMatches +=Â match >>Â 1; |
---|
1752 | Â Â Â Â Â Â Â Â } |
---|
1753 | Â Â Â Â Â Â } |
---|
1754 |       if (iParam < numberParameters_ && !numberQuery) { |
---|
1755 | Â Â Â Â Â Â Â Â // found |
---|
1756 | Â Â Â Â Â Â Â Â CbcOrClpParam found =Â parameters_[iParam]; |
---|
1757 | Â Â Â Â Â Â Â Â CbcOrClpParameterType type =Â found.type(); |
---|
1758 |         int valid; |
---|
1759 | Â Â Â Â Â Â Â Â numberGoodCommands++; |
---|
1760 |         if (type == CBC_PARAM_ACTION_BAB && goodModel) { |
---|
1761 | #ifndef CBC_USE_INITIAL_TIME |
---|
1762 |          if (model_.useElapsedTime()) |
---|
1763 |           model_.setDblParam(CbcModel::CbcStartSeconds, CoinGetTimeOfDay()); |
---|
1764 | Â Â Â Â Â Â Â Â Â else |
---|
1765 |           model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); |
---|
1766 | #endif |
---|
1767 | Â Â Â Â Â Â Â Â Â Â // check if any integers |
---|
1768 | #ifndef CBC_OTHER_SOLVER |
---|
1769 | #ifdef COIN_HAS_ASL |
---|
1770 |           if (info.numberSos && doSOS && statusUserFunction_[0]) { |
---|
1771 | Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
1772 | Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â info.numberSos; |
---|
1773 | Â Â Â Â Â Â Â Â Â Â } |
---|
1774 | #endif |
---|
1775 | Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1776 |           if (!lpSolver->integerInformation() && !numberSOS && |
---|
1777 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â !clpSolver->numberSOS()Â &&Â !model_.numberObjects()Â &&Â !clpSolver->numberObjects()) |
---|
1778 | Â Â Â Â Â Â Â Â Â Â Â Â type =Â CLP_PARAM_ACTION_DUALSIMPLEX; |
---|
1779 | #endif |
---|
1780 | Â Â Â Â Â Â Â Â } |
---|
1781 |         if (type == CBC_PARAM_GENERALQUERY) { |
---|
1782 |           bool evenHidden = false; |
---|
1783 |           int printLevel = |
---|
1784 | Â Â Â Â Â Â Â Â Â Â Â Â parameters_[whichParam(CLP_PARAM_STR_ALLCOMMANDS, |
---|
1785 |                         numberParameters_, parameters_)].currentOptionAsInteger(); |
---|
1786 |           int convertP[] = {2, 1, 0}; |
---|
1787 | Â Â Â Â Â Â Â Â Â Â printLevel =Â convertP[printLevel]; |
---|
1788 |           if ((verbose&8) != 0) { |
---|
1789 | Â Â Â Â Â Â Â Â Â Â Â Â // even hidden |
---|
1790 | Â Â Â Â Â Â Â Â Â Â Â Â evenHidden =Â true; |
---|
1791 | Â Â Â Â Â Â Â Â Â Â Â Â verbose &=Â ~8; |
---|
1792 | Â Â Â Â Â Â Â Â Â Â } |
---|
1793 | #ifdef COIN_HAS_ASL |
---|
1794 |           if (verbose < 4 && statusUserFunction_[0]) |
---|
1795 | Â Â Â Â Â Â Â Â Â Â Â Â verbose +=Â 4; |
---|
1796 | #endif |
---|
1797 |           if (verbose < 4) { |
---|
1798 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "In argument list keywords have leading - " |
---|
1799 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ", -stdin or just - switches to stdin"Â <<Â std::endl; |
---|
1800 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "One command per line (and no -)"Â <<Â std::endl; |
---|
1801 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd? gives list of possibilities, if only one + explanation"Â <<Â std::endl; |
---|
1802 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd?? adds explanation, if only one fuller help"Â <<Â std::endl; |
---|
1803 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd without value (where expected) gives current value"Â <<Â std::endl; |
---|
1804 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "abcd value sets value"Â <<Â std::endl; |
---|
1805 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Commands are:"Â <<Â std::endl; |
---|
1806 |           } else { |
---|
1807 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Cbc options are set within AMPL with commands like:"Â <<Â std::endl <<Â std::endl; |
---|
1808 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Â Â Â Â Â option cbc_options \"cuts=root log=2 feas=on slog=1\""Â <<Â std::endl <<Â std::endl; |
---|
1809 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "only maximize, dual, primal, help and quit are recognized without ="Â <<Â std::endl; |
---|
1810 | Â Â Â Â Â Â Â Â Â Â } |
---|
1811 |           int maxAcross = 10; |
---|
1812 |           if ((verbose % 4) != 0) |
---|
1813 | Â Â Â Â Â Â Â Â Â Â Â Â maxAcross =Â 1; |
---|
1814 |           int limits[] = {1, 51, 101, 151, 201, 251, 301, 351, 401}; |
---|
1815 | Â Â Â Â Â Â Â Â Â Â std::vector<std::string>Â types; |
---|
1816 | Â Â Â Â Â Â Â Â Â Â types.push_back("Double parameters:"); |
---|
1817 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut double parameters:"); |
---|
1818 | Â Â Â Â Â Â Â Â Â Â types.push_back("Integer parameters:"); |
---|
1819 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut integer parameters:"); |
---|
1820 | Â Â Â Â Â Â Â Â Â Â types.push_back("Keyword parameters:"); |
---|
1821 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut keyword parameters:"); |
---|
1822 | Â Â Â Â Â Â Â Â Â Â types.push_back("Actions or string parameters:"); |
---|
1823 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut actions:"); |
---|
1824 |           int iType; |
---|
1825 |           for (iType = 0; iType < 8; iType++) { |
---|
1826 |             int across = 0; |
---|
1827 |             int lengthLine = 0; |
---|
1828 |             if ((verbose % 4) != 0) |
---|
1829 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1830 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â types[iType]Â <<Â std::endl; |
---|
1831 |             if ((verbose&2) != 0) |
---|
1832 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1833 |             for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
1834 |               int type = parameters_[iParam].type(); |
---|
1835 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //printf("%d type %d limits %d %d display %d\n",iParam, |
---|
1836 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â type,limits[iType],limits[iType+1],parameters_[iParam].displayThis()); |
---|
1837 |               if ((parameters_[iParam].displayThis() >= printLevel || evenHidden) && |
---|
1838 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type >=Â limits[iType] |
---|
1839 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â type <Â limits[iType+1])Â { |
---|
1840 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // but skip if not useful for ampl (and in ampl mode) |
---|
1841 |                 if (verbose >= 4 && (parameters_[iParam].whereUsed()&4) == 0) |
---|
1842 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue; |
---|
1843 |                 if (!across) { |
---|
1844 |                   if ((verbose&2) != 0) |
---|
1845 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Command "; |
---|
1846 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1847 |                 int length = parameters_[iParam].lengthMatchName() + 1; |
---|
1848 |                 if (lengthLine + length > 80) { |
---|
1849 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1850 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
1851 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lengthLine =Â 0; |
---|
1852 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1853 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " "Â <<Â parameters_[iParam].matchName(); |
---|
1854 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lengthLine +=Â length; |
---|
1855 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across++; |
---|
1856 |                 if (across == maxAcross) { |
---|
1857 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
1858 |                   if ((verbose % 4) != 0) { |
---|
1859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put out description as well |
---|
1860 |                     if ((verbose&1) != 0) |
---|
1861 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " "Â <<Â parameters_[iParam].shortHelp(); |
---|
1862 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1863 |                     if ((verbose&2) != 0) { |
---|
1864 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "---- description"Â <<Â std::endl; |
---|
1865 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].printLongHelp(); |
---|
1866 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "----"Â <<Â std::endl <<Â std::endl; |
---|
1867 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1868 |                   } else { |
---|
1869 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1870 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1871 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1872 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1873 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1874 |             if (across) |
---|
1875 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1876 | Â Â Â Â Â Â Â Â Â Â } |
---|
1877 |         } else if (type == CBC_PARAM_FULLGENERALQUERY) { |
---|
1878 | Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Full list of commands is:"Â <<Â std::endl; |
---|
1879 |           int maxAcross = 5; |
---|
1880 |           int limits[] = {1, 51, 101, 151, 201, 251, 301, 351, 401}; |
---|
1881 | Â Â Â Â Â Â Â Â Â Â std::vector<std::string>Â types; |
---|
1882 | Â Â Â Â Â Â Â Â Â Â types.push_back("Double parameters:"); |
---|
1883 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut double parameters:"); |
---|
1884 | Â Â Â Â Â Â Â Â Â Â types.push_back("Integer parameters:"); |
---|
1885 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut integer parameters:"); |
---|
1886 | Â Â Â Â Â Â Â Â Â Â types.push_back("Keyword parameters:"); |
---|
1887 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut keyword parameters:"); |
---|
1888 | Â Â Â Â Â Â Â Â Â Â types.push_back("Actions or string parameters:"); |
---|
1889 | Â Â Â Â Â Â Â Â Â Â types.push_back("Branch and Cut actions:"); |
---|
1890 |           int iType; |
---|
1891 |           for (iType = 0; iType < 8; iType++) { |
---|
1892 |             int across = 0; |
---|
1893 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â types[iType]Â <<Â "Â "; |
---|
1894 |             for ( iParam = 0; iParam < numberParameters_; iParam++ ) { |
---|
1895 |               int type = parameters_[iParam].type(); |
---|
1896 |               if (type >= limits[iType] |
---|
1897 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â type <Â limits[iType+1])Â { |
---|
1898 |                 if (!across) |
---|
1899 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Â "; |
---|
1900 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].matchName()Â <<Â "Â "; |
---|
1901 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across++; |
---|
1902 |                 if (across == maxAcross) { |
---|
1903 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1904 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â across =Â 0; |
---|
1905 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1906 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1907 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1908 |             if (across) |
---|
1909 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â std::endl; |
---|
1910 | Â Â Â Â Â Â Â Â Â Â } |
---|
1911 |         } else if (type < 101) { |
---|
1912 | Â Â Â Â Â Â Â Â Â Â // get next field as double |
---|
1913 |           double value = CoinReadGetDoubleField(argc, argv, &valid); |
---|
1914 |           if (!valid) { |
---|
1915 |             if (type < 51) { |
---|
1916 |               int returnCode; |
---|
1917 |               const char * message = |
---|
1918 |                 parameters_[iParam].setDoubleParameterWithMessage(lpSolver, value, returnCode); |
---|
1919 |               if (!noPrinting_ && strlen(message)) { |
---|
1920 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1921 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
1922 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1923 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1924 |             } else if (type < 81) { |
---|
1925 |               int returnCode; |
---|
1926 |               const char * message = |
---|
1927 |                 parameters_[iParam].setDoubleParameterWithMessage(model_, value, returnCode); |
---|
1928 |               if (!noPrinting_ && strlen(message)) { |
---|
1929 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1930 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
1931 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1932 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1933 |             } else { |
---|
1934 |               int returnCode; |
---|
1935 |               const char * message = |
---|
1936 |                 parameters_[iParam].setDoubleParameterWithMessage(lpSolver, value, returnCode); |
---|
1937 |               if (!noPrinting_ && strlen(message)) { |
---|
1938 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1939 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
1940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1942 |               switch (type) { |
---|
1943 |               case CBC_PARAM_DBL_DJFIX: |
---|
1944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â djFix =Â value; |
---|
1945 | #ifndef CBC_OTHER_SOLVER |
---|
1946 |                 if (goodModel && djFix < 1.0e20) { |
---|
1947 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // do some fixing |
---|
1948 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (model_.solver()); |
---|
1949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->initialSolve(); |
---|
1950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
1951 |                   int numberColumns = lpSolver->numberColumns(); |
---|
1952 |                   int i; |
---|
1953 |                   const char * type = lpSolver->integerInformation(); |
---|
1954 |                   double * lower = lpSolver->columnLower(); |
---|
1955 |                   double * upper = lpSolver->columnUpper(); |
---|
1956 |                   double * solution = lpSolver->primalColumnSolution(); |
---|
1957 |                   double * dj = lpSolver->dualColumnSolution(); |
---|
1958 |                   int numberFixed = 0; |
---|
1959 |                   double dextra4 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA4, numberParameters_, parameters_)].doubleValue(); |
---|
1960 |                   if (dextra4) |
---|
1961 |                     printf("Multiple for continuous dj fixing is %g\n", dextra4); |
---|
1962 |                   for (i = 0; i < numberColumns; i++) { |
---|
1963 |                     double djValue = dj[i]; |
---|
1964 |                     if (!type[i]) |
---|
1965 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â djValue *=Â dextra4; |
---|
1966 |                     if (type[i] || dextra4) { |
---|
1967 |                       double value = solution[i]; |
---|
1968 |                       if (value < lower[i] + 1.0e-5 && djValue > djFix) { |
---|
1969 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution[i]Â =Â lower[i]; |
---|
1970 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â upper[i]Â =Â lower[i]; |
---|
1971 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberFixed++; |
---|
1972 |                       } else if (value > upper[i] - 1.0e-5 && djValue < -djFix) { |
---|
1973 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution[i]Â =Â upper[i]; |
---|
1974 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lower[i]Â =Â upper[i]; |
---|
1975 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberFixed++; |
---|
1976 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1977 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1978 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1979 |                   sprintf(generalPrint, "%d columns fixed\n", numberFixed); |
---|
1980 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
1981 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
1982 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
1983 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1984 | #endif |
---|
1985 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1986 |               case CBC_PARAM_DBL_TIGHTENFACTOR: |
---|
1987 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tightenFactor =Â value; |
---|
1988 |                 if (!complicatedInteger) |
---|
1989 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
1990 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1991 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â default: |
---|
1992 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
1993 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1994 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
1995 |           } else if (valid == 1) { |
---|
1996 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " is illegal for double parameter "Â <<Â parameters_[iParam].name()Â <<Â " value remains "Â << |
---|
1997 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].doubleValue()Â <<Â std::endl; |
---|
1998 |           } else { |
---|
1999 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2000 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].doubleValue()Â <<Â std::endl; |
---|
2001 | Â Â Â Â Â Â Â Â Â Â } |
---|
2002 |         } else if (type < 201) { |
---|
2003 | Â Â Â Â Â Â Â Â Â Â // get next field as int |
---|
2004 |           int value = CoinReadGetIntField(argc, argv, &valid); |
---|
2005 |           if (!valid) { |
---|
2006 |             if (type < 151) { |
---|
2007 |               if (parameters_[iParam].type() == CLP_PARAM_INT_PRESOLVEPASS) |
---|
2008 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â value; |
---|
2009 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_IDIOT) |
---|
2010 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doIdiot =Â value; |
---|
2011 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SPRINT) |
---|
2012 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSprint =Â value; |
---|
2013 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_OUTPUTFORMAT) |
---|
2014 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â outputFormat =Â value; |
---|
2015 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SLPVALUE) |
---|
2016 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â slpValue =Â value; |
---|
2017 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_CPP) |
---|
2018 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cppValue =Â value; |
---|
2019 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PRESOLVEOPTIONS) |
---|
2020 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveOptions =Â value; |
---|
2021 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PRINTOPTIONS) |
---|
2022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printOptions =Â value; |
---|
2023 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_SUBSTITUTION) |
---|
2024 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â substitution =Â value; |
---|
2025 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_DUALIZE) |
---|
2026 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â value; |
---|
2027 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_PROCESSTUNE) |
---|
2028 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â value; |
---|
2029 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_USESOLUTION) |
---|
2030 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â useSolution =Â value; |
---|
2031 |               else if (parameters_[iParam].type() == CLP_PARAM_INT_VERBOSE) |
---|
2032 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â verbose =Â value; |
---|
2033 |               int returnCode; |
---|
2034 |               const char * message = |
---|
2035 |                 parameters_[iParam].setIntParameterWithMessage(lpSolver, value, returnCode); |
---|
2036 |               if (!noPrinting_ && strlen(message)) { |
---|
2037 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2038 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2039 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2040 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2041 |             } else { |
---|
2042 |               if (parameters_[iParam].type() == CBC_PARAM_INT_CUTPASS) |
---|
2043 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPass =Â value; |
---|
2044 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_CUTPASSINTREE) |
---|
2045 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPassInTree =Â value; |
---|
2046 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_STRONGBRANCHING || |
---|
2047 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_NUMBERBEFORE) |
---|
2048 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â strongChanged =Â true; |
---|
2049 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_FPUMPTUNE || |
---|
2050 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_FPUMPTUNE2 || |
---|
2051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].type()Â ==Â CBC_PARAM_INT_FPUMPITS) |
---|
2052 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pumpChanged =Â true; |
---|
2053 |               else if (parameters_[iParam].type() == CBC_PARAM_INT_EXPERIMENT) { |
---|
2054 |                 int addFlags=0; |
---|
2055 |                 if (value>=10) { |
---|
2056 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â addFlags =Â 1048576*(value/10); |
---|
2057 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value =Â value %Â 10; |
---|
2058 |                  parameters[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters, parameters)].setIntValue(value); |
---|
2059 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2060 |                 if (value >= 1) { |
---|
2061 |                   int values[]={24003,280003,792003,24003,24003}; |
---|
2062 |                   if (value>=2&&value<=3) { |
---|
2063 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // swap default diving |
---|
2064 |                    int iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
2065 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2066 |                    iParam = whichParam(CBC_PARAM_STR_DIVINGP, numberParameters_, parameters_); |
---|
2067 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
2068 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2069 |                   int extra4 = values[value-1]+addFlags; |
---|
2070 |                   parameters[whichParam(CBC_PARAM_INT_EXTRA4, numberParameters, parameters)].setIntValue(extra4); |
---|
2071 |                   if (!noPrinting_) { |
---|
2072 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2073 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "switching on global root cuts for gomory and knapsack" |
---|
2074 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2075 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2076 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "using OSL factorization" |
---|
2077 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2078 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2079 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â "extra options - -rens on -extra4 " |
---|
2080 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<extra4<<" -passc 1000!" |
---|
2081 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2082 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2083 |                   parameters[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters, parameters)].setCurrentOption("forceOnStrong"); |
---|
2084 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 8; |
---|
2085 |                   parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption("onGlobal"); |
---|
2086 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â 5; |
---|
2087 |                   parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption("onGlobal"); |
---|
2088 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â 5; |
---|
2089 |                   parameters_[whichParam(CLP_PARAM_STR_FACTORIZATION, numberParameters_, parameters_)].setCurrentOption("osl"); |
---|
2090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->forceOtherFactorization(3); |
---|
2091 |                   parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].setIntValue(100); |
---|
2092 |                   parameters[whichParam(CBC_PARAM_INT_CUTPASS, numberParameters, parameters)].setIntValue(1000); |
---|
2093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cutPass =Â 1000; |
---|
2094 |                   parameters[whichParam(CBC_PARAM_STR_RENS, numberParameters, parameters)].setCurrentOption("on"); |
---|
2095 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2096 |               } else if (parameters_[iParam].type() == CBC_PARAM_INT_STRATEGY) { |
---|
2097 |                 if (value == 0) { |
---|
2098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setAwayAtRoot(0.05); |
---|
2099 |                   int iParam; |
---|
2100 |                   iParam = whichParam(CBC_PARAM_INT_DIVEOPT, numberParameters_, parameters_); |
---|
2101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(-1); |
---|
2102 |                   iParam = whichParam(CBC_PARAM_INT_FPUMPITS, numberParameters_, parameters_); |
---|
2103 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(20); |
---|
2104 |                   iParam = whichParam(CBC_PARAM_INT_FPUMPTUNE, numberParameters_, parameters_); |
---|
2105 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(1003); |
---|
2106 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â initialPumpTune =Â 1003; |
---|
2107 |                   iParam = whichParam(CLP_PARAM_INT_PROCESSTUNE, numberParameters_, parameters_); |
---|
2108 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setIntValue(-1); |
---|
2109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â 0; |
---|
2110 |                   iParam = whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_); |
---|
2111 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2112 |                   iParam = whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_); |
---|
2113 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("off"); |
---|
2114 |                   iParam = whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_); |
---|
2115 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOption("on"); |
---|
2116 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â 1; |
---|
2117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2118 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2119 |               int returnCode; |
---|
2120 |               const char * message = |
---|
2121 |                 parameters_[iParam].setIntParameterWithMessage(model_, value, returnCode); |
---|
2122 |               if (!noPrinting_ && strlen(message)) { |
---|
2123 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2124 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2125 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2126 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2127 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2128 |           } else if (valid == 1) { |
---|
2129 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â " is illegal for integer parameter "Â <<Â parameters_[iParam].name()Â <<Â " value remains "Â << |
---|
2130 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].intValue()Â <<Â std::endl; |
---|
2131 |           } else { |
---|
2132 | Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].intValue()Â <<Â std::endl; |
---|
2134 | Â Â Â Â Â Â Â Â Â Â } |
---|
2135 |         } else if (type < 301) { |
---|
2136 | Â Â Â Â Â Â Â Â Â Â // one of several strings |
---|
2137 |           std::string value = CoinReadGetString(argc, argv); |
---|
2138 |           int action = parameters_[iParam].parameterOption(value); |
---|
2139 |           if (action < 0) { |
---|
2140 |             if (value != "EOL") { |
---|
2141 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // no match |
---|
2142 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].printOptions(); |
---|
2143 |             } else { |
---|
2144 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // print current value |
---|
2145 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â parameters_[iParam].name()Â <<Â " has value "Â << |
---|
2146 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].currentOption()Â <<Â std::endl; |
---|
2147 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2148 |           } else { |
---|
2149 |             const char * message = |
---|
2150 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[iParam].setCurrentOptionWithMessage(action); |
---|
2151 |             if (!noPrinting_ && strlen(message)) { |
---|
2152 |               generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2153 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â message |
---|
2154 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2155 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2156 | Â Â Â Â Â Â Â Â Â Â Â Â // for now hard wired |
---|
2157 |             switch (type) { |
---|
2158 |             case CLP_PARAM_STR_DIRECTION: |
---|
2159 |               if (action == 0) |
---|
2160 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(1); |
---|
2161 |               else if (action == 1) |
---|
2162 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(-1); |
---|
2163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2164 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setOptimizationDirection(0); |
---|
2165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2166 |             case CLP_PARAM_STR_DUALPIVOT: |
---|
2167 |               if (action == 0) { |
---|
2168 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep(3); |
---|
2169 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2170 |               } else if (action == 1) { |
---|
2171 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowDantzig dantzig; |
---|
2172 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //ClpDualRowSteepest dantzig(5); |
---|
2173 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(dantzig); |
---|
2174 |               } else if (action == 2) { |
---|
2175 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // partial steep |
---|
2176 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep(2); |
---|
2177 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2178 |               } else { |
---|
2179 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpDualRowSteepest steep; |
---|
2180 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setDualRowPivotAlgorithm(steep); |
---|
2181 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2182 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2183 |             case CLP_PARAM_STR_PRIMALPIVOT: |
---|
2184 |               if (action == 0) { |
---|
2185 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(3); |
---|
2186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2187 |               } else if (action == 1) { |
---|
2188 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(0); |
---|
2189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2190 |               } else if (action == 2) { |
---|
2191 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnDantzig dantzig; |
---|
2192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(dantzig); |
---|
2193 |               } else if (action == 3) { |
---|
2194 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(4); |
---|
2195 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2196 |               } else if (action == 4) { |
---|
2197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(1); |
---|
2198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2199 |               } else if (action == 5) { |
---|
2200 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(2); |
---|
2201 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2202 |               } else if (action == 6) { |
---|
2203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPrimalColumnSteepest steep(10); |
---|
2204 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPrimalColumnPivotAlgorithm(steep); |
---|
2205 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2206 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2207 |             case CLP_PARAM_STR_SCALING: |
---|
2208 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->scaling(action); |
---|
2209 |               solver->setHintParam(OsiDoScale, action != 0, OsiHintTry); |
---|
2210 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doScaling =Â action; |
---|
2211 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2212 |             case CLP_PARAM_STR_AUTOSCALE: |
---|
2213 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setAutomaticScaling(action !=Â 0); |
---|
2214 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2215 |             case CLP_PARAM_STR_SPARSEFACTOR: |
---|
2216 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setSparseFactorization((1Â -Â action)Â !=Â 0); |
---|
2217 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2218 |             case CLP_PARAM_STR_BIASLU: |
---|
2219 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->setBiasLU(action); |
---|
2220 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2221 |             case CLP_PARAM_STR_PERTURBATION: |
---|
2222 |               if (action == 0) |
---|
2223 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPerturbation(50); |
---|
2224 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2225 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPerturbation(100); |
---|
2226 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2227 |             case CLP_PARAM_STR_ERRORSALLOWED: |
---|
2228 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â allowImportErrors =Â action; |
---|
2229 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2230 |             case CLP_PARAM_STR_INTPRINT: |
---|
2231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â printMode =Â action; |
---|
2232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //case CLP_PARAM_NOTUSED_ALGORITHM: |
---|
2234 |               //algorithm = action; |
---|
2235 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //defaultSettings=false; // user knows what she is doing |
---|
2236 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //abort(); |
---|
2237 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //break; |
---|
2238 |             case CLP_PARAM_STR_KEEPNAMES: |
---|
2239 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â keepImportNames =Â 1Â -Â action; |
---|
2240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2241 |             case CLP_PARAM_STR_PRESOLVE: |
---|
2242 |               if (action == 0) |
---|
2243 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 5; |
---|
2244 |               else if (action == 1) |
---|
2245 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 0; |
---|
2246 |               else if (action == 2) |
---|
2247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â 10; |
---|
2248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolveFile =Â true; |
---|
2250 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2251 |             case CLP_PARAM_STR_PFI: |
---|
2252 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->setForrestTomlin(action ==Â 0); |
---|
2253 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2254 |             case CLP_PARAM_STR_FACTORIZATION: |
---|
2255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->factorization()->forceOtherFactorization(action); |
---|
2256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2257 |             case CLP_PARAM_STR_CRASH: |
---|
2258 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doCrash =Â action; |
---|
2259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2260 |             case CLP_PARAM_STR_VECTOR: |
---|
2261 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doVector =Â action; |
---|
2262 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2263 |             case CLP_PARAM_STR_MESSAGES: |
---|
2264 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->messageHandler()->setPrefix(action !=Â 0); |
---|
2265 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2266 |             case CLP_PARAM_STR_CHOLESKY: |
---|
2267 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â choleskyType =Â action; |
---|
2268 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2269 |             case CLP_PARAM_STR_GAMMA: |
---|
2270 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gamma =Â action; |
---|
2271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2272 |             case CLP_PARAM_STR_BARRIERSCALE: |
---|
2273 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â scaleBarrier =Â action; |
---|
2274 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2275 |             case CLP_PARAM_STR_KKT: |
---|
2276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doKKT =Â action; |
---|
2277 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2278 |             case CLP_PARAM_STR_CROSSOVER: |
---|
2279 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â crossover =Â action; |
---|
2280 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2281 |             case CLP_PARAM_STR_TIME_MODE: |
---|
2282 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setUseElapsedTime(action!=0); |
---|
2283 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2284 |             case CBC_PARAM_STR_SOS: |
---|
2285 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSOS =Â action; |
---|
2286 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2287 |             case CBC_PARAM_STR_GOMORYCUTS: |
---|
2288 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2289 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â action; |
---|
2290 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2291 |             case CBC_PARAM_STR_PROBINGCUTS: |
---|
2292 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2293 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â action; |
---|
2294 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2295 |             case CBC_PARAM_STR_KNAPSACKCUTS: |
---|
2296 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2297 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â action; |
---|
2298 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2299 |             case CBC_PARAM_STR_REDSPLITCUTS: |
---|
2300 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2301 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplitAction =Â action; |
---|
2302 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2303 |             case CBC_PARAM_STR_CLIQUECUTS: |
---|
2304 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2305 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â cliqueAction =Â action; |
---|
2306 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2307 |             case CBC_PARAM_STR_FLOWCUTS: |
---|
2308 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2309 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â flowAction =Â action; |
---|
2310 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2311 |             case CBC_PARAM_STR_MIXEDCUTS: |
---|
2312 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2313 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â mixedAction =Â action; |
---|
2314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2315 |             case CBC_PARAM_STR_TWOMIRCUTS: |
---|
2316 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2317 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirAction =Â action; |
---|
2318 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2319 |             case CBC_PARAM_STR_LANDPCUTS: |
---|
2320 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2321 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â landpAction =Â action; |
---|
2322 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2323 |             case CBC_PARAM_STR_RESIDCUTS: |
---|
2324 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2325 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â residualCapacityAction =Â action; |
---|
2326 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2327 | #ifdef ZERO_HALF_CUTS |
---|
2328 |             case CBC_PARAM_STR_ZEROHALFCUTS: |
---|
2329 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â zerohalfAction =Â action; |
---|
2331 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2332 | #endif |
---|
2333 |             case CBC_PARAM_STR_ROUNDING: |
---|
2334 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2335 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2336 |             case CBC_PARAM_STR_FPUMP: |
---|
2337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2338 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2339 |             case CBC_PARAM_STR_RINS: |
---|
2340 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2341 |             case CBC_PARAM_STR_DINS: |
---|
2342 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2343 |             case CBC_PARAM_STR_RENS: |
---|
2344 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2345 |             case CBC_PARAM_STR_CUTSSTRATEGY: |
---|
2346 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â action; |
---|
2347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingAction =Â action; |
---|
2348 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackAction =Â action; |
---|
2349 | #ifdef ZERO_HALF_CUTS |
---|
2350 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â zerohalfAction =Â action; |
---|
2351 | #endif |
---|
2352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â cliqueAction =Â action; |
---|
2353 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â flowAction =Â action; |
---|
2354 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â mixedAction =Â action; |
---|
2355 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirAction =Â action; |
---|
2356 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //landpAction = action; |
---|
2357 |               parameters_[whichParam(CBC_PARAM_STR_GOMORYCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2358 |               parameters_[whichParam(CBC_PARAM_STR_PROBINGCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2359 |               parameters_[whichParam(CBC_PARAM_STR_KNAPSACKCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2360 |               parameters_[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2361 |               parameters_[whichParam(CBC_PARAM_STR_FLOWCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2362 |               parameters_[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2363 |               parameters_[whichParam(CBC_PARAM_STR_TWOMIRCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2364 | #ifdef ZERO_HALF_CUTS |
---|
2365 |               parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2366 | #endif |
---|
2367 |               if (!action) { |
---|
2368 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â redsplitAction =Â action; |
---|
2369 |                 parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â landpAction =Â action; |
---|
2371 |                 parameters_[whichParam(CBC_PARAM_STR_LANDPCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2372 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â residualCapacityAction =Â action; |
---|
2373 |                 parameters_[whichParam(CBC_PARAM_STR_RESIDCUTS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2374 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2375 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2376 |             case CBC_PARAM_STR_HEURISTICSTRATEGY: |
---|
2377 |               parameters_[whichParam(CBC_PARAM_STR_ROUNDING, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2378 |               parameters_[whichParam(CBC_PARAM_STR_GREEDY, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2379 |               parameters_[whichParam(CBC_PARAM_STR_COMBINE, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2380 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //parameters_[whichParam(CBC_PARAM_STR_LOCALTREE,numberParameters_,parameters_)].setCurrentOption(action); |
---|
2381 |               parameters_[whichParam(CBC_PARAM_STR_FPUMP, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2382 |               parameters_[whichParam(CBC_PARAM_STR_DIVINGC, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2383 |               parameters_[whichParam(CBC_PARAM_STR_RINS, numberParameters_, parameters_)].setCurrentOption(action); |
---|
2384 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2385 |             case CBC_PARAM_STR_GREEDY: |
---|
2386 |             case CBC_PARAM_STR_DIVINGS: |
---|
2387 |             case CBC_PARAM_STR_DIVINGC: |
---|
2388 |             case CBC_PARAM_STR_DIVINGF: |
---|
2389 |             case CBC_PARAM_STR_DIVINGG: |
---|
2390 |             case CBC_PARAM_STR_DIVINGL: |
---|
2391 |             case CBC_PARAM_STR_DIVINGP: |
---|
2392 |             case CBC_PARAM_STR_DIVINGV: |
---|
2393 |             case CBC_PARAM_STR_COMBINE: |
---|
2394 |             case CBC_PARAM_STR_PIVOTANDCOMPLEMENT: |
---|
2395 |             case CBC_PARAM_STR_PIVOTANDFIX: |
---|
2396 |             case CBC_PARAM_STR_RANDROUND: |
---|
2397 |             case CBC_PARAM_STR_LOCALTREE: |
---|
2398 |             case CBC_PARAM_STR_NAIVE: |
---|
2399 |             case CBC_PARAM_STR_CPX: |
---|
2400 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â defaultSettings =Â false;Â // user knows what she is doing |
---|
2401 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2402 |             case CBC_PARAM_STR_COSTSTRATEGY: |
---|
2403 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â useCosts =Â action; |
---|
2404 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2405 |             case CBC_PARAM_STR_NODESTRATEGY: |
---|
2406 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â nodeStrategy =Â action; |
---|
2407 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2408 |             case CBC_PARAM_STR_PREPROCESS: |
---|
2409 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â action; |
---|
2410 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2411 | Â Â Â Â Â Â Â Â Â Â Â Â default: |
---|
2412 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //abort(); |
---|
2413 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2414 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2415 | Â Â Â Â Â Â Â Â Â Â } |
---|
2416 |         } else { |
---|
2417 | Â Â Â Â Â Â Â Â Â Â // action |
---|
2418 |           if (type == CLP_PARAM_ACTION_EXIT) { |
---|
2419 | #ifdef COIN_HAS_ASL |
---|
2420 |             if (statusUserFunction_[0]) { |
---|
2421 |               if (info.numberIntegers || info.numberBinary) { |
---|
2422 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // integer |
---|
2423 |               } else { |
---|
2424 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // linear |
---|
2425 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â writeAmpl(&info); |
---|
2427 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â freeArrays2(&info); |
---|
2428 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â freeArgs(&info); |
---|
2429 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2430 | #endif |
---|
2431 | Â Â Â Â Â Â Â Â Â Â Â Â break;Â // stop all |
---|
2432 | Â Â Â Â Â Â Â Â Â Â } |
---|
2433 |           switch (type) { |
---|
2434 |           case CLP_PARAM_ACTION_DUALSIMPLEX: |
---|
2435 |           case CLP_PARAM_ACTION_PRIMALSIMPLEX: |
---|
2436 |           case CLP_PARAM_ACTION_SOLVECONTINUOUS: |
---|
2437 |           case CLP_PARAM_ACTION_BARRIER: |
---|
2438 |             if (goodModel) { |
---|
2439 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Say not in integer |
---|
2440 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â -1; |
---|
2441 |               double objScale = |
---|
2442 |                 parameters_[whichParam(CLP_PARAM_DBL_OBJSCALE2, numberParameters_, parameters_)].doubleValue(); |
---|
2443 |               if (objScale != 1.0) { |
---|
2444 |                 int iColumn; |
---|
2445 |                 int numberColumns = lpSolver->numberColumns(); |
---|
2446 |                 double * dualColumnSolution = |
---|
2447 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->dualColumnSolution(); |
---|
2448 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpObjective *Â obj =Â lpSolver->objectiveAsObject(); |
---|
2449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert(dynamic_cast<ClpLinearObjective *>Â (obj)); |
---|
2450 |                 double offset; |
---|
2451 |                 double * objective = obj->gradient(NULL, NULL, offset, true); |
---|
2452 |                 for (iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
2453 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualColumnSolution[iColumn]Â *=Â objScale; |
---|
2454 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objective[iColumn]Â *=Â objScale;; |
---|
2455 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2456 |                 int iRow; |
---|
2457 |                 int numberRows = lpSolver->numberRows(); |
---|
2458 |                 double * dualRowSolution = |
---|
2459 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->dualRowSolution(); |
---|
2460 |                 for (iRow = 0; iRow < numberRows; iRow++) |
---|
2461 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualRowSolution[iRow]Â *=Â objScale; |
---|
2462 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setObjectiveOffset(objScale*lpSolver->objectiveOffset()); |
---|
2463 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::SolveType method; |
---|
2465 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::PresolveType presolveType; |
---|
2466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â model2 =Â lpSolver; |
---|
2467 |               if (dualize) { |
---|
2468 |                 bool tryIt = true; |
---|
2469 |                 double fractionColumn = 1.0; |
---|
2470 |                 double fractionRow = 1.0; |
---|
2471 |                 if (dualize == 3) { |
---|
2472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 1; |
---|
2473 |                   int numberColumns = lpSolver->numberColumns(); |
---|
2474 |                   int numberRows = lpSolver->numberRows(); |
---|
2475 |                   if (numberRows < 50000 || 5*numberColumns > numberRows) { |
---|
2476 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tryIt =Â false; |
---|
2477 |                   } else { |
---|
2478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fractionColumn =Â 0.1; |
---|
2479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fractionRow =Â 0.1; |
---|
2480 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2481 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2482 |                 if (tryIt) { |
---|
2483 |                   model2 = static_cast<ClpSimplexOther *> (model2)->dualOfModel(fractionRow, fractionColumn); |
---|
2484 |                   if (model2) { |
---|
2485 |                     sprintf(generalPrint, "Dual of model has %d rows and %d columns", |
---|
2486 |                         model2->numberRows(), model2->numberColumns()); |
---|
2487 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2488 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2489 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2490 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setOptimizationDirection(1.0); |
---|
2491 |                   } else { |
---|
2492 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
2493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 0; |
---|
2494 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2495 |                 } else { |
---|
2496 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dualize =Â 0; |
---|
2497 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2498 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2499 |               if (noPrinting_) |
---|
2500 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setLogLevel(0); |
---|
2501 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve solveOptions; |
---|
2502 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setPresolveActions(presolveOptions); |
---|
2503 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setSubstitution(substitution); |
---|
2504 |               if (preSolve != 5 && preSolve) { |
---|
2505 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumber; |
---|
2506 |                 if (preSolve < 0) { |
---|
2507 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve =Â -Â preSolve; |
---|
2508 |                   if (preSolve <= 100) { |
---|
2509 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumber; |
---|
2510 |                     sprintf(generalPrint, "Doing %d presolve passes - picking up non-costed slacks", |
---|
2511 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve); |
---|
2512 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2513 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2514 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2515 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setDoSingletonColumn(true); |
---|
2516 |                   } else { |
---|
2517 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve -=Â 100; |
---|
2518 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveNumberCost; |
---|
2519 |                     sprintf(generalPrint, "Doing %d presolve passes - picking up costed slacks", |
---|
2520 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preSolve); |
---|
2521 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2522 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2523 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2524 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2526 |               } else if (preSolve) { |
---|
2527 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOn; |
---|
2528 |               } else { |
---|
2529 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOff; |
---|
2530 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2531 |               solveOptions.setPresolveType(presolveType, preSolve); |
---|
2532 |               if (type == CLP_PARAM_ACTION_DUALSIMPLEX || |
---|
2533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type ==Â CLP_PARAM_ACTION_SOLVECONTINUOUS)Â { |
---|
2534 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useDual; |
---|
2535 |               } else if (type == CLP_PARAM_ACTION_PRIMALSIMPLEX) { |
---|
2536 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::usePrimalorSprint; |
---|
2537 |               } else { |
---|
2538 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrier; |
---|
2539 |                 if (crossover == 1) { |
---|
2540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrierNoCross; |
---|
2541 |                 } else if (crossover == 2) { |
---|
2542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpObjective *Â obj =Â lpSolver->objectiveAsObject(); |
---|
2543 |                   if (obj->type() > 1) { |
---|
2544 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::useBarrierNoCross; |
---|
2545 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveType =Â ClpSolve::presolveOff; |
---|
2546 |                     solveOptions.setPresolveType(presolveType, preSolve); |
---|
2547 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2548 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2549 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2550 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â solveOptions.setSolveType(method); |
---|
2551 |               if (preSolveFile) |
---|
2552 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â presolveOptions |=Â 0x40000000; |
---|
2553 |               solveOptions.setSpecialOption(4, presolveOptions); |
---|
2554 |               solveOptions.setSpecialOption(5, printOptions); |
---|
2555 |               if (doVector) { |
---|
2556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â matrix =Â lpSolver->clpMatrix(); |
---|
2557 |                 if (dynamic_cast< ClpPackedMatrix*>(matrix)) { |
---|
2558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix *Â clpMatrix =Â dynamic_cast<Â ClpPackedMatrix*>(matrix); |
---|
2559 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpMatrix->makeSpecialColumnCopy(); |
---|
2560 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2562 |               if (method == ClpSolve::useDual) { |
---|
2563 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // dual |
---|
2564 |                 if (doCrash) |
---|
2565 |                   solveOptions.setSpecialOption(0, 1, doCrash); // crash |
---|
2566 |                 else if (doIdiot) |
---|
2567 |                   solveOptions.setSpecialOption(0, 2, doIdiot); // possible idiot |
---|
2568 |               } else if (method == ClpSolve::usePrimalorSprint) { |
---|
2569 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // primal |
---|
2570 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // if slp turn everything off |
---|
2571 |                 if (slpValue > 0) { |
---|
2572 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doCrash =Â false; |
---|
2573 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doSprint =Â 0; |
---|
2574 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doIdiot =Â -1; |
---|
2575 |                   solveOptions.setSpecialOption(1, 10, slpValue); // slp |
---|
2576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â method =Â ClpSolve::usePrimal; |
---|
2577 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2578 |                 if (doCrash) { |
---|
2579 |                   solveOptions.setSpecialOption(1, 1, doCrash); // crash |
---|
2580 |                 } else if (doSprint > 0) { |
---|
2581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // sprint overrides idiot |
---|
2582 |                   solveOptions.setSpecialOption(1, 3, doSprint); // sprint |
---|
2583 |                 } else if (doIdiot > 0) { |
---|
2584 |                   solveOptions.setSpecialOption(1, 2, doIdiot); // idiot |
---|
2585 |                 } else if (slpValue <= 0) { |
---|
2586 |                   if (doIdiot == 0) { |
---|
2587 |                     if (doSprint == 0) |
---|
2588 |                       solveOptions.setSpecialOption(1, 4); // all slack |
---|
2589 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2590 |                       solveOptions.setSpecialOption(1, 9); // all slack or sprint |
---|
2591 |                   } else { |
---|
2592 |                     if (doSprint == 0) |
---|
2593 |                       solveOptions.setSpecialOption(1, 8); // all slack or idiot |
---|
2594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2595 |                       solveOptions.setSpecialOption(1, 7); // initiative |
---|
2596 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2597 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2598 |                 if (basisHasValues == -1) |
---|
2599 |                   solveOptions.setSpecialOption(1, 11); // switch off values |
---|
2600 |               } else if (method == ClpSolve::useBarrier || method == ClpSolve::useBarrierNoCross) { |
---|
2601 |                 int barrierOptions = choleskyType; |
---|
2602 |                 if (scaleBarrier) |
---|
2603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 8; |
---|
2604 |                 if (doKKT) |
---|
2605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 16; |
---|
2606 |                 if (gamma) |
---|
2607 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 32Â *Â gamma; |
---|
2608 |                 if (crossover == 3) |
---|
2609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â barrierOptions |=Â 256;Â // try presolve in crossover |
---|
2610 |                 solveOptions.setSpecialOption(4, barrierOptions); |
---|
2611 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2612 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setMaximumSeconds(model_.getMaximumSeconds()); |
---|
2613 | #ifdef COIN_HAS_LINK |
---|
2614 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â coinSolver =Â model_.solver(); |
---|
2615 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â linkSolver =Â dynamic_cast<Â OsiSolverLink*>Â (coinSolver); |
---|
2616 |               if (!linkSolver) { |
---|
2617 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->initialSolve(solveOptions); |
---|
2618 |               } else { |
---|
2619 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // special solver |
---|
2620 |                 int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
2621 |                 double * solution = NULL; |
---|
2622 |                 if (testOsiOptions < 10) { |
---|
2623 |                   solution = linkSolver->nonlinearSLP(slpValue > 0 ? slpValue : 20 , 1.0e-5); |
---|
2624 |                 } else if (testOsiOptions >= 10) { |
---|
2625 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinModel coinModel =Â *linkSolver->coinModel(); |
---|
2626 |                   ClpSimplex * tempModel = approximateSolution(coinModel, slpValue > 0 ? slpValue : 50 , 1.0e-5, 0); |
---|
2627 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (tempModel); |
---|
2628 |                   solution = CoinCopyOfArray(tempModel->primalColumnSolution(), coinModel.numberColumns()); |
---|
2629 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setObjectiveValue(tempModel->objectiveValue()); |
---|
2630 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setProblemStatus(tempModel->problemStatus()); |
---|
2631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->setSecondaryStatus(tempModel->secondaryStatus()); |
---|
2632 |                   delete tempModel; |
---|
2633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2634 |                 if (solution) { |
---|
2635 |                   memcpy(model2->primalColumnSolution(), solution, |
---|
2636 |                       CoinMin(model2->numberColumns(), linkSolver->coinModel()->numberColumns())*sizeof(double)); |
---|
2637 |                   delete [] solution; |
---|
2638 |                 } else { |
---|
2639 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("No nonlinear solution\n"); |
---|
2640 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2642 | #else |
---|
2643 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->initialSolve(solveOptions); |
---|
2644 | #endif |
---|
2645 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
2646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // map states |
---|
2647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* clp status |
---|
2648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 - unknown e.g. before solve or if postSolve says not optimal |
---|
2649 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 - optimal |
---|
2650 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - primal infeasible |
---|
2651 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - dual infeasible |
---|
2652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 - stopped on iterations or time |
---|
2653 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - stopped due to errors |
---|
2654 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 - stopped by event handler (virtual int ClpEventHandler::event()) */ |
---|
2655 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* cbc status |
---|
2656 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 before branchAndBound |
---|
2657 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found |
---|
2658 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (or check value of best solution) |
---|
2659 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 stopped - on maxnodes, maxsols, maxtime |
---|
2660 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 difficulties so run was abandoned |
---|
2661 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (5 event user programmed event occurred) */ |
---|
2662 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* clp secondary status of problem - may get extended |
---|
2663 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 - none |
---|
2664 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - primal infeasible because dual limit reached OR probably primal |
---|
2665 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â infeasible but can't prove it (main status 4) |
---|
2666 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - scaled problem optimal - unscaled problem has primal infeasibilities |
---|
2667 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 - scaled problem optimal - unscaled problem has dual infeasibilities |
---|
2668 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - scaled problem optimal - unscaled problem has primal and dual infeasibilities |
---|
2669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 - giving up in primal with flagged variables |
---|
2670 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 6 - failed due to empty problem check |
---|
2671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7 - postSolve says not optimal |
---|
2672 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8 - failed due to bad element check |
---|
2673 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 9 - status was 3 and stopped on time |
---|
2674 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 100 up - translation of enum from ClpEventHandler |
---|
2675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
2676 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* cbc secondary status of problem |
---|
2677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â -1 unset (status_ will also be -1) |
---|
2678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 search completed with solution |
---|
2679 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 linear relaxation not feasible (or worse than cutoff) |
---|
2680 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 stopped on gap |
---|
2681 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 stopped on nodes |
---|
2682 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 stopped on time |
---|
2683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5 stopped on user event |
---|
2684 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 6 stopped on solutions |
---|
2685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7 linear relaxation unbounded |
---|
2686 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
2687 |                 int iStatus = model2->status(); |
---|
2688 |                 int iStatus2 = model2->secondaryStatus(); |
---|
2689 |                 if (iStatus == 0) { |
---|
2690 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
2691 |                   if (found.type() == CBC_PARAM_ACTION_BAB) { |
---|
2692 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // set best solution in model as no integers |
---|
2693 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setBestSolution(model2->primalColumnSolution(), |
---|
2694 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->numberColumns(), |
---|
2695 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getObjValue()* |
---|
2696 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getObjSense()); |
---|
2697 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2698 |                 } else if (iStatus == 1) { |
---|
2699 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
2700 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 1;Â // say infeasible |
---|
2701 |                 } else if (iStatus == 2) { |
---|
2702 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
2703 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 7;Â // say unbounded |
---|
2704 |                 } else if (iStatus == 3) { |
---|
2705 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 1; |
---|
2706 |                   if (iStatus2 == 9) |
---|
2707 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 4; |
---|
2708 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
2709 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 3;Â // Use nodes - as closer than solutions |
---|
2710 |                 } else if (iStatus == 4) { |
---|
2711 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 2;Â // difficulties |
---|
2712 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
2713 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2714 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(iStatus); |
---|
2715 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(iStatus2); |
---|
2716 |                 if ((iStatus == 2 || iStatus2 > 0) && |
---|
2717 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â !noPrinting_)Â { |
---|
2718 |                   std::string statusName[] = {"", "Stopped on ", "Run abandoned", "", "", "User ctrl-c"}; |
---|
2719 |                   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", "Problem proven infeasible"}; |
---|
2720 |                   sprintf(generalPrint, "\nResult - %s%s\n\n", |
---|
2721 |                       statusName[iStatus].c_str(), |
---|
2722 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â minor[iStatus2].c_str()); |
---|
2723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
2724 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Enumerated nodes:Â Â Â Â Â Â 0\n"); |
---|
2725 |                   sprintf(generalPrint + strlen(generalPrint), |
---|
2726 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "Total iterations:Â Â Â Â Â Â 0\n"); |
---|
2727 | #ifndef CBC_QUIET |
---|
2728 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
2729 |                       "Time (CPU seconds):     %.2f\n", |
---|
2730 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinCpuTime()Â -Â time0); |
---|
2731 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprintf(generalPrint +Â strlen(generalPrint), |
---|
2732 |                       "Time (Wallclock Seconds):  %.2f\n", |
---|
2733 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinGetTimeOfDay()-time0Elapsed); |
---|
2734 | #endif |
---|
2735 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2736 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2737 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2738 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2739 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //assert (lpSolver==clpSolver->getModelPtr()); |
---|
2740 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (clpSolver ==Â model_.solver()); |
---|
2741 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->setWarmStart(NULL); |
---|
2742 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
2743 |                 if (babModel_) { |
---|
2744 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(iStatus); |
---|
2745 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(iStatus2); |
---|
2746 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2747 |                 int returnCode = callBack(&model, 1); |
---|
2748 |                 if (returnCode) { |
---|
2749 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
2750 |                   delete babModel_; |
---|
2751 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
2752 |                   return returnCode; |
---|
2753 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2754 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2755 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â basisHasValues =Â 1; |
---|
2756 |               if (dualize) { |
---|
2757 |                 int returnCode = static_cast<ClpSimplexOther *> (lpSolver)->restoreFromDual(model2); |
---|
2758 |                 if (model2->status() == 3) |
---|
2759 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â returnCode =Â 0; |
---|
2760 |                 delete model2; |
---|
2761 |                 if (returnCode && dualize != 2) |
---|
2762 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->primal(1); |
---|
2763 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
2764 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2765 | #ifdef COIN_HAS_ASL |
---|
2766 |               if (statusUserFunction_[0]) { |
---|
2767 |                 double value = model2->getObjValue() * model2->getObjSense(); |
---|
2768 |                 char buf[300]; |
---|
2769 |                 int pos = 0; |
---|
2770 |                 int iStat = model2->status(); |
---|
2771 |                 if (iStat == 0) { |
---|
2772 |                   pos += sprintf(buf + pos, "optimal," ); |
---|
2773 |                 } else if (iStat == 1) { |
---|
2774 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // infeasible |
---|
2775 |                   pos += sprintf(buf + pos, "infeasible,"); |
---|
2776 |                 } else if (iStat == 2) { |
---|
2777 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // unbounded |
---|
2778 |                   pos += sprintf(buf + pos, "unbounded,"); |
---|
2779 |                 } else if (iStat == 3) { |
---|
2780 |                   pos += sprintf(buf + pos, "stopped on iterations or time,"); |
---|
2781 |                 } else if (iStat == 4) { |
---|
2782 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 7; |
---|
2783 |                   pos += sprintf(buf + pos, "stopped on difficulties,"); |
---|
2784 |                 } else if (iStat == 5) { |
---|
2785 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 3; |
---|
2786 |                   pos += sprintf(buf + pos, "stopped on ctrl-c,"); |
---|
2787 |                 } else if (iStat == 6) { |
---|
2788 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // bab infeasible |
---|
2789 |                   pos += sprintf(buf + pos, "integer infeasible,"); |
---|
2790 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 1; |
---|
2791 |                 } else { |
---|
2792 |                   pos += sprintf(buf + pos, "status unknown,"); |
---|
2793 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStat =Â 6; |
---|
2794 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2795 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â iStat; |
---|
2796 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â value; |
---|
2797 |                 pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), |
---|
2798 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value); |
---|
2799 |                 sprintf(buf + pos, "\n%d iterations", |
---|
2800 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2->getIterationCount()); |
---|
2801 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.primalSolution); |
---|
2802 |                 int numberColumns = model2->numberColumns(); |
---|
2803 |                 info.primalSolution = reinterpret_cast<double *> (malloc(numberColumns * sizeof(double))); |
---|
2804 |                 CoinCopyN(model2->primalColumnSolution(), numberColumns, info.primalSolution); |
---|
2805 |                 int numberRows = model2->numberRows(); |
---|
2806 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.dualSolution); |
---|
2807 |                 info.dualSolution = reinterpret_cast<double *> (malloc(numberRows * sizeof(double))); |
---|
2808 |                 CoinCopyN(model2->dualRowSolution(), numberRows, info.dualSolution); |
---|
2809 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â model2->getBasis(); |
---|
2810 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.rowStatus); |
---|
2811 |                 info.rowStatus = reinterpret_cast<int *> (malloc(numberRows * sizeof(int))); |
---|
2812 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.columnStatus); |
---|
2813 |                 info.columnStatus = reinterpret_cast<int *> (malloc(numberColumns * sizeof(int))); |
---|
2814 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Put basis in |
---|
2815 |                 int i; |
---|
2816 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // free,basic,ub,lb are 0,1,2,3 |
---|
2817 |                 for (i = 0; i < numberRows; i++) { |
---|
2818 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getArtifStatus(i); |
---|
2819 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.rowStatus[i]Â =Â status; |
---|
2820 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2821 |                 for (i = 0; i < numberColumns; i++) { |
---|
2822 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getStructStatus(i); |
---|
2823 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.columnStatus[i]Â =Â status; |
---|
2824 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2825 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put buffer into info |
---|
2826 |                 strcpy(info.buffer, buf); |
---|
2827 |                 delete basis; |
---|
2828 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2829 | #endif |
---|
2830 |             } else { |
---|
2831 | #ifndef DISALLOW_PRINTING |
---|
2832 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2833 | #endif |
---|
2834 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2835 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2836 |           case CLP_PARAM_ACTION_STATISTICS: |
---|
2837 |             if (goodModel) { |
---|
2838 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If presolve on look at presolved |
---|
2839 |               bool deleteModel2 = false; |
---|
2840 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â model2 =Â lpSolver; |
---|
2841 |               if (preSolve) { |
---|
2842 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPresolve pinfo; |
---|
2843 |                 int presolveOptions2 = presolveOptions&~0x40000000; |
---|
2844 |                 if ((presolveOptions2&0xffff) != 0) |
---|
2845 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.setPresolveActions(presolveOptions2); |
---|
2846 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.setSubstitution(substitution); |
---|
2847 |                 if ((printOptions&1) != 0) |
---|
2848 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pinfo.statistics(); |
---|
2849 |                 double presolveTolerance = |
---|
2850 |                   parameters_[whichParam(CLP_PARAM_DBL_PRESOLVETOLERANCE, numberParameters_, parameters_)].doubleValue(); |
---|
2851 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 = |
---|
2852 |                   pinfo.presolvedModel(*lpSolver, presolveTolerance, |
---|
2853 |                              true, preSolve); |
---|
2854 |                 if (model2) { |
---|
2855 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Statistics for presolved model\n"); |
---|
2856 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â deleteModel2 =Â true; |
---|
2857 |                 } else { |
---|
2858 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Presolved model looks infeasible - will use unpresolved\n"); |
---|
2859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
2860 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2861 |               } else { |
---|
2862 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Statistics for unpresolved model\n"); |
---|
2863 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model2 =Â lpSolver; |
---|
2864 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2865 |               statistics(lpSolver, model2); |
---|
2866 |               if (deleteModel2) |
---|
2867 |                 delete model2; |
---|
2868 |             } else { |
---|
2869 | #ifndef DISALLOW_PRINTING |
---|
2870 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2871 | #endif |
---|
2872 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2873 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2874 |           case CLP_PARAM_ACTION_TIGHTEN: |
---|
2875 |             if (goodModel) { |
---|
2876 |               int numberInfeasibilities = lpSolver->tightenPrimalBounds(); |
---|
2877 |               if (numberInfeasibilities) |
---|
2878 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Analysis indicates model infeasible"Â <<Â std::endl; |
---|
2879 |             } else { |
---|
2880 | #ifndef DISALLOW_PRINTING |
---|
2881 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2882 | #endif |
---|
2883 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2884 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2885 |           case CLP_PARAM_ACTION_PLUSMINUS: |
---|
2886 |             if (goodModel) { |
---|
2887 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â saveMatrix =Â lpSolver->clpMatrix(); |
---|
2888 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix*Â clpMatrix = |
---|
2889 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<Â ClpPackedMatrix*>(saveMatrix); |
---|
2890 |               if (clpMatrix) { |
---|
2891 |                 ClpPlusMinusOneMatrix * newMatrix = new ClpPlusMinusOneMatrix(*(clpMatrix->matrix())); |
---|
2892 |                 if (newMatrix->getIndices()) { |
---|
2893 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->replaceMatrix(newMatrix); |
---|
2894 |                   delete saveMatrix; |
---|
2895 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix converted to +- one matrix"Â <<Â std::endl; |
---|
2896 |                 } else { |
---|
2897 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix can not be converted to +- 1 matrix"Â <<Â std::endl; |
---|
2898 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2899 |               } else { |
---|
2900 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix not a ClpPackedMatrix"Â <<Â std::endl; |
---|
2901 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2902 |             } else { |
---|
2903 | #ifndef DISALLOW_PRINTING |
---|
2904 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2905 | #endif |
---|
2906 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2907 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2908 |           case CLP_PARAM_ACTION_OUTDUPROWS: |
---|
2909 | Â Â Â Â Â Â Â Â Â Â Â Â dominatedCuts =Â true; |
---|
2910 | #ifdef JJF_ZERO |
---|
2911 |             if (goodModel) { |
---|
2912 |               int numberRows = clpSolver->getNumRows(); |
---|
2913 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //int nOut = outDupRow(clpSolver); |
---|
2914 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglDuplicateRow dupcuts(clpSolver); |
---|
2915 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â storedCuts =Â dupcuts.outDuplicates(clpSolver)Â !=Â 0; |
---|
2916 |               int nOut = numberRows - clpSolver->getNumRows(); |
---|
2917 |               if (nOut && !noPrinting_) |
---|
2918 |                 sprintf(generalPrint, "%d rows eliminated", nOut); |
---|
2919 |               generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
2920 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
2921 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
2922 |             } else { |
---|
2923 | #ifndef DISALLOW_PRINTING |
---|
2924 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2925 | #endif |
---|
2926 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2927 | #endif |
---|
2928 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2929 |           case CLP_PARAM_ACTION_NETWORK: |
---|
2930 |             if (goodModel) { |
---|
2931 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â saveMatrix =Â lpSolver->clpMatrix(); |
---|
2932 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix*Â clpMatrix = |
---|
2933 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<Â ClpPackedMatrix*>(saveMatrix); |
---|
2934 |               if (clpMatrix) { |
---|
2935 |                 ClpNetworkMatrix * newMatrix = new ClpNetworkMatrix(*(clpMatrix->matrix())); |
---|
2936 |                 if (newMatrix->getIndices()) { |
---|
2937 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->replaceMatrix(newMatrix); |
---|
2938 |                   delete saveMatrix; |
---|
2939 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix converted to network matrix"Â <<Â std::endl; |
---|
2940 |                 } else { |
---|
2941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix can not be converted to network matrix"Â <<Â std::endl; |
---|
2942 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2943 |               } else { |
---|
2944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Matrix not a ClpPackedMatrix"Â <<Â std::endl; |
---|
2945 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2946 |             } else { |
---|
2947 | #ifndef DISALLOW_PRINTING |
---|
2948 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "** Current model not valid"Â <<Â std::endl; |
---|
2949 | #endif |
---|
2950 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2951 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
2952 |           case CBC_PARAM_ACTION_DOHEURISTIC: |
---|
2953 |             if (goodModel) { |
---|
2954 |               int vubAction = parameters_[whichParam(CBC_PARAM_INT_VUBTRY, numberParameters_, parameters_)].intValue(); |
---|
2955 |               if (vubAction != -1) { |
---|
2956 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // look at vubs |
---|
2957 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // extra1 is number of ints to leave free |
---|
2958 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Just ones which affect >= extra3 |
---|
2959 |                 int extra3 = parameters_[whichParam(CBC_PARAM_INT_EXTRA3, numberParameters_, parameters_)].intValue(); |
---|
2960 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* 2 is cost above which to fix if feasible |
---|
2961 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3 is fraction of integer variables fixed if relaxing (0.97) |
---|
2962 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 is fraction of all variables fixed if relaxing (0.0) |
---|
2963 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
2964 |                 double dextra[6]; |
---|
2965 |                 int extra[5]; |
---|
2966 |                 extra[1] = parameters_[whichParam(CBC_PARAM_INT_EXTRA1, numberParameters_, parameters_)].intValue(); |
---|
2967 |                 int exp1 = parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters_, |
---|
2968 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_)].intValue(); |
---|
2969 |                 if (exp1 == 4 && extra[1] == -1) |
---|
2970 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra[1]Â =Â 999998; |
---|
2971 |                 dextra[1] = parameters_[whichParam(CBC_PARAM_DBL_FAKEINCREMENT, numberParameters_, parameters_)].doubleValue(); |
---|
2972 |                 dextra[2] = parameters_[whichParam(CBC_PARAM_DBL_FAKECUTOFF, numberParameters_, parameters_)].doubleValue(); |
---|
2973 |                 dextra[3] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
2974 |                 dextra[4] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA4, numberParameters_, parameters_)].doubleValue(); |
---|
2975 |                 dextra[5] = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA5, numberParameters_, parameters_)].doubleValue(); |
---|
2976 |                 if (!dextra[3]) |
---|
2977 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dextra[3]Â =Â 0.97; |
---|
2978 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //OsiClpSolverInterface * newSolver = |
---|
2979 |                 fixVubs(model_, extra3, vubAction, generalMessageHandler, |
---|
2980 |                     debugValues, dextra, extra); |
---|
2981 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //assert (!newSolver); |
---|
2982 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
2983 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Actually do heuristics |
---|
2984 |               doHeuristics(&model_, 2, parameters_, |
---|
2985 |                      numberParameters_, noPrinting_, initialPumpTune); |
---|
2986 |               if (model_.bestSolution()) { |
---|
2987 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(1); |
---|
2988 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(6); |
---|
2989 | #ifdef COIN_HAS_ASL |
---|
2990 |                 if (statusUserFunction_[0]) { |
---|
2991 |                   double value = model_.getObjValue(); |
---|
2992 |                   char buf[300]; |
---|
2993 |                   int pos = 0; |
---|
2994 |                   pos += sprintf(buf + pos, "feasible,"); |
---|
2995 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â 0; |
---|
2996 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â value; |
---|
2997 |                   pos += sprintf(buf + pos, " objective %.*g", ampl_obj_prec(), |
---|
2998 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value); |
---|
2999 |                   sprintf(buf + pos, "\n0 iterations"); |
---|
3000 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.primalSolution); |
---|
3001 |                   int numberColumns = lpSolver->numberColumns(); |
---|
3002 |                   info.primalSolution = reinterpret_cast<double *> (malloc(numberColumns * sizeof(double))); |
---|
3003 |                   CoinCopyN(model_.bestSolution(), numberColumns, info.primalSolution); |
---|
3004 |                   int numberRows = lpSolver->numberRows(); |
---|
3005 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.dualSolution); |
---|
3006 |                   info.dualSolution = reinterpret_cast<double *> (malloc(numberRows * sizeof(double))); |
---|
3007 |                   CoinZeroN(info.dualSolution, numberRows); |
---|
3008 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis *Â basis =Â lpSolver->getBasis(); |
---|
3009 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.rowStatus); |
---|
3010 |                   info.rowStatus = reinterpret_cast<int *> (malloc(numberRows * sizeof(int))); |
---|
3011 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.columnStatus); |
---|
3012 |                   info.columnStatus = reinterpret_cast<int *> (malloc(numberColumns * sizeof(int))); |
---|
3013 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Put basis in |
---|
3014 |                   int i; |
---|
3015 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // free,basic,ub,lb are 0,1,2,3 |
---|
3016 |                   for (i = 0; i < numberRows; i++) { |
---|
3017 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getArtifStatus(i); |
---|
3018 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.rowStatus[i]Â =Â status; |
---|
3019 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3020 |                   for (i = 0; i < numberColumns; i++) { |
---|
3021 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinWarmStartBasis::Status status =Â basis->getStructStatus(i); |
---|
3022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.columnStatus[i]Â =Â status; |
---|
3023 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3024 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // put buffer into info |
---|
3025 |                   strcpy(info.buffer, buf); |
---|
3026 |                   delete basis; |
---|
3027 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3028 | #endif |
---|
3029 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3030 |               int returnCode = callBack(&model, 6); |
---|
3031 |               if (returnCode) { |
---|
3032 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3033 |                 delete babModel_; |
---|
3034 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3035 |                 return returnCode; |
---|
3036 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3037 | Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3038 | Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3039 |           case CBC_PARAM_ACTION_MIPLIB: |
---|
3040 | Â Â Â Â Â Â Â Â Â Â Â Â // User can set options - main difference is lack of model and CglPreProcess |
---|
3041 | Â Â Â Â Â Â Â Â Â Â Â Â goodModel =Â true; |
---|
3042 | Â Â Â Â Â Â Â Â Â Â Â Â /* |
---|
3043 | Â Â Â Â Â Â Â Â Â Â Â Â Â Run branch-and-cut. First set a few options -- node comparison, scaling. |
---|
3044 | Â Â Â Â Â Â Â Â Â Â Â Â Â Print elapsed time at the end. |
---|
3045 | Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
3046 |           case CBC_PARAM_ACTION_BAB: // branchAndBound |
---|
3047 | Â Â Â Â Â Â Â Â Â Â Â Â // obsolete case STRENGTHEN: |
---|
3048 |             if (goodModel) { |
---|
3049 |               bool miplib = type == CBC_PARAM_ACTION_MIPLIB; |
---|
3050 |               int logLevel = parameters_[slog].intValue(); |
---|
3051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Reduce printout |
---|
3052 |               if (logLevel <= 1) { |
---|
3053 |                 model_.solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3054 |               } else { |
---|
3055 |                 model_.solver()->setHintParam(OsiDoReducePrint, false, OsiHintTry); |
---|
3056 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3057 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3058 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3059 | #ifndef CBC_OTHER_SOLVER |
---|
3060 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3061 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3062 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3063 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->getModelPtr()->scaling(doScaling); |
---|
3064 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lpSolver =Â si->getModelPtr(); |
---|
3065 |                 if (doVector) { |
---|
3066 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpMatrixBase *Â matrix =Â lpSolver->clpMatrix(); |
---|
3067 |                   if (dynamic_cast< ClpPackedMatrix*>(matrix)) { |
---|
3068 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpPackedMatrix *Â clpMatrix =Â dynamic_cast<Â ClpPackedMatrix*>(matrix); |
---|
3069 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpMatrix->makeSpecialColumnCopy(); |
---|
3070 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3071 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3072 | #elif CBC_OTHER_SOLVER==1 |
---|
3073 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiCpxSolverInterface *Â si = |
---|
3074 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiCpxSolverInterface *>(solver)Â ; |
---|
3075 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3076 | #endif |
---|
3077 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nrows =Â si->getNumRows(); |
---|
3078 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_ncols =Â si->getNumCols(); |
---|
3079 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedrows =Â si->getNumRows(); |
---|
3080 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedcols =Â si->getNumCols(); |
---|
3081 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if quadratic |
---|
3082 | #ifndef CBC_OTHER_SOLVER |
---|
3083 | #ifdef COIN_HAS_LINK |
---|
3084 |                 if (!complicatedInteger) { |
---|
3085 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpQuadraticObjective *Â obj =Â (dynamic_cast<Â ClpQuadraticObjective*>(lpSolver->objectiveAsObject())); |
---|
3086 |                   if (obj) { |
---|
3087 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3088 |                     int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
3089 |                     parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].setIntValue(CoinMax(0, testOsiOptions)); |
---|
3090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // create coin model |
---|
3091 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â coinModel =Â lpSolver->createCoinModel(); |
---|
3092 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (coinModel); |
---|
3093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // load from coin model |
---|
3094 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink solver1; |
---|
3095 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2 =Â solver1.clone(); |
---|
3096 |                     model_.assignSolver(solver2, false); |
---|
3097 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â si = |
---|
3098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiSolverLink *>(model_.solver())Â ; |
---|
3099 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3100 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(0.001); |
---|
3101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // need some relative granularity |
---|
3102 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(100.0); |
---|
3103 |                     double dextra3 = parameters_[whichParam(CBC_PARAM_DBL_DEXTRA3, numberParameters_, parameters_)].doubleValue(); |
---|
3104 |                     if (dextra3) |
---|
3105 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultMeshSize(dextra3); |
---|
3106 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setDefaultBound(1000.0); |
---|
3107 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setIntegerPriority(1000); |
---|
3108 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setBiLinearPriority(10000); |
---|
3109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions2(2Â +Â 4Â +Â 8); |
---|
3110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CoinModel *Â model2 =Â coinModel; |
---|
3111 |                     si->load(*model2, true, parameters_[log].intValue()); |
---|
3112 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // redo |
---|
3113 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver =Â model_.solver(); |
---|
3114 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
3115 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
3116 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->messageHandler()->setLogLevel(0)Â ; |
---|
3117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â testOsiParameters =Â 0; |
---|
3118 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 2;Â // allow cuts |
---|
3119 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â coinSolver =Â model_.solver(); |
---|
3120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â linkSolver =Â dynamic_cast<Â OsiSolverLink*>Â (coinSolver); |
---|
3121 |                     if (linkSolver->quadraticModel()) { |
---|
3122 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â qp =Â linkSolver->quadraticModel(); |
---|
3123 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //linkSolver->nonlinearSLP(CoinMax(slpValue,10),1.0e-5); |
---|
3124 |                       qp->nonlinearSLP(CoinMax(slpValue, 40), 1.0e-5); |
---|
3125 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â qp->primal(1); |
---|
3126 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLinearizedQuadratic solver2(qp); |
---|
3127 |                       const double * solution = NULL; |
---|
3128 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Reduce printout |
---|
3129 |                       solver2.setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3130 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcModel model2(solver2); |
---|
3131 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Now do requested saves and modifications |
---|
3132 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcModel *Â cbcModel =Â &Â model2; |
---|
3133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â osiModel =Â model2.solver(); |
---|
3134 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclpModel =Â dynamic_cast<Â OsiClpSolverInterface*>Â (osiModel); |
---|
3135 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â clpModel =Â osiclpModel->getModelPtr(); |
---|
3136 | |
---|
3137 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Set changed values |
---|
3138 | |
---|
3139 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglProbing probing; |
---|
3140 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxProbe(10); |
---|
3141 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxLook(10); |
---|
3142 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxElements(200); |
---|
3143 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxProbeRoot(50); |
---|
3144 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setMaxLookRoot(10); |
---|
3145 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setRowCuts(3); |
---|
3146 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probing.setUsingObjective(true); |
---|
3147 |                       cbcModel->addCutGenerator(&probing, -1, "Probing", true, false, false, -100, -1, -1); |
---|
3148 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(0)->setTiming(true); |
---|
3149 | |
---|
3150 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglGomory gomory; |
---|
3151 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomory.setLimitAtRoot(512); |
---|
3152 |                       cbcModel->addCutGenerator(&gomory, -98, "Gomory", true, false, false, -100, -1, -1); |
---|
3153 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(1)->setTiming(true); |
---|
3154 | |
---|
3155 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglKnapsackCover knapsackCover; |
---|
3156 |                       cbcModel->addCutGenerator(&knapsackCover, -98, "KnapsackCover", true, false, false, -100, -1, -1); |
---|
3157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(2)->setTiming(true); |
---|
3158 | |
---|
3159 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglRedSplit redSplit; |
---|
3160 |                       cbcModel->addCutGenerator(&redSplit, -99, "RedSplit", true, false, false, -100, -1, -1); |
---|
3161 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(3)->setTiming(true); |
---|
3162 | |
---|
3163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglClique clique; |
---|
3164 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setStarCliqueReport(false); |
---|
3165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setRowCliqueReport(false); |
---|
3166 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clique.setMinViolation(0.1); |
---|
3167 |                       cbcModel->addCutGenerator(&clique, -98, "Clique", true, false, false, -100, -1, -1); |
---|
3168 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(4)->setTiming(true); |
---|
3169 | |
---|
3170 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglMixedIntegerRounding2 mixedIntegerRounding2; |
---|
3171 |                       cbcModel->addCutGenerator(&mixedIntegerRounding2, -98, "MixedIntegerRounding2", true, false, false, -100, -1, -1); |
---|
3172 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(5)->setTiming(true); |
---|
3173 | |
---|
3174 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglFlowCover flowCover; |
---|
3175 |                       cbcModel->addCutGenerator(&flowCover, -98, "FlowCover", true, false, false, -100, -1, -1); |
---|
3176 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(6)->setTiming(true); |
---|
3177 | |
---|
3178 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglTwomir twomir; |
---|
3179 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomir.setMaxElements(250); |
---|
3180 |                       cbcModel->addCutGenerator(&twomir, -99, "Twomir", true, false, false, -100, -1, -1); |
---|
3181 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->cutGenerator(7)->setTiming(true); |
---|
3182 | |
---|
3183 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicFPump heuristicFPump(*cbcModel); |
---|
3184 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setWhen(13); |
---|
3185 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setMaximumPasses(20); |
---|
3186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setMaximumRetries(7); |
---|
3187 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setHeuristicName("feasibility pump"); |
---|
3188 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setInitialWeight(1); |
---|
3189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicFPump.setFractionSmall(0.6); |
---|
3190 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicFPump); |
---|
3191 | |
---|
3192 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcRounding rounding(*cbcModel); |
---|
3193 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rounding.setHeuristicName("rounding"); |
---|
3194 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&rounding); |
---|
3195 | |
---|
3196 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicLocal heuristicLocal(*cbcModel); |
---|
3197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setHeuristicName("combine solutions"); |
---|
3198 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setSearchType(1); |
---|
3199 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicLocal.setFractionSmall(0.6); |
---|
3200 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicLocal); |
---|
3201 | |
---|
3202 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicGreedyCover heuristicGreedyCover(*cbcModel); |
---|
3203 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicGreedyCover.setHeuristicName("greedy cover"); |
---|
3204 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicGreedyCover); |
---|
3205 | |
---|
3206 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicGreedyEquality heuristicGreedyEquality(*cbcModel); |
---|
3207 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â heuristicGreedyEquality.setHeuristicName("greedy equality"); |
---|
3208 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->addHeuristic(&heuristicGreedyEquality); |
---|
3209 | |
---|
3210 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcCompareDefault compare; |
---|
3211 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNodeComparison(compare); |
---|
3212 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNumberBeforeTrust(5); |
---|
3213 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setSpecialOptions(2); |
---|
3214 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->messageHandler()->setLogLevel(1); |
---|
3215 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMaximumCutPassesAtRoot(-100); |
---|
3216 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMaximumCutPasses(1); |
---|
3217 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setMinimumDrop(0.05); |
---|
3218 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // For branchAndBound this may help |
---|
3219 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->defaultFactorizationFrequency(); |
---|
3220 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->setDualBound(1.0001e+08); |
---|
3221 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->setPerturbation(50); |
---|
3222 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclpModel->setSpecialOptions(193); |
---|
3223 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclpModel->messageHandler()->setLogLevel(0); |
---|
3224 |                       osiclpModel->setIntParam(OsiMaxNumIterationHotStart, 100); |
---|
3225 |                       osiclpModel->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3226 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // You can save some time by switching off message building |
---|
3227 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // clpModel->messagesPointer()->setDetailMessages(100,10000,(int *) NULL); |
---|
3228 | |
---|
3229 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Solve |
---|
3230 | |
---|
3231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->initialSolve(); |
---|
3232 |                       if (clpModel->tightenPrimalBounds() != 0) { |
---|
3233 | #ifndef DISALLOW_PRINTING |
---|
3234 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Problem is infeasible - tightenPrimalBounds!"Â <<Â std::endl; |
---|
3235 | #endif |
---|
3236 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3237 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3238 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpModel->dual();Â // clean up |
---|
3239 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->initialSolve(); |
---|
3240 | #ifdef CBC_THREAD |
---|
3241 |                       int numberThreads = parameters_[whichParam(CBC_PARAM_INT_THREADS, numberParameters_, parameters_)].intValue(); |
---|
3242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->setNumberThreads(numberThreads %Â 100); |
---|
3243 |                       cbcModel->setThreadMode(CoinMin(numberThreads / 100, 7)); |
---|
3244 | #endif |
---|
3245 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //setCutAndHeuristicOptions(*cbcModel); |
---|
3246 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcModel->branchAndBound(); |
---|
3247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLinearizedQuadratic *Â solver3 =Â dynamic_cast<OsiSolverLinearizedQuadratic *>Â (model2.solver()); |
---|
3248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (solver3); |
---|
3249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solution =Â solver3->bestSolution(); |
---|
3250 |                       double bestObjectiveValue = solver3->bestObjectiveValue(); |
---|
3251 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â linkSolver->setBestObjectiveValue(bestObjectiveValue); |
---|
3252 |                       linkSolver->setBestSolution(solution, solver3->getNumCols()); |
---|
3253 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcHeuristicDynamic3 dynamic(model_); |
---|
3254 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic.setHeuristicName("dynamic pass thru"); |
---|
3255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.addHeuristic(&dynamic); |
---|
3256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // if convex |
---|
3257 |                       if ((linkSolver->specialOptions2()&4) != 0) { |
---|
3258 |                         int numberColumns = coinModel->numberColumns(); |
---|
3259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (linkSolver->objectiveVariable()Â ==Â numberColumns); |
---|
3260 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // add OA cut |
---|
3261 |                         double offset; |
---|
3262 |                         double * gradient = new double [numberColumns+1]; |
---|
3263 |                         memcpy(gradient, qp->objectiveAsObject()->gradient(qp, solution, offset, true, 2), |
---|
3264 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberColumns*sizeof(double)); |
---|
3265 |                         double rhs = 0.0; |
---|
3266 |                         int * column = new int[numberColumns+1]; |
---|
3267 |                         int n = 0; |
---|
3268 |                         for (int i = 0; i < numberColumns; i++) { |
---|
3269 |                           double value = gradient[i]; |
---|
3270 |                           if (fabs(value) > 1.0e-12) { |
---|
3271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gradient[n]Â =Â value; |
---|
3272 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rhs +=Â value *Â solution[i]; |
---|
3273 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â column[n++]Â =Â i; |
---|
3274 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3275 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gradient[n]Â =Â -1.0; |
---|
3277 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â column[n++]Â =Â numberColumns; |
---|
3278 |                         storedAmpl.addCut(-COIN_DBL_MAX, offset + 1.0e-7, n, column, gradient); |
---|
3279 |                         delete [] gradient; |
---|
3280 |                         delete [] column; |
---|
3281 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3282 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // could do three way branching round a) continuous b) best solution |
---|
3283 |                       printf("obj %g\n", bestObjectiveValue); |
---|
3284 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â linkSolver->initialSolve(); |
---|
3285 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3286 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3287 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3288 | #endif |
---|
3289 | #endif |
---|
3290 |                 if (logLevel <= 1) |
---|
3291 |                   si->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
---|
3292 | #ifndef CBC_OTHER_SOLVER |
---|
3293 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions(0x40000000); |
---|
3294 | #endif |
---|
3295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3296 |               if (!miplib) { |
---|
3297 |                 if (!preSolve) { |
---|
3298 |                   model_.solver()->setHintParam(OsiDoPresolveInInitial, false, OsiHintTry); |
---|
3299 |                   model_.solver()->setHintParam(OsiDoPresolveInResolve, false, OsiHintTry); |
---|
3300 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3301 |                 double time1a = CoinCpuTime(); |
---|
3302 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3303 | #ifndef CBC_OTHER_SOLVER |
---|
3304 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3305 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3306 |                 if (si) |
---|
3307 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setSpecialOptions(si->specialOptions()Â |Â 1024); |
---|
3308 | #endif |
---|
3309 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.initialSolve(); |
---|
3310 | #ifndef CBC_OTHER_SOLVER |
---|
3311 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â clpSolver =Â si->getModelPtr(); |
---|
3312 |                 int iStatus = clpSolver->status(); |
---|
3313 |                 int iStatus2 = clpSolver->secondaryStatus(); |
---|
3314 |                 if (iStatus == 0) { |
---|
3315 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
3316 |                 } else if (iStatus == 1) { |
---|
3317 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3318 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 1;Â // say infeasible |
---|
3319 |                 } else if (iStatus == 2) { |
---|
3320 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 0; |
---|
3321 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 7;Â // say unbounded |
---|
3322 |                 } else if (iStatus == 3) { |
---|
3323 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 1; |
---|
3324 |                   if (iStatus2 == 9) |
---|
3325 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 4; |
---|
3326 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3327 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 3;Â // Use nodes - as closer than solutions |
---|
3328 |                 } else if (iStatus == 4) { |
---|
3329 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â 2;Â // difficulties |
---|
3330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus2 =Â 0; |
---|
3331 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3332 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(iStatus); |
---|
3333 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(iStatus2); |
---|
3334 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->setWarmStart(NULL); |
---|
3335 |                 int returnCode = callBack(&model_, 1); |
---|
3336 |                 if (returnCode) { |
---|
3337 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3338 |                   delete babModel_; |
---|
3339 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3340 |                   return returnCode; |
---|
3341 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3342 |                 if (clpSolver->status() > 0) { |
---|
3343 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3344 |                   if (babModel_) { |
---|
3345 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(iStatus); |
---|
3346 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(iStatus2); |
---|
3347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3348 |                   if (!noPrinting_) { |
---|
3349 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iStatus =Â clpSolver->status(); |
---|
3350 |                     const char * msg[] = {"infeasible", "unbounded", "stopped", |
---|
3351 |                                "difficulties", "other" |
---|
3352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }; |
---|
3353 |                     sprintf(generalPrint, "Problem is %s - %.2f seconds", |
---|
3354 |                         msg[iStatus-1], CoinCpuTime() - time1a); |
---|
3355 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3356 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3357 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3358 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3359 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3360 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver->setSpecialOptions(clpSolver->specialOptions()Â |Â IN_BRANCH_AND_BOUND);Â // say is Cbc (and in branch and bound) |
---|
3362 | #elif CBC_OTHER_SOLVER==1 |
---|
3363 | #endif |
---|
3364 |                 if (!noPrinting_) { |
---|
3365 |                   sprintf(generalPrint, "Continuous objective value is %g - %.2f seconds", |
---|
3366 |                       solver->getObjValue(), CoinCpuTime() - time1a); |
---|
3367 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3368 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3369 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3371 |                 if (model_.getMaximumNodes() == -987654321) { |
---|
3372 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if No objective! |
---|
3373 |                   int numberColumns = clpSolver->getNumCols(); |
---|
3374 |                   const double * obj = clpSolver->getObjCoefficients(); |
---|
3375 |                   const double * lower = clpSolver->getColLower(); |
---|
3376 |                   const double * upper = clpSolver->getColUpper(); |
---|
3377 |                   int nObj = 0; |
---|
3378 |                   for (int i = 0; i < numberColumns; i++) { |
---|
3379 |                     if (upper[i] > lower[i] && obj[i]) |
---|
3380 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nObj++; |
---|
3381 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3382 |                   if (!nObj) { |
---|
3383 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("************No objective!!\n"); |
---|
3384 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setMaximumSolutions(1); |
---|
3385 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Column copy |
---|
3386 |                     CoinPackedMatrix matrixByCol(*model_.solver()->getMatrixByCol()); |
---|
3387 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const double * element = matrixByCol.getElements(); |
---|
3388 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const int * row = matrixByCol.getIndices(); |
---|
3389 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //const CoinBigIndex * columnStart = matrixByCol.getVectorStarts(); |
---|
3390 |                     const int * columnLength = matrixByCol.getVectorLengths(); |
---|
3391 |                     for (int i = 0; i < numberColumns; i++) { |
---|
3392 |                       double value = (CoinDrand48() + 0.5) * 10000; |
---|
3393 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value =Â 10; |
---|
3394 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â value *=Â columnLength[i]; |
---|
3395 |                       int iValue = static_cast<int> (value) / 10; |
---|
3396 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //iValue=1; |
---|
3397 |                       clpSolver->setObjCoeff(i, iValue); |
---|
3398 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3399 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3400 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3401 | #ifndef CBC_OTHER_SOLVER |
---|
3402 |                 if (!complicatedInteger && preProcess == 0 && clpSolver->tightenPrimalBounds(0.0, 0, true) != 0) { |
---|
3403 | #ifndef DISALLOW_PRINTING |
---|
3404 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Problem is infeasible - tightenPrimalBounds!"Â <<Â std::endl; |
---|
3405 | #endif |
---|
3406 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3407 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3408 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3409 |                   if (babModel_) { |
---|
3410 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3411 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3412 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3413 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3414 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3415 |                 if (clpSolver->dualBound() == 1.0e10) { |
---|
3416 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex temp =Â *clpSolver; |
---|
3417 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â temp.setLogLevel(0); |
---|
3418 |                   temp.dual(0, 7); |
---|
3419 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // user did not set - so modify |
---|
3420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get largest scaled away from bound |
---|
3421 |                   double largest = 1.0e-12; |
---|
3422 |                   double largestScaled = 1.0e-12; |
---|
3423 |                   int numberRows = temp.numberRows(); |
---|
3424 |                   const double * rowPrimal = temp.primalRowSolution(); |
---|
3425 |                   const double * rowLower = temp.rowLower(); |
---|
3426 |                   const double * rowUpper = temp.rowUpper(); |
---|
3427 |                   const double * rowScale = temp.rowScale(); |
---|
3428 |                   int iRow; |
---|
3429 |                   for (iRow = 0; iRow < numberRows; iRow++) { |
---|
3430 |                     double value = rowPrimal[iRow]; |
---|
3431 |                     double above = value - rowLower[iRow]; |
---|
3432 |                     double below = rowUpper[iRow] - value; |
---|
3433 |                     if (above < 1.0e12) { |
---|
3434 |                       largest = CoinMax(largest, above); |
---|
3435 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3436 |                     if (below < 1.0e12) { |
---|
3437 |                       largest = CoinMax(largest, below); |
---|
3438 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3439 |                     if (rowScale) { |
---|
3440 |                       double multiplier = rowScale[iRow]; |
---|
3441 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â above *=Â multiplier; |
---|
3442 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â below *=Â multiplier; |
---|
3443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3444 |                     if (above < 1.0e12) { |
---|
3445 |                       largestScaled = CoinMax(largestScaled, above); |
---|
3446 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3447 |                     if (below < 1.0e12) { |
---|
3448 |                       largestScaled = CoinMax(largestScaled, below); |
---|
3449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3450 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3451 | |
---|
3452 |                   int numberColumns = temp.numberColumns(); |
---|
3453 |                   const double * columnPrimal = temp.primalColumnSolution(); |
---|
3454 |                   const double * columnLower = temp.columnLower(); |
---|
3455 |                   const double * columnUpper = temp.columnUpper(); |
---|
3456 |                   const double * columnScale = temp.columnScale(); |
---|
3457 |                   int iColumn; |
---|
3458 |                   for (iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
3459 |                     double value = columnPrimal[iColumn]; |
---|
3460 |                     double above = value - columnLower[iColumn]; |
---|
3461 |                     double below = columnUpper[iColumn] - value; |
---|
3462 |                     if (above < 1.0e12) { |
---|
3463 |                       largest = CoinMax(largest, above); |
---|
3464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3465 |                     if (below < 1.0e12) { |
---|
3466 |                       largest = CoinMax(largest, below); |
---|
3467 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3468 |                     if (columnScale) { |
---|
3469 |                       double multiplier = 1.0 / columnScale[iColumn]; |
---|
3470 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â above *=Â multiplier; |
---|
3471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â below *=Â multiplier; |
---|
3472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3473 |                     if (above < 1.0e12) { |
---|
3474 |                       largestScaled = CoinMax(largestScaled, above); |
---|
3475 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3476 |                     if (below < 1.0e12) { |
---|
3477 |                       largestScaled = CoinMax(largestScaled, below); |
---|
3478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3480 | #ifdef COIN_DEVELOP |
---|
3481 |                   if (!noPrinting_) |
---|
3482 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Largest (scaled) away from bound "Â <<Â largestScaled |
---|
3483 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â " unscaled "Â <<Â largest <<Â std::endl; |
---|
3484 | #endif |
---|
3485 |                   clpSolver->setDualBound(CoinMax(1.0001e8, CoinMin(100.0*largest, 1.00001e10))); |
---|
3486 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3487 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->resolve();Â // clean up |
---|
3488 | #endif |
---|
3489 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3490 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If user made settings then use them |
---|
3491 |               if (!defaultSettings) { |
---|
3492 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver =Â model_.solver(); |
---|
3493 |                 if (!doScaling) |
---|
3494 |                   solver->setHintParam(OsiDoScale, false, OsiHintTry); |
---|
3495 | #ifndef CBC_OTHER_SOLVER |
---|
3496 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3497 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(solver)Â ; |
---|
3498 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3499 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get clp itself |
---|
3500 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â modelC =Â si->getModelPtr(); |
---|
3501 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (modelC->tightenPrimalBounds()!=0) { |
---|
3502 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //std::cout<<"Problem is infeasible!"<<std::endl; |
---|
3503 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //break; |
---|
3504 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //} |
---|
3505 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // bounds based on continuous |
---|
3506 |                 if (tightenFactor && !complicatedInteger) { |
---|
3507 |                   if (modelC->tightenPrimalBounds(tightenFactor) != 0) { |
---|
3508 | #ifndef DISALLOW_PRINTING |
---|
3509 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Problem is infeasible!"Â <<Â std::endl; |
---|
3510 | #endif |
---|
3511 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3512 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3513 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel if exists |
---|
3514 |                     if (babModel_) { |
---|
3515 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3516 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3517 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3518 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3519 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3520 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3521 | #endif |
---|
3522 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3523 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if we want preprocessing |
---|
3524 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â saveSolver =Â NULL; |
---|
3525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglPreProcess process; |
---|
3526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â cbcPreProcessPointer =Â &Â process; |
---|
3527 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Say integers in sync |
---|
3528 |               bool integersOK = true; |
---|
3529 |               delete babModel_; |
---|
3530 |               babModel_ = new CbcModel(model_); |
---|
3531 | #ifndef CBC_OTHER_SOLVER |
---|
3532 |               int numberChanged = 0; |
---|
3533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver3 =Â clpSolver->clone(); |
---|
3534 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver3); |
---|
3535 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â clpSolver2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (babModel_->solver()); |
---|
3536 |               if (clpSolver2->messageHandler()->logLevel()) |
---|
3537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver2->messageHandler()->setLogLevel(1); |
---|
3538 |               if (logLevel > -1) |
---|
3539 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver2->messageHandler()->setLogLevel(logLevel); |
---|
3540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver2->getModelPtr(); |
---|
3541 |               if (lpSolver->factorizationFrequency() == 200 && !miplib) { |
---|
3542 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // User did not touch preset |
---|
3543 |                 int numberRows = lpSolver->numberRows(); |
---|
3544 |                 const int cutoff1 = 10000; |
---|
3545 |                 const int cutoff2 = 100000; |
---|
3546 |                 const int base = 75; |
---|
3547 |                 const int freq0 = 50; |
---|
3548 |                 const int freq1 = 200; |
---|
3549 |                 const int freq2 = 400; |
---|
3550 |                 const int maximum = 1000; |
---|
3551 |                 int frequency; |
---|
3552 |                 if (numberRows < cutoff1) |
---|
3553 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â numberRows /Â freq0; |
---|
3554 |                 else if (numberRows < cutoff2) |
---|
3555 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â cutoff1 /Â freq0 +Â (numberRows -Â cutoff1)Â /Â freq1; |
---|
3556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
3557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â frequency =Â base +Â cutoff1 /Â freq0 +Â (cutoff2 -Â cutoff1)Â /Â freq1 +Â (numberRows -Â cutoff2)Â /Â freq2; |
---|
3558 |                 lpSolver->setFactorizationFrequency(CoinMin(maximum, frequency)); |
---|
3559 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3560 | #elif CBC_OTHER_SOLVER==1 |
---|
3561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver3 =Â model_.solver()->clone(); |
---|
3562 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver3); |
---|
3563 | #endif |
---|
3564 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â time2 =Â CoinCpuTime(); |
---|
3565 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â totalTime +=Â time2 -Â time1; |
---|
3566 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //time1 = time2; |
---|
3567 |               double timeLeft = babModel_->getMaximumSeconds(); |
---|
3568 |               int numberOriginalColumns = babModel_->solver()->getNumCols(); |
---|
3569 |               if (preProcess == 7) { |
---|
3570 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // use strategy instead |
---|
3571 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3572 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â useStrategy =Â true; |
---|
3573 | #ifdef COIN_HAS_LINK |
---|
3574 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // empty out any cuts |
---|
3575 |                 if (storedAmpl.sizeRowCuts()) { |
---|
3576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Emptying ampl stored cuts as internal preprocessing\n"); |
---|
3577 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglStored temp; |
---|
3578 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â storedAmpl =Â temp; |
---|
3579 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3580 | #endif |
---|
3581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3582 |               if (preProcess && type == CBC_PARAM_ACTION_BAB) { |
---|
3583 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // see whether to switch off preprocessing |
---|
3584 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // only allow SOS and integer |
---|
3585 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â objects =Â babModel_->objects(); |
---|
3586 |                int numberObjects = babModel_->numberObjects(); |
---|
3587 |                for (int iObj = 0; iObj < numberObjects; iObj++) { |
---|
3588 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSOS *Â objSOS = |
---|
3589 |                  dynamic_cast <CbcSOS *>(objects[iObj]) ; |
---|
3590 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleInteger *Â objSimpleInteger = |
---|
3591 |                  dynamic_cast <CbcSimpleInteger *>(objects[iObj]) ; |
---|
3592 |                 if (!objSimpleInteger&&!objSOS) { |
---|
3593 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess=0; |
---|
3594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3595 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3596 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3597 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3598 |               if (type == CBC_PARAM_ACTION_BAB) { |
---|
3599 |                 double limit; |
---|
3600 |                 clpSolver->getDblParam(OsiDualObjectiveLimit, limit); |
---|
3601 |                 if (clpSolver->getObjValue()*clpSolver->getObjSense() >= |
---|
3602 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â limit*clpSolver->getObjSense()) |
---|
3603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â preProcess =Â 0; |
---|
3604 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3605 |               if (preProcess && type == CBC_PARAM_ACTION_BAB) { |
---|
3606 | #ifndef CBC_OTHER_SOLVER |
---|
3607 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // See if sos from mps file |
---|
3608 |                 if (numberSOS == 0 && clpSolver->numberSOS() && doSOS) { |
---|
3609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
3610 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â clpSolver->numberSOS(); |
---|
3611 |                   const CoinSet * setInfo = clpSolver->setInfo(); |
---|
3612 |                   sosStart = new int [numberSOS+1]; |
---|
3613 |                   sosType = new char [numberSOS]; |
---|
3614 |                   int i; |
---|
3615 |                   int nTotal = 0; |
---|
3616 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart[0]Â =Â 0; |
---|
3617 |                   for ( i = 0; i < numberSOS; i++) { |
---|
3618 |                     int type = setInfo[i].setType(); |
---|
3619 |                     int n = setInfo[i].numberEntries(); |
---|
3620 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosType[i]Â =Â static_cast<char>(type); |
---|
3621 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nTotal +=Â n; |
---|
3622 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart[i+1]Â =Â nTotal; |
---|
3623 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3624 |                   sosIndices = new int[nTotal]; |
---|
3625 |                   sosReference = new double [nTotal]; |
---|
3626 |                   for (i = 0; i < numberSOS; i++) { |
---|
3627 |                     int n = setInfo[i].numberEntries(); |
---|
3628 |                     const int * which = setInfo[i].which(); |
---|
3629 |                     const double * weights = setInfo[i].weights(); |
---|
3630 |                     int base = sosStart[i]; |
---|
3631 |                     for (int j = 0; j < n; j++) { |
---|
3632 |                       int k = which[j]; |
---|
3633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices[j+base]Â =Â k; |
---|
3634 |                       sosReference[j+base] = weights ? weights[j] : static_cast<double> (j); |
---|
3635 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3637 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3638 | #endif |
---|
3639 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveSolver =Â babModel_->solver()->clone(); |
---|
3640 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Do not try and produce equality cliques and |
---|
3641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â do up to 10 passes */ |
---|
3642 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â solver2; |
---|
3643 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3644 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Tell solver we are in Branch and Cut |
---|
3645 |                   saveSolver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo) ; |
---|
3646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Default set of cut generators |
---|
3647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CglProbing generator1; |
---|
3648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setUsingObjective(1); |
---|
3649 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPass(1); |
---|
3650 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPassRoot(1); |
---|
3651 |                   generator1.setMaxProbeRoot(CoinMin(3000, saveSolver->getNumCols())); |
---|
3652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElements(100); |
---|
3653 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElementsRoot(200); |
---|
3654 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxLookRoot(50); |
---|
3655 |                   if (saveSolver->getNumCols() > 3000) |
---|
3656 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxProbeRoot(123); |
---|
3657 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setRowCuts(3); |
---|
3658 |                   if ((tunePreProcess&1) != 0) { |
---|
3659 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // heavy probing |
---|
3660 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxPassRoot(2); |
---|
3661 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxElements(300); |
---|
3662 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator1.setMaxProbeRoot(saveSolver->getNumCols()); |
---|
3663 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3664 |                   if ((babModel_->specialOptions()&65536) != 0) |
---|
3665 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.setOptions(1); |
---|
3666 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Add in generators |
---|
3667 |                   if ((model_.moreSpecialOptions()&65536)==0) |
---|
3668 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.addCutGenerator(&generator1); |
---|
3669 |                   int translate[] = {9999, 0, 0, -3, 2, 3, -2, 9999, 4, 5}; |
---|
3670 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.passInMessageHandler(babModel_->messageHandler()); |
---|
3671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //process.messageHandler()->setLogLevel(babModel_->logLevel()); |
---|
3672 | #ifdef COIN_HAS_ASL |
---|
3673 |                   if (info.numberSos && doSOS && statusUserFunction_[0]) { |
---|
3674 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
3675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â info.numberSos; |
---|
3676 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart =Â info.sosStart; |
---|
3677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices =Â info.sosIndices; |
---|
3678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3679 | #endif |
---|
3680 |                   if (numberSOS && doSOS) { |
---|
3681 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
3682 |                     int numberColumns = saveSolver->getNumCols(); |
---|
3683 |                     char * prohibited = new char[numberColumns]; |
---|
3684 |                     memset(prohibited, 0, numberColumns); |
---|
3685 |                     int n = sosStart[numberSOS]; |
---|
3686 |                     for (int i = 0; i < n; i++) { |
---|
3687 |                       int iColumn = sosIndices[i]; |
---|
3688 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
3689 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3690 |                     process.passInProhibited(prohibited, numberColumns); |
---|
3691 |                     delete [] prohibited; |
---|
3692 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3693 |                   if (!model_.numberObjects() && true) { |
---|
3694 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* model may not have created objects |
---|
3695 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If none then create |
---|
3696 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
3697 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.findIntegers(true); |
---|
3698 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3699 |                   if (model_.numberObjects()) { |
---|
3700 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â oldObjects =Â babModel_->objects(); |
---|
3701 |                     int numberOldObjects = babModel_->numberObjects(); |
---|
3702 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
3703 |                     int numberColumns = saveSolver->getNumCols(); |
---|
3704 |                     char * prohibited = new char[numberColumns]; |
---|
3705 |                     memset(prohibited, 0, numberColumns); |
---|
3706 |                     int numberProhibited = 0; |
---|
3707 |                     for (int iObj = 0; iObj < numberOldObjects; iObj++) { |
---|
3708 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSOS *Â obj = |
---|
3709 |                         dynamic_cast <CbcSOS *>(oldObjects[iObj]) ; |
---|
3710 |                       if (obj) { |
---|
3711 |                         int n = obj->numberMembers(); |
---|
3712 |                         const int * which = obj->members(); |
---|
3713 |                         for (int i = 0; i < n; i++) { |
---|
3714 |                           int iColumn = which[i]; |
---|
3715 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
3716 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberProhibited++; |
---|
3717 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3718 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3719 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcLotsize *Â obj2 = |
---|
3720 |                         dynamic_cast <CbcLotsize *>(oldObjects[iObj]) ; |
---|
3721 |                       if (obj2) { |
---|
3722 |                         int iColumn = obj2->columnNumber(); |
---|
3723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prohibited[iColumn]Â =Â 1; |
---|
3724 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberProhibited++; |
---|
3725 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3726 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3727 |                     if (numberProhibited) |
---|
3728 |                       process.passInProhibited(prohibited, numberColumns); |
---|
3729 |                     delete [] prohibited; |
---|
3730 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3731 |                   int numberPasses = 10; |
---|
3732 |                   if (tunePreProcess >= 1000000) { |
---|
3733 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberPasses =Â (tunePreProcess /Â 1000000)Â -Â 1; |
---|
3734 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â tunePreProcess %Â 1000000; |
---|
3735 |                   } else if (tunePreProcess >= 1000) { |
---|
3736 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberPasses =Â (tunePreProcess /Â 1000)Â -Â 1; |
---|
3737 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess =Â tunePreProcess %Â 1000; |
---|
3738 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3739 | #ifndef CBC_OTHER_SOLVER |
---|
3740 |                   if (doSprint > 0) { |
---|
3741 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Sprint for primal solves |
---|
3742 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::SolveType method =Â ClpSolve::usePrimalorSprint; |
---|
3743 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSolve::PresolveType presolveType =Â ClpSolve::presolveOff; |
---|
3744 |                     int numberPasses = 5; |
---|
3745 |                     int options[] = {0, 3, 0, 0, 0, 0}; |
---|
3746 |                     int extraInfo[] = { -1, 20, -1, -1, -1, -1}; |
---|
3747 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extraInfo[1]Â =Â doSprint; |
---|
3748 |                     int independentOptions[] = {0, 0, 3}; |
---|
3749 |                     ClpSolve clpSolve(method, presolveType, numberPasses, |
---|
3750 |                              options, extraInfo, independentOptions); |
---|
3751 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say use in OsiClp |
---|
3752 |                     clpSolve.setSpecialOption(6, 1); |
---|
3753 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
3754 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSolveOptions(clpSolve); |
---|
3755 |                     osiclp->setHintParam(OsiDoDualInResolve, false); |
---|
3756 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // switch off row copy |
---|
3757 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setSpecialOptions(osiclp->getModelPtr()->specialOptions()Â |Â 256); |
---|
3758 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setInfeasibilityCost(1.0e11); |
---|
3759 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3760 | #endif |
---|
3761 | #ifndef CBC_OTHER_SOLVER |
---|
3762 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3763 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
3764 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSpecialOptions(osiclp->specialOptions()Â |Â 1024); |
---|
3765 |                     int savePerturbation = osiclp->getModelPtr()->perturbation(); |
---|
3766 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //#define CBC_TEMP1 |
---|
3767 | #ifdef CBC_TEMP1 |
---|
3768 |                     if (savePerturbation == 50) |
---|
3769 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setPerturbation(52);Â // try less |
---|
3770 | #endif |
---|
3771 |                     if ((model_.moreSpecialOptions()&65536)!=0) |
---|
3772 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.setOptions(2+4+8);Â // no cuts |
---|
3773 |                     solver2 = process.preProcessNonDefault(*saveSolver, translate[preProcess], numberPasses, |
---|
3774 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess); |
---|
3775 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*solver2->writeMps("after"); |
---|
3776 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveSolver->writeMps("before");*/ |
---|
3777 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->getModelPtr()->setPerturbation(savePerturbation); |
---|
3778 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3779 | #elif CBC_OTHER_SOLVER==1 |
---|
3780 |                   solver2 = process.preProcessNonDefault(*saveSolver, translate[preProcess], numberPasses, |
---|
3781 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tunePreProcess); |
---|
3782 | #endif |
---|
3783 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integersOK =Â false;Â // We need to redo if CbcObjects exist |
---|
3784 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Tell solver we are not in Branch and Cut |
---|
3785 |                   saveSolver->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; |
---|
3786 |                   if (solver2) |
---|
3787 |                     solver2->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; |
---|
3788 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3789 | #ifdef COIN_HAS_ASL |
---|
3790 |                 if (!solver2 && statusUserFunction_[0]) { |
---|
3791 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // infeasible |
---|
3792 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.problemStatus =Â 1; |
---|
3793 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.objValue =Â 1.0e100; |
---|
3794 |                   sprintf(info.buffer, "infeasible/unbounded by pre-processing"); |
---|
3795 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.primalSolution =Â NULL; |
---|
3796 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.dualSolution =Â NULL; |
---|
3797 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3798 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3799 | #endif |
---|
3800 |                 if (!noPrinting_) { |
---|
3801 |                   if (!solver2) { |
---|
3802 |                     sprintf(generalPrint, "Pre-processing says infeasible or unbounded"); |
---|
3803 |                     generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
3804 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
3805 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
3806 |                   } else { |
---|
3807 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //printf("processed model has %d rows, %d columns and %d elements\n", |
---|
3808 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â solver2->getNumRows(),solver2->getNumCols(),solver2->getNumElements()); |
---|
3809 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3810 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3811 |                 if (!solver2) { |
---|
3812 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // say infeasible for solution |
---|
3813 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integerStatus =Â 6; |
---|
3814 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3815 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3816 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3817 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3818 |                 } else { |
---|
3819 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedrows =Â solver2->getNumRows(); |
---|
3820 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â statistics_nprocessedcols =Â solver2->getNumCols(); |
---|
3821 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(-1); |
---|
3822 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(-1); |
---|
3823 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3824 |                 int returnCode = callBack(babModel_, 2); |
---|
3825 |                 if (returnCode) { |
---|
3826 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // exit if user wants |
---|
3827 |                   delete babModel_; |
---|
3828 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_ =Â NULL; |
---|
3829 |                   return returnCode; |
---|
3830 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3831 |                 if (!solver2) |
---|
3832 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3833 |                 if (model_.bestSolution()) { |
---|
3834 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // need to redo - in case no better found in BAB |
---|
3835 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // just get integer part right |
---|
3836 |                   const int * originalColumns = process.originalColumns(); |
---|
3837 |                   int numberColumns = solver2->getNumCols(); |
---|
3838 |                   double * bestSolution = babModel_->bestSolution(); |
---|
3839 |                   const double * oldBestSolution = model_.bestSolution(); |
---|
3840 |                   for (int i = 0; i < numberColumns; i++) { |
---|
3841 |                     int jColumn = originalColumns[i]; |
---|
3842 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bestSolution[i]Â =Â oldBestSolution[jColumn]; |
---|
3843 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3844 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3845 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //solver2->resolve(); |
---|
3846 |                 if (preProcess == 2) { |
---|
3847 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â clpSolver2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver2); |
---|
3848 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lpSolver =Â clpSolver2->getModelPtr(); |
---|
3849 |                   lpSolver->writeMps("presolved.mps", 0, 1, lpSolver->optimizationDirection()); |
---|
3850 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("Preprocessed model (minimization) on presolved.mps\n"); |
---|
3851 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3852 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3853 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // look at new integers |
---|
3854 |                   int numberOriginalColumns = |
---|
3855 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.originalModel()->getNumCols(); |
---|
3856 |                   const int * originalColumns = process.originalColumns(); |
---|
3857 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp2 =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver2); |
---|
3858 |                   int numberColumns = osiclp2->getNumCols(); |
---|
3859 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (saveSolver); |
---|
3860 |                   for (int i = 0; i < numberColumns; i++) { |
---|
3861 |                     int iColumn = originalColumns[i]; |
---|
3862 |                     if (iColumn < numberOriginalColumns) { |
---|
3863 |                       if (osiclp2->isInteger(i) && !osiclp->isInteger(iColumn)) |
---|
3864 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp2->setOptionalInteger(i);Â // say optional |
---|
3865 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3866 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3867 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3868 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // we have to keep solver2 so pass clone |
---|
3869 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solver2 =Â solver2->clone(); |
---|
3870 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver2); |
---|
3871 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setOriginalColumns(process.originalColumns()); |
---|
3872 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->initialSolve(); |
---|
3873 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumSeconds(timeLeft -Â (CoinCpuTime()Â -Â time2)); |
---|
3874 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3875 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // now tighten bounds |
---|
3876 |               if (!miplib) { |
---|
3877 | #ifndef CBC_OTHER_SOLVER |
---|
3878 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â si = |
---|
3879 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dynamic_cast<OsiClpSolverInterface *>(babModel_->solver())Â ; |
---|
3880 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (si !=Â NULL); |
---|
3881 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // get clp itself |
---|
3882 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â modelC =Â si->getModelPtr(); |
---|
3883 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (noPrinting_) |
---|
3884 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //modelC->setLogLevel(0); |
---|
3885 |                 if (!complicatedInteger && modelC->tightenPrimalBounds() != 0) { |
---|
3886 | #ifndef DISALLOW_PRINTING |
---|
3887 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::cout <<Â "Problem is infeasible!"Â <<Â std::endl; |
---|
3888 | #endif |
---|
3889 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setProblemStatus(0); |
---|
3890 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â model_.setSecondaryStatus(1); |
---|
3891 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // and in babModel_ if exists |
---|
3892 |                   if (babModel_) { |
---|
3893 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setProblemStatus(0); |
---|
3894 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSecondaryStatus(1); |
---|
3895 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3896 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break; |
---|
3897 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3898 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â si->resolve(); |
---|
3899 | #elif CBC_OTHER_SOLVER==1 |
---|
3900 | #endif |
---|
3901 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3902 |               if (debugValues) { |
---|
3903 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // for debug |
---|
3904 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â std::string problemName ; |
---|
3905 |                 babModel_->solver()->getStrParam(OsiProbName, problemName) ; |
---|
3906 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->activateRowCutDebugger(problemName.c_str())Â ; |
---|
3907 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirGen.probname_ =Â CoinStrdup(problemName.c_str()); |
---|
3908 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // checking seems odd |
---|
3909 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //redsplitGen.set_given_optsol(babModel_->solver()->getRowCutDebuggerAlways()->optimalSolution(), |
---|
3910 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->getNumCols()); |
---|
3911 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3912 |               int testOsiOptions = parameters_[whichParam(CBC_PARAM_INT_TESTOSI, numberParameters_, parameters_)].intValue(); |
---|
3913 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //#ifdef COIN_HAS_ASL |
---|
3914 | #ifndef JJF_ONE |
---|
3915 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If linked then see if expansion wanted |
---|
3916 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
3917 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverLink *Â solver3 =Â dynamic_cast<OsiSolverLink *>Â (babModel_->solver()); |
---|
3918 |                 int options = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].intValue() / 10000; |
---|
3919 |                 if (solver3 || (options&16) != 0) { |
---|
3920 |                   if (options) { |
---|
3921 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* |
---|
3922 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 - force mini branch and bound |
---|
3923 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2 - set priorities high on continuous |
---|
3924 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 4 - try adding OA cuts |
---|
3925 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8 - try doing quadratic linearization |
---|
3926 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 16 - try expanding knapsacks |
---|
3927 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
3928 |                     if ((options&16)) { |
---|
3929 |                       int numberColumns = saveCoinModel.numberColumns(); |
---|
3930 |                       int numberRows = saveCoinModel.numberRows(); |
---|
3931 |                       whichColumn = new int[numberColumns]; |
---|
3932 |                       knapsackStart = new int[numberRows+1]; |
---|
3933 |                       knapsackRow = new int[numberRows]; |
---|
3934 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberKnapsack =Â 10000; |
---|
3935 |                       int extra1 = parameters_[whichParam(CBC_PARAM_INT_EXTRA1, numberParameters_, parameters_)].intValue(); |
---|
3936 |                       int extra2 = parameters_[whichParam(CBC_PARAM_INT_EXTRA2, numberParameters_, parameters_)].intValue(); |
---|
3937 |                       int logLevel = parameters_[log].intValue(); |
---|
3938 |                       OsiSolverInterface * solver = expandKnapsack(saveCoinModel, whichColumn, knapsackStart, |
---|
3939 |                                      knapsackRow, numberKnapsack, |
---|
3940 |                                      storedAmpl, logLevel, extra1, extra2, |
---|
3941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â saveTightenedModel); |
---|
3942 |                       if (solver) { |
---|
3943 | #ifndef CBC_OTHER_SOLVER |
---|
3944 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â clpSolver =Â dynamic_cast<Â OsiClpSolverInterface*>Â (solver); |
---|
3945 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (clpSolver); |
---|
3946 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver =Â clpSolver->getModelPtr(); |
---|
3947 | #endif |
---|
3948 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->assignSolver(solver); |
---|
3949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â testOsiOptions =Â 0; |
---|
3950 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // allow gomory |
---|
3951 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â complicatedInteger =Â 0; |
---|
3952 | #ifdef COIN_HAS_ASL |
---|
3953 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Priorities already done |
---|
3954 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â free(info.priorities); |
---|
3955 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info.priorities =Â NULL; |
---|
3956 | #endif |
---|
3957 |                       } else { |
---|
3958 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberKnapsack =Â 0; |
---|
3959 |                         delete [] whichColumn; |
---|
3960 |                         delete [] knapsackStart; |
---|
3961 |                         delete [] knapsackRow; |
---|
3962 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â whichColumn =Â NULL; |
---|
3963 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackStart =Â NULL; |
---|
3964 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â knapsackRow =Â NULL; |
---|
3965 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3966 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3967 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3968 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3969 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3970 | #endif |
---|
3971 |               if (useCosts && testOsiOptions < 0) { |
---|
3972 |                 int numberColumns = babModel_->getNumCols(); |
---|
3973 |                 int * sort = new int[numberColumns]; |
---|
3974 |                 double * dsort = new double[numberColumns]; |
---|
3975 |                 int * priority = new int [numberColumns]; |
---|
3976 |                 const double * objective = babModel_->getObjCoefficients(); |
---|
3977 |                 const double * lower = babModel_->getColLower() ; |
---|
3978 |                 const double * upper = babModel_->getColUpper() ; |
---|
3979 |                 const CoinPackedMatrix * matrix = babModel_->solver()->getMatrixByCol(); |
---|
3980 |                 const int * columnLength = matrix->getVectorLengths(); |
---|
3981 |                 int iColumn; |
---|
3982 |                 int n = 0; |
---|
3983 |                 for (iColumn = 0; iColumn < numberColumns; iColumn++) { |
---|
3984 |                   if (babModel_->isInteger(iColumn)) { |
---|
3985 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sort[n]Â =Â n; |
---|
3986 |                     if (useCosts == 1) |
---|
3987 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dsort[n++]Â =Â -fabs(objective[iColumn]); |
---|
3988 |                     else if (useCosts == 2) |
---|
3989 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dsort[n++]Â =Â iColumn; |
---|
3990 |                     else if (useCosts == 3) |
---|
3991 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dsort[n++]Â =Â upper[iColumn]Â -Â lower[iColumn]; |
---|
3992 |                     else if (useCosts == 4) |
---|
3993 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dsort[n++]Â =Â -(upper[iColumn]Â -Â lower[iColumn]); |
---|
3994 |                     else if (useCosts == 5) |
---|
3995 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dsort[n++]Â =Â -columnLength[iColumn]; |
---|
3996 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3997 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
3998 |                 CoinSort_2(dsort, dsort + n, sort); |
---|
3999 |                 int level = 0; |
---|
4000 |                 double last = -1.0e100; |
---|
4001 |                 for (int i = 0; i < n; i++) { |
---|
4002 |                   int iPut = sort[i]; |
---|
4003 |                   if (dsort[i] != last) { |
---|
4004 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â level++; |
---|
4005 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last =Â dsort[i]; |
---|
4006 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4007 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â priority[iPut]Â =Â level; |
---|
4008 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4009 |                 babModel_->passInPriorities( priority, false); |
---|
4010 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integersOK =Â true; |
---|
4011 |                 delete [] priority; |
---|
4012 |                 delete [] sort; |
---|
4013 |                 delete [] dsort; |
---|
4014 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4015 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Set up heuristics |
---|
4016 |               doHeuristics(babModel_, ((!miplib) ? 1 : 10), parameters_, |
---|
4017 |                      numberParameters_, noPrinting_, initialPumpTune); |
---|
4018 |               if (!miplib) { |
---|
4019 |                 if (parameters_[whichParam(CBC_PARAM_STR_LOCALTREE, numberParameters_, parameters_)].currentOptionAsInteger()) { |
---|
4020 |                   CbcTreeLocal localTree(babModel_, NULL, 10, 0, 0, 10000, 2000); |
---|
4021 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->passInTreeHandler(localTree); |
---|
4022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4023 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4024 |               if (type == CBC_PARAM_ACTION_MIPLIB) { |
---|
4025 |                 if (babModel_->numberStrong() == 5 && babModel_->numberBeforeTrust() == 5) |
---|
4026 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setNumberBeforeTrust(10); |
---|
4027 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4028 |               int experimentFlag = parameters_[whichParam(CBC_PARAM_INT_EXPERIMENT, numberParameters_, |
---|
4029 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_)].intValue(); |
---|
4030 |               int strategyFlag = parameters_[whichParam(CBC_PARAM_INT_STRATEGY, numberParameters_, |
---|
4031 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_)].intValue(); |
---|
4032 |               int bothFlags = CoinMax(CoinMin(experimentFlag, 1), strategyFlag); |
---|
4033 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // add cut generators if wanted |
---|
4034 |               int switches[30]; |
---|
4035 |               int accuracyFlag[30]; |
---|
4036 |               char doAtEnd[30]; |
---|
4037 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â memset(doAtEnd,0,30); |
---|
4038 |               int numberGenerators = 0; |
---|
4039 |               int translate[] = { -100, -1, -99, -98, 1, -1098, -999, 1, 1, 1, -1}; |
---|
4040 |               if (probingAction) { |
---|
4041 |                 int numberColumns = babModel_->solver()->getNumCols(); |
---|
4042 |                 if (probingAction > 7) { |
---|
4043 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxElements(numberColumns); |
---|
4044 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxElementsRoot(numberColumns); |
---|
4045 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4046 |                 probingGen.setMaxProbeRoot(CoinMin(2000, numberColumns)); |
---|
4047 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxProbeRoot(123); |
---|
4048 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxProbe(123); |
---|
4049 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxLookRoot(20); |
---|
4050 |                 if (probingAction == 7 || probingAction == 9) |
---|
4051 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setRowCuts(-3);Â // strengthening etc just at root |
---|
4052 |                 if (probingAction == 8 || probingAction == 9) { |
---|
4053 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Number of unsatisfied variables to look at |
---|
4054 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxProbeRoot(numberColumns); |
---|
4055 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxProbe(numberColumns); |
---|
4056 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // How far to follow the consequences |
---|
4057 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxLook(50); |
---|
4058 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxLookRoot(50); |
---|
4059 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4060 |                 if (probingAction == 10) { |
---|
4061 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxPassRoot(2); |
---|
4062 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxProbeRoot(numberColumns); |
---|
4063 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â probingGen.setMaxLookRoot(100); |
---|
4064 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4065 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // If 5 then force on |
---|
4066 |                 int iAction = translate[probingAction]; |
---|
4067 |                 if (probingAction == 5) |
---|
4068 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iAction =Â 1; |
---|
4069 |                 babModel_->addCutGenerator(&probingGen, iAction, "Probing"); |
---|
4070 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 5; |
---|
4071 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4072 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4073 |               if (gomoryAction && (complicatedInteger != 1 || |
---|
4074 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (gomoryAction ==Â 1Â ||Â gomoryAction >=Â 4)))Â { |
---|
4075 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try larger limit |
---|
4076 |                 int numberColumns = babModel_->getNumCols(); |
---|
4077 |                 if (gomoryAction == 7) { |
---|
4078 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â 4; |
---|
4079 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(numberColumns); |
---|
4080 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(numberColumns); |
---|
4081 |                 } else if (gomoryAction == 8) { |
---|
4082 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryAction =Â 3; |
---|
4083 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(numberColumns); |
---|
4084 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(200); |
---|
4085 |                 } else if (numberColumns > 5000) { |
---|
4086 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //#define MORE_CUTS2 |
---|
4087 | #ifdef MORE_CUTS2 |
---|
4088 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try larger limit |
---|
4089 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(numberColumns); |
---|
4090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(200); |
---|
4091 | #else |
---|
4092 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(2000); |
---|
4093 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //gomoryGen.setLimit(200); |
---|
4094 | #endif |
---|
4095 |                 } else { |
---|
4096 | #ifdef MORE_CUTS2 |
---|
4097 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try larger limit |
---|
4098 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(numberColumns); |
---|
4099 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(200); |
---|
4100 | #endif |
---|
4101 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4102 |                 int cutLength = |
---|
4103 |                   parameters_[whichParam(CBC_PARAM_INT_CUTLENGTH, numberParameters_, parameters_)].intValue(); |
---|
4104 |                 if (cutLength != -1) { |
---|
4105 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimitAtRoot(cutLength); |
---|
4106 |                   if (cutLength < 10000000) { |
---|
4107 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(cutLength); |
---|
4108 |                   } else { |
---|
4109 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setLimit(cutLength %Â 10000000); |
---|
4110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4111 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4112 |                 int laGomory = parameters_[whichParam(CBC_PARAM_STR_LAGOMORYCUTS, numberParameters_, parameters_)].currentOptionAsInteger(); |
---|
4113 |                 int gType = translate[gomoryAction]; |
---|
4114 |                 if (!laGomory) { |
---|
4115 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Normal |
---|
4116 |                  babModel_->addCutGenerator(&gomoryGen, translate[gomoryAction], "Gomory"); |
---|
4117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 3; |
---|
4118 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4119 |                 } else { |
---|
4120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â laGomory--; |
---|
4121 |                  int type = (laGomory % 3)+1; |
---|
4122 |                  int when = laGomory/3; |
---|
4123 |                  char atEnd = (when<2) ? 1 : 0; |
---|
4124 |                  int gomoryTypeMajor = 0; |
---|
4125 |                  if (when<3) { |
---|
4126 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // normal as well |
---|
4127 |                   babModel_->addCutGenerator(&gomoryGen, gType, "Gomory"); |
---|
4128 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 3; |
---|
4129 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4130 |                   if (when==2) |
---|
4131 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryTypeMajor=10; |
---|
4132 |                  } else { |
---|
4133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â when--;Â // so on |
---|
4134 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryTypeMajor=20; |
---|
4135 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4136 |                  if (!when) |
---|
4137 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gType=-99;Â // root |
---|
4138 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.passInOriginalSolver(babModel_->solver()); |
---|
4139 |                  if ((type&1) !=0) { |
---|
4140 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // clean |
---|
4141 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setGomoryType(gomoryTypeMajor+1); |
---|
4142 |                   babModel_->addCutGenerator(&gomoryGen, gType, "GomoryL1"); |
---|
4143 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 3; |
---|
4144 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doAtEnd[numberGenerators]=atEnd; |
---|
4145 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4146 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4147 |                  if ((type&2) !=0) { |
---|
4148 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // simple |
---|
4149 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gomoryGen.setGomoryType(gomoryTypeMajor+2); |
---|
4150 |                   babModel_->addCutGenerator(&gomoryGen, gType, "GomoryL2"); |
---|
4151 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 3; |
---|
4152 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â doAtEnd[numberGenerators]=atEnd; |
---|
4153 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4154 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4155 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4156 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4157 | #ifdef CLIQUE_ANALYSIS |
---|
4158 |               if (miplib && !storedAmpl.sizeRowCuts()) { |
---|
4159 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("looking at probing\n"); |
---|
4160 |                 babModel_->addCutGenerator(&storedAmpl, 1, "Stored"); |
---|
4161 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4162 | #endif |
---|
4163 |               if (knapsackAction) { |
---|
4164 |                 babModel_->addCutGenerator(&knapsackGen, translate[knapsackAction], "Knapsack"); |
---|
4165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 1; |
---|
4166 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â -2; |
---|
4167 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4168 |               if (redsplitAction && !complicatedInteger) { |
---|
4169 |                 babModel_->addCutGenerator(&redsplitGen, translate[redsplitAction], "Reduce-and-split"); |
---|
4170 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 5; |
---|
4171 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 1; |
---|
4172 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4173 |               if (cliqueAction) { |
---|
4174 |                 babModel_->addCutGenerator(&cliqueGen, translate[cliqueAction], "Clique"); |
---|
4175 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 0; |
---|
4176 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4177 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4178 |               if (mixedAction) { |
---|
4179 |                 babModel_->addCutGenerator(&mixedGen, translate[mixedAction], "MixedIntegerRounding2"); |
---|
4180 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 2; |
---|
4181 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 0; |
---|
4182 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4183 |               if (flowAction) { |
---|
4184 |                 babModel_->addCutGenerator(&flowGen, translate[flowAction], "FlowCover"); |
---|
4185 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 2; |
---|
4186 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 1; |
---|
4187 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4188 |               if (twomirAction && (complicatedInteger != 1 || |
---|
4189 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (twomirAction ==Â 1Â ||Â twomirAction >=Â 4)))Â { |
---|
4190 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try larger limit |
---|
4191 |                 int numberColumns = babModel_->getNumCols(); |
---|
4192 |                 if (twomirAction == 7) { |
---|
4193 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirAction =Â 4; |
---|
4194 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirGen.setMaxElements(numberColumns); |
---|
4195 |                 } else if (numberColumns > 5000 && twomirAction == 4) { |
---|
4196 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â twomirGen.setMaxElements(2000); |
---|
4197 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4198 |                 babModel_->addCutGenerator(&twomirGen, translate[twomirAction], "TwoMirCuts"); |
---|
4199 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 4; |
---|
4200 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 1; |
---|
4201 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4202 | #ifndef DEBUG_MALLOC |
---|
4203 |               if (landpAction) { |
---|
4204 |                 babModel_->addCutGenerator(&landpGen, translate[landpAction], "LiftAndProject"); |
---|
4205 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 5; |
---|
4206 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 1; |
---|
4207 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4208 | #endif |
---|
4209 |               if (residualCapacityAction) { |
---|
4210 |                 babModel_->addCutGenerator(&residualCapacityGen, translate[residualCapacityAction], "ResidualCapacity"); |
---|
4211 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 5; |
---|
4212 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 1; |
---|
4213 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4214 | #ifdef ZERO_HALF_CUTS |
---|
4215 |               if (zerohalfAction) { |
---|
4216 |                 if (zerohalfAction > 4) { |
---|
4217 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //zerohalfAction -=4; |
---|
4218 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â zerohalfGen.setFlags(1); |
---|
4219 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4220 |                 babModel_->addCutGenerator(&zerohalfGen, translate[zerohalfAction], "ZeroHalf"); |
---|
4221 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accuracyFlag[numberGenerators]Â =Â 5; |
---|
4222 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â switches[numberGenerators++]Â =Â 2; |
---|
4223 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4224 | #endif |
---|
4225 |               if (dominatedCuts) |
---|
4226 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSpecialOptions(babModel_->specialOptions()Â |Â 64); |
---|
4227 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Say we want timings |
---|
4228 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberGenerators =Â babModel_->numberCutGenerators(); |
---|
4229 |               int iGenerator; |
---|
4230 |               int cutDepth = |
---|
4231 |                 parameters_[whichParam(CBC_PARAM_INT_CUTDEPTH, numberParameters_, parameters_)].intValue(); |
---|
4232 |               for (iGenerator = 0; iGenerator < numberGenerators; iGenerator++) { |
---|
4233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcCutGenerator *Â generator =Â babModel_->cutGenerator(iGenerator); |
---|
4234 |                 int howOften = generator->howOften(); |
---|
4235 |                 if (howOften == -98 || howOften == -99) |
---|
4236 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setSwitchOffIfLessThan(switches[iGenerator]); |
---|
4237 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Use if any at root as more likely later and fairly cheap |
---|
4238 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (switches[iGenerator]==-2) |
---|
4239 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //generator->setWhetherToUse(true); |
---|
4240 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setInaccuracy(accuracyFlag[iGenerator]); |
---|
4241 |                 if (doAtEnd[iGenerator]) { |
---|
4242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setWhetherCallAtEnd(true); |
---|
4243 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setMustCallAgain(true); |
---|
4244 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4245 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setTiming(true); |
---|
4246 |                 if (cutDepth >= 0) |
---|
4247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â generator->setWhatDepth(cutDepth)Â ; |
---|
4248 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Could tune more |
---|
4250 |               if (!miplib) { |
---|
4251 |                 double minimumDrop = |
---|
4252 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fabs(babModel_->solver()->getObjValue())Â *Â 1.0e-5Â +Â 1.0e-5; |
---|
4253 |                 babModel_->setMinimumDrop(CoinMin(5.0e-2, minimumDrop)); |
---|
4254 |                 if (cutPass == -1234567) { |
---|
4255 |                   if (babModel_->getNumCols() < 500) |
---|
4256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPassesAtRoot(-100);Â // always do 100 if possible |
---|
4257 |                   else if (babModel_->getNumCols() < 5000) |
---|
4258 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPassesAtRoot(100);Â // use minimum drop |
---|
4259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4260 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPassesAtRoot(20); |
---|
4261 |                 } else { |
---|
4262 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPassesAtRoot(cutPass); |
---|
4263 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4264 |                 if (cutPassInTree == -1234567) |
---|
4265 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPasses(4); |
---|
4266 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4267 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPasses(cutPassInTree); |
---|
4268 |               } else if (cutPass != -1234567) { |
---|
4269 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMaximumCutPassesAtRoot(cutPass); |
---|
4270 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4271 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Do more strong branching if small |
---|
4272 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (babModel_->getNumCols()<5000) |
---|
4273 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //babModel_->setNumberStrong(20); |
---|
4274 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Switch off strong branching if wanted |
---|
4275 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //if (babModel_->getNumCols()>10*babModel_->getNumRows()) |
---|
4276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //babModel_->setNumberStrong(0); |
---|
4277 |               if (!noPrinting_) { |
---|
4278 |                 int iLevel = parameters_[log].intValue(); |
---|
4279 |                 if (iLevel < 0) { |
---|
4280 |                   if (iLevel > -10) { |
---|
4281 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setPrintingMode(1); |
---|
4282 |                   } else { |
---|
4283 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setPrintingMode(2); |
---|
4284 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLevel +=Â 10; |
---|
4285 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â parameters_[log].setIntValue(iLevel); |
---|
4286 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4287 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLevel =Â -iLevel; |
---|
4288 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4289 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->messageHandler()->setLogLevel(iLevel); |
---|
4290 |                 if (babModel_->getNumCols() > 2000 || babModel_->getNumRows() > 1500 || |
---|
4291 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->messageHandler()->logLevel()Â >Â 1) |
---|
4292 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setPrintFrequency(100); |
---|
4293 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4294 | |
---|
4295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->setIntParam(OsiMaxNumIterationHotStart, |
---|
4296 |                                parameters_[whichParam(CBC_PARAM_INT_MAXHOTITS, numberParameters_, parameters_)].intValue()); |
---|
4297 | #ifndef CBC_OTHER_SOLVER |
---|
4298 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (babModel_->solver()); |
---|
4299 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // go faster stripes |
---|
4300 |               if ((osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500)) { |
---|
4301 |                 osiclp->setupForRepeatedUse(2, parameters_[slog].intValue()); |
---|
4302 |                 if (bothFlags >= 1) { |
---|
4303 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lp =Â osiclp->getModelPtr(); |
---|
4304 |                   int specialOptions = lp->specialOptions(); |
---|
4305 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lp->setSpecialOptions(specialOptions |Â (2048Â +Â 4096)); |
---|
4306 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4307 |               } else { |
---|
4308 |                 osiclp->setupForRepeatedUse(0, parameters_[slog].intValue()); |
---|
4309 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4310 |               if (bothFlags >= 2) { |
---|
4311 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lp =Â osiclp->getModelPtr(); |
---|
4312 |                 int specialOptions = lp->specialOptions(); |
---|
4313 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lp->setSpecialOptions(specialOptions |Â (2048Â +Â 4096)); |
---|
4314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4315 |               double increment = babModel_->getCutoffIncrement();; |
---|
4316 |               int * changed = NULL; |
---|
4317 |               if (!miplib && increment == normalIncrement) |
---|
4318 |                 changed = analyze( osiclp, numberChanged, increment, false, generalMessageHandler, noPrinting); |
---|
4319 | #elif CBC_OTHER_SOLVER==1 |
---|
4320 |               double increment = babModel_->getCutoffIncrement();; |
---|
4321 | #endif |
---|
4322 |               if (debugValues) { |
---|
4323 |                 int numberColumns = babModel_->solver()->getNumCols(); |
---|
4324 |                 if (numberDebugValues == numberColumns) { |
---|
4325 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // for debug |
---|
4326 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->activateRowCutDebugger(debugValues)Â ; |
---|
4327 |                 } else { |
---|
4328 |                   int numberOriginalColumns = |
---|
4329 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process.originalModel()->getNumCols(); |
---|
4330 |                   if (numberDebugValues <= numberOriginalColumns) { |
---|
4331 |                     const int * originalColumns = process.originalColumns(); |
---|
4332 |                     double * newValues = new double [numberColumns]; |
---|
4333 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // in case preprocess added columns! |
---|
4334 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // need to find values |
---|
4335 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiSolverInterface *Â siCopy = |
---|
4336 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->clone(); |
---|
4337 |                     for (int i = 0; i < numberColumns; i++) { |
---|
4338 |                       int jColumn = originalColumns[i]; |
---|
4339 |                       if (jColumn < numberDebugValues && |
---|
4340 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â siCopy->isInteger(i))Â { |
---|
4341 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // integer variable |
---|
4342 |                         double soln = floor(debugValues[jColumn] + 0.5); |
---|
4343 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Set bounds to fix variable to its solution |
---|
4344 |                         siCopy->setColUpper(i, soln); |
---|
4345 |                         siCopy->setColLower(i, soln); |
---|
4346 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4347 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4348 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // All integers have been fixed at optimal value. |
---|
4349 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Now solve to get continuous values |
---|
4350 |                     siCopy->setHintParam(OsiDoScale, false); |
---|
4351 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â siCopy->initialSolve(); |
---|
4352 |                     if (siCopy->isProvenOptimal()) { |
---|
4353 |                       memcpy(newValues, siCopy->getColSolution(), |
---|
4354 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberColumns*sizeof(double)); |
---|
4355 |                     } else { |
---|
4356 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("BAD debug file\n"); |
---|
4357 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â siCopy->writeMps("Bad"); |
---|
4358 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â exit(22); |
---|
4359 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4360 |                     delete siCopy; |
---|
4361 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // for debug |
---|
4362 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->solver()->activateRowCutDebugger(newValues)Â ; |
---|
4363 |                     delete [] newValues; |
---|
4364 |                   } else { |
---|
4365 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printf("debug file has incorrect number of columns\n"); |
---|
4366 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4367 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4368 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4369 |               babModel_->setCutoffIncrement(CoinMax(babModel_->getCutoffIncrement(), increment)); |
---|
4370 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Turn this off if you get problems |
---|
4371 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Used to be automatically set |
---|
4372 |               int mipOptions = parameters_[whichParam(CBC_PARAM_INT_MIPOPTIONS, numberParameters_, parameters_)].intValue() % 10000; |
---|
4373 |               if (mipOptions != (1057)) { |
---|
4374 |                 sprintf(generalPrint, "mip options %d", mipOptions); |
---|
4375 |                 generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4376 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4377 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4378 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4379 | #ifndef CBC_OTHER_SOLVER |
---|
4380 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSpecialOptions(mipOptions); |
---|
4381 | #elif CBC_OTHER_SOLVER==1 |
---|
4382 | #endif |
---|
4383 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â // probably faster to use a basis to get integer solutions |
---|
4384 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSpecialOptions(babModel_->specialOptions()Â |Â 2); |
---|
4385 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â currentBranchModel =Â babModel_; |
---|
4386 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â //OsiSolverInterface * strengthenedModel=NULL; |
---|
4387 |               if (type == CBC_PARAM_ACTION_BAB || |
---|
4388 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â type ==Â CBC_PARAM_ACTION_MIPLIB)Â { |
---|
4389 |                 if (strategyFlag == 1) { |
---|
4390 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try reduced model |
---|
4391 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSpecialOptions(babModel_->specialOptions()Â |Â 512); |
---|
4392 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4393 |                 if (experimentFlag >= 5 || strategyFlag == 2) { |
---|
4394 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try reduced model at root |
---|
4395 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSpecialOptions(babModel_->specialOptions()Â |Â 32768); |
---|
4396 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4397 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4398 |                   int depthMiniBab = parameters_[whichParam(CBC_PARAM_INT_DEPTHMINIBAB, numberParameters_, parameters_)].intValue(); |
---|
4399 |                   if (depthMiniBab != -1) |
---|
4400 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setFastNodeDepth(depthMiniBab); |
---|
4401 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4402 |                 int extra4 = parameters_[whichParam(CBC_PARAM_INT_EXTRA4, numberParameters_, parameters_)].intValue(); |
---|
4403 |                 if (extra4 >= 0) { |
---|
4404 |                   int strategy = extra4 % 10; |
---|
4405 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra4 /=Â 10; |
---|
4406 |                   int method = extra4 % 100; |
---|
4407 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra4 /=Â 100; |
---|
4408 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra4 =Â strategy +Â method *Â 8Â +Â extra4 *Â 1024; |
---|
4409 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setMoreSpecialOptions(extra4); |
---|
4410 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4411 |                 int moreMipOptions = parameters_[whichParam(CBC_PARAM_INT_MOREMIPOPTIONS, numberParameters_, parameters_)].intValue(); |
---|
4412 |                 if (moreMipOptions >= 0) { |
---|
4413 |                   sprintf(generalPrint, "more mip options %d", moreMipOptions); |
---|
4414 |                   generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4415 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4416 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4417 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiClpSolverInterface *Â osiclp =Â dynamic_cast<Â OsiClpSolverInterface*>Â (babModel_->solver()); |
---|
4418 |                   if (moreMipOptions == 10000) { |
---|
4419 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // test memory saving |
---|
4420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â moreMipOptions -=Â 10000; |
---|
4421 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ClpSimplex *Â lpSolver =Â osiclp->getModelPtr(); |
---|
4422 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setPersistenceFlag(1); |
---|
4423 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // switch off row copy if few rows |
---|
4424 |                     if (lpSolver->numberRows() < 150) |
---|
4425 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lpSolver->setSpecialOptions(lpSolver->specialOptions()Â |Â 256); |
---|
4426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4427 |                   if (moreMipOptions < 10000 && moreMipOptions) { |
---|
4428 |                     if (((moreMipOptions + 1) % 1000000) != 0) |
---|
4429 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSearchStrategy(moreMipOptions %Â 1000000); |
---|
4430 |                   } else if (moreMipOptions < 100000) { |
---|
4431 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // try reduced model |
---|
4432 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSpecialOptions(babModel_->specialOptions()Â |Â 512); |
---|
4433 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4434 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // go faster stripes |
---|
4435 |                   if ( moreMipOptions >= 999999) { |
---|
4436 |                     if (osiclp) { |
---|
4437 |                       int save = osiclp->specialOptions(); |
---|
4438 |                       osiclp->setupForRepeatedUse(2, 0); |
---|
4439 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â osiclp->setSpecialOptions(save |Â osiclp->specialOptions()); |
---|
4440 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4441 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4442 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4443 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4444 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
---|
4445 |                 int extra1 = parameters_[whichParam(CBC_PARAM_INT_EXTRA1, numberParameters_, parameters_)].intValue(); |
---|
4446 |                 if (extra1 != -1) { |
---|
4447 |                   if (extra1 < 0) { |
---|
4448 |                     if (extra1 == -7777) |
---|
4449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra1 =Â -1; |
---|
4450 |                     else if (extra1 == -8888) |
---|
4451 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â extra1 =Â 1; |
---|
4452 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setWhenCuts(-extra1); |
---|
4453 |                   } else if (extra1 < 19000) { |
---|
4454 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setSearchStrategy(extra1); |
---|
4455 |                     printf("XXXXX searchStrategy %d\n", extra1); |
---|
4456 |                   } else { |
---|
4457 |                     int n = extra1 - 20000; |
---|
4458 |                     if (!n) |
---|
4459 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â n--; |
---|
4460 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setNumberAnalyzeIterations(n); |
---|
4461 |                     printf("XXXXX analyze %d\n", extra1); |
---|
4462 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4463 |                 } else if (bothFlags >= 1) { |
---|
4464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setWhenCuts(999998); |
---|
4465 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4467 |               if (type == CBC_PARAM_ACTION_BAB) { |
---|
4468 | #ifdef COIN_HAS_ASL |
---|
4469 |                 if (statusUserFunction_[0]) { |
---|
4470 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â priorities =Â info.priorities; |
---|
4471 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â branchDirection =Â info.branchDirection; |
---|
4472 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pseudoDown =Â info.pseudoDown; |
---|
4473 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pseudoUp =Â info.pseudoUp; |
---|
4474 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solutionIn =Â info.primalSolution; |
---|
4475 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prioritiesIn =Â info.priorities; |
---|
4476 |                   if (info.numberSos && doSOS) { |
---|
4477 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // SOS |
---|
4478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberSOS =Â info.numberSos; |
---|
4479 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosStart =Â info.sosStart; |
---|
4480 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices =Â info.sosIndices; |
---|
4481 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosType =Â info.sosType; |
---|
4482 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosReference =Â info.sosReference; |
---|
4483 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosPriority =Â info.sosPriority; |
---|
4484 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4485 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4486 | #endif |
---|
4487 |                 const int * originalColumns = preProcess ? process.originalColumns() : NULL; |
---|
4488 |                 if (solutionIn && useSolution >= 0) { |
---|
4489 |                   if (!prioritiesIn) { |
---|
4490 |                     int n; |
---|
4491 |                     if (preProcess) { |
---|
4492 |                       int numberColumns = babModel_->getNumCols(); |
---|
4493 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // extend arrays in case SOS |
---|
4494 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â n =Â originalColumns[numberColumns-1]Â +Â 1; |
---|
4495 |                     } else { |
---|
4496 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â n =Â babModel_->getNumCols(); |
---|
4497 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4498 |                     prioritiesIn = reinterpret_cast<int *> (malloc(n * sizeof(int))); |
---|
4499 |                     for (int i = 0; i < n; i++) |
---|
4500 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prioritiesIn[i]Â =Â 100; |
---|
4501 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4502 |                   if (preProcess) { |
---|
4503 |                     int numberColumns = babModel_->getNumCols(); |
---|
4504 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // extend arrays in case SOS |
---|
4505 |                     int n = originalColumns[numberColumns-1] + 1; |
---|
4506 |                     int nSmaller = CoinMin(n, numberOriginalColumns); |
---|
4507 |                     double * solutionIn2 = new double [n]; |
---|
4508 |                     int * prioritiesIn2 = new int[n]; |
---|
4509 |                     int i; |
---|
4510 |                     for (i = 0; i < nSmaller; i++) { |
---|
4511 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solutionIn2[i]Â =Â solutionIn[i]; |
---|
4512 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prioritiesIn2[i]Â =Â prioritiesIn[i]; |
---|
4513 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4514 |                     for (; i < n; i++) { |
---|
4515 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solutionIn2[i]Â =Â 0.0; |
---|
4516 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prioritiesIn2[i]Â =Â 1000000; |
---|
4517 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4518 |                     int iLast = -1; |
---|
4519 |                     for (i = 0; i < numberColumns; i++) { |
---|
4520 |                       int iColumn = originalColumns[i]; |
---|
4521 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (iColumn >Â iLast); |
---|
4522 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iLast =Â iColumn; |
---|
4523 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â solutionIn2[i]Â =Â solutionIn2[iColumn]; |
---|
4524 |                       if (prioritiesIn) |
---|
4525 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prioritiesIn2[i]Â =Â prioritiesIn2[iColumn]; |
---|
4526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4527 |                     if (useSolution) |
---|
4528 |                       babModel_->setHotstartSolution(solutionIn2, prioritiesIn2); |
---|
4529 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4530 |                       babModel_->setBestSolution(solutionIn2, numberColumns, |
---|
4531 |                                     COIN_DBL_MAX, true); |
---|
4532 |                     delete [] solutionIn2; |
---|
4533 |                     delete [] prioritiesIn2; |
---|
4534 |                   } else { |
---|
4535 |                     if (useSolution) |
---|
4536 |                       babModel_->setHotstartSolution(solutionIn, prioritiesIn); |
---|
4537 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4538 |                       babModel_->setBestSolution(solutionIn, babModel_->getNumCols(), |
---|
4539 |                                     COIN_DBL_MAX, true); |
---|
4540 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4541 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4542 |                 OsiSolverInterface * testOsiSolver = (testOsiOptions >= 0) ? babModel_->solver() : NULL; |
---|
4543 |                 if (!testOsiSolver) { |
---|
4544 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // ************************************************************* |
---|
4545 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // CbcObjects |
---|
4546 |                   if (preProcess && (process.numberSOS() || babModel_->numberObjects())) { |
---|
4547 |                     int numberSOS = process.numberSOS(); |
---|
4548 |                     int numberIntegers = babModel_->numberIntegers(); |
---|
4549 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* model may not have created objects |
---|
4550 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If none then create |
---|
4551 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
4552 |                     if (!numberIntegers || !babModel_->numberObjects()) { |
---|
4553 |                       int type = (pseudoUp) ? 1 : 0; |
---|
4554 |                       babModel_->findIntegers(true, type); |
---|
4555 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberIntegers =Â babModel_->numberIntegers(); |
---|
4556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â integersOK =Â true; |
---|
4557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â oldObjects =Â babModel_->objects(); |
---|
4559 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Do sets and priorities |
---|
4560 |                     OsiObject ** objects = new OsiObject * [numberSOS]; |
---|
4561 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // set old objects to have low priority |
---|
4562 |                     int numberOldObjects = babModel_->numberObjects(); |
---|
4563 |                     int numberColumns = babModel_->getNumCols(); |
---|
4564 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // backward pointer to new variables |
---|
4565 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // extend arrays in case SOS |
---|
4566 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (originalColumns); |
---|
4567 |                     int n = originalColumns[numberColumns-1] + 1; |
---|
4568 |                     n = CoinMax(n, CoinMax(numberColumns, numberOriginalColumns)); |
---|
4569 |                     int * newColumn = new int[n]; |
---|
4570 |                     int i; |
---|
4571 |                     for (i = 0; i < numberOriginalColumns; i++) |
---|
4572 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumn[i]Â =Â -1; |
---|
4573 |                     for (i = 0; i < numberColumns; i++) |
---|
4574 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â newColumn[originalColumns[i]]Â =Â i; |
---|
4575 |                     if (!integersOK) { |
---|
4576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Change column numbers etc |
---|
4577 |                       int n = 0; |
---|
4578 |                       for (int iObj = 0; iObj < numberOldObjects; iObj++) { |
---|
4579 |                         int iColumn = oldObjects[iObj]->columnNumber(); |
---|
4580 |                         if (iColumn < 0 || iColumn >= numberOriginalColumns) { |
---|
4581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldObjects[n++]Â =Â oldObjects[iObj]; |
---|
4582 |                         } else { |
---|
4583 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iColumn =Â newColumn[iColumn]; |
---|
4584 |                           if (iColumn >= 0) { |
---|
4585 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleInteger *Â obj = |
---|
4586 |                               dynamic_cast <CbcSimpleInteger *>(oldObjects[iObj]) ; |
---|
4587 |                             if (obj) { |
---|
4588 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setColumnNumber(iColumn); |
---|
4589 |                             } else { |
---|
4590 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // only other case allowed is lotsizing |
---|
4591 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcLotsize *Â obj2 = |
---|
4592 |                                 dynamic_cast <CbcLotsize *>(oldObjects[iObj]) ; |
---|
4593 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (obj2); |
---|
4594 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj2->setModelSequence(iColumn); |
---|
4595 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4596 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldObjects[n++]Â =Â oldObjects[iObj]; |
---|
4597 |                           } else { |
---|
4598 |                             delete oldObjects[iObj]; |
---|
4599 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4600 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4601 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4602 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->setNumberObjects(n); |
---|
4603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â numberOldObjects =Â n; |
---|
4604 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â babModel_->zapIntegerInformation(); |
---|
4605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4606 |                     int nMissing = 0; |
---|
4607 |                     for (int iObj = 0; iObj < numberOldObjects; iObj++) { |
---|
4608 |                       if (process.numberSOS()) |
---|
4609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oldObjects[iObj]->setPriority(numberColumns +Â 1); |
---|
4610 |                       int iColumn = oldObjects[iObj]->columnNumber(); |
---|
4611 |                       if (iColumn < 0 || iColumn >= numberOriginalColumns) { |
---|
4612 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSOS *Â obj = |
---|
4613 |                           dynamic_cast <CbcSOS *>(oldObjects[iObj]) ; |
---|
4614 |                         if (obj) { |
---|
4615 |                           int n = obj->numberMembers(); |
---|
4616 |                           int * which = obj->mutableMembers(); |
---|
4617 |                           double * weights = obj->mutableWeights(); |
---|
4618 |                           int nn = 0; |
---|
4619 |                           for (i = 0; i < n; i++) { |
---|
4620 |                             int iColumn = which[i]; |
---|
4621 |                             int jColumn = newColumn[iColumn]; |
---|
4622 |                             if (jColumn >= 0) { |
---|
4623 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â which[nn]Â =Â jColumn; |
---|
4624 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â weights[nn++]Â =Â weights[i]; |
---|
4625 |                             } else { |
---|
4626 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nMissing++; |
---|
4627 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4628 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4629 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setNumberMembers(nn); |
---|
4630 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4631 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue; |
---|
4632 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4633 |                       if (originalColumns) |
---|
4634 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iColumn =Â originalColumns[iColumn]; |
---|
4635 |                       if (branchDirection) { |
---|
4636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleInteger *Â obj = |
---|
4637 |                           dynamic_cast <CbcSimpleInteger *>(oldObjects[iObj]) ; |
---|
4638 |                         if (obj) { |
---|
4639 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setPreferredWay(branchDirection[iColumn]); |
---|
4640 |                         } else { |
---|
4641 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcObject *Â obj = |
---|
4642 |                             dynamic_cast <CbcObject *>(oldObjects[iObj]) ; |
---|
4643 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (obj); |
---|
4644 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj->setPreferredWay(branchDirection[iColumn]); |
---|
4645 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4647 |                       if (pseudoUp) { |
---|
4648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CbcSimpleIntegerPseudoCost *Â obj1a = |
---|
4649 |                           dynamic_cast <CbcSimpleIntegerPseudoCost *>(oldObjects[iObj]) ; |
---|
4650 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â assert (obj1a); |
---|
4651 |                         if (pseudoDown[iColumn] > 0.0) |
---|
4652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj1a->setDownPseudoCost(pseudoDown[iColumn]); |
---|
4653 |                         if (pseudoUp[iColumn] > 0.0) |
---|
4654 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â obj1a->setUpPseudoCost(pseudoUp[iColumn]); |
---|
4655 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4656 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4657 |                     if (nMissing) { |
---|
4658 |                       sprintf(generalPrint, "%d SOS variables vanished due to pre processing? - check validity?", nMissing); |
---|
4659 |                       generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4660 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4661 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4662 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4663 |                     delete [] newColumn; |
---|
4664 |                     const int * starts = process.startSOS(); |
---|
4665 |                     const int * which = process.whichSOS(); |
---|
4666 |                     const int * type = process.typeSOS(); |
---|
4667 |                     const double * weight = process.weightSOS(); |
---|
4668 |                     int iSOS; |
---|
4669 |                     for (iSOS = 0; iSOS < numberSOS; iSOS++) { |
---|
4670 |                       int iStart = starts[iSOS]; |
---|
4671 |                       int n = starts[iSOS+1] - iStart; |
---|
4672 |                       objects[iSOS] = new CbcSOS(babModel_, n, which + iStart, weight + iStart, |
---|
4673 |                                     iSOS, type[iSOS]); |
---|
4674 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // branch on long sets first |
---|
4675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objects[iSOS]->setPriority(numberColumns -Â n); |
---|
4676 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4677 |                     if (numberSOS) |
---|
4678 |                       babModel_->addObjects(numberSOS, objects); |
---|
4679 |                     for (iSOS = 0; iSOS < numberSOS; iSOS++) |
---|
4680 |                       delete objects[iSOS]; |
---|
4681 |                     delete [] objects; |
---|
4682 |                   } else if (priorities || branchDirection || pseudoDown || pseudoUp || numberSOS) { |
---|
4683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // do anyway for priorities etc |
---|
4684 |                     int numberIntegers = babModel_->numberIntegers(); |
---|
4685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* model may not have created objects |
---|
4686 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If none then create |
---|
4687 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */ |
---|
4688 |                     if (!numberIntegers || !babModel_->numberObjects()) { |
---|
4689 |                       int type = (pseudoUp) ? 1 : 0; |
---|
4690 |                       babModel_->findIntegers(true, type); |
---|
4691 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4692 |                     if (numberSOS) { |
---|
4693 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Do sets and priorities |
---|
4694 |                       OsiObject ** objects = new OsiObject * [numberSOS]; |
---|
4695 |                       int iSOS; |
---|
4696 |                       if (originalColumns) { |
---|
4697 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // redo sequence numbers |
---|
4698 |                         int numberColumns = babModel_->getNumCols(); |
---|
4699 |                         int nOld = originalColumns[numberColumns-1] + 1; |
---|
4700 |                         int * back = new int[nOld]; |
---|
4701 |                         int i; |
---|
4702 |                         for (i = 0; i < nOld; i++) |
---|
4703 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â back[i]Â =Â -1; |
---|
4704 |                         for (i = 0; i < numberColumns; i++) |
---|
4705 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â back[originalColumns[i]]Â =Â i; |
---|
4706 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Really need better checks |
---|
4707 |                         int nMissing = 0; |
---|
4708 |                         int n = sosStart[numberSOS]; |
---|
4709 |                         for (i = 0; i < n; i++) { |
---|
4710 |                           int iColumn = sosIndices[i]; |
---|
4711 |                           int jColumn = back[iColumn]; |
---|
4712 |                           if (jColumn >= 0) |
---|
4713 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sosIndices[i]Â =Â jColumn; |
---|
4714 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else |
---|
4715 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â nMissing++; |
---|
4716 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4717 |                         delete [] back; |
---|
4718 |                         if (nMissing) { |
---|
4719 |                           sprintf(generalPrint, "%d SOS variables vanished due to pre processing? - check validity?", nMissing); |
---|
4720 |                           generalMessageHandler->message(CLP_GENERAL, generalMessages) |
---|
4721 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â generalPrint |
---|
4722 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â <<Â CoinMessageEol; |
---|
4723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4724 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4725 |                       for (iSOS = 0; iSOS < numberSOS; iSOS++) { |
---|
4726 |                         int iStart = sosStart[iSOS]; |
---|
4727 |                         int n = sosStart[iSOS+1] - iStart; |
---|
4728 |                         objects[iSOS] = new CbcSOS(babModel_, n, sosIndices + iStart, sosReference + iStart, |
---|
4729 |                                       iSOS, sosType[iSOS]); |
---|
4730 |                         if (sosPriority) |
---|
4731 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objects[iSOS]->setPriority(sosPriority[iSOS]); |
---|
4732 |                         else if (!prioritiesIn) |
---|
4733 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â objects[iSOS]->setPriority(10);Â // rather than 1000 |
---|
4734 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
---|
4735 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // delete any existing SOS objects |
---|
4736 |                       int numberObjects = babModel_->numberObjects(); |
---|
4737 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OsiObject **Â oldObjects =Â babModel_->objects(); |
---|
4738 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|