UG

Ubiquity Generator framework

scipParaSolver.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and software framework */
4/* UG --- Ubquity Generator Framework */
5/* */
6/* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7/* Copyright (C) 2021-2026 by Zuse Institute Berlin, */
8/* licensed under LGPL version 3 or later. */
9/* Commercial licenses are available through <licenses@zib.de> */
10/* */
11/* This code is free software; you can redistribute it and/or */
12/* modify it under the terms of the GNU Lesser General Public License */
13/* as published by the Free Software Foundation; either version 3 */
14/* of the License, or (at your option) any later version. */
15/* */
16/* This program is distributed in the hope that it will be useful, */
17/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19/* GNU Lesser General Public License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23/* */
24/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25
26/**@file scipParaSolver.cpp
27 * @brief ParaSolver extension for SCIP: Parallelized solver implementation for SCIP.
28 * @author Yuji Shinano
29 *
30 *
31 *
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36
37#include <cfloat>
38#include <cstring>
39#include <cstdlib>
40#ifndef _MSC_VER
41#include <unistd.h>
42#endif
43#include <typeinfo>
44#include <string>
45#include <sstream>
46#include "ug/paraInitialStat.h"
47#include "ug_bb/bbParaComm.h"
48#include "ug_bb/bbParaNode.h"
50#include "ug_bb/bbParaSolver.h"
53#include "objscip/objscip.h"
54#include "scipParaTagDef.h"
55#include "scipParaParamSet.h"
59#include "scipParaObjProp.h"
61#include "scipParaInitialStat.h"
63#include "scipParaObjNodesel.h"
65#include "scip/scip.h"
66#ifdef UG_DEBUG_SOLUTION
67#ifndef WITH_DEBUG_SOLUTION
68#define WITH_DEBUG_SOLUTION
69#endif
70#include "scip/debug.h"
71#include "scip/struct_scip.h"
72#include "scip/struct_set.h"
73#endif
74// #include "scip/scipdefplugins.h"
75
76using namespace ParaSCIP;
77
78#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
79extern long long virtualMemUsedAtLc;
80extern double memoryLimitOfSolverSCIP;
81#endif
82
83extern void
85extern void
87
88/*
89 * Callback methods of conflict handler
90 */
91#define CONFLICTHDLR_NAME "conflictCollector"
92#define CONFLICTHDLR_DESC "conflict handler to collect conflicts"
93#define CONFLICTHDLR_PRIORITY +100000000
94static
95SCIP_DECL_CONFLICTEXEC(conflictExecCollector)
96{ /*lint --e{715}*/
97 SCIP_VAR** vars;
98 SCIP_Real* vals;
99 SCIP_Real lhs;
100 int i;
101
102 assert(conflicthdlr != NULL);
103 assert(strcmp(SCIPconflicthdlrGetName(conflicthdlr), CONFLICTHDLR_NAME) == 0);
104 assert(bdchginfos != NULL || nbdchginfos == 0);
105 assert(result != NULL);
106
107 /* don't process already resolved conflicts */
108 if( resolved )
109 {
110 *result = SCIP_DIDNOTRUN;
111 return SCIP_OKAY;
112 }
113
114 *result = SCIP_DIDNOTFIND;
115
116 /* create array of variables and coefficients: sum_{i \in P} x_i - sum_{i \in N} x_i >= 1 - |N| */
117 SCIP_CALL( SCIPallocBufferArray(scip, &vars, nbdchginfos) );
118 SCIP_CALL( SCIPallocBufferArray(scip, &vals, nbdchginfos) );
119 lhs = 1.0;
120 for( i = 0; i < nbdchginfos; ++i )
121 {
122 assert(bdchginfos != NULL);
123
124 vars[i] = SCIPbdchginfoGetVar(bdchginfos[i]);
125
126 /* we can only treat binary variables */
127 /**@todo extend linear conflict constraints to some non-binary cases */
128 if( !SCIPvarIsBinary(vars[i]) )
129 break;
130
131 /* check whether the variable is fixed to zero (P) or one (N) in the conflict set */
132 if( SCIPbdchginfoGetNewbound(bdchginfos[i]) < 0.5 )
133 vals[i] = 1.0;
134 else
135 {
136 vals[i] = -1.0;
137 lhs -= 1.0;
138 }
139 }
140
141 if( i == nbdchginfos )
142 {
143 ScipParaSolver *scipParaSolver = reinterpret_cast<ScipParaSolver *>(SCIPconflicthdlrGetData(conflicthdlr));
144 std::list<LocalNodeInfoPtr> *conflictConsList = scipParaSolver->getConflictConsList();
145 LocalNodeInfo *localNodeInfo = new LocalNodeInfo;
146 localNodeInfo->linearRhs = SCIPinfinity(scip);
147 localNodeInfo->nLinearCoefs = nbdchginfos;
148 localNodeInfo->idxLinearCoefsVars = new int[nbdchginfos];
149 localNodeInfo->linearCoefs = new double[nbdchginfos];
150 for( i = 0; i < nbdchginfos; ++i )
151 {
152 SCIP_VAR *transformVar = vars[i];
153 SCIP_Real scalar = vals[i];
154 SCIP_Real constant = 0.0;
155 if( SCIPvarGetOrigvarSum(&transformVar, &scalar, &constant ) == SCIP_INVALIDDATA )
156 break;
157 // assert(transformVar != NULL);
158 if( transformVar )
159 {
160 lhs -= constant;
161 if( scipParaSolver->isOriginalIndeciesMap() )
162 {
163 localNodeInfo->idxLinearCoefsVars[i] = scipParaSolver->getOriginalIndex(SCIPvarGetIndex(transformVar));
164 }
165 else
166 {
167 localNodeInfo->idxLinearCoefsVars[i] = SCIPvarGetIndex(transformVar);
168 }
169 localNodeInfo->linearCoefs[i] = scalar;
170 }
171 else
172 {
173 break;
174 }
175 }
176 if( i == nbdchginfos )
177 {
178 localNodeInfo->linearLhs = lhs;
179 conflictConsList->push_back(localNodeInfo);
180 }
181 else
182 {
183 delete [] localNodeInfo->idxLinearCoefsVars;
184 delete [] localNodeInfo->linearCoefs;
185 delete localNodeInfo;
186 }
187 }
188
189 /* free temporary memory */
190 SCIPfreeBufferArray(scip, &vals);
191 SCIPfreeBufferArray(scip, &vars);
192
193 return SCIP_OKAY;
194}
195
196void
197ScipParaSolver::setWinnerRacingParams(
198 UG::ParaRacingRampUpParamSet *inRacingParams /**< winner solver pramset */
199 )
200{
201 if( !userPlugins )
202 {
203 SCIP_CALL_ABORT( SCIPresetParams(scip) );
204 }
205
207 {
208 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
209 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
210 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
211 if( inRacingParams )
212 {
213#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
214 ScipParaRacingRampUpParamSet *scipRacingParams = dynamic_cast< ScipParaRacingRampUpParamSet * >(inRacingParams);
215 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "misc/permutationseed", scipRacingParams->getPermuteProbSeed()) );
216#endif
217 }
218 }
219 else
220 {
221 ScipParaRacingRampUpParamSet *scipRacingParams = dynamic_cast< ScipParaRacingRampUpParamSet * >(inRacingParams);
222 setRacingParams(scipRacingParams, true);
223 }
224
225#if SCIP_VERSION >= 320
227#endif
228
229}
230
231void
233 UG::ParaRacingRampUpParamSet *inRacingParams,
234 bool winnerParam
235 )
236{
237 ScipParaRacingRampUpParamSet *scipRacingParams = dynamic_cast< ScipParaRacingRampUpParamSet * >(inRacingParams);
238
239 if( !winnerParam && !userPlugins )
240 {
241 SCIP_CALL_ABORT( SCIPresetParams(scip) );
242 }
243
244 if ( std::string(paraParams->getStringParamValue(UG::RacingParamsDirPath)) != std::string("") )
245 {
246 assert( scipRacingParams->getScipDiffParamSet() );
247 if( !winnerParam )
248 {
249 scipRacingParams->getScipDiffParamSet()->setParametersInScip(scip);
250 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/randomseedshift", scipRacingParams->getScipRacingParamSeed()) );
251 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/permutationseed", scipRacingParams->getPermuteProbSeed()) );
252 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/lpseed", scipRacingParams->getPermuteProbSeed()) );
253 // int tempInt = 0;
254 // SCIP_CALL_ABORT( SCIPgetIntParam(scip, "lp/solvefreq", &tempInt) );
255 // std::cout << "R." << paraComm->getRank() << " lp/solvefreq = " << tempInt << std::endl;
256 }
257 }
258 else
259 {
261 {
262 if( !winnerParam && scipRacingParams->getScipDiffParamSet() )
263 {
264 scipRacingParams->getScipDiffParamSet()->setParametersInScip(scip);
265 }
266 }
267 else
268 {
269 int nHeuristics;
271 {
272 nHeuristics = scipRacingParams->getScipRacingParamSeed() % 2;
273 }
274 else
275 {
276 nHeuristics = scipRacingParams->getScipRacingParamSeed() % 4;
277 }
278 int nPresolving = (scipRacingParams->getScipRacingParamSeed()/4) % 4;
279 int nSeparating = (scipRacingParams->getScipRacingParamSeed()/(4*4)) % 4;
280
281 switch( nHeuristics )
282 {
283 case 0:
284 {
285 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
286 break;
287 }
288 case 1:
289 {
290 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
291 break;
292 }
293 case 2:
294 {
295 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_FAST, TRUE) );
296 break;
297 }
298 case 3:
299 {
300 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_OFF, TRUE) );
301 break;
302 }
303 default:
304 THROW_LOGICAL_ERROR1("invalid nHeuristics");
305 }
306 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "heuristics/ObjLim/freq", 1) );
307
308 switch( nPresolving )
309 {
310 case 0:
311 {
312 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
313 break;
314 }
315 case 1:
316 {
317#ifdef _COMM_PTH
319 {
320 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
321 }
322 else
323 {
324 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
325 }
326#else
327 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
328#endif
329 break;
330 }
331 case 2:
332 {
333 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_FAST, TRUE) );
334 break;
335 }
336 case 3:
337 {
338 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_OFF, TRUE) );
339 break;
340 }
341 default:
342 THROW_LOGICAL_ERROR1("invalid nPresolving");
343 }
344
345 switch( nSeparating )
346 {
347 case 0:
348 {
349 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
350 break;
351 }
352 case 1:
353 {
354#ifdef _COMM_PTH
356 {
357 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
358 }
359 else
360 {
362 {
363 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
364 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
365 }
366 else
367 {
368 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
369 }
370 }
371#else
373 {
374 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
375 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
376 }
377 else
378 {
379 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_AGGRESSIVE, TRUE) );
380 }
381#endif
382 break;
383 }
384 case 2:
385 {
386 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_FAST, TRUE) );
387 break;
388 }
389 case 3:
390 {
391 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_OFF, TRUE) );
392 break;
393 }
394 default:
395 THROW_LOGICAL_ERROR1("invalid nSeparating");
396 }
397 }
398
399 assert(SCIPgetStage(scip) <= SCIP_STAGE_TRANSFORMED);
400 // make sure that the permutation works on transformed problem
401#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
402 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "misc/permutationseed", scipRacingParams->getPermuteProbSeed()) );
403#endif
404
408 {
410 }
411
412 if( !winnerParam && scipRacingParams->getPermuteProbSeed() >= 64 ) // after all parameters tested, random branchig variable selection
413 {
414 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "branching/random/maxdepth", 2) );
415 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "branching/random/priority", 100000) );
416 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "branching/random/seed", scipRacingParams->getGenerateBranchOrderSeed()) );
417 }
418 }
419
421 {
422 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/randomseedshift", scipRacingParams->getScipRacingParamSeed()) );
423 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/permutationseed", scipRacingParams->getPermuteProbSeed()) );
424 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "randomization/lpseed", scipRacingParams->getPermuteProbSeed()) );
425 if( scipRacingParams->getScipDiffParamSet() )
426 {
427 scipRacingParams->getScipDiffParamSet()->setParametersInScip(scip);
428 }
429 }
430
431#if SCIP_VERSION >= 320
433#endif
434
435 // writeSubproblem();
436
437}
438
439void
441 )
442{
443 assert(currentTask);
444
445 UG::BbParaNode *bbCurrentNode = dynamic_cast<UG::BbParaNode *>(currentTask);
446
447#ifdef UG_DEBUG_SOLUTION
448 if( scip->set->debugsoldata == NULL )
449 {
450 SCIP_CALL_ABORT( SCIPdebugSolDataCreate(&((scip->set)->debugsoldata)));
451 // SCIPdebugSetMainscipset(scip->set);
452 }
453#endif
454
455 /** set instance specific parameters */
456 // if( currentNode->isRootNode() && !(paraParams->getBoolParamValue(UseRootNodeCuts)) )
457 // Probably, in order to avoid root node settings twice. Once root nodes is solved in LC
458 // when UseRootNodeCuts is specified. However, for racing ramp-up, this is too bad.
459 // So, I changed the specification. The root node parameter settings is applied twice now
460
461 // Do not reset here, because racing parameters might be set already.
462 // SCIP_CALL_ABORT( SCIPresetParams(scip) );
463
464 /** set original node selection strategy */
465 // setOriginalNodeSelectionStrategy();
467 nodesel->reset();
468 if( bbCurrentNode->isRootTask() )
469 {
470 if ( std::string(paraParams->getStringParamValue(UG::RacingParamsDirPath)) == std::string("") )
471 {
473 }
476 isRacingStage() &&
477 paraComm->getRank() == 1 ) // rank 1 should be all default
478 )
479 {
480 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_OFF, TRUE) );
481 }
482 }
483 else
484 {
486 {
487 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_DEFAULT, TRUE) );
488 }
490 {
491 if( scipDiffParamSet ) // this may not be necessary , check setWinnerRacingParams(0)
492 {
494 }
495 }
496
497 /*
498 if( paraParams->getBoolParamValue(UG::ControlCollectingModeOnSolverSide) )
499 {
500 int maxrestarts;
501 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/maxrestarts", &maxrestarts) );
502 if( maxrestarts < 0 )
503 {
504 std::cerr << "presolving/maxrestarts >= 0 when you specify ControlCollectingModeOnSolverSide = TRUE."
505 << std::endl;
506 exit(1);
507 }
508 }
509 else
510 {
511 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/maxrestarts", 0 ) );
512 }
513 */
514 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/maxrestarts", getOriginalMaxRestart()) );
515 }
516
517#if SCIP_APIVERSION >= 163
518 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "symmetries/enabled", FALSE ) ); // Symmetry handling is explicitly turned off in Solver for this version (SCIP 11.0)
519#else
520 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "misc/usesymmetry", 0 ) ); // Symmetry handling is explicitly turned off in Solver for this version (SCIP 5.0)
521#endif
522
523#if SCIP_VERSION >= 320
525#endif
526
527 double dualBoundValue = bbCurrentNode->getDualBoundValue();
528
529 ScipParaDiffSubproblem *scipParaDiffSubproblem = dynamic_cast< ScipParaDiffSubproblem* >(currentTask->getDiffSubproblem());
530
531 SCIP_VAR **orgVars = SCIPgetOrigVars(scip); // variables are indexed by index
532 int nOrg = SCIPgetNOrigVars(scip); // the number of original variables
533 if( scipParaDiffSubproblem )
534 {
536 {
537 assert( mapToSolverLocalIndecies );
538 for(int v = 0; v < scipParaDiffSubproblem->getNBoundChanges(); v++)
539 {
540 assert(mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]] >= 0);
541 if( mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]] < nOrg )
542 {
543 if( scipParaDiffSubproblem->getBoundType(v) == SCIP_BOUNDTYPE_LOWER )
544 {
545 SCIP_CALL_ABORT(
546 SCIPchgVarLbGlobal(
547 scip,
548 orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]],
549 scipParaDiffSubproblem->getBranchBound(v) )
550 );
551 if( scipParaDiffSubproblem->getIndex(v) < nOrgVars )
552 {
553 assert(SCIPisEQ(scip,SCIPvarGetLbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]]),scipParaDiffSubproblem->getBranchBound(v)));
554 assert(SCIPisLE(scip,SCIPvarGetLbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]]),SCIPvarGetUbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]])));
555 }
556 }
557 else if (scipParaDiffSubproblem->getBoundType(v) == SCIP_BOUNDTYPE_UPPER)
558 {
559 SCIP_CALL_ABORT(SCIPchgVarUbGlobal(
560 scip,
561 orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]],
562 scipParaDiffSubproblem->getBranchBound(v) )
563 );
564 if( scipParaDiffSubproblem->getIndex(v) < nOrgVars )
565 {
566 assert(SCIPisEQ(scip,SCIPvarGetUbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]]),scipParaDiffSubproblem->getBranchBound(v)));
567 assert(SCIPisLE(scip,SCIPvarGetLbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]]),SCIPvarGetUbGlobal(orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]]])));
568 }
569 }
570 else
571 {
572 THROW_LOGICAL_ERROR2("Invalid bound type: type = ", static_cast<int>(scipParaDiffSubproblem->getBoundType(v))) ;
573 }
574 }
575 else
576 {
577 std::cout << "fixing branching variable index = " << mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIndex(v)]] << " is omitted!" << std::endl;
578 }
579 }
580 }
581 else
582 {
583 for(int v = 0; v < scipParaDiffSubproblem->getNBoundChanges(); v++)
584 {
585 if( scipParaDiffSubproblem->getIndex(v) < nOrg )
586 {
587 if( scipParaDiffSubproblem->getBoundType(v) == SCIP_BOUNDTYPE_LOWER )
588 {
589 SCIP_CALL_ABORT(
590 SCIPchgVarLbGlobal(
591 scip,
592 orgVars[scipParaDiffSubproblem->getIndex(v)],
593 scipParaDiffSubproblem->getBranchBound(v) )
594 );
595 if( scipParaDiffSubproblem->getIndex(v) < nOrgVars )
596 {
597 assert(SCIPisEQ(scip,SCIPvarGetLbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)]),scipParaDiffSubproblem->getBranchBound(v)));
598 assert(SCIPisLE(scip,SCIPvarGetLbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)]),SCIPvarGetUbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)])));
599 }
600 }
601 else if (scipParaDiffSubproblem->getBoundType(v) == SCIP_BOUNDTYPE_UPPER)
602 {
603 SCIP_CALL_ABORT(SCIPchgVarUbGlobal(
604 scip,
605 orgVars[scipParaDiffSubproblem->getIndex(v)],
606 scipParaDiffSubproblem->getBranchBound(v) )
607 );
608 if( scipParaDiffSubproblem->getIndex(v) < nOrgVars )
609 {
610 assert(SCIPisEQ(scip,SCIPvarGetUbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)]),scipParaDiffSubproblem->getBranchBound(v)));
611 assert(SCIPisLE(scip,SCIPvarGetLbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)]),SCIPvarGetUbGlobal(orgVars[scipParaDiffSubproblem->getIndex(v)])));
612 }
613 }
614 else
615 {
616 THROW_LOGICAL_ERROR2("Invalid bound type: type = ", static_cast<int>(scipParaDiffSubproblem->getBoundType(v))) ;
617 }
618 }
619 else
620 {
621 std::cout << "fixing branching variable index = " << scipParaDiffSubproblem->getIndex(v) << " is omitted!" << std::endl;
622 }
623 }
624 }
625
626 if( scipParaDiffSubproblem->getNBranchConsLinearConss() > 0 ||
627 scipParaDiffSubproblem->getNBranchConsSetppcConss() > 0 ||
628 scipParaDiffSubproblem->getNLinearConss() > 0 ||
629 scipParaDiffSubproblem->getNBendersLinearConss() > 0 ||
630 scipParaDiffSubproblem->getNBoundDisjunctions() )
631 {
632 assert(addedConss == 0);
633 addedConss = new SCIP_CONS*[scipParaDiffSubproblem->getNBranchConsLinearConss()
634 + scipParaDiffSubproblem->getNBranchConsSetppcConss()
635 + scipParaDiffSubproblem->getNLinearConss()
636 + scipParaDiffSubproblem->getNBendersLinearConss()
637 + scipParaDiffSubproblem->getNBoundDisjunctions()];
638 }
639
640 SCIP_CONS* cons;
641 char consname[SCIP_MAXSTRLEN];
642
643 int c = 0;
644 for(; c < scipParaDiffSubproblem->getNBranchConsLinearConss() ; c++ )
645 {
646 SCIP_VAR** vars;
647 SCIP_Real* vals;
648 int nVars = scipParaDiffSubproblem->getBranchConsNLinearCoefs(c);
649
650 /* create array of variables and coefficients */
651 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vars, nVars) );
652 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vals, nVars) );
653
655 {
656 for( int v = 0; v < nVars; ++v )
657 {
658 vars[v] = orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getBranchConsLinearIdxCoefsVars(c,v)]]];
659 vals[v] = scipParaDiffSubproblem->getBranchConsLinearCoefs(c,v);
660 }
661 }
662 else
663 {
664 for( int v = 0; v < nVars; ++v )
665 {
666 vars[v] = orgVars[scipParaDiffSubproblem->getBranchConsLinearIdxCoefsVars(c,v)];
667 vals[v] = scipParaDiffSubproblem->getBranchConsLinearCoefs(c,v);
668 }
669 }
670
671 /* create a constraint */
672 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s", scipParaDiffSubproblem->getBranchConsLinearConsNames(c));
673 SCIP_CALL_ABORT( SCIPcreateConsLinear(scip, &cons, consname, nVars, vars, vals,
674 scipParaDiffSubproblem->getBranchConsLinearLhs(c), scipParaDiffSubproblem->getBranchConsLinearRhs(c),
675 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
676 /** only a constraint whose "enforce is TRUE can be written in transformed problem */
677
678 /* add constraint to SCIP */
679 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
680 assert(cons);
681 addedConss[c] = cons;
682 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
683 /* free temporary memory */
684 SCIPfreeBufferArray(scip, &vals);
685 SCIPfreeBufferArray(scip, &vars);
686 }
687
688 int i = 0;
689 for(; c < (scipParaDiffSubproblem->getNBranchConsLinearConss()
690 + scipParaDiffSubproblem->getNBranchConsSetppcConss()) ; c++ )
691 {
692 SCIP_VAR** vars;
693
694 int nVars = scipParaDiffSubproblem->getBranchConsSetppcNVars(i);
695 /* create array of variables, types and bounds */
696 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vars, nVars) );
697
699 {
700 for( int v = 0; v < nVars; ++v )
701 {
702 vars[v] = orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getBranchConsSetppcVars(i,v)]]];
703 }
704 }
705 else
706 {
707 for( int v = 0; v < nVars; ++v )
708 {
709 vars[v] = orgVars[scipParaDiffSubproblem->getBranchConsSetppcVars(i,v)];
710 }
711 }
712
713 /* create a constraint */
714 assert( scipParaDiffSubproblem->getBranchConsSetppcType(i) == SCIP_SETPPCTYPE_PARTITIONING ); // currently, only this should be used
715 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s", scipParaDiffSubproblem->getBranchConsSetppcConsNames(i));
716 if( scipParaDiffSubproblem->getBranchConsSetppcType(i) == SCIP_SETPPCTYPE_PARTITIONING )
717 {
718 SCIP_CALL_ABORT( SCIPcreateConsSetpart(scip, &cons, consname, nVars, vars,
719 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE ) );
720 } else if ( scipParaDiffSubproblem->getBranchConsSetppcType(i) == SCIP_SETPPCTYPE_PACKING )
721 {
722 SCIP_CALL_ABORT( SCIPcreateConsSetpack(scip, &cons, consname, nVars, vars,
723 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE ) );
724 } else if ( scipParaDiffSubproblem->getBranchConsSetppcType(i) == SCIP_SETPPCTYPE_COVERING )
725 {
726 SCIP_CALL_ABORT( SCIPcreateConsSetcover(scip, &cons, consname, nVars, vars,
727 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE ) );
728 } else {
729 THROW_LOGICAL_ERROR2("Unknown setppc constraint is received: type = ", scipParaDiffSubproblem->getBranchConsSetppcType(i));
730 }
731
732 /* add constraint to SCIP */
733 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
734 assert(cons);
735 addedConss[c] = cons;
736 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
737 /* free temporary memory */
738 SCIPfreeBufferArray(scip, &vars);
739 i++;
740 }
741
742 i = 0;
743 for(; c < (scipParaDiffSubproblem->getNBranchConsLinearConss()
744 + scipParaDiffSubproblem->getNBranchConsSetppcConss()
745 + scipParaDiffSubproblem->getNLinearConss()) ; c++ )
746 {
747 SCIP_VAR** vars;
748 SCIP_Real* vals;
749 int nVars = scipParaDiffSubproblem->getNLinearCoefs(i);
750
751 /* create array of variables and coefficients */
752 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vars, nVars) );
753 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vals, nVars) );
754
756 {
757 for( int v = 0; v < nVars; ++v )
758 {
759 vars[v] = orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIdxLinearCoefsVars(i,v)]]];
760 vals[v] = scipParaDiffSubproblem->getLinearCoefs(i,v);
761 }
762 }
763 else
764 {
765 for( int v = 0; v < nVars; ++v )
766 {
767 vars[v] = orgVars[scipParaDiffSubproblem->getIdxLinearCoefsVars(i,v)];
768 vals[v] = scipParaDiffSubproblem->getLinearCoefs(i,v);
769 }
770 }
771
772 /* create a constraint */
773 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "cli%d", i);
774 SCIP_CALL_ABORT( SCIPcreateConsLinear(scip, &cons, consname, nVars, vars, vals,
775 scipParaDiffSubproblem->getLinearLhs(i), scipParaDiffSubproblem->getLinearRhs(i),
776 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
777 /** only a constraint whose "enforce is TRUE can be written in transformed problem */
778
779 /* add constraint to SCIP */
780 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
781 assert(cons);
782 addedConss[c] = cons;
783 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
784 /* free temporary memory */
785 SCIPfreeBufferArray(scip, &vals);
786 SCIPfreeBufferArray(scip, &vars);
787 i++;
788 }
789
790 i = 0;
791 for(; c < (scipParaDiffSubproblem->getNBranchConsLinearConss()
792 + scipParaDiffSubproblem->getNBranchConsSetppcConss()
793 + scipParaDiffSubproblem->getNLinearConss()
794 + scipParaDiffSubproblem->getNBendersLinearConss()) ; c++ )
795 {
796 SCIP_VAR** vars;
797 SCIP_Real* vals;
798 int nVars = scipParaDiffSubproblem->getNBendersLinearCoefs(i);
799
800 /* create array of variables and coefficients */
801 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vars, nVars) );
802 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vals, nVars) );
803
805 {
806 for( int v = 0; v < nVars; ++v )
807 {
808 vars[v] = orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIdxBendersLinearCoefsVars(i,v)]]];
809 vals[v] = scipParaDiffSubproblem->getBendersLinearCoefs(i,v);
810 }
811 }
812 else
813 {
814 for( int v = 0; v < nVars; ++v )
815 {
816 vars[v] = orgVars[scipParaDiffSubproblem->getIdxBendersLinearCoefsVars(i,v)];
817 vals[v] = scipParaDiffSubproblem->getBendersLinearCoefs(i,v);
818 }
819 }
820
821 /* create a constraint */
822 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "cli%d", i);
823 SCIP_CALL_ABORT( SCIPcreateConsLinear(scip, &cons, consname, nVars, vars, vals,
824 scipParaDiffSubproblem->getBendersLinearLhs(i), scipParaDiffSubproblem->getBendersLinearRhs(i),
825 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
826 /** only a constraint whose "enforce is TRUE can be written in transformed problem */
827
828 /* add constraint to SCIP */
829 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
830 assert(cons);
831 addedConss[c] = cons;
832 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
833 /* free temporary memory */
834 SCIPfreeBufferArray(scip, &vals);
835 SCIPfreeBufferArray(scip, &vars);
836 i++;
837 }
838
839 i = 0;
840 for(; c < (scipParaDiffSubproblem->getNBranchConsLinearConss()
841 + scipParaDiffSubproblem->getNBranchConsSetppcConss()
842 + scipParaDiffSubproblem->getNLinearConss()
843 + scipParaDiffSubproblem->getNBendersLinearConss()
844 + scipParaDiffSubproblem->getNBoundDisjunctions()) ; c++ )
845 {
846 SCIP_VAR** vars;
847 SCIP_BOUNDTYPE *types;
848 SCIP_Real* bounds;
849 int nVars = scipParaDiffSubproblem->getNVarsBoundDisjunction(i);
850 /* create array of variables, types and bounds */
851 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vars, nVars) );
852 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &types, nVars) );
853 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &bounds, nVars) );
854
856 {
857 for( int v = 0; v < nVars; ++v )
858 {
859 vars[v] = orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIdxBoundDisjunctionVars(i,v)]]];
860 types[v] = scipParaDiffSubproblem->getBoundTypesBoundDisjunction(i,v);
861 bounds[v] = scipParaDiffSubproblem->getBoundsBoundDisjunction(i,v);
862 }
863 }
864 else
865 {
866 for( int v = 0; v < nVars; ++v )
867 {
868 vars[v] = orgVars[scipParaDiffSubproblem->getIdxBoundDisjunctionVars(i,v)];
869 types[v] = scipParaDiffSubproblem->getBoundTypesBoundDisjunction(i,v);
870 bounds[v] = scipParaDiffSubproblem->getBoundsBoundDisjunction(i,v);
871 }
872 }
873
874 /* create a constraint */
875 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "bdj%d", i);
876 SCIP_CALL_ABORT( SCIPcreateConsBounddisjunction(scip, &cons, consname, nVars, vars, types, bounds,
877 scipParaDiffSubproblem->getFlagBoundDisjunctionInitial(i),
878 scipParaDiffSubproblem->getFlagBoundDisjunctionSeparate(i),
879 scipParaDiffSubproblem->getFlagBoundDisjunctionEnforce(i),
880 scipParaDiffSubproblem->getFlagBoundDisjunctionCheck(i),
881 scipParaDiffSubproblem->getFlagBoundDisjunctionPropagate(i),
882 scipParaDiffSubproblem->getFlagBoundDisjunctionLocal(i),
883 scipParaDiffSubproblem->getFlagBoundDisjunctionModifiable(i),
884 scipParaDiffSubproblem->getFlagBoundDisjunctionDynamic(i),
885 scipParaDiffSubproblem->getFlagBoundDisjunctionRemovable(i),
886 scipParaDiffSubproblem->getFlagBoundDisjunctionStickingatnode(i) ) );
887 /* add constraint to SCIP */
888 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
889 assert(cons);
890 addedConss[c] = cons;
891 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
892 /* free temporary memory */
893 SCIPfreeBufferArray(scip, &bounds);
894 SCIPfreeBufferArray(scip, &types);
895 SCIPfreeBufferArray(scip, &vars);
896 i++;
897 }
898 nAddedConss = c;
899 }
900
901
902 int addingConsParam = getParaParamSet()->getIntParamValue(AddDualBoundCons);
903 addedDualCons = 0;
904 if( addingConsParam != 0 )
905 {
906 if( ( addingConsParam == 1 && !SCIPisGT(scip, bbCurrentNode->getDualBoundValue(), bbCurrentNode->getInitialDualBoundValue()) )
907 || addingConsParam == 2 || addingConsParam == 3 )
908 {
909 SCIP_CONS* cons;
910 int nvars = SCIPgetNVars(scip);
911 SCIP_VAR **vars = SCIPgetVars(scip);
912 SCIP_Real* vals = new SCIP_Real[nvars];
913 for(int v = 0; v < nvars; ++v )
914 {
915 vals[v] = SCIPvarGetObj(vars[v]);
916 }
917 SCIP_CALL_ABORT( SCIPcreateConsLinear(scip, &cons, "objective", nvars, vars, vals, dualBoundValue, SCIPinfinity(scip),
918 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
919 assert( SCIPisEQ( scip, SCIPgetTransObjscale(scip), 1.0 ) );
920 assert( SCIPisZero( scip, SCIPgetTransObjoffset(scip) ) );
921
922 /** try to automatically convert a linear constraint into a more specific and more specialized constraint */
923
924 /* add constraint to SCIP */
925 SCIP_CALL_ABORT( SCIPaddCons(scip, cons) );
926 SCIP_CALL_ABORT( SCIPreleaseCons(scip, &cons) );
927 addedDualCons = cons;
928 }
929 }
930
931 if( userPlugins && scipParaDiffSubproblem )
932 {
933 userPlugins->newSubproblem(scip, scipParaDiffSubproblem->getBranchLinearConss(), scipParaDiffSubproblem->getBranchSetppcConss());
934 }
935
937 {
938 setWinnerRacingParams(winnerRacingParams); // winner parameters are set, again
939 // std::cout << winnerRacingParams->toString() << std::endl;
940 }
941
942 /// do not save solutions to original problem space
943 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/transsolsorig", FALSE) );
944
945 if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM)
946 {
947 SCIP_CALL_ABORT( SCIPtransformProb(scip));
948 }
949
950 if( scipParaDiffSubproblem && scipParaDiffSubproblem->getNVarBranchStats() > 0 )
951 {
952 orgVars = SCIPgetOrigVars(scip); /* original problem's variables */
954 {
955 for( int i = 0; i < scipParaDiffSubproblem->getNVarBranchStats(); i++ )
956 {
957 SCIP_CALL_ABORT( SCIPinitVarBranchStats(scip, orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIdxLBranchStatsVars(i)]]],
958 scipParaDiffSubproblem->getDownpscost(i),
959 scipParaDiffSubproblem->getUppscost(i),
960 scipParaDiffSubproblem->getDownvsids(i),
961 scipParaDiffSubproblem->getUpvsids(i),
962 scipParaDiffSubproblem->getDownconflen(i),
963 scipParaDiffSubproblem->getUpconflen(i),
964 scipParaDiffSubproblem->getDowninfer(i),
965 scipParaDiffSubproblem->getUpinfer(i),
966 scipParaDiffSubproblem->getDowncutoff(i),
967 scipParaDiffSubproblem->getUpcutoff(i)
968 )
969 );
970 }
971 }
972 else
973 {
974 for( int i = 0; i < scipParaDiffSubproblem->getNVarBranchStats(); i++ )
975 {
976 SCIP_CALL_ABORT( SCIPinitVarBranchStats(scip, orgVars[scipParaDiffSubproblem->getIdxLBranchStatsVars(i)],
977 scipParaDiffSubproblem->getDownpscost(i),
978 scipParaDiffSubproblem->getUppscost(i),
979 scipParaDiffSubproblem->getDownvsids(i),
980 scipParaDiffSubproblem->getUpvsids(i),
981 scipParaDiffSubproblem->getDownconflen(i),
982 scipParaDiffSubproblem->getUpconflen(i),
983 scipParaDiffSubproblem->getDowninfer(i),
984 scipParaDiffSubproblem->getUpinfer(i),
985 scipParaDiffSubproblem->getDowncutoff(i),
986 scipParaDiffSubproblem->getUpcutoff(i)
987 )
988 );
989 }
990 }
991 }
992
993#if SCIP_VERSION >= 312
994 // std::cout << " VERSION >= 320 " << std::endl;
995
996 if( scipParaDiffSubproblem && scipParaDiffSubproblem->getNVarValueVars() > 0 )
997 {
998 orgVars = SCIPgetOrigVars(scip); /* original problem's variables */
1000 {
1001 for( int i = 0; i < scipParaDiffSubproblem->getNVarValueVars(); i++ )
1002 {
1003 for( int j = 0; j < scipParaDiffSubproblem->getNVarValueValues(i); j++ )
1004 {
1005 SCIP_CALL_ABORT( SCIPinitVarValueBranchStats(scip, orgVars[mapToProbIndecies[mapToSolverLocalIndecies[scipParaDiffSubproblem->getIdxLBranchStatsVars(i)]]],
1006 scipParaDiffSubproblem->getVarValue(i,j),
1007 scipParaDiffSubproblem->getVarValueDownvsids(i,j),
1008 scipParaDiffSubproblem->getVarVlaueUpvsids(i,j),
1009 scipParaDiffSubproblem->getVarValueDownconflen(i,j),
1010 scipParaDiffSubproblem->getVarValueUpconflen(i,j),
1011 scipParaDiffSubproblem->getVarValueDowninfer(i,j),
1012 scipParaDiffSubproblem->getVarValueUpinfer(i,j),
1013 scipParaDiffSubproblem->getVarValueDowncutoff(i,j),
1014 scipParaDiffSubproblem->getVarValueUpcutoff(i,j)
1015 )
1016 );
1017 /*
1018 std::cout << mapToOriginalIndecies[scipParaDiffSubproblem->getIdxLBranchStatsVars(i)]
1019 << ", "
1020 << scipParaDiffSubproblem->getVarValue(i,j)
1021 << ", "
1022 << scipParaDiffSubproblem->getVarValueDownvsids(i,j)
1023 << ", "
1024 << scipParaDiffSubproblem->getVarVlaueUpvsids(i,j)
1025 << ", "
1026 << scipParaDiffSubproblem->getVarValueDownconflen(i,j)
1027 << ", "
1028 << scipParaDiffSubproblem->getVarValueUpconflen(i,j)
1029 << ", "
1030 << scipParaDiffSubproblem->getVarValueDowninfer(i,j)
1031 << ", "
1032 << scipParaDiffSubproblem->getVarValueUpinfer(i,j)
1033 << ", "
1034 << scipParaDiffSubproblem->getVarValueDowncutoff(i,j)
1035 << ", "
1036 << scipParaDiffSubproblem->getVarValueUpcutoff(i,j)
1037 << std::endl;
1038 */
1039 }
1040 }
1041 }
1042 else
1043 {
1044 for( int i = 0; i < scipParaDiffSubproblem->getNVarValueVars(); i++ )
1045 {
1046 for( int j = 0; j < scipParaDiffSubproblem->getNVarValueValues(i); j++ )
1047 {
1048 SCIP_CALL_ABORT( SCIPinitVarValueBranchStats(scip, orgVars[scipParaDiffSubproblem->getIdxLBranchStatsVars(i)],
1049 scipParaDiffSubproblem->getVarValue(i,j),
1050 scipParaDiffSubproblem->getVarValueDownvsids(i,j),
1051 scipParaDiffSubproblem->getVarVlaueUpvsids(i,j),
1052 scipParaDiffSubproblem->getVarValueDownconflen(i,j),
1053 scipParaDiffSubproblem->getVarValueUpconflen(i,j),
1054 scipParaDiffSubproblem->getVarValueDowninfer(i,j),
1055 scipParaDiffSubproblem->getVarValueUpinfer(i,j),
1056 scipParaDiffSubproblem->getVarValueDowncutoff(i,j),
1057 scipParaDiffSubproblem->getVarValueUpcutoff(i,j)
1058 )
1059 );
1060 }
1061 }
1062 }
1063 /** for debug *********************
1064 int nvars; ** number of variables
1065 int nbinvars; ** number of binary variables
1066 int nintvars; ** number of integer variables
1067 SCIP_VAR** vars; ** transformed problem's variables
1068 SCIP_CALL_ABORT( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
1069 int ngenvars = nbinvars+nintvars;
1070 int nOrgVarst = 0;
1071
1072 if( ngenvars > 0 )
1073 {
1074 std::cout << "R." << paraComm->getRank() << ", ngenvars = " << ngenvars << std::endl;;
1075 for( int i = 0; i < ngenvars; i++ )
1076 {
1077 assert( SCIPvarGetType(vars[i]) == SCIP_VARTYPE_BINARY || SCIPvarGetType(vars[i]) == SCIP_VARTYPE_INTEGER );
1078
1079 SCIP_VAR *transformVar = vars[i];
1080 SCIP_Real scalar = 1.0;
1081 SCIP_Real constant = 0.0;
1082 SCIP_CALL_ABORT( SCIPvarGetOrigvarSum(&transformVar, &scalar, &constant ) );
1083 assert(transformVar != NULL);
1084
1085 if( transformVar ) // The variable in the transformed space
1086 {
1087 SCIP_VALUEHISTORY* valuehistory = SCIPvarGetValuehistory(vars[i]);
1088 if( valuehistory != NULL )
1089 {
1090 nOrgVarst++;
1091 }
1092 else
1093 {
1094 std::cout << "R." << paraComm->getRank() << ", no history for var i = " << i << std::endl;
1095 std::cout << "R." << paraComm->getRank() << ", org = " << SCIPvarGetValuehistory(transformVar) << std::endl;
1096 }
1097 }
1098 else
1099 {
1100 std::cout << "R." << paraComm->getRank() << ", no transfrom var i = " << i << std::endl;;
1101 }
1102 }
1103 }
1104 if( nOrgVarst == 0 )
1105 {
1106 std::cout << "Failed to set Var Value stat. R." << paraComm->getRank() << std::endl;;
1107 abort();
1108 }
1109 else
1110 {
1111 std::cout << "Set " << nOrgVarst << " Var Value stat. R." << paraComm->getRank() << std::endl;;
1112 }
1113 *** end of debug */
1114 }
1115#endif
1116
1117// if( userPlugins && scipParaDiffSubproblem)
1118// {
1119// userPlugins->newSubproblem(scip, scipParaDiffSubproblem->getBranchLinearConss(), scipParaDiffSubproblem->getBranchSetppcConss());
1120// }
1121
1122}
1123
1124void
1126 )
1127{
1129 {
1130 DEF_SCIP_PARA_COMM( scipParaComm, paraComm);
1131 ScipParaInitialStat *initialStat = scipParaComm->createScipParaInitialStat(scip);
1132 initialStat->send(paraComm, 0);
1133 delete initialStat;
1134 }
1135 SCIP_CALL_ABORT( SCIPfreeTransform(scip) );
1136
1137 int c = 0;
1139 {
1140 ScipParaDiffSubproblem *scipParaDiffSubproblem = dynamic_cast< ScipParaDiffSubproblem* >(currentTask->getDiffSubproblem());
1141 if( scipParaDiffSubproblem->getNLinearConss() > 0 )
1142 {
1143 for(; c < scipParaDiffSubproblem->getNLinearConss() ; c++ )
1144 {
1145 if( !SCIPconsIsDeleted(addedConss[c]) )
1146 {
1147 SCIP_CALL_ABORT( SCIPdelCons(scip, addedConss[c]) );
1148 }
1149 }
1150 }
1151 }
1152
1153 if( addedConss )
1154 {
1155 for(; c < nAddedConss; c++ )
1156 {
1157 if( !SCIPconsIsDeleted(addedConss[c]) )
1158 {
1159 SCIP_CALL_ABORT( SCIPdelCons(scip, addedConss[c]) );
1160 }
1161 }
1162 delete [] addedConss;
1163 addedConss = 0;
1164 }
1165
1166 if( addedDualCons )
1167 {
1168 SCIP_CALL_ABORT( SCIPdelCons(scip, addedDualCons) );
1169 addedDualCons = 0;
1170 }
1171
1172 SCIP_VAR **orgVars = SCIPgetOrigVars(scip); // variables are indexed by index
1173 // Taking into account multi-aggregate vars.
1174 // int n = SCIPgetNOrigVars(scip); // the number of original variables
1175 // assert( n == nOrgVars );
1176 assert( nOrgVarsInSolvers == SCIPgetNOrigVars(scip));
1177 // for( int v = 0; v < n; v++ )
1178 for( int v = 0; v < nOrgVars; v++ )
1179 {
1180 SCIP_CALL_ABORT( SCIPchgVarLbGlobal( scip,orgVars[v], orgVarLbs[v] ) );
1181 SCIP_CALL_ABORT( SCIPchgVarUbGlobal( scip,orgVars[v], orgVarUbs[v] ) );
1182 }
1183
1184 if( racingWinner )
1185 {
1188 // std::cout << "Winner: nTightened = " << nTightened << ", nTightenedInt = " << nTightenedInt << std::endl;
1189 }
1190
1194 {
1196 }
1197
1198}
1199
1200void
1202 )
1203{
1204 DEF_SCIP_PARA_COMM( scipParaComm, paraComm);
1205 SCIP_SOL *sol = SCIPgetBestSol(scip);
1206 int nVars = SCIPgetNOrigVars(scip);
1207 SCIP_VAR **vars = SCIPgetOrigVars(scip);
1208 SCIP_Real *vals = new SCIP_Real[nVars];
1209 SCIP_CALL_ABORT( SCIPgetSolVals(scip, sol, nVars, vars, vals) );
1211 {
1212 SCIP_VAR **varsInOrig = new SCIP_VAR*[nVars];
1213 SCIP_Real *valsInOrig = new SCIP_Real[nVars]();
1214 int nVarsInOrig = 0;
1215 for( int i = 0; i < nVars; i++ )
1216 {
1217 if( getOriginalIndex(SCIPvarGetIndex(vars[i])) >= 0 )
1218 {
1219 varsInOrig[nVarsInOrig] = vars[i];
1220 valsInOrig[nVarsInOrig] = vals[i];
1221 nVarsInOrig++;
1222 }
1223 }
1225 scipParaComm->createScipParaSolution(
1226 this,
1227 SCIPgetSolOrigObj(scip, sol),
1228 nVarsInOrig,
1229 varsInOrig,
1230 valsInOrig
1231 )
1232 );
1233 delete [] varsInOrig;
1234 delete [] valsInOrig;
1235 }
1236 else
1237 {
1239 scipParaComm->createScipParaSolution(
1240 this,
1241 SCIPgetSolOrigObj(scip, sol),
1242 nVars,
1243 vars,
1244 vals
1245 )
1246 );
1247 }
1248 delete [] vals;
1249}
1250
1251void
1253 )
1254{
1255 SCIP_Real feastol;
1256
1258 {
1260 }
1261
1262 // if( paraParams->getBoolParamValue(UG::CheckGapInLC) )
1263 // {
1264 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "limits/gap", 0.0 ) );
1265 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "limits/absgap", 0.0 ) );
1266 // }
1267
1268 // if( paraParams->getBoolParamValue(UG::CheckFeasibilityInLC) )
1269 // {
1270#if SCIP_APIVERSION < 61
1271 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "numerics/lpfeastol", orgLpfeastol / 10.0) );
1272#endif
1273
1274 feastol = orgFeastol / 10.0;
1275
1276 if( SCIPsumepsilon(scip) > feastol )
1277 {
1278 if( SCIPepsilon(scip) > feastol )
1279 {
1280 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "numerics/epsilon", feastol) );
1281 }
1282
1283 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "numerics/sumepsilon", feastol) );
1284 }
1285
1286 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "numerics/feastol", feastol) );
1287 // }
1288
1289 /** solve */
1291 {
1292 assert(conflictConsList->size() == 0);
1293 }
1294
1295 /* don't catch control+c */
1296 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/catchctrlc", FALSE) );
1297
1298 /** set cutoff value */
1299#ifdef UG_DEBUG_SOLUTION
1300 const double limit = DBL_MAX;
1301 if( limit < globalBestIncumbentValue )
1302 {
1303 SCIP_CALL_ABORT( SCIPsetObjlimit(scip, limit) );
1304 }
1305 else
1306 {
1307 SCIP_CALL_ABORT( SCIPsetObjlimit(scip, globalBestIncumbentValue) );
1308 }
1309 // if( ( !currentNode->getDiffSubproblem() ) ||
1310 // currentNode->getDiffSubproblem()->isOptimalSolIncluded() )
1311 // {
1312 // writeSubproblem();
1313 // }
1315#else
1316 /** set cutoff value */
1317 SCIP_CALL_ABORT( SCIPsetObjlimit(scip, globalBestIncumbentValue) );
1318#endif
1320
1321#ifdef _DEBUG_DET
1323#endif
1324
1325 // if( paraComm->getRank() == 1) checkVarsAndIndex("***before solve***",scip);
1326
1327#if SCIP_APIVERSION >= 163
1328 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "symmetries/enabled", FALSE ) ); // Symmetry handling is explicitly turn off in Solver for this version (SCIP 11.0)
1329#else
1330 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "misc/usesymmetry", 0 ) ); // Symmetry handling is explicitly turn off in Solver for this version (SCIP 5.0)
1331#endif
1332
1333 SCIP_CALL_ABORT( SCIPsetIntParam(scip,"timing/clocktype", 2) ); // always wall clock time, racing may change clocktype
1334 // writeSubproblem();
1335
1336#ifdef UG_DEBUG_SOLUTION
1337 // assert( paraNode == currentNode );
1338 if( ( !currentTask->getDiffSubproblem() ) ||
1339 currentTask->getDiffSubproblem()->isOptimalSolIncluded() )
1340 {
1341 SCIPdebugSolEnable(scip);
1342 std::cout << "R." << paraComm->getRank() << ": enable debug" << std::endl;
1343 assert( SCIPdebugSolIsEnabled(scip) == TRUE );
1344 }
1345 else
1346 {
1347 SCIPdebugSolDisable(scip);
1348 std::cout << "R." << paraComm->getRank() << ": disable debug" << std::endl;
1349 assert( SCIPdebugSolIsEnabled(scip) == FALSE );
1350 }
1351#endif
1352
1353#if (SCIP_VERSION >= 700)
1355 {
1356 if( !isRacingStage() )
1357 {
1358 SCIP_CALL_ABORT( SCIPsetCharParam(scip, "estimation/restarts/restartpolicy", 'n' ) );
1359 }
1360 }
1361#endif
1362
1364 {
1365 double timeRemains = std::max(0.0, (paraParams->getRealParamValue(UG::TimeLimit) - paraTimer->getElapsedTime()) );
1366 SCIP_CALL_ABORT( SCIPsetIntParam(scip,"timing/clocktype", 2) ); // to confirm this for the scip environment actually to work
1367 SCIP_CALL_ABORT( SCIPsetRealParam(scip,"limits/time", timeRemains) );
1368 }
1369
1370#if SCIP_APIVERSION >= 101
1371 if( SCIPgetParam(scip, "presolving/milp/threads") != NULL )
1372 {
1373 int nmilpthreads = 0;
1374 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/milp/threads", &nmilpthreads) );
1375 assert( nmilpthreads == 1 );
1376 }
1377#endif
1378
1379 terminationMode = UG::CompTerminatedNormally; // assume that it terminates normally
1380
1381 // writeSubproblem();
1382 SCIP_RETCODE ret = SCIPsolve(scip);
1383 if( ret != SCIP_OKAY )
1384 {
1385#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
1386 SCIPprintError(ret, NULL);
1387#else
1388 SCIPprintError(ret);
1389#endif
1391 if( userPlugins )
1392 {
1394 }
1395#ifdef _MSC_VER
1396 _sleep(10);
1397#else
1398 sleep(10);
1399#endif
1400 std::cout << "ret = " << (int)ret << std::endl;
1401 THROW_LOGICAL_ERROR1("SCIP terminate with NO SCIP_OKAY");
1402 }
1403
1404 // Notification message has to complete
1406 {
1408 }
1409
1410 // Then, solver status should be checked
1411 SCIP_STATUS status = SCIPgetStatus(scip);
1412
1413#if SCIP_APIVERSION >= 101
1414 if( paraParams->getIntParamValue(UG::RampUpPhaseProcess) == 3 && // self-split ramp-up
1415 currentTask->isRootTask() // the following should do only for the self-split ramp-up procedure
1416 )
1417 {
1418 if( status == SCIP_STATUS_OPTIMAL )
1419 {
1421 }
1422 if( selfSplitNodesel->inSampling() && status == SCIP_STATUS_OPTIMAL ) // it is still sampling. This means the poroblem was solved
1423 {
1424 if( paraComm->getRank() == 1 )
1425 {
1427 }
1428 return;
1429 }
1430 else
1431 {
1432 sendLocalSolution(); // solution was not sent during sampling to generate the same search tree
1433 }
1434 }
1435#endif
1436
1437// if( status == SCIP_STATUS_OPTIMAL ) // when sub-MIP is solved at root node, the solution may not be saved
1438 if( SCIPgetNSols(scip) > 0 )
1439 {
1442 }
1443// else
1444// {
1445#ifdef UG_DEBUG_SOLUTION
1446 if( status != SCIP_STATUS_OPTIMAL )
1447 {
1448 if( SCIPdebugSolIsEnabled(scip) &&
1449 // currentTask->getMergingStatus() != 3 &&
1452 {
1453 std::cout << "R" << paraComm->getRank() << " solver lost optimal solution." << std::endl;
1454 throw "Optimal solution lost!";
1455 }
1456 }
1457#endif
1458// if( status == SCIP_STATUS_MEMLIMIT )
1459// {
1460// std::cout << "Warning: SCIP was interrupted because the memory limit was reached" << std::endl;
1461// abort();
1462// }
1463// }
1464
1465// std::cout << "R" << paraComm->getRank() << " status = " << (int)status << std::endl;
1466
1467 if( status == SCIP_STATUS_OPTIMAL ||
1468 status == SCIP_STATUS_GAPLIMIT )
1469
1470 {
1471 solverDualBound = SCIPgetDualbound(scip);
1472 // if( status == SCIP_STATUS_OPTIMAL )
1473 // {
1474 // current best solution may not be accepted in LC
1475 // solverDualBound = std::max(solverDualBound, getGlobalBestIncumbentValue() );
1476 // should not do above, since globalBestIncumbentValue might not be updated
1477 // }
1478
1479 /*
1480 double dualBound = SCIPgetDualbound(scip);
1481 if( isRacingStage() )
1482 {
1483 if( dualBound > solverDualBound )
1484 {
1485 solverDualBound = dualBound;
1486 }
1487 }
1488 else
1489 {
1490 solverDualBound = dualBound;
1491 // maximalDualBound = std::max(dualBound, currentNode->getDualBoundValue());
1492 if( EPSEQ( maximalDualBound, -DBL_MAX, eps ) )
1493 {
1494 maximalDualBound = std::max(dualBound, currentNode->getDualBoundValue());
1495 }
1496 else
1497 {
1498 if( !SCIPisInfinity(scip, -dualBound) &&
1499 dualBound > currentNode->getDualBoundValue() &&
1500 dualBound < maximalDualBound )
1501 {
1502 maximalDualBound = dualBound;
1503 }
1504 else
1505 {
1506 if( maximalDualBound < currentNode->getDualBoundValue() )
1507 {
1508 maximalDualBound = currentNode->getDualBoundValue();
1509 }
1510 }
1511 }
1512 }
1513 */
1514 }
1515 else if( status == SCIP_STATUS_INFEASIBLE )
1516 {
1517 if( EPSEQ(globalBestIncumbentValue, DBL_MAX, eps ) )
1518 {
1519 solverDualBound = SCIPgetDualbound(scip);
1520 }
1521 else
1522 {
1524 }
1525 }
1526 else
1527 {
1528 if( status == SCIP_STATUS_NODELIMIT )
1529 {
1530 throw "SCIP terminated with SCIP_STATUS_NODELIMIT";
1531 }
1532 else if( status == SCIP_STATUS_TOTALNODELIMIT )
1533 {
1534 throw "SCIP terminated with SCIP_STATUS_TOTALNODELIMIT";
1535 }
1536 else if( status == SCIP_STATUS_STALLNODELIMIT )
1537 {
1538 throw "SCIP terminated with SCIP_STATUS_STALLNODELIMIT";
1539 }
1540 else if( status == SCIP_STATUS_TIMELIMIT )
1541 {
1542 // throw "SCIP terminated with SCIP_STATUS_TIMELIMIT";
1543 solverDualBound = SCIPgetDualbound(scip);
1545 if( isRacingStage() )
1546 {
1547 racingIsInterrupted = true;
1548 }
1549 }
1550 else if( status == SCIP_STATUS_MEMLIMIT )
1551 {
1552 memoryLimitIsReached = true;
1553 }
1554 else if( status == SCIP_STATUS_SOLLIMIT )
1555 {
1556 throw "SCIP terminated with SCIP_STATUS_SOLLIMIT";
1557 }
1558 else if( status == SCIP_STATUS_BESTSOLLIMIT )
1559 {
1560 throw "SCIP terminated with SCIP_STATUS_BESTSOLLIMIT";
1561 }
1562 else if( status == SCIP_STATUS_USERINTERRUPT && SCIPisObjIntegral(scip) )
1563 {
1564 if( SCIPfeasCeil(scip, dynamic_cast<UG::BbParaNode *>(getCurrentNode())->getDualBoundValue()) >= getGlobalBestIncumbentValue() )
1565 {
1566 solverDualBound = SCIPfeasCeil(scip, dynamic_cast<UG::BbParaNode *>(getCurrentNode())->getDualBoundValue());
1567 }
1568 else
1569 {
1570 solverDualBound = std::max(dynamic_cast<UG::BbParaNode *>(getCurrentNode())->getDualBoundValue(), SCIPgetDualbound(scip));
1571 }
1572 }
1573 else if( status == SCIP_STATUS_USERINTERRUPT )
1574 {
1575 solverDualBound = std::max(dynamic_cast<UG::BbParaNode *>(getCurrentNode())->getDualBoundValue(), SCIPgetDualbound(scip));
1576 }
1577 else
1578 {
1579 solverDualBound = -DBL_MAX;
1580 }
1581 /*
1582 if( maximalDualBound < currentNode->getDualBoundValue() )
1583 {
1584 maximalDualBound = currentNode->getDualBoundValue();
1585 }
1586 */
1587 }
1588
1589 /*
1590 double dualBound = SCIPgetDualbound(scip);
1591 if( isRacingStage() )
1592 {
1593 if( dualBound > maximalDualBound )
1594 {
1595 maximalDualBound = dualBound;
1596 }
1597 }
1598 else
1599 {
1600 if( !SCIPisInfinity(scip, -dualBound) &&
1601 dualBound < maximalDualBound )
1602 {
1603 maximalDualBound = dualBound;
1604 }
1605 }
1606 */
1607
1608
1609 if( conflictConsList && conflictConsList->size() > 0 )
1610 {
1611 int nConfilcts = conflictConsList->size();
1612 for(int i = 0; i < nConfilcts; i++ )
1613 {
1614 assert(!conflictConsList->empty());
1615 LocalNodeInfo *info= conflictConsList->front();
1616 conflictConsList->pop_front();
1617 if( info->linearCoefs ) delete[] info->linearCoefs;
1618 if( info->idxLinearCoefsVars ) delete[] info->idxLinearCoefsVars;
1619 delete info;
1620 }
1621 }
1622
1623#if SCIP_APIVERSION >= 101
1624 if( paraParams->getIntParamValue(UG::RampUpPhaseProcess) == 3 && // self-split ramp-up
1626 {
1627 int numnodesels = SCIPgetNNodesels( scip );
1628 SCIP_NODESEL** nodesels = SCIPgetNodesels( scip );
1629 int i;
1630 for( i = 0; i < numnodesels; ++i )
1631 {
1632 std::string nodeselname(SCIPnodeselGetName(nodesels[i]));
1633 if( std::string(nodeselname) == std::string("ScipParaObjSelfSplitNodeSel") )
1634 {
1635 break;
1636 }
1637 }
1638 assert( i != numnodesels );
1639 SCIP_CALL_ABORT( SCIPsetNodeselStdPriority(scip, nodesels[i], -INT_MAX/4 ) );
1640 }
1641#endif
1642
1643}
1644
1645long long
1647 )
1648{
1649 if( SCIPgetStage(scip) == SCIP_STAGE_SOLVING || SCIPgetStage(scip) == SCIP_STAGE_SOLVED )
1650 {
1651 return SCIPgetNTotalNodes(scip);
1652 }
1653 else
1654 {
1655 return 0;
1656 }
1657}
1658
1659int
1661 )
1662{
1663 if( SCIPgetStage(scip) == SCIP_STAGE_SOLVING || SCIPgetStage(scip) == SCIP_STAGE_SOLVED )
1664 {
1665 return SCIPgetNNodesLeft(scip);
1666 }
1667 else
1668 {
1669 if( SCIPgetStage(scip) >= SCIP_STAGE_PRESOLVING && SCIPgetStage(scip) <= SCIP_STAGE_INITSOLVE )
1670 {
1671 return 1;
1672 }
1673 else
1674 {
1675 return 0;
1676 }
1677 }
1678}
1679
1680double
1682 )
1683{
1684 if( SCIPgetStage(scip) == SCIP_STAGE_PRESOLVING || SCIPgetStage(scip) == SCIP_STAGE_INITSOLVE )
1685 {
1686 return dynamic_cast<UG::BbParaNode *>(currentTask)->getDualBoundValue();
1687 }
1688 else
1689 {
1690 return SCIPgetDualbound(scip);
1691 }
1692}
1693
1695 int argc,
1696 char **argv,
1697 int inNhanders, // number of valid message handlers
1699 UG::ParaParamSet *inParaParamSet,
1700 UG::ParaInstance *inParaInstance,
1701 UG::ParaDeterministicTimer *inDetTimer
1702 ) : BbParaSolver(argc, argv, inNhanders, comm, inParaParamSet, inParaInstance, inDetTimer),
1703 messagehdlr(0),
1704 logfile(0),
1705 originalParamSet(0),
1706 conflictConsList(0),
1707 userPlugins(0),
1708 commPointHdlr(0),
1709 nodesel(0),
1710#if SCIP_APIVERSION >= 101
1711 selfSplitNodesel(0),
1712#endif
1713 scipPropagator(0),
1714 interruptMsgMonitor(0),
1715 nPreviousNodesLeft(0),
1716 originalPriority(0),
1717 nOrgVars(0),
1718 nOrgVarsInSolvers(0),
1719 orgVarLbs(0),
1720 orgVarUbs(0),
1721 tightenedVarLbs(0),
1722 tightenedVarUbs(0),
1723 mapToOriginalIndecies(0),
1724 mapToSolverLocalIndecies(0),
1725 mapToProbIndecies(0),
1726 // stuffingMaxrounds(0),
1727 // domcolMaxrounds(0),
1728 // dualcompMaxrounds(0),
1729 // dualinferMaxrounds(0),
1730 // dualaggMaxrounds(0),
1731 // abspowerDualpresolve(0),
1732 // andDualpresolving(0),
1733 // cumulativeDualpresolve(0),
1734 // knapsackDualpresolving(0),
1735 // linearDualpresolving(0),
1736 // setppcDualpresolving(0),
1737 // logicorDualpresolving(0),
1738 miscAllowdualreds(0),
1739 nAddedConss(0),
1740 addedConss(0),
1741 addedDualCons(0),
1742 settingsNameLC(0),
1743 fiberSCIP(false),
1744 quiet(false),
1745 collectingModeIsProhibited(false),
1746 problemFileName(0),
1747 orgFeastol(0.0),
1748 orgLpfeastol(0.0),
1749 copyIncreasedVariables(false)
1750{
1751
1752 // ScipMessageHandlerFunctionPointer *scipMessageHandler = reinterpret_cast<ScipMessageHandlerFunctionPointer *>(messageHandler);
1753 // no additional message handlers
1754
1755 char* logname = NULL;
1756
1757 ScipParaInstance *scipParaInstance = dynamic_cast< ScipParaInstance *>(paraInstance);
1758
1759 /* Initialize the SCIP environment */
1760 /*********
1761 * Setup *
1762 *********/
1763 /* initialize SCIP */
1764 SCIP_CALL_ABORT( SCIPcreate(&scip) );
1765 SCIP_CALL_ABORT( SCIPsetIntParam(scip,"timing/clocktype", 2) ); // always wall clock time
1767 {
1768 double timeRemains = std::max(0.0, (paraParams->getRealParamValue(UG::TimeLimit) - paraTimer->getElapsedTime() + 3.0) ); // 3.0: timming issue
1769 SCIP_CALL_ABORT( SCIPsetRealParam(scip,"limits/time", timeRemains) );
1770 }
1771 /** set user plugins */
1772 ::setUserPlugins(this);
1774 {
1775 /* include default SCIP plugins */
1776 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(scip) );
1777 /** include user plugins */
1779 }
1780 /* include communication point handler */
1782 commPointHdlr = new ScipParaObjCommPointHdlr(paraComm, this, updator);
1783 SCIP_CALL_ABORT( SCIPincludeObjEventhdlr(scip, commPointHdlr, TRUE) );
1784 SCIP_CALL_ABORT( SCIPincludeObjHeur(scip, updator, TRUE) );
1785
1786 /* include propagator */
1790 {
1792 SCIP_CALL_ABORT( SCIPincludeObjProp(scip, scipPropagator, TRUE) );
1795 }
1796
1797 /* include node selector */
1798 nodesel = new ScipParaObjNodesel(this);
1799 SCIP_CALL_ABORT( SCIPincludeObjNodesel(scip, nodesel, TRUE) );
1800#if SCIP_APIVERSION >= 101
1801 if( paraParams->getIntParamValue(UG::RampUpPhaseProcess) == 3 ) // self-split ramp-up
1802 {
1803 selfSplitNodesel = new ScipParaObjSelfSplitNodesel(
1804 paraComm->getRank() - 1,
1805 paraComm->getSize() - 1,
1807 paraComm,
1808 this,
1809 scip
1810 );
1811 SCIP_CALL_ABORT( SCIPincludeObjNodesel(scip, selfSplitNodesel, TRUE) );
1812 }
1813#endif
1814 /* include branch rule plugins */
1815 SCIP_CALL_ABORT( SCIPincludeObjBranchrule(scip, new ScipParaObjBranchRule(this), TRUE) );
1816
1817 if( inParaParamSet->getBoolParamValue(UG::TransferConflictCuts) )
1818 {
1819 conflictConsList = new std::list<LocalNodeInfoPtr>;
1820 SCIP_CONFLICTHDLRDATA *conflictHdrData = reinterpret_cast< SCIP_CONFLICTHDLRDATA * >(this);
1821 /* create conflict handler to collects conflicts */
1822#if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0
1823 SCIP_CALL_ABORT( SCIPincludeConflicthdlr(scip, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
1824 NULL, NULL, NULL, NULL, NULL, NULL, conflictExecCollector, conflictHdrData) );
1825#else
1826 SCIP_CALL_ABORT( SCIPincludeConflicthdlrBasic(scip, NULL, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
1827 conflictExecCollector, conflictHdrData) );
1828#endif
1829 }
1830
1831 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/feastol", &orgFeastol ) );
1832 if( SCIP_APIVERSION < 61 )
1833 {
1834 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/lpfeastol", &orgLpfeastol ) );
1835 }
1836
1837 /********************
1838 * Parse parameters *
1839 ********************/
1840 for( int i = 3; i < argc; ++i ) /** the first argument is runtime parameter file for ParaSCIP */
1841 {
1842 if( strcmp(argv[i], "-l") == 0 )
1843 {
1844 i++;
1845 if( i < argc )
1846 logname = argv[i];
1847 else
1848 {
1849 THROW_LOGICAL_ERROR1("missing log filename after parameter '-l'");
1850 }
1851 }
1852 else if( strcmp(argv[i], "-q") == 0 )
1853 quiet = true;
1854 // other arguments are omitted in Solver
1855 }
1856
1857 /***********************************
1858 * create log file message handler *
1859 ***********************************/
1861 {
1862 // SCIP_CALL_ABORT( SCIPsetMessagehdlr(NULL) );
1863#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
1864 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, NULL, TRUE, FALSE), TRUE) );
1865 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
1866#else
1867 SCIPsetMessagehdlrQuiet(scip, TRUE);
1868#endif
1869 }
1870 else
1871 {
1872 if( logname != NULL || quiet )
1873 {
1874 if( logname != NULL )
1875 {
1876 std::ostringstream os;
1877 os << logname << comm->getRank();
1878 logfile = fopen(os.str().c_str(), "a"); // append to log file */
1879 if( logfile == NULL )
1880 {
1881 THROW_LOGICAL_ERROR3("cannot open log file <", logname, "> for writing");
1882 }
1883 }
1884 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, logfile, quiet, FALSE), TRUE) );
1885#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
1886 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
1887#else
1888 SCIP_CALL_ABORT( SCIPsetMessagehdlr(scip, messagehdlr) );
1889 SCIP_CALL_ABORT( SCIPmessagehdlrRelease(&messagehdlr));
1890#endif
1891 }
1892 }
1893
1894 DEF_SCIP_PARA_COMM( scipParaComm, paraComm );
1895 scipDiffParamSetRoot = scipParaComm->createScipDiffParamSet();
1896 scipDiffParamSetRoot->bcast(comm, 0); /** this bcast is sent as SolverInitializationMessage */
1897 scipDiffParamSet = scipParaComm->createScipDiffParamSet();
1898 scipDiffParamSet->bcast(comm, 0); /** this bcast is sent as SolverInitializationMessage */
1899 int tempIsWarmStarted;
1900 comm->bcast(&tempIsWarmStarted, 1, UG::ParaINT, 0);
1901 warmStarted = (tempIsWarmStarted == 1);
1904 {
1905 int solutionExists = 0;
1906 comm->bcast(&solutionExists, 1, UG::ParaINT, 0);
1907 if( solutionExists )
1908 {
1911 }
1912 }
1913
1914 /** set parameters for SCIP: this values are reseted before solving */
1915 /* move to the place after problem has been created because the parameters may be changed.
1916 scipDiffParamSet->setParametersInScip(scip);
1917 SCIP_Real epsilon;
1918 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/epsilon", &epsilon));
1919 eps = epsilon;
1920 */
1921
1922 char *isolname = 0;
1923 for( int i = 3; i < argc; ++i ) /** the first argument is runtime parameter file for ParaSCIP */
1924 /** the second argument is problem file name */
1925 {
1926 if( strcmp(argv[i], "-sl") == 0 )
1927 {
1928 i++;
1929 if( i < argc )
1930 {
1931 settingsNameLC = argv[i];
1932 break;
1933 }
1934 else
1935 {
1936 std::cerr << "missing settings filename after parameter '-sl'" << std::endl;
1937 exit(1);
1938 }
1939 }
1940 else if ( strcmp(argv[i], "-isol") == 0 )
1941 {
1942 i++;
1943 if( i < argc )
1944 {
1945 isolname = argv[i];
1946 }
1947 else
1948 {
1949 std::cerr << "missing settings filename after parameter '-isol'" << std::endl;
1950 exit(1);
1951 }
1952 }
1953 }
1954
1955#if( !defined(UG_QUBO) && !defined(UG_SMOOTHIE) )
1956
1957 /** create problem */
1958 scipParaInstance->createProblem(scip,
1965 isolname
1966 );
1967
1968 if( SCIPgetStage(scip) == SCIP_STAGE_INIT && paraParams->getIntParamValue(UG::InstanceTransferMethod) == 2)
1969 {
1970 delete paraComm;
1971 exit(0); // the problem should be solved in LC
1972 }
1973
1974 /** set parameters for SCIP: this values are reseted before solving */
1977 SCIP_Real epsilon;
1978 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/epsilon", &epsilon));
1979 eps = epsilon;
1980
1983 {
1984 /* initialize SCIP to check root solvability */
1985 SCIP_CALL_ABORT( SCIPcreate(&scipToCheckEffectOfRootNodeProcesses) );
1986 /* include default SCIP plugins */
1987 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(scipToCheckEffectOfRootNodeProcesses) );
1988 /* include scipParaConshdlr plugins */
1996 isolname
1997 );
1999 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrestarts", 0) );
2000 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrounds", 0) );
2001 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/linear/presolpairwise", FALSE) );
2002 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/and/presolpairwise", FALSE) );
2003 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/logicor/presolpairwise", FALSE) );
2004 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/setppc/presolpairwise", FALSE) );
2005 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "propagating/probing/maxprerounds", 0) );
2006 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/feaspump/freq", -1) );
2007 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/rens/freq", -1) );
2008 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxcutsroot", 100) );
2009 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxroundsroot", 5) );
2010 }
2011 delete paraInstance;
2012 paraInstance = 0;
2013
2014 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "limits/memory", dynamic_cast<ScipParaParamSet *>(paraParams)->getRealParamValue(MemoryLimit)) );
2015// if( paraComm->getRank() == 1 )
2016// {
2017// std::cout << "*** set memory limit to " << dynamic_cast<ScipParaParamSet *>(paraParams)->getRealParamValue(MemoryLimit) << " for each SCIP ***" << std::endl;
2018// }
2019
2020 /** save original priority of changing node selector */
2021 assert(scip);
2023
2024#ifndef SCIP_EVENTTYPE_COMM
2025 // std::cout << "#### SCIP_EVENTTYPE_COMM is not defined!" << std::endl;
2027 {
2028 interruptMsgMonitor = new ScipParaInterruptMsgMonitor(scipParaComm, this);
2029 // interruptMsgMonitorThread = std::thread( runInterruptMsgMonitorThread, interruptMsgMonitor );
2031 t.detach();
2032 }
2033#endif
2034
2035#endif
2036}
2037
2039 int argc,
2040 char **argv,
2041 int inNhanders, // number of valid message handlers
2043 UG::ParaParamSet *inParaParamSet,
2044 UG::ParaInstance *inParaInstance,
2045 UG::ParaDeterministicTimer *inDetTimer,
2046 double timeOffset,
2047 bool thread
2048 ) : BbParaSolver(argc, argv, inNhanders, comm, inParaParamSet, inParaInstance, inDetTimer),
2049 messagehdlr(0),
2050 logfile(0),
2051 originalParamSet(0),
2052 conflictConsList(0),
2053 userPlugins(0),
2054 commPointHdlr(0),
2055 nodesel(0),
2056#if SCIP_APIVERSION >= 101
2057 selfSplitNodesel(0),
2058#endif
2059 scipPropagator(0),
2060 interruptMsgMonitor(0),
2061 originalPriority(0),
2062 orgMaxRestart(0),
2063 nOrgVars(0),
2064 nOrgVarsInSolvers(0),
2065 orgVarLbs(0),
2066 orgVarUbs(0),
2067 tightenedVarLbs(0),
2068 tightenedVarUbs(0),
2069 mapToOriginalIndecies(0),
2070 mapToSolverLocalIndecies(0),
2071 mapToProbIndecies(0),
2072 // stuffingMaxrounds(0),
2073 // domcolMaxrounds(0),
2074 // dualcompMaxrounds(0),
2075 // dualinferMaxrounds(0),
2076 // dualaggMaxrounds(0),
2077 // abspowerDualpresolve(0),
2078 // andDualpresolving(0),
2079 // cumulativeDualpresolve(0),
2080 // knapsackDualpresolving(0),
2081 // linearDualpresolving(0),
2082 // setppcDualpresolving(0),
2083 // logicorDualpresolving(0),
2084 miscAllowdualreds(0),
2085 nAddedConss(0),
2086 addedConss(0),
2087 addedDualCons(0),
2088 settingsNameLC(0),
2089 fiberSCIP(true),
2090 quiet(false),
2091 collectingModeIsProhibited(false),
2092 problemFileName(0),
2093 orgFeastol(0.0),
2094 orgLpfeastol(0.0),
2095 copyIncreasedVariables(false)
2096{
2097 assert(thread); // This is a constructor for threads parallel version
2098
2099 // ScipMessageHandlerFunctionPointer *scipMessageHandler = reinterpret_cast<ScipMessageHandlerFunctionPointer *>(messageHandler);
2100 // no additional message handlers
2101
2102 char* logname = NULL;
2103
2104 ScipParaInstance *scipParaInstance = dynamic_cast<ScipParaInstance *>(paraInstance);
2105
2106 paraTimer->setOffset(timeOffset);
2107
2108 /* Initialize the SCIP environment */
2109 /*********
2110 * Setup *
2111 *********/
2113 {
2114 /* copy SCIP environment */
2115 scip = scipParaInstance->getScip();
2116 SCIP_CALL_ABORT( SCIPresetParams(scip) ); // if LC parameter settings are applied,
2117 // it is necessary to reset them
2118 }
2119 else
2120 {
2121 SCIP_CALL_ABORT( SCIPcreate(&scip) );
2122 SCIP_CALL_ABORT( SCIPsetIntParam(scip,"timing/clocktype", 2) ); // always wall clock time
2124 {
2125 double timeRemains = std::max( 0.0, (paraParams->getRealParamValue(UG::TimeLimit) - paraTimer->getElapsedTime() + 3.0) ); // 3.0: timming issue
2126 SCIP_CALL_ABORT( SCIPsetRealParam(scip,"limits/time", timeRemains) );
2127 }
2128 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(scip) );
2129 /** user include plugins */
2131 }
2132
2133 /* include communication point handler */
2135 commPointHdlr = new ScipParaObjCommPointHdlr(paraComm, this, updator);
2136 SCIP_CALL_ABORT( SCIPincludeObjEventhdlr(scip, commPointHdlr, TRUE) );
2137 SCIP_CALL_ABORT( SCIPincludeObjHeur(scip, updator, TRUE) );
2138
2139 /* include propagator */
2143 {
2145 SCIP_CALL_ABORT( SCIPincludeObjProp(scip, scipPropagator, TRUE) );
2148 }
2149
2150 /* include node selector */
2151 nodesel = new ScipParaObjNodesel(this);
2152 SCIP_CALL_ABORT( SCIPincludeObjNodesel(scip, nodesel, TRUE) );
2153#if SCIP_APIVERSION >= 101
2154 if( paraParams->getIntParamValue(UG::RampUpPhaseProcess) == 3 ) // self-split ramp-up
2155 {
2156 selfSplitNodesel = new ScipParaObjSelfSplitNodesel(
2157 paraComm->getRank() - 1,
2158 paraComm->getSize() - 1,
2160 paraComm,
2161 this,
2162 scip
2163 );
2164 SCIP_CALL_ABORT( SCIPincludeObjNodesel(scip, selfSplitNodesel, TRUE) );
2165 }
2166#endif
2167 /* include branch rule plugins */
2168 SCIP_CALL_ABORT( SCIPincludeObjBranchrule(scip, new ScipParaObjBranchRule(this), TRUE) );
2169
2170 if( inParaParamSet->getBoolParamValue(UG::TransferConflictCuts) )
2171 {
2172 conflictConsList = new std::list<LocalNodeInfoPtr>;
2173 SCIP_CONFLICTHDLRDATA *conflictHdrData = reinterpret_cast< SCIP_CONFLICTHDLRDATA * >(this);
2174 /* create conflict handler to collects conflicts */
2175#if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0
2176 SCIP_CALL_ABORT( SCIPincludeConflicthdlr(scip, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
2177 NULL, NULL, NULL, NULL, NULL, NULL, conflictExecCollector, conflictHdrData) );
2178#else
2179 SCIP_CALL_ABORT( SCIPincludeConflicthdlrBasic(scip, NULL, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
2180 conflictExecCollector, conflictHdrData) );
2181#endif
2182 }
2183
2184 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/feastol", &orgFeastol ) );
2185 if( SCIP_APIVERSION < 61 )
2186 {
2187 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/lpfeastol", &orgLpfeastol ) );
2188 }
2189
2190 /********************
2191 * Parse parameters *
2192 ********************/
2193 for( int i = 3; i < argc; ++i ) /** the first argument is runtime parameter file for ParaSCIP */
2194 {
2195 if( strcmp(argv[i], "-l") == 0 )
2196 {
2197 i++;
2198 if( i < argc )
2199 logname = argv[i];
2200 else
2201 {
2202 THROW_LOGICAL_ERROR1("missing log filename after parameter '-l'");
2203 }
2204 }
2205 else if( strcmp(argv[i], "-q") == 0 )
2206 quiet = true;
2207 // other arguments are omitted in Solver
2208 }
2209
2210 /***********************************
2211 * create log file message handler *
2212 ***********************************/
2214 {
2215#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2216 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, NULL, TRUE, FALSE), TRUE) );
2217 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
2218#else
2219 SCIPsetMessagehdlrQuiet(scip, TRUE );
2220#endif
2221 }
2222 else
2223 {
2224 if( logname != NULL || quiet )
2225 {
2226 paraComm->lockApp(); // if solver runs as thread, this lock is necessary
2227 if( logname != NULL )
2228 {
2229 std::ostringstream os;
2230 os << logname << comm->getRank();
2231 logfile = fopen(os.str().c_str(), "a"); // append to log file */
2232 if( logfile == NULL )
2233 {
2234 THROW_LOGICAL_ERROR3("cannot open log file <", logname, "> for writing");
2235 }
2236 }
2237 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, logfile, quiet, TRUE), TRUE) );
2238#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2239 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
2240#else
2241 SCIP_CALL_ABORT( SCIPsetMessagehdlr(scip, messagehdlr) );
2242 SCIP_CALL_ABORT( SCIPmessagehdlrRelease(&messagehdlr));
2243#endif
2245 }
2246 }
2247
2248 DEF_SCIP_PARA_COMM( scipParaComm, paraComm );
2249 scipDiffParamSetRoot = scipParaComm->createScipDiffParamSet();
2250 scipDiffParamSetRoot->bcast(comm, 0); /** this bcast is sent as SolverInitializationMessage */
2251 scipDiffParamSet = scipParaComm->createScipDiffParamSet();
2252 scipDiffParamSet->bcast(comm, 0); /** this bcast is sent as SolverInitializationMessage */
2253 int tempIsWarmStarted;
2254 comm->bcast(&tempIsWarmStarted, 1, UG::ParaINT, 0);
2255 warmStarted = (tempIsWarmStarted == 1);
2257
2259 {
2260 int solutionExists = 0;
2261 paraComm->bcast(&solutionExists, 1, UG::ParaINT, 0);
2262 }
2263 else
2264 {
2266 {
2267 int solutionExists = 0;
2268 comm->bcast(&solutionExists, 1, UG::ParaINT, 0);
2269 if( solutionExists )
2270 {
2273 }
2274 }
2275 }
2276
2277 /** set parameters for SCIP: this values are reseted before solving */
2278 /* move to the place after problem has been created because the parameters may be changed.
2279 scipDiffParamSet->setParametersInScip(scip);
2280 SCIP_Real epsilon;
2281 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/epsilon", &epsilon));
2282 eps = epsilon;
2283 */
2284
2285 char *isolname = 0;
2286 for( int i = 3; i < argc; ++i ) /** the first argument is runtime parameter file for ParaSCIP */
2287 /** the second argument is problem file name */
2288 {
2289 if( strcmp(argv[i], "-sl") == 0 )
2290 {
2291 i++;
2292 if( i < argc )
2293 {
2294 settingsNameLC = argv[i];
2295 break;
2296 }
2297 else
2298 {
2299 std::cerr << "missing settings filename after parameter '-sl'" << std::endl;
2300 exit(1);
2301 }
2302 }
2303 else if ( strcmp(argv[i], "-isol") == 0 )
2304 {
2305 i++;
2306 if( i < argc )
2307 {
2308 isolname = argv[i];
2309 }
2310 else
2311 {
2312 std::cerr << "missing settings filename after parameter '-isol'" << std::endl;
2313 exit(1);
2314 }
2315 }
2316 }
2317
2318#if( !defined(UG_QUBO) && !defined(UG_SMOOTHIE) )
2319
2320 /** create problem */
2321 scipParaInstance->createProblem(scip,
2328 isolname
2329 );
2330
2331 /** set parameters for SCIP: this values are reseted before solving */
2333 SCIP_Real epsilon;
2334 SCIP_CALL_ABORT( SCIPgetRealParam(scip, "numerics/epsilon", &epsilon));
2335 eps = epsilon;
2336
2339 {
2340 /* initialize SCIP to check root solvability */
2341 SCIP_CALL_ABORT( SCIPcreate(&scipToCheckEffectOfRootNodeProcesses) );
2342 /* include default SCIP plugins */
2343 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(scipToCheckEffectOfRootNodeProcesses) );
2344 /* include scipParaConshdlr plugins */
2352 isolname
2353 );
2355 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrestarts", 0) );
2356 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrounds", 0) );
2357 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/linear/presolpairwise", FALSE) );
2358 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/and/presolpairwise", FALSE) );
2359 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/logicor/presolpairwise", FALSE) );
2360 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/setppc/presolpairwise", FALSE) );
2361 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "propagating/probing/maxprerounds", 0) );
2362 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/feaspump/freq", -1) );
2363 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/rens/freq", -1) );
2364 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxcutsroot", 100) );
2365 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxroundsroot", 5) );
2366 }
2367 delete paraInstance;
2368 paraInstance = 0;
2369
2370 // std::cout << "##################### paraInstance is deleted ####################" << std::endl;
2371
2372#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
2373 assert( memoryLimitOfSolverSCIP > 0.0 );
2374 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "limits/memory", memoryLimitOfSolverSCIP) );
2375#else
2376 SCIP_CALL_ABORT( SCIPsetRealParam(scip, "limits/memory", (dynamic_cast<ScipParaParamSet *>(paraParams)->getRealParamValue(MemoryLimit))/(paraComm->getSize()*SCIP_MEMORY_COPY_FACTOR))); // LC has SCIP env.
2377#endif
2378// if( paraComm->getRank() == 1 )
2379// {
2380// std::cout << "*** set memory limit to " << dynamic_cast<ScipParaParamSet *>(paraParams)->getRealParamValue(MemoryLimit)/(paraComm->getSize()*SCIP_MEMORY_COPY_FACTOR) << " for each SCIP ***" << std::endl;
2381// }
2382
2383 /** save original priority of changing node selector */
2385
2386#ifndef SCIP_EVENTTYPE_COMM
2387 // std::cout << "#### SCIP_EVENTTYPE_COMM is not defined!" << std::endl;
2389 {
2390 interruptMsgMonitor = new ScipParaInterruptMsgMonitor(scipParaComm, this);
2391 // interruptMsgMonitorThread = std::thread( runInterruptMsgMonitorThread, interruptMsgMonitor );
2393 t.detach();
2394 }
2395#endif
2396
2397#endif
2398}
2399
2401 )
2402{
2404 {
2406 }
2407
2408 /** delete scip diff param sets */
2411 if( userPlugins ) delete userPlugins;
2412
2413 /** reset message handler */
2414 // message handler is mangaed within scip. It is freed at SCIPfree
2415#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2416 if( messagehdlr )
2417 {
2418 SCIP_CALL_ABORT( SCIPsetDefaultMessagehdlr() );
2419 SCIP_CALL_ABORT( SCIPfreeObjMessagehdlr(&messagehdlr) );
2420 }
2421#endif
2422
2423 /* free SCIP environment */
2425 {
2426 SCIP_CALL_ABORT( SCIPfree(&scipToCheckEffectOfRootNodeProcesses) );
2427 }
2428 SCIP_CALL_ABORT( SCIPfree(&scip) );
2429
2430 /** close log file */
2431 if( logfile ) fclose(logfile);
2432
2433 if( conflictConsList && conflictConsList->size() > 0 )
2434 {
2435 int nConfilcts = conflictConsList->size();
2436 for(int i = 0; i < nConfilcts; i++ )
2437 {
2438 assert(!conflictConsList->empty());
2439 LocalNodeInfo *info= conflictConsList->front();
2440 conflictConsList->pop_front();
2441 if( info->linearCoefs ) delete[] info->linearCoefs;
2442 if( info->idxLinearCoefsVars ) delete[] info->idxLinearCoefsVars;
2443 delete info;
2444 }
2445 }
2446
2448
2449 if( orgVarLbs ) delete [] orgVarLbs;
2450 if( orgVarUbs ) delete [] orgVarUbs;
2451 if( tightenedVarLbs )
2452 {
2453 delete [] tightenedVarLbs;
2454 }
2455 if( tightenedVarUbs )
2456 {
2457 delete [] tightenedVarUbs;
2458 }
2461 if( mapToProbIndecies) delete [] mapToProbIndecies;
2462 if( addedConss ) delete [] addedConss;
2463
2464 // DON'T FREE problemFileName
2465
2466 ///
2467 /// The following code was in Solver base class before
2468 ///
2471 {
2473 }
2474
2476 {
2477 for(;;)
2478 {
2479 // if( !( paraParams->getRealParamValue(UG::TimeLimit) > 0.0 && paraParams->getRealParamValue(UG::TimeLimit) <= paraTimer->getElapsedTime() ) )
2480 // {
2481 while( !waitToken(paraComm->getRank()) )
2482 {
2484 // if( ( paraParams->getRealParamValue(UG::TimeLimit) > 0.0
2485 // && paraParams->getRealParamValue(UG::TimeLimit) <= paraTimer->getElapsedTime() ) )
2486 // {
2487 // break;
2488 // }
2489 }
2490 // paraDetTimer->update(1.0);
2491 // previousCommTime = paraDetTimer->getElapsedTime();
2492 if( paraComm->passTermToken(paraComm->getRank()) ) break;
2493 // }
2494 }
2495 }
2496
2497 double stopTime = paraTimer->getElapsedTime();
2501
2502 double detTime = -1.0;
2503 if( paraDetTimer )
2504 {
2505 detTime = paraDetTimer->getElapsedTime();
2506 }
2507
2508 DEF_BB_PARA_COMM(bbParaComm, paraComm);
2509
2510 UG::BbParaSolverTerminationState *paraSolverTerminationState = dynamic_cast<UG::BbParaSolverTerminationState *>(bbParaComm->createParaSolverTerminationState(
2512 paraComm->getRank(),
2514 minNSolved,
2515 maxNSolved,
2516 totalNSent,
2531 nTightened,
2533 calcTermState,
2534 stopTime,
2544 detTime ));
2545 paraSolverTerminationState->send(paraComm, 0, UG::TagTerminated);
2546
2547 delete paraSolverTerminationState;
2548
2549 // if( interruptMsgMonitor )
2550 // {
2551 // interruptMsgMonitorThread.join();
2552 // }
2553
2554}
2555
2556void
2558 const std::string& filename
2559 )
2560{
2561 FILE *file = fopen(filename.c_str(),"a");
2562 if( !file )
2563 {
2564 std::cout << "file : " << filename << "cannot open." << std::endl;
2565 abort();
2566 }
2567 SCIP_CALL_ABORT( SCIPprintTransProblem(scip, file, "cip", FALSE) );
2568}
2569
2570void
2572 )
2573{
2574 SCIP *backupScip = scip;
2577 /** set cutoff value */
2578 SCIP_CALL_ABORT( SCIPsetObjlimit(scip, globalBestIncumbentValue) );
2579 /** solve */
2580 SCIP_CALL_ABORT( SCIPsolve(scip) );
2581 nSolvedWithNoPreprocesses = SCIPgetNNodes(scip);
2583 scip = backupScip;
2584}
2585
2586void
2588 UG::ParaSolution *sol
2589 )
2590{
2591
2592 if( SCIPgetStage(scip) <= SCIP_STAGE_TRANSFORMING || SCIPgetStage(scip) >= SCIP_STAGE_SOLVED )
2593 {
2594 THROW_LOGICAL_ERROR1("invalid tyrNewSolution");
2595 }
2596
2597 ScipParaSolution *tempSol = dynamic_cast< ScipParaSolution * >(sol);
2598 SCIP_SOL* newsol; /* solution to be created for the original problem */
2599
2601 {
2602 return;
2603 //
2604 // It would be good to install the solution to SCIP as the PartialSolution.
2605 // However, currently SCIP does not support this.
2606 // In the future, this might be better to change.
2607 //
2608 // if( SCIPcreatePartialSol(scip, &newsol, 0) != SCIP_OKAY ) // SCIP_CALL_ABORT ????
2609 // {
2610 // return;
2611 // }
2612 }
2613 else
2614 {
2615 if( SCIPcreateOrigSol(scip, &newsol, 0) != SCIP_OKAY ) // SCIP_CALL_ABORT ????
2616 {
2617 return;
2618 }
2619 }
2620
2621
2622 SCIP_VAR** vars = SCIPgetOrigVars(scip);
2623 SCIP_Real* vals = new SCIP_Real[tempSol->getNVars()]();
2624 int i;
2625 for(i = 0; i < tempSol->getNVars(); i++ )
2626 {
2627 int probindex = tempSol->indexAmongSolvers(i);
2628 if( mapToProbIndecies )
2629 {
2630 probindex = mapToProbIndecies[tempSol->indexAmongSolvers(i)];
2631 }
2632 // assert( probindex >= 0 );
2633 if( probindex >= 0 )
2634 {
2635 vals[probindex] = tempSol->getValues()[i];
2636 }
2637 // /* skip inactive varibales */
2638 // if( probindex < 0 )
2639 // continue;
2640 // SCIP_CALL_ABORT( SCIPsetSolVal(scip, newsol, vars[probindex], tempSol->getValues()[i]) );
2641 }
2642 SCIP_CALL_ABORT( SCIPsetSolVals(scip, newsol, tempSol->getNVars(), vars, vals) );
2643 delete [] vals;
2644 // if( i != tempSol->getNVars() )
2645 // {
2646 // /** the given solution should be generated in original space,
2647 // * therefore the solution values cannot use for ParaSCIP
2648 // */
2649 // SCIP_CALL_ABORT( SCIPfreeSol(scip, &newsol) );
2650 // // delete tempSol; // this case, DO NOT DELETE tempSol.
2651 // return;
2652 // }
2653
2654#if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0
2655 if( SCIPgetStage(scip) == SCIP_STAGE_TRANSFORMED || SCIPgetStage(scip) == SCIP_STAGE_PRESOLVED )
2656#else
2657 if( // SCIPgetStage(scip) == SCIP_STAGE_TRANSFORMED ||
2658 SCIPgetStage(scip) == SCIP_STAGE_PRESOLVED ||
2659 SCIPgetStage(scip) == SCIP_STAGE_INITPRESOLVE )
2660#endif
2661 {
2662 SCIP_Bool success;
2663#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
2664 SCIP_CALL_ABORT( SCIPtrySolFree(scip, &newsol, FALSE, TRUE, TRUE, TRUE, &success) );
2665#else
2666 SCIP_CALL_ABORT( SCIPtrySolFree(scip, &newsol, FALSE, TRUE, TRUE, TRUE, TRUE, &success) );
2667#endif
2668 // std::cout << "Rank " << paraComm->getRank() << ": success = " << success << std::endl;
2669 // if( !success ) abort();
2670 }
2671 else
2672 {
2673 SCIP_CALL_ABORT( SCIPheurPassSolTrySol(scip, SCIPfindHeur(scip, "trysol"), newsol) );
2674 SCIP_CALL_ABORT( SCIPfreeSol(scip, &newsol) );
2675 }
2676}
2677
2678void
2680 )
2681{
2683 if( !originalParamSet )
2684 {
2685 DEF_SCIP_PARA_COMM( scipParaComm, paraComm );
2686 originalParamSet = scipParaComm->createScipDiffParamSet(scip);;
2687 }
2688 SCIP_CALL_ABORT( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_FAST, TRUE) );
2689 SCIP_CALL_ABORT( SCIPsetPresolving(scip, SCIP_PARAMSETTING_FAST, TRUE) );
2690 SCIP_CALL_ABORT( SCIPsetSeparating(scip, SCIP_PARAMSETTING_FAST, TRUE) );
2691}
2692
2693void
2695 )
2696{
2697 assert(originalParamSet);
2700
2701#if SCIP_VERSION >= 320
2703#endif
2704
2705}
2706
2707// static int id = 0;
2708
2709void
2711 )
2712{
2713 std::string subcipprefix("SolverCip");
2714 std::string subcipfilename;
2715 std::ostringstream oss;
2716 oss << subcipprefix << paraComm->getRank();
2717 // oss << subcipprefix << paraComm->getRank() << "." << id++;;
2718 subcipfilename = oss.str();
2719 subcipfilename += ".cip";
2720 SCIP_CALL_ABORT( SCIPwriteOrigProblem(scip, subcipfilename.c_str(), "cip", FALSE) );
2721#ifdef UG_DEBUG_SOLUTION
2722 if( ( !currentTask->getDiffSubproblem() ) ||
2723 currentTask->getDiffSubproblem()->isOptimalSolIncluded() )
2724 {
2725 std::cout << "** " << subcipfilename << " contains optimal solution." << std::endl;
2726 }
2727 else
2728 {
2729 std::cout << "** " << subcipfilename << " does NOT contain optimal solution." << std::endl;
2730 }
2731#endif
2732 subcipfilename = oss.str();
2733 subcipfilename += "-t.cip";
2734 if( SCIPgetStage(scip) >= SCIP_STAGE_TRANSFORMED )
2735 {
2736 SCIP_CALL_ABORT( SCIPwriteTransProblem(scip, subcipfilename.c_str(), "cip", FALSE) );
2737 }
2738 char name[SCIP_MAXSTRLEN];
2739 (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "SolverCip%d.set", paraComm->getRank());
2740 SCIP_CALL_ABORT( SCIPwriteParams(scip, name, TRUE, FALSE) );
2741}
2742
2743void
2745 )
2746{
2747 assert(paraInstance);
2748 ScipParaInstance *scipParaInstance = dynamic_cast<ScipParaInstance*>(paraInstance);
2749 nOrgVars = scipParaInstance->getNVars(); // number of original variables in LC
2750 nOrgVarsInSolvers = SCIPgetNOrigVars(scip); // maybe increaded
2751 assert( nOrgVarsInSolvers == scipParaInstance->getVarIndexRange() );
2752 // if( nOrgVars == 0 ) nOrgVars = nOrgVarsInSolver;
2753 // nOrgVars = nOrgVarsInSolver;
2754 // assert( nOrgVars <= paraInstance->getVarIndexRange() ); // when copy generated additional variables, this does not hold
2755 orgVarLbs = new SCIP_Real[nOrgVarsInSolvers];
2756 orgVarUbs = new SCIP_Real[nOrgVarsInSolvers];
2757 if( scipParaInstance->isOriginalIndeciesMap() )
2758 {
2759 SCIP_VAR **vars = SCIPgetVars(scip);
2763 {
2764 if( nOrgVarsInSolvers > 0 )
2765 {
2766 tightenedVarLbs = new double[nOrgVarsInSolvers];
2767 tightenedVarUbs = new double[nOrgVarsInSolvers];
2768 }
2769 // for(int v = 0; v < paraInstance->getVarIndexRange(); v++)
2770 // for( int v = 0; v < nOrgVarsInSolvers ; v++ )
2771 for( int v = 0; v < nOrgVars ; v++ )
2772 {
2773 // int orgIndex = scipParaInstance->getOrigProbIndex(SCIPvarGetIndex(vars[v]));
2774 // assert(orgIndex >= 0);
2775 tightenedVarLbs[v] = orgVarLbs[v] = scipParaInstance->getVarLb(v);
2776 tightenedVarUbs[v] = orgVarUbs[v] = scipParaInstance->getVarUb(v);
2777 // std::cout << scipParaInstance->getVarName(v) << " orgVarLbs[" << v << "] = " << orgVarLbs[v] << std::endl;
2778 // std::cout << scipParaInstance->getVarName(v) << " orgVarUbs[" << v << "] = " << orgVarUbs[v] << std::endl;
2779 }
2780 }
2781 else
2782 {
2783 // for(int v = 0; v < paraInstance->getVarIndexRange(); v++)
2784 // for( int v = 0; v < nOrgVarsInSolvers ; v++ )
2785 for( int v = 0; v < nOrgVars; v++ )
2786 {
2787 // int orgIndex = scipParaInstance->getOrigProbIndex(SCIPvarGetIndex(vars[v]));
2788 // assert(orgIndex >= 0);
2789 orgVarLbs[v] = scipParaInstance->getVarLb(v);
2790 orgVarUbs[v] = scipParaInstance->getVarUb(v);
2791 // std::cout << scipParaInstance->getVarName(v) << " orgVarLbs[" << v << "] = " << orgVarLbs[v] << std::endl;
2792 // std::cout << scipParaInstance->getVarName(v) << " orgVarUbs[" << v << "] = " << orgVarUbs[v] << std::endl;
2793 }
2794 }
2795 assert( mapToOriginalIndecies == 0 && mapToProbIndecies == 0 );
2796 mapToOriginalIndecies = scipParaInstance->extractOrigProbIndexMap();
2798 mapToProbIndecies = new int[SCIPgetNTotalVars(scip)]; // need to allocate enough for SCIPvarGetIndex(scip)
2799 for( int i = 0; i < SCIPgetNTotalVars(scip); i++ )
2800 {
2801 mapToProbIndecies[i] = -1;
2802 }
2803 for( int i = 0; i < nOrgVarsInSolvers; i++ )
2804 {
2805 mapToProbIndecies[SCIPvarGetIndex(vars[i])] = i;
2806 }
2807 if ( dynamic_cast<ScipParaInstance *>(paraInstance)->isCopyIncreasedVariables() )
2808 {
2810 }
2811 }
2812 else
2813 {
2817 {
2818 if( nOrgVars )
2819 {
2820 tightenedVarLbs = new double[nOrgVars];
2821 tightenedVarUbs = new double[nOrgVars];
2822 }
2823 // for(int v = 0; v < paraInstance->getVarIndexRange(); v++)
2824 // for( int v = 0; v < nOrgVarsInSolvers; v++ )
2825 for( int v = 0; v < nOrgVars; v++ )
2826 {
2827 tightenedVarLbs[v] = orgVarLbs[v] = scipParaInstance->getVarLb(v);
2828 tightenedVarUbs[v] = orgVarUbs[v] = scipParaInstance->getVarUb(v);
2829 // std::cout << scipParaInstance->getVarName(v) << " orgVarLbs[" << v << "] = " << orgVarLbs[v] << std::endl;
2830 // std::cout << scipParaInstance->getVarName(v) << " orgVarUbs[" << v << "] = " << orgVarUbs[v] << std::endl;
2831 }
2832 }
2833 else
2834 {
2835 // for(int v = 0; v < paraInstance->getVarIndexRange(); v++)
2836 // for( int v = 0; v < nOrgVarsInSolvers; v++ )
2837 for( int v = 0; v < nOrgVars; v++ )
2838 {
2839 orgVarLbs[v] = scipParaInstance->getVarLb(v);
2840 orgVarUbs[v] = scipParaInstance->getVarUb(v);
2841 // std::cout << scipParaInstance->getVarName(v) << " orgVarLbs[" << v << "] = " << orgVarLbs[v] << std::endl;
2842 // std::cout << scipParaInstance->getVarName(v) << " orgVarUbs[" << v << "] = " << orgVarUbs[v] << std::endl;
2843 }
2844 }
2845 }
2846}
2847
2848void
2850 )
2851{
2852 /*************************************
2853 ** This function does not work well **
2854 **************************************/
2855 /****************************
2856 ** reset original instance *
2857 *****************************/
2858 /* Reinitialize the SCIP environment */
2859 /* free SCIP environment */
2861 {
2862 SCIP_CALL_ABORT( SCIPfree(&scipToCheckEffectOfRootNodeProcesses) );
2863 }
2864 SCIP_CALL_ABORT( SCIPfree(&scip) );
2865 if( orgVarLbs ) delete [] orgVarLbs;
2866 if( orgVarUbs ) delete [] orgVarUbs;
2867 /*********
2868 * Setup *
2869 *********/
2870 if( fiberSCIP )
2871 {
2873 // setUserPlugins(paraInstance); // instance data should not be read from original data file
2875 /* copy SCIP environment */
2876 ScipParaInstance *scipParaInstance = dynamic_cast<ScipParaInstance*>(paraInstance);
2877 scip = scipParaInstance->getScip();
2878 SCIP_CALL_ABORT( SCIPresetParams(scip) ); // if LC parameter settings are applied,
2879 // it is necessary to reset them
2880 }
2881 else
2882 {
2885 ScipParaInstance *scipParaInstance = dynamic_cast<ScipParaInstance*>(paraInstance);
2886 scipParaInstance->setFileName(problemFileName);
2888 /* initialize SCIP */
2889 SCIP_CALL_ABORT( SCIPcreate(&scip) );
2890 SCIP_CALL_ABORT( SCIPsetIntParam(scip,"timing/clocktype", 2) ); // always wall clock time
2892 {
2893 double timeRemains = std::max( 0.0, (paraParams->getRealParamValue(UG::TimeLimit) - paraTimer->getElapsedTime() + 3.0) ); // 3.0: timming issue
2894 SCIP_CALL_ABORT( SCIPsetRealParam(scip,"limits/time", timeRemains) );
2895 }
2896 /* include default SCIP plugins */
2897 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(scip) );
2898 /** user include plugins */
2900 }
2901
2902 /* include communication point handler */
2904 commPointHdlr = new ScipParaObjCommPointHdlr(paraComm, this, updator);
2905 SCIP_CALL_ABORT( SCIPincludeObjEventhdlr(scip, commPointHdlr, TRUE) );
2906 SCIP_CALL_ABORT( SCIPincludeObjHeur(scip, updator, TRUE) );
2907
2908 /* include propagator */
2912 {
2914 SCIP_CALL_ABORT( SCIPincludeObjProp(scip, scipPropagator, TRUE) );
2917 }
2918
2919 /* include node selector */
2920 nodesel = new ScipParaObjNodesel(this);
2921 SCIP_CALL_ABORT( SCIPincludeObjNodesel(scip, nodesel, TRUE) );
2922 /* include branch rule plugins */
2923 SCIP_CALL_ABORT( SCIPincludeObjBranchrule(scip, new ScipParaObjBranchRule(this), TRUE) );
2924
2926 {
2927 assert(conflictConsList);
2928 delete conflictConsList;
2929 conflictConsList = new std::list<LocalNodeInfoPtr>;
2930 SCIP_CONFLICTHDLRDATA *conflictHdrData = reinterpret_cast< SCIP_CONFLICTHDLRDATA * >(this);
2931 /* create conflict handler to collects conflicts */
2932#if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0
2933 SCIP_CALL_ABORT( SCIPincludeConflicthdlr(scip, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
2934 NULL, NULL, NULL, NULL, NULL, NULL, conflictExecCollector, conflictHdrData) );
2935#else
2936 SCIP_CALL_ABORT( SCIPincludeConflicthdlrBasic(scip, NULL, CONFLICTHDLR_NAME, CONFLICTHDLR_DESC, CONFLICTHDLR_PRIORITY,
2937 conflictExecCollector, conflictHdrData) );
2938#endif
2939 }
2940
2942 {
2943 // SCIP_CALL_ABORT( SCIPsetMessagehdlr(NULL) );
2944#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2945 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, NULL, TRUE, FALSE), TRUE) );
2946 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
2947#else
2948 SCIPsetMessagehdlrQuiet(scip, TRUE);
2949#endif
2950 }
2951 else
2952 {
2953 if( logfile != NULL || quiet )
2954 {
2955 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&messagehdlr, new ScipParaObjMessageHdlr(paraComm, logfile, quiet, FALSE), TRUE) );
2956#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2957 SCIP_CALL_ABORT( SCIPsetMessagehdlr(messagehdlr) );
2958#else
2959 SCIP_CALL_ABORT( SCIPsetMessagehdlr(scip, messagehdlr) );
2960 SCIP_CALL_ABORT( SCIPmessagehdlrRelease(&messagehdlr));
2961#endif
2962 }
2963 }
2964
2965 ScipParaInstance *scipParaInstance = dynamic_cast<ScipParaInstance*>(paraInstance);
2966 scipParaInstance->createProblem(scip,
2973 NULL
2974 );
2977 {
2985 NULL
2986 );
2988 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrestarts", 0) );
2989 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "presolving/maxrounds", 0) );
2990 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/linear/presolpairwise", FALSE) );
2991 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/and/presolpairwise", FALSE) );
2992 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/logicor/presolpairwise", FALSE) );
2993 SCIP_CALL_ABORT( SCIPsetBoolParam(scipToCheckEffectOfRootNodeProcesses, "constraints/setppc/presolpairwise", FALSE) );
2994 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "propagating/probing/maxprerounds", 0) );
2995 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/feaspump/freq", -1) );
2996 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "heuristics/rens/freq", -1) );
2997 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxcutsroot", 100) );
2998 SCIP_CALL_ABORT( SCIPsetIntParam(scipToCheckEffectOfRootNodeProcesses, "separating/maxroundsroot", 5) );
2999 }
3000 delete paraInstance;
3001 paraInstance = 0;
3002}
3003
3004void
3006 )
3007{
3008 if( SCIPgetStage(scip) != SCIP_STAGE_SOLVING )
3009 {
3011 {
3012 // setWinnerRacingParams(winnerRacingParams); // winner parameters are set, again
3013 // std::cout << winnerRacingParams->toString() << std::endl;
3014 }
3015 else
3016 {
3018 }
3019 }
3021
3022#if SCIP_VERSION >= 320
3023 if( currentTask )
3024 {
3026 }
3027#endif
3028}
3029
3030void
3032 )
3033{
3034 char *bakFileName = NULL;
3035 SCIP_CALL_ABORT( SCIPgetStringParam(scip,"visual/bakfilename", &bakFileName) );
3036 if( strcmp(bakFileName,"-") != 0 )
3037 {
3038 std::ostringstream os;
3039 os << bakFileName << "_" << paraComm->getRank();
3040 SCIP_CALL_ABORT( SCIPsetStringParam(scip,"visual/bakfilename", os.str().c_str() ) );
3041 SCIP_CALL_ABORT( SCIPsetStringParam(scip,"visual/baknodeprefix", ((currentTask->getTaskId()).toString()+":").c_str() ) );
3042 SCIP_CALL_ABORT( SCIPsetStringParam(scip,"visual/bakrootinfo", (currentTask->getGeneratorTaskId()).toString().c_str() ) );
3043 SCIP_CALL_ABORT( SCIPsetRealParam(scip,"visual/baktimeoffset", paraTimer->getElapsedTime() ) );
3044 }
3045}
3046
3047int
3049 int source,
3050 int tag
3051 )
3052{
3053 int tightenedIdex;
3054 double tightenedBound;
3056 paraComm->receive( (void *)&tightenedIdex, 1, UG::ParaINT, source, UG::TagLbBoundTightenedIndex )
3057 );
3059 paraComm->receive( (void *)&tightenedBound, 1, UG::ParaDOUBLE, source, UG::TagLbBoundTightenedBound )
3060 );
3061
3063 {
3064 return 0;
3065 }
3066
3067 if( mapToProbIndecies )
3068 {
3069 assert( mapToSolverLocalIndecies );
3070 assert(mapToProbIndecies[mapToSolverLocalIndecies[tightenedIdex]] >= 0);
3071 tightenedIdex = mapToProbIndecies[mapToSolverLocalIndecies[tightenedIdex]];
3072 }
3073 assert( SCIPisLE(scip,orgVarLbs[tightenedIdex], tightenedBound) &&
3074 SCIPisGE(scip,orgVarUbs[tightenedIdex], tightenedBound) );
3075 // std::cout << "Rank " << paraComm->getRank() << ": receive tightened lower bond. idx = " << tightenedIdex << ", bound = " << tightenedBound << std::endl;
3076 SCIP_Var* var = SCIPvarGetTransVar(SCIPgetOrigVars(scip)[tightenedIdex]);
3077 if( var && SCIPisLT(scip,tightenedVarLbs[tightenedIdex], tightenedBound) && SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR )
3078 {
3079 // std::cout << "Solver Lb = " << tightenedVarLbs[tightenedIdex]
3080 // << ", Rank " << paraComm->getRank() << ": try to tighten lower bond. idx = " << tightenedIdex << ", bound = " << tightenedBound << std::endl;
3081 scipPropagator->addBoundChange(scip, SCIP_BOUNDTYPE_LOWER, tightenedIdex, tightenedBound );
3082 tightenedVarLbs[tightenedIdex] = tightenedBound;
3083
3084 }
3085
3086 return 0;
3087}
3088
3089int
3091 int source,
3092 int tag
3093 )
3094{
3095 int tightenedIdex;
3096 double tightenedBound;
3098 paraComm->receive( (void *)&tightenedIdex, 1, UG::ParaINT, source, UG::TagUbBoundTightenedIndex )
3099 );
3101 paraComm->receive( (void *)&tightenedBound, 1, UG::ParaDOUBLE, source, UG::TagUbBoundTightenedBound )
3102 );
3103
3105 {
3106 return 0;
3107 }
3108
3109 if( mapToProbIndecies )
3110 {
3111 assert( mapToSolverLocalIndecies );
3112 assert(mapToProbIndecies[mapToSolverLocalIndecies[tightenedIdex]] >= 0);
3113 tightenedIdex = mapToProbIndecies[mapToSolverLocalIndecies[tightenedIdex]];
3114 }
3115 assert( SCIPisLE(scip,orgVarLbs[tightenedIdex], tightenedBound) &&
3116 SCIPisGE(scip,orgVarUbs[tightenedIdex], tightenedBound) );
3117 // std::cout << "Rank " << paraComm->getRank() << ": receive tightened upper bond. idx = " << tightenedIdex << ", bound = " << tightenedBound << std::endl;
3118 SCIP_Var* var = SCIPvarGetTransVar(SCIPgetOrigVars(scip)[tightenedIdex]);
3119 if( var && SCIPisGT(scip,tightenedVarUbs[tightenedIdex], tightenedBound) && SCIPvarGetStatus(var) != SCIP_VARSTATUS_MULTAGGR )
3120 {
3121 // std::cout << "Solver Ub = " << tightenedVarUbs[tightenedIdex]
3122 // << ", Rank " << paraComm->getRank() << ": try to tighten upper bond. idx = " << tightenedIdex << ", bound = " << tightenedBound << std::endl;
3123 scipPropagator->addBoundChange(scip, SCIP_BOUNDTYPE_UPPER, tightenedIdex, tightenedBound );
3124 tightenedVarUbs[tightenedIdex] = tightenedBound;
3125 }
3126
3127 return 0;
3128}
3129
3130/** get number of tightened variables during racing */
3131int
3133 )
3134{
3135 if( scipPropagator )
3136 {
3137 return scipPropagator->getNtightened();
3138 }
3139 else
3140 {
3141 if( nTightened > 0 )
3142 {
3143 return nTightened;
3144 }
3145 else
3146 {
3147 return 0;
3148 }
3149 }
3150}
3151
3152/** get number of tightened integral variables during racing */
3153int
3155 )
3156{
3157 if( scipPropagator )
3158 {
3160 }
3161 else
3162 {
3163 if( nTightened > 0 )
3164 {
3165 return nTightenedInt;
3166 }
3167 else
3168 {
3169 return 0;
3170 }
3171 }
3172}
3173
3174void
3176 )
3177{
3178 /* presolvers */
3179#if 0
3180 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/stuffing/maxrounds", &stuffingMaxrounds) );
3181 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/domcol/maxrounds", &domcolMaxrounds) );
3182#if ( SCIP_VERSION >= 322 || (SCIP_VERSION == 321 && SCIP_SUBVERSION >= 2) )
3183 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/dualcomp/maxrounds", &dualcompMaxrounds) ); /*TODO: ok? */
3184#endif
3185 SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/dualinfer/maxrounds", &dualinferMaxrounds) ); /*TODO: probably fine */
3186 // SCIP_CALL_ABORT( SCIPgetIntParam(scip, "presolving/dualagg/maxrounds", &dualaggMaxrounds ) ); // TODO: seems to have no copy callback */
3187 /* constraint handlers */
3188 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/abspower/dualpresolve", &abspowerDualpresolve) );
3189 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/and/dualpresolving", &andDualpresolving) );
3190 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/cumulative/dualpresolve", &cumulativeDualpresolve) );
3191 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/knapsack/dualpresolving", &knapsackDualpresolving) );
3192 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/linear/dualpresolving", &linearDualpresolving) );
3193 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/setppc/dualpresolving", &setppcDualpresolving) );
3194 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "constraints/logicor/dualpresolving", &logicorDualpresolving) );
3195#endif
3196 if ( isRacingStage() && paraComm->getRank() != 1 )
3197 {
3198#if SCIP_APIVERSION > 34
3199 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "misc/allowstrongdualreds", &miscAllowdualreds) );
3200#else
3201 SCIP_CALL_ABORT( SCIPgetBoolParam(scip, "misc/allowdualreds", &miscAllowdualreds) );
3202#endif
3203 }
3204}
3205
3206void
3208 )
3209{
3210 /* presolvers */
3211#if 0
3212 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/stuffing/maxrounds", 0) );
3213 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/domcol/maxrounds", 0) );
3214#if ( SCIP_VERSION >= 322 || (SCIP_VERSION == 321 && SCIP_SUBVERSION >= 2) )
3215 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualcomp/maxrounds", 0) ); /*TODO: ok? */
3216#endif
3217 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualinfer/maxrounds", 0) ); /*TODO: probably fine */
3218 // SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualagg/maxrounds", 0) ); // TODO: seems to have no copy callback */
3219 /* constraint handlers */
3220 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/abspower/dualpresolve", FALSE) );
3221 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/and/dualpresolving", FALSE) );
3222 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/cumulative/dualpresolve", FALSE) );
3223 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/knapsack/dualpresolving", FALSE) );
3224 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/linear/dualpresolving", FALSE) );
3225 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/setppc/dualpresolving", FALSE) );
3226 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/logicor/dualpresolving", FALSE) );
3227#endif
3228 if ( isRacingStage() && paraComm->getRank() != 1 )
3229 {
3230#if SCIP_APIVERSION > 34
3231 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/allowstrongdualreds", FALSE) );
3232#else
3233 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/allowdualreds", FALSE) );
3234#endif
3235 }
3236}
3237
3238void
3240 )
3241{
3242 /* presolvers */
3243#if 0
3244 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/stuffing/maxrounds", stuffingMaxrounds) );
3245 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/domcol/maxrounds", domcolMaxrounds) );
3246#if ( SCIP_VERSION >= 322 || (SCIP_VERSION == 321 && SCIP_SUBVERSION >= 2) )
3247 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualcomp/maxrounds", dualcompMaxrounds) ); /*TODO: ok? */
3248#endif
3249 SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualinfer/maxrounds", dualinferMaxrounds) ); /*TODO: probably fine */
3250 // SCIP_CALL_ABORT( SCIPsetIntParam(scip, "presolving/dualagg/maxrounds", dualaggMaxrounds ) ); // TODO: seems to have no copy callback */
3251 /* constraint handlers */
3252 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/setppc/dualpresolving", setppcDualpresolving) );
3253 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "constraints/logicor/dualpresolving", logicorDualpresolving) );
3254#endif
3256 paraParams->getIntParamValue(UG::RampUpPhaseProcess) == 2 ) // may not be in racing statge
3257 && paraComm->getRank() != 1 )
3258 {
3259#if SCIP_APIVERSION > 34
3260 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/allowstrongdualreds", miscAllowdualreds) );
3261#else
3262 SCIP_CALL_ABORT( SCIPsetBoolParam(scip, "misc/allowdualreds", miscAllowdualreds) );
3263#endif
3264 }
3265}
3266
3267void
3269{
3270 SCIP_CALL_ABORT( SCIPinterruptSolve(scip) );
3272}
3273
3274bool
3276{
3277 return commPointHdlr->isInterrupting();
3278}
#define DEF_BB_PARA_COMM(para_comm, comm)
Base class of communicator for UG Framework.
Base class for instance data.
Base class for BbParaNode.
Base class for solution.
This class contains solver termination state which is transferred form Solver to LC.
Base class for solver: Generic parallelized solver.
void setParametersInScip(SCIP *scip)
virtual int bcast(UG::ParaComm *comm, int root)=0
SCIP_Real getBoundsBoundDisjunction(int i, int j)
ScipParaDiffSubproblemBranchLinearCons * getBranchLinearConss()
SCIP_Real getVarValueUpinfer(int i, int j)
SCIP_Real getBendersLinearCoefs(int i, int j)
SCIP_Real getVarValueDownconflen(int i, int j)
SCIP_Real getVarValueDownvsids(int i, int j)
SCIP_BOUNDTYPE getBoundTypesBoundDisjunction(int i, int j)
SCIP_Real getVarValueUpcutoff(int i, int j)
SCIP_Real getBranchConsLinearCoefs(int i, int j)
SCIP_Real getVarValueDowninfer(int i, int j)
SCIP_Real getVarValueUpconflen(int i, int j)
ScipParaDiffSubproblemBranchSetppcCons * getBranchSetppcConss()
SCIP_Real getVarValueDowncutoff(int i, int j)
SCIP_Real getVarVlaueUpvsids(int i, int j)
virtual void setFileName(const char *fileName)=0
void createProblem(SCIP *scip, int method, bool noPreprocessingInLC, bool usetRootNodeCuts, ScipDiffParamSet *scipDiffParamSetRoot, ScipDiffParamSet *scipDiffParamSet, char *settingsNameLC, char *isolname)
void addBoundChange(SCIP *scip, SCIP_BOUNDTYPE boundType, int index, SCIP_Real bound)
class BbParaParamSet
void tryNewSolution(UG::ParaSolution *sol)
int lbBoundTightened(int source, int tag)
virtual void createSubproblem()
int getOriginalIndex(int index)
ScipParaSolver(int argc, char **argv, UG::ParaComm *comm, UG::ParaParamSet *paraParamSet, UG::ParaInstance *inParaInstance, UG::ParaDeterministicTimer *detTimer)
ScipDiffParamSet * originalParamSet
SCIP_MESSAGEHDLR * messagehdlr
std::list< LocalNodeInfoPtr > * conflictConsList
void setRacingParams(UG::ParaRacingRampUpParamSet *inRacingParams, bool winnerParam)
ScipDiffParamSet * scipDiffParamSet
ScipParaObjNodesel * nodesel
ScipParaInterruptMsgMonitor * interruptMsgMonitor
interrupt message monitor
ScipUserPlugins * userPlugins
ScipParaObjCommPointHdlr * commPointHdlr
void setWinnerRacingParams(UG::ParaRacingRampUpParamSet *inRacingParams)
void setUserPlugins(ScipUserPlugins *inUi)
unsigned int miscAllowdualreds
ScipParaObjProp * scipPropagator
void writeCurrentTaskProblem(const std::string &filename)
int ubBoundTightened(int source, int tag)
static void runInterruptMsgMonitorThread(void *threadData)
std::list< LocalNodeInfoPtr > * getConflictConsList()
SCIP * scipToCheckEffectOfRootNodeProcesses
ScipDiffParamSet * scipDiffParamSetRoot
void includeUserPlugins(SCIP *inScip)
virtual void writeSubproblem(SCIP *scip)
virtual void newSubproblem(SCIP *scip, const ScipParaDiffSubproblemBranchLinearCons *linearConss, const ScipParaDiffSubproblemBranchSetppcCons *setppcConss)
class BbParaNode
Definition: bbParaNode.h:62
double getInitialDualBoundValue()
getter of initial dual bound value
Definition: bbParaNode.h:314
double getDualBoundValue()
getter of dual bound value
Definition: bbParaNode.h:303
class BbParaSolverTerminationState (Solver termination state in a ParaSolver)
int minNSolved
minimum number of subtree nodes rooted from ParaNode
Definition: bbParaSolver.h:103
bool restartingRacing
indicate that this solver is restarting racing
Definition: bbParaSolver.h:146
int maxNSolved
maximum number of subtree nodes rooted from ParaNode
Definition: bbParaSolver.h:104
bool isRacingInterruptRequested()
check if racing interrupt was requested or not
Definition: bbParaSolver.h:834
int nTransferredLocalCutsFromSolver
number of local cuts transferred from this Solver
Definition: bbParaSolver.h:105
int nTightened
the number of tightened variable bounds in racing
Definition: bbParaSolver.h:126
bool isCollectingAllNodes()
check if Solver is sending all nodes to LoadCoordinaor or not
int maxRestarts
maximum number of restarts
Definition: bbParaSolver.h:113
ParaTask * getCurrentNode()
get current ParaNode object
Definition: bbParaSolver.h:981
int totalNSolved
Counters related to this BbParaSolver.
Definition: bbParaSolver.h:102
ParaParamSet * getParaParamSet()
get ParaParamSet object
int nParaNodesSolvedAtRoot
number of ParaNodes solved at root node
Definition: bbParaSolver.h:116
bool lightWeightRootNodeComputation
indicate that fast root node computation is required
Definition: bbParaSolver.h:80
virtual void waitNotificationIdMessage()
wait notification id message to synchronized with LoadCoordinator
double maxRootNodeTime
maximum time consumed by root node process
Definition: bbParaSolver.h:90
virtual void sendLocalSolution()
send solution found in this Solver
double getGlobalBestIncumbentValue()
get global best incumbent value
Definition: bbParaSolver.h:971
virtual void iReceiveMessages()
non-blocking receive messages
int nSolvedWithNoPreprocesses
number of nodes solved when it is solved with no preprocesses
Definition: bbParaSolver.h:97
int totalNSent
accumulated number of nodes sent from this BbParaSolver
Definition: bbParaSolver.h:114
int minRestarts
minimum number of restarts
Definition: bbParaSolver.h:112
double solverDualBound
dual bound value achieved for a subproblem
Definition: bbParaSolver.h:137
int nTightenedInt
the number of tightened integral variable bounds in racing
Definition: bbParaSolver.h:127
int nTransferredBendersCutsFromSolver
number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:108
bool isRacingStage()
check if Solver is in racing stage or not
double minRootNodeTime
minimum time consumed by root node process
Definition: bbParaSolver.h:89
int minTransferredLocalCutsFromSolver
minimum number of local cuts transferred from this Solver
Definition: bbParaSolver.h:106
int minTransferredBendersCutsFromSolver
minimum number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:109
int nParaNodesSolvedAtPreCheck
number of ParaNodes solved at pre-checking of root node solvability
Definition: bbParaSolver.h:117
int maxTransferredBendersCutsFromSolver
maximum number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:110
virtual bool saveIfImprovedSolutionWasFound(ParaSolution *sol)
save improved solution if it was found in this Solver
int maxTransferredLocalCutsFromSolver
maximum number of local cuts transferred from this Solver
Definition: bbParaSolver.h:107
double totalRootNodeTime
accumulated root node process time solved by this solver so far
Definition: bbParaSolver.h:88
int totalNImprovedIncumbent
accumulated number of improvements of incumbent value in this BbParaSolver
Definition: bbParaSolver.h:115
int nTotalRestarts
number of total restarts
Definition: bbParaSolver.h:111
bool waitToken(int rank)
wait token for deterministic mode
int getRank()
get rank of caller's thread
int bcast(void *buffer, int count, const int datatypeId, int root)
broadcast function for standard ParaData types
Base class of communicator object.
Definition: paraComm.h:102
virtual void lockApp()=0
lock UG application to synchronize with other threads
virtual ParaSolution * createParaSolution()=0
create ParaSolution object by default constructor
virtual int getSize()=0
get number of UG processes or UG threads depending on run-time environment
virtual bool passTermToken(int rank)
pass termination token from the rank to the next
Definition: paraComm.h:211
virtual void unlockApp()=0
unlock UG application to synchronize with other threads
virtual int receive(void *bufer, int count, const int datatypeId, int source, const int tag)=0
receive function for standard ParaData types
virtual int bcast(void *buffer, int count, const int datatypeId, int root)=0
Some action need to be taken for fault tolerant, when the functions return. So, they rerun status val...
virtual ParaInstance * createParaInstance()=0
create ParaInstance object by default constructor
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
class for deterministic timer
virtual double getElapsedTime()=0
getter of the deterministic time
virtual void send(ParaComm *comm, int dest)=0
send function for ParaInitialStat object
class for instance data
Definition: paraInstance.h:51
virtual int bcast(ParaComm *comm, int rank, int method)=0
broadcast function to all solvers
class ParaParamSet
Definition: paraParamSet.h:850
bool getBoolParamValue(int param)
get bool parameter value
bool getBoolParamDefaultValue(int param)
get default value of bool parameter
double getRealParamValue(int param)
get real parameter value
int getIntParamValue(int param)
get int parameter value
const char * getStringParamValue(int param)
get string parameter value
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class for solution
Definition: paraSolution.h:54
virtual void bcast(ParaComm *comm, int root)=0
broadcast solution data
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object
class ParaSolver
Definition: paraSolver.h:71
double idleTimeToWaitNotificationId
idle time to wait a message within collecting mode
Definition: paraSolver.h:121
ParaParamSet * paraParams
ParaParamSet object.
Definition: paraSolver.h:83
ParaComm * paraComm
ParaCommunicator object.
Definition: paraSolver.h:82
void setTerminationMode(int tm)
set termination mode
Definition: paraSolver.h:837
ParaTask * currentTask
solving task
Definition: paraSolver.h:97
bool notificationProcessed
if true, notification is issued but not receive the corresponding LCB
Definition: paraSolver.h:140
int nParaTasksReceived
Counters related to this ParaSolver.
Definition: paraSolver.h:135
double idleTimeBetweenParaTasks
idle time between ParaTasks processing
Definition: paraSolver.h:119
bool racingIsInterrupted
indicate whether if racing phases is interrupted or not: true - interrupted
Definition: paraSolver.h:106
ParaSolution * globalBestIncumbentSolution
global best solution. However, this is not always feasible for the current sub-MIP
Definition: paraSolver.h:92
double previousIdleTimeToWaitToken
previous idle time to wait token
Definition: paraSolver.h:124
bool memoryLimitIsReached
indicate if memory limit is reached or not, when base solver has memory management feature
Definition: paraSolver.h:109
ParaRacingRampUpParamSet * winnerRacingParams
Winner ParaRacingRampUpParamSet object.
Definition: paraSolver.h:86
bool warmStarted
indicate whether if system is warm started or not
Definition: paraSolver.h:103
double eps
absolute values smaller than this are considered zero esp should be set in the constructor of the der...
Definition: paraSolver.h:142
double idleTimeToWaitToken
idle time to wait token
Definition: paraSolver.h:123
ParaTimer * paraTimer
timer for this ParaSolver
Definition: paraSolver.h:88
double idleTimeToWaitAckCompletion
idle time to wait acknowledgment of completion
Definition: paraSolver.h:122
bool isRacingWinner()
check if this solver is in racing ramp-up or not
Definition: paraSolver.h:530
double previousStopTime
Idle Times.
Definition: paraSolver.h:117
double idleTimeAfterLastParaTask
idle time after the last ParaTask was solved
Definition: paraSolver.h:120
double globalBestIncumbentValue
global best incumbent value
Definition: paraSolver.h:91
bool racingWinner
indicate racing ramp-up winner or not: true - winner
Definition: paraSolver.h:107
ParaDeterministicTimer * paraDetTimer
deterministic timer for this ParaSolver
Definition: paraSolver.h:89
double idleTimeToFirstParaTask
idle time to start solving the first ParaTask
Definition: paraSolver.h:118
int nParaTasksSolved
number of ParaTasks solved ( received ) in this ParaSolver
Definition: paraSolver.h:136
int terminationMode
indicate that termination mode 0: no termination mode 1: normal termination mode 2: interrupted termi...
Definition: paraSolver.h:99
ParaInstance * paraInstance
root problem instance
Definition: paraSolver.h:96
bool isRootTask()
check if root task or not
Definition: paraTask.h:624
TaskId getGeneratorTaskId()
getter of generator task id
Definition: paraTask.h:814
TaskId getTaskId()
getter of task id
Definition: paraTask.h:794
ParaDiffSubproblem * getDiffSubproblem()
getter of diffSubproblem
Definition: paraTask.h:854
void setOffset(double time)
Definition: paraTimer.h:74
virtual double getElapsedTime()=0
get elapsed time
static ScipParaCommTh * comm
Definition: fscip.cpp:73
static bool interrupted
Definition: fscip.cpp:78
static const int CustomizedToSharedMemory
static const int AddDualBoundCons
struct ParaSCIP::LocalNodeInfo_t LocalNodeInfo
static const int MemoryLimit
static const int RacingParamsDirPath
Definition: paraParamSet.h:131
static const int NoSolverPresolvingAtRootDefaultSet
static const int CompTerminatedByInterruptRequest
Definition: paraDef.h:184
static const int TagLbBoundTightenedBound
Definition: bbParaTagDef.h:63
static const int NoUpperBoundTransferInRacing
static const int UseRootNodeCuts
static const int NoTerminationMode
termination mode
Definition: paraSolver.h:60
static const int NoAggressiveSeparatorInRacing
static const int TagLbBoundTightenedIndex
Definition: bbParaTagDef.h:62
static const int ProvingRun
static const int ParaINT
Definition: paraComm.h:66
static const int InstanceTransferMethod
static const int TagTerminated
Definition: paraTagDef.h:58
static const int TagUbBoundTightenedIndex
Definition: bbParaTagDef.h:64
static const int TransferConflictCuts
static const int CheckEffectOfRootNodePreprocesses
static const int NoPreprocessingInLC
static const int TimeLimit
Definition: paraParamSet.h:106
static const int TimeLimitTerminationMode
Definition: paraSolver.h:63
static const int ControlCollectingModeOnSolverSide
static const int Deterministic
Definition: paraParamSet.h:76
static const int RampUpPhaseProcess
static const int CompTerminatedNormally
Definition: paraDef.h:182
static const int InterruptedTerminationMode
Definition: paraSolver.h:62
static const int TagUbBoundTightenedBound
Definition: bbParaTagDef.h:65
static const int RacingStatBranching
static const int AllowTreeSearchRestart
static const int Quiet
Definition: paraParamSet.h:71
static const int NoSolverPresolvingAtRoot
static const int DistributeBestPrimalSolution
static const int ParaDOUBLE
Definition: paraComm.h:76
static const int SelfSplitTreeDepth
static const int SetAllDefaultsAfterRacing
static const int CommunicateTighterBoundsInRacing
#define PARA_COMM_CALL(paracommcall)
Definition: paraComm.h:47
#define THROW_LOGICAL_ERROR1(msg1)
Definition: paraDef.h:52
#define THROW_LOGICAL_ERROR2(msg1, msg2)
Definition: paraDef.h:69
#define EPSEQ(x, y, eps)
Definition: paraDef.h:166
#define THROW_LOGICAL_ERROR3(msg1, msg2, msg3)
Definition: paraDef.h:86
Base class for initial statistics collecting class.
#define DEF_SCIP_PARA_COMM(scip_para_comm, comm)
ParaInitialStat extension for SCIP solver.
Branching rule plug-in for SCIP solver.
Event handlr for communication point.
heuristic to update objlimit
SCIP message handler for ParaSCIP and FiberSCIP.
C++ wrapper for propagators.
node selector for self-split ramp-up
#define SCIP_MEMORY_COPY_FACTOR
ParaRacingRampUpParamSet extension for SCIP solver.
void setUserPlugins(UG::ParaInstance *instance)
static SCIP_DECL_CONFLICTEXEC(conflictExecCollector)
#define CONFLICTHDLR_PRIORITY
#define CONFLICTHDLR_NAME
#define CONFLICTHDLR_DESC
double memoryLimitOfSolverSCIP
Definition: fscip.cpp:71
long long virtualMemUsedAtLc
Definition: fscip.cpp:70