Scippy

UG

Ubiquity Generator framework

scipParaDiffSubproblem.h
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 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 scipParaDiffSubproblem.h
27  * @brief ParaInitialStat extension for SCIP solver.
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 #ifndef __SCIP_PARA_DIFF_SUBPROBLEM_H__
38 #define __SCIP_PARA_DIFF_SUBPROBLEM_H__
39 
40 #include <cstring>
41 #include <iostream>
42 #include <fstream>
43 #include "ug/paraComm.h"
44 #ifdef UG_WITH_ZLIB
45 #include "ug/gzstream.h"
46 #endif
47 #include "ug_bb/bbParaInstance.h"
49 #include "scip/scip.h"
50 #include "scip/history.h"
51 #include "scip/cons_bounddisjunction.h"
52 
53 namespace ParaSCIP
54 {
55 
56 class ScipParaSolver;
57 
58 typedef struct BranchConsLinearInfo_t
59 {
60  /********************************
61  * for branching constraint *
62  * *****************************/
63  char * consName; /**< name of this constraint */
64  SCIP_Real linearLhs; /**< array of lhs */
65  SCIP_Real linearRhs; /**< array of rhs */
66  int nLinearCoefs; /**< array of number of coefficient values for linear constrains */
67  SCIP_Real *linearCoefs; /**< array of non-zero coefficient values of linear constrains */
68  int *idxLinearCoefsVars; /**< array of indices of no-zero coefficient values of linear constrains */
71 
72 typedef struct BranchConsSetppcInfo_t
73 {
74  /********************************
75  * for branching constraint *
76  * *****************************/
77  char * consName; /**< name of this constraint */
78  int nSetppcVars; /**< array of numbers of indices of variables for setppc constrains */
79  int setppcType; /**< setppc Type */
80  int *idxSetppcVars; /**< array of indices of variables for setppc constrains */
83 
85 {
86 public:
87  int nLinearConss; /**< number of linear constrains */
88  SCIP_Real *linearLhss; /**< array of lhs */
89  SCIP_Real *linearRhss; /**< array of rhs */
90  int *nLinearCoefs; /**< array of number of coefficient values for linear constrains */
91  SCIP_Real **linearCoefs; /**< array of non-zero coefficient values of linear constrains */
92  int **idxLinearCoefsVars; /**< array of indices of no-zero coefficient values of linear constrains */
93  int lConsNames; /**< length of cons names space: each name is separated by \0 */
94  char *consNames; /**< constraint names */
95 
96  /** default constructor */
98  ) :nLinearConss(0),
99  linearLhss(0),
100  linearRhss(0),
101  nLinearCoefs(0),
102  linearCoefs(0),
103  idxLinearCoefsVars(0),
104  lConsNames(0),
105  consNames(0)
106  {
107  }
108  /** destractor */
110  )
111  {
112  if( linearLhss ) delete[] linearLhss;
113  if( linearRhss ) delete[] linearRhss;
114  for( int c = 0; c < nLinearConss; c++ )
115  {
116  if( nLinearCoefs[c] > 0 )
117  {
118  if( linearCoefs[c] ) delete[] linearCoefs[c];
119  if( idxLinearCoefsVars[c] ) delete[] idxLinearCoefsVars[c];
120  }
121  }
122  if( nLinearCoefs ) delete[] nLinearCoefs;
123  if( linearCoefs ) delete[] linearCoefs;
124  if( idxLinearCoefsVars ) delete[] idxLinearCoefsVars;
125  if( consNames ) delete[] consNames;
126  }
127 };
128 
130 {
131 public:
132  int nSetppcConss; /**< number of setppc constrains */
133  int *nSetppcVars; /**< array of numbers of indices of variables for setppc constrains */
134  int *setppcTypes; /**< setppc Types */
135  int **idxSetppcVars; /**< array of indices of variables for setppc constrains */
136  int lConsNames; /**< length of cons names space: each name is separated by \0 */
137  char *consNames; /**< constraint names */
138  /** default constructor */
140  ) :nSetppcConss(0),
141  nSetppcVars(0),
142  setppcTypes(0),
143  idxSetppcVars(0),
144  lConsNames(0),
145  consNames(0)
146  {
147  }
148  /** destractor */
150  )
151  {
152  if( nSetppcVars ) delete[] nSetppcVars;
153  if( setppcTypes ) delete[] setppcTypes;
154  for( int c = 0; c < nSetppcConss; c++ )
155  {
156  if( idxSetppcVars[c] ) delete[] idxSetppcVars[c];
157  }
158  if (idxSetppcVars ) delete [] idxSetppcVars;
159  if( consNames ) delete[] consNames;
160  }
161 };
162 
164 {
165 public:
166  int nLinearConss; /**< number of linear constrains */
167  SCIP_Real *linearLhss; /**< array of lhs */
168  SCIP_Real *linearRhss; /**< array of rhs */
169  int *nLinearCoefs; /**< array of number of coefficient values for linear constrains */
170  SCIP_Real **linearCoefs; /**< array of non-zero coefficient values of linear constrains */
171  int **idxLinearCoefsVars; /**< array of indices of no-zero coefficient values of linear constrains */
172 
173  /** default constructor */
175  ) :nLinearConss(0),
176  linearLhss(0),
177  linearRhss(0),
178  nLinearCoefs(0),
179  linearCoefs(0),
180  idxLinearCoefsVars(0)
181  {
182  }
183  /** destractor */
185  )
186  {
187  if( linearLhss ) delete[] linearLhss;
188  if( linearRhss ) delete[] linearRhss;
189  for( int c = 0; c < nLinearConss; c++ )
190  {
191  if( nLinearCoefs[c] > 0 )
192  {
193  if( linearCoefs[c] ) delete[] linearCoefs[c];
194  if( idxLinearCoefsVars[c] ) delete[] idxLinearCoefsVars[c];
195  }
196  }
197  if( nLinearCoefs ) delete[] nLinearCoefs;
198  if( linearCoefs ) delete[] linearCoefs;
199  if( idxLinearCoefsVars ) delete[] idxLinearCoefsVars;
200  }
201 };
202 
204 {
205 public:
206  int nBoundDisjunctions; /**< number of bound disjunction constraints */
207  int nTotalVarsBoundDisjunctions; /**< total number of vars in bound disjunction constraints */
208  int *nVarsBoundDisjunction;/**< number of variables in bound disjunction constraint */
209  SCIP_Bool *flagBoundDisjunctionInitial; /**< should the LP relaxation of constraint be in the initial LP? Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
210  SCIP_Bool *flagBoundDisjunctionSeparate; /**< should the constraint be separated during LP processing? Usually set to TRUE. */
211  SCIP_Bool *flagBoundDisjunctionEnforce; /**< should the constraint be enforced during node processing? TRUE for model constraints, FALSE for additional, redundant constraints. */
212  SCIP_Bool *flagBoundDisjunctionCheck; /**< should the constraint be checked for feasibility? TRUE for model constraints, FALSE for additional, redundant constraints. */
213  SCIP_Bool *flagBoundDisjunctionPropagate; /**< should the constraint be propagated during node processing? Usually set to TRUE. */
214  SCIP_Bool *flagBoundDisjunctionLocal; /**< is constraint only valid locally? Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
215  SCIP_Bool *flagBoundDisjunctionModifiable;/**< is constraint modifiable (subject to column generation)? Usually set to FALSE. In column generation applications, set to TRUE if pricing adds coefficients to this constraint. */
216  SCIP_Bool *flagBoundDisjunctionDynamic; /**< is constraint subject to aging? Usually set to FALSE. Set to TRUE for own cuts which are separated as constraints.*/
217  SCIP_Bool *flagBoundDisjunctionRemovable; /**< should the relaxation be removed from the LP due to aging or cleanup? Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'.*/
218  SCIP_Bool *flagBoundDisjunctionStickingatnode; /**< should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
219  int **idxBoundDisjunctionVars; /**< index of bound disjunction vars */
220  SCIP_BOUNDTYPE **boundTypesBoundDisjunction; /**< array of bound types in bound disjunction constraint */
221  SCIP_Real **boundsBoundDisjunction; /**< array of bounds in bound disjunction constraint */
222 
223  /** default constructor */
225  ) : nBoundDisjunctions(0),
226  nTotalVarsBoundDisjunctions(0),
227  nVarsBoundDisjunction(0),
228  flagBoundDisjunctionInitial(0),
229  flagBoundDisjunctionSeparate(0),
230  flagBoundDisjunctionEnforce(0),
231  flagBoundDisjunctionCheck(0),
232  flagBoundDisjunctionPropagate(0),
233  flagBoundDisjunctionLocal(0),
234  flagBoundDisjunctionModifiable(0),
235  flagBoundDisjunctionDynamic(0),
236  flagBoundDisjunctionRemovable(0),
237  flagBoundDisjunctionStickingatnode(0),
238  idxBoundDisjunctionVars(0),
239  boundTypesBoundDisjunction(0),
240  boundsBoundDisjunction(0)
241  {
242  }
243  /** destractor */
245  )
246  {
247  for( int i = 0; i < nBoundDisjunctions; i++ )
248  {
249  if( nVarsBoundDisjunction[i] > 0 )
250  {
251  if( idxBoundDisjunctionVars[i] ) delete[] idxBoundDisjunctionVars[i];
252  if( boundTypesBoundDisjunction[i] ) delete[] boundTypesBoundDisjunction[i];
253  if( boundsBoundDisjunction[i] ) delete[] boundsBoundDisjunction[i];
254  }
255  }
256  if( idxBoundDisjunctionVars ) delete[] idxBoundDisjunctionVars;
257  if( boundTypesBoundDisjunction ) delete[] boundTypesBoundDisjunction;
258  if( boundsBoundDisjunction ) delete[] boundsBoundDisjunction;
259  if( nVarsBoundDisjunction ) delete[] nVarsBoundDisjunction;
260  if( flagBoundDisjunctionInitial ) delete[] flagBoundDisjunctionInitial;
261  if( flagBoundDisjunctionSeparate ) delete[] flagBoundDisjunctionSeparate;
262  if( flagBoundDisjunctionEnforce ) delete[] flagBoundDisjunctionEnforce;
263  if( flagBoundDisjunctionCheck ) delete[] flagBoundDisjunctionCheck;
264  if( flagBoundDisjunctionPropagate ) delete[] flagBoundDisjunctionPropagate;
265  if( flagBoundDisjunctionLocal ) delete[] flagBoundDisjunctionLocal;
266  if( flagBoundDisjunctionModifiable ) delete[] flagBoundDisjunctionModifiable;
267  if( flagBoundDisjunctionDynamic ) delete[] flagBoundDisjunctionDynamic;
268  if( flagBoundDisjunctionRemovable ) delete[] flagBoundDisjunctionRemovable;
269  if( flagBoundDisjunctionStickingatnode ) delete[] flagBoundDisjunctionStickingatnode;
270  }
271 };
272 
274 {
275 public:
276  int offset; /**< root node depth of the collected nodes */
277  int nVarBranchStats; /**< number of branch stats */
278  int *idxBranchStatsVars; /**< indices of branch stats vars */
279  SCIP_Real *downpscost; /**< values to which pseudocosts for downwards branching */
280  SCIP_Real *uppscost; /**< values to which pseudocosts for upwards branching */
281  SCIP_Real *downvsids; /**< values to which VSIDS score for downwards branching */
282  SCIP_Real *upvsids; /**< values to which VSIDS score for upwards branching */
283  SCIP_Real *downconflen; /**< values to which conflict length score for downwards branching */
284  SCIP_Real *upconflen; /**< values to which conflict length score for upwards branching */
285  SCIP_Real *downinfer; /**< values to which inference counter for downwards branching */
286  SCIP_Real *upinfer; /**< values to which inference counter for upwards branching */
287  SCIP_Real *downcutoff; /**< values to which cutoff counter for downwards branching */
288  SCIP_Real *upcutoff; /**< values to which cutoff counter for upwards branching */
289 
290  /** default constructor */
292  ) : offset(0),
293  nVarBranchStats(0),
294  idxBranchStatsVars(0),
295  downpscost(0),
296  uppscost(0),
297  downvsids(0),
298  upvsids(0),
299  downconflen(0),
300  upconflen(0),
301  downinfer(0),
302  upinfer(0),
303  downcutoff(0),
304  upcutoff(0)
305  {
306  }
307  /** destractor */
309  )
310  {
311  if( idxBranchStatsVars ) delete[] idxBranchStatsVars;
312  if( downpscost ) delete[] downpscost;
313  if( uppscost ) delete[] uppscost;
314  if( downvsids ) delete[] downvsids;
315  if( upvsids ) delete[] upvsids;
316  if( downconflen ) delete[] downconflen;
317  if( upconflen ) delete[] upconflen;
318  if( downinfer ) delete[] downinfer;
319  if( upinfer ) delete[] upinfer;
320  if( downcutoff ) delete[] downcutoff;
321  if( upcutoff ) delete[] upcutoff;
322  }
323 };
324 
326 {
327 public:
328  int nVarValueVars; /**< number of variable value variables */
329  int nVarValues; /**< number of variable values, for getting statistics */
330  int *idxVarValueVars; /**< indicies of variable value vars */
331  int *nVarValueValues; /**< number of values for a variable */
332  SCIP_Real **varValue; /**< domain value, or SCIP_UNKNOWN */
333  SCIP_Real **varValueDownvsids; /**< value to which VSIDS score for downwards branching should be initialized */
334  SCIP_Real **varVlaueUpvsids; /**< value to which VSIDS score for upwards branching should be initialized */
335  SCIP_Real **varValueDownconflen; /**< value to which conflict length score for downwards branching should be initialized */
336  SCIP_Real **varValueUpconflen; /**< value to which conflict length score for upwards branching should be initialized */
337  SCIP_Real **varValueDowninfer; /**< value to which inference counter for downwards branching should be initialized */
338  SCIP_Real **varValueUpinfer; /**< value to which inference counter for upwards branching should be initialized */
339  SCIP_Real **varValueDowncutoff; /**< value to which cutoff counter for downwards branching should be initialized */
340  SCIP_Real **varValueUpcutoff; /**< value to which cutoff counter for upwards branching should be initialized */
341  /** default constructor */
343  ) : nVarValueVars(0),
344  nVarValues(0),
345  idxVarValueVars(0),
346  nVarValueValues(0),
347  varValue(0),
348  varValueDownvsids(0),
349  varVlaueUpvsids(0),
350  varValueDownconflen(0),
351  varValueUpconflen(0),
352  varValueDowninfer(0),
353  varValueUpinfer(0),
354  varValueDowncutoff(0),
355  varValueUpcutoff(0)
356  {
357  }
358  /** destractor */
360  )
361  {
362  for( int i = 0; i < nVarValueVars; i++ )
363  {
364  if( nVarValueValues[i] > 0 )
365  {
366  if( varValue[i] ) delete[] varValue[i];
367  if( varValueDownvsids[i] ) delete[] varValueDownvsids[i];
368  if( varVlaueUpvsids[i] ) delete[] varVlaueUpvsids[i];
369  if( varValueDownconflen[i] ) delete[] varValueDownconflen[i];
370  if( varValueUpconflen[i] ) delete[] varValueUpconflen[i];
371  if( varValueDowninfer[i] ) delete[] varValueDowninfer[i];
372  if( varValueUpinfer[i] ) delete[] varValueUpinfer[i];
373  if( varValueDowncutoff[i] ) delete[] varValueDowncutoff[i];
374  if( varValueUpcutoff[i] ) delete[] varValueUpcutoff[i];
375  }
376  }
377  if( varValue ) delete [] varValue;
378  if( varValueDownvsids ) delete[] varValueDownvsids;
379  if( varVlaueUpvsids ) delete[] varVlaueUpvsids;
380  if( varValueDownconflen ) delete[] varValueDownconflen;
381  if( varValueUpconflen ) delete[] varValueUpconflen;
382  if( varValueDowninfer ) delete[] varValueDowninfer;
383  if( varValueUpinfer ) delete[] varValueUpinfer;
384  if( varValueDowncutoff ) delete[] varValueDowncutoff;
385  if( varValueUpcutoff ) delete[] varValueUpcutoff;
386  if( idxVarValueVars ) delete[] idxVarValueVars;
387  if( nVarValueValues ) delete[] nVarValueValues;
388  }
389 };
390 
391 /** The difference between instance and subproblem: this is base class */
393 {
394 protected:
395  int localInfoIncluded; /**< 0 (0000 0000): not included
396  1 (0000 0001): if local cuts are included
397  2 (0000 0010): if conflicts are included
398  3 (0000 0011): if local cuts and conflicts are included */
399  /******************************
400  * for variable bound changes *
401  * ***************************/
402  int nBoundChanges; /**< number of branching variables */
403  int *indicesAmongSolvers; /**< array of variable indices ( unique index ) */
404  SCIP_Real *branchBounds; /**< array of bounds which the branchings */
405  SCIP_BOUNDTYPE *boundTypes; /**< array of boundtypes which the branchings */
406  /*******************************************
407  * for the case of branching by constraint *
408  * ****************************************/
409  ScipParaDiffSubproblemBranchLinearCons *branchLinearConss; /**< point to branch constraints */
410  ScipParaDiffSubproblemBranchSetppcCons *branchSetppcConss; /**< point to branch constraints */
411  /************************************
412  * for local cuts and conflict cuts *
413  * *********************************/
414  ScipParaDiffSubproblemLinearCons *linearConss; /**< point to linear constraint data */
415  /************************************
416  * for benders cuts *
417  * *********************************/
418  ScipParaDiffSubproblemLinearCons *bendersLinearConss; /**< point to benders linear constraint data */
419  /********************************
420  * for conflicts *
421  * *****************************/
422  ScipParaDiffSubproblemBoundDisjunctions *boundDisjunctions; /**< point to bound disjunctions */
423  /********************************
424  * for local var brnach stats *
425  * *****************************/
426  ScipParaDiffSubproblemVarBranchStats *varBranchStats; /**< point to varialbe branch stats */
427  /**************************************
428  * for local var value brnach stats *
429  * ***********************************/
430  ScipParaDiffSubproblemVarValues *varValues; /**< point to variable values */
431 #ifdef UG_DEBUG_SOLUTION
432  int includeOptimalSol; /**< indicate if sub-MIP includes optimal solution or not. 1: include, 0: not */
433 #endif
434 public:
435  /** default constructor */
437  )
438  : localInfoIncluded(0),
439  nBoundChanges(0), indicesAmongSolvers(0), branchBounds(0), boundTypes(0),
440  branchLinearConss(0),
441  branchSetppcConss(0),
442  linearConss(0),
443  bendersLinearConss(0),
444  boundDisjunctions(0),
445  varBranchStats(0),
446  varValues(0)
447  {
448 #ifdef UG_DEBUG_SOLUTION
449  includeOptimalSol = 0;
450 #endif
451  }
452 
454  SCIP *scip,
455  ScipParaSolver *scipParaSolver,
456  int nNewBranchVars,
457  SCIP_VAR **newBranchVars,
458  SCIP_Real *newBranchBounds,
459  SCIP_BOUNDTYPE *newBoundTypes,
460  int nAddedConss,
461  SCIP_CONS **addedConss
462  );
463 
465  ScipParaDiffSubproblem *diffSubproblem
466  ) : localInfoIncluded(0),
467  nBoundChanges(0), indicesAmongSolvers(0), branchBounds(0), boundTypes(0),
468  branchLinearConss(0),
469  branchSetppcConss(0),
470  linearConss(0),
471  bendersLinearConss(0),
472  boundDisjunctions(0),
473  varBranchStats(0),
474  varValues(0)
475 
476  {
477  if( !diffSubproblem ) return;
478 
479  localInfoIncluded = diffSubproblem->localInfoIncluded;
480  nBoundChanges = diffSubproblem->nBoundChanges;
481  if( nBoundChanges )
482  {
483  indicesAmongSolvers = new int[nBoundChanges];
484  branchBounds = new SCIP_Real[nBoundChanges];
485  boundTypes = new SCIP_BOUNDTYPE[nBoundChanges];
486  for( int i = 0; i < nBoundChanges; i++ )
487  {
488  indicesAmongSolvers[i] = diffSubproblem->indicesAmongSolvers[i];
489  branchBounds[i] = diffSubproblem->branchBounds[i];
490  boundTypes[i] = diffSubproblem->boundTypes[i];
491  }
492  }
493 
494  if( diffSubproblem->branchLinearConss )
495  {
496  branchLinearConss = new ScipParaDiffSubproblemBranchLinearCons();
497  branchLinearConss->nLinearConss = diffSubproblem->branchLinearConss->nLinearConss;
498  assert( branchLinearConss->nLinearConss > 0 );
499  branchLinearConss->linearLhss = new SCIP_Real[branchLinearConss->nLinearConss];
500  branchLinearConss->linearRhss = new SCIP_Real[branchLinearConss->nLinearConss];
501  branchLinearConss->nLinearCoefs = new int[branchLinearConss->nLinearConss];
502  branchLinearConss->linearCoefs = new SCIP_Real*[branchLinearConss->nLinearConss];
503  branchLinearConss->idxLinearCoefsVars = new int*[branchLinearConss->nLinearConss];
504  for( int c = 0; c < branchLinearConss->nLinearConss; c++ )
505  {
506  branchLinearConss->linearLhss[c] = diffSubproblem->branchLinearConss->linearLhss[c];
507  branchLinearConss->linearRhss[c] = diffSubproblem->branchLinearConss->linearRhss[c];
508  branchLinearConss->nLinearCoefs[c] = diffSubproblem->branchLinearConss->nLinearCoefs[c];
509  branchLinearConss->linearCoefs[c] = new SCIP_Real[branchLinearConss->nLinearCoefs[c]];
510  branchLinearConss->idxLinearCoefsVars[c] = new int[branchLinearConss->nLinearCoefs[c]];
511  for( int v = 0; v < branchLinearConss->nLinearCoefs[c]; v++ )
512  {
513  branchLinearConss->linearCoefs[c][v] = diffSubproblem->branchLinearConss->linearCoefs[c][v];
514  branchLinearConss->idxLinearCoefsVars[c][v] = diffSubproblem->branchLinearConss->idxLinearCoefsVars[c][v];
515  }
516  }
517  branchLinearConss->lConsNames = diffSubproblem->branchLinearConss->lConsNames;
518  branchLinearConss->consNames = new char[branchLinearConss->lConsNames+1];
519  for( int c = 0; c < branchLinearConss->lConsNames; c++ )
520  {
521  branchLinearConss->consNames[c] = diffSubproblem->branchLinearConss->consNames[c];
522  }
523  branchLinearConss->consNames[branchLinearConss->lConsNames] = '\0';
524  }
525 
526  if( diffSubproblem->branchSetppcConss )
527  {
528  branchSetppcConss = new ScipParaDiffSubproblemBranchSetppcCons();
529  branchSetppcConss->nSetppcConss = diffSubproblem->branchSetppcConss->nSetppcConss;
530  assert( branchSetppcConss->nSetppcConss > 0 );
531  branchSetppcConss->nSetppcVars = new int[branchSetppcConss->nSetppcConss];
532  branchSetppcConss->setppcTypes = new int[branchSetppcConss->nSetppcConss];
533  branchSetppcConss->idxSetppcVars = new int*[branchSetppcConss->nSetppcConss];
534  for( int c = 0; c < branchSetppcConss->nSetppcConss; c++ )
535  {
536  branchSetppcConss->nSetppcVars[c] = diffSubproblem->branchSetppcConss->nSetppcVars[c];
537  branchSetppcConss->setppcTypes[c] = diffSubproblem->branchSetppcConss->setppcTypes[c];
538  branchSetppcConss->idxSetppcVars[c] = new int[branchSetppcConss->nSetppcVars[c]];
539  for( int v = 0; v < branchSetppcConss->nSetppcVars[c]; v++ )
540  {
541  branchSetppcConss->idxSetppcVars[c][v] = diffSubproblem->branchSetppcConss->idxSetppcVars[c][v];
542  }
543  }
544  branchSetppcConss->lConsNames = diffSubproblem->branchSetppcConss->lConsNames;
545  branchSetppcConss->consNames = new char[branchSetppcConss->lConsNames+1];
546  for( int c = 0; c < branchSetppcConss->lConsNames; c++ )
547  {
548  branchSetppcConss->consNames[c] = diffSubproblem->branchSetppcConss->consNames[c];
549  }
550  branchSetppcConss->consNames[branchSetppcConss->lConsNames] = '\0';
551  }
552 
553  if( diffSubproblem->linearConss )
554  {
555  linearConss = new ScipParaDiffSubproblemLinearCons();
556  linearConss->nLinearConss = diffSubproblem->linearConss->nLinearConss;
557  assert( linearConss->nLinearConss > 0 );
558  // std::cout << "linearConss->nLinearConss = " << linearConss->nLinearConss << std::endl;
559  linearConss->linearLhss = new SCIP_Real[linearConss->nLinearConss];
560  linearConss->linearRhss = new SCIP_Real[linearConss->nLinearConss];
561  linearConss->nLinearCoefs = new int[linearConss->nLinearConss];
562  linearConss->linearCoefs = new SCIP_Real*[linearConss->nLinearConss];
563  linearConss->idxLinearCoefsVars = new int*[linearConss->nLinearConss];
564  for( int c = 0; c < linearConss->nLinearConss; c++ )
565  {
566  linearConss->linearLhss[c] = diffSubproblem->linearConss->linearLhss[c];
567  linearConss->linearRhss[c] = diffSubproblem->linearConss->linearRhss[c];
568  linearConss->nLinearCoefs[c] = diffSubproblem->linearConss->nLinearCoefs[c];
569  linearConss->linearCoefs[c] = new SCIP_Real[linearConss->nLinearCoefs[c]];
570  linearConss->idxLinearCoefsVars[c] = new int[linearConss->nLinearCoefs[c]];
571  for( int v = 0; v < linearConss->nLinearCoefs[c]; v++ )
572  {
573  linearConss->linearCoefs[c][v] = diffSubproblem->linearConss->linearCoefs[c][v];
574  linearConss->idxLinearCoefsVars[c][v] = diffSubproblem->linearConss->idxLinearCoefsVars[c][v];
575  }
576  }
577  }
578 
579  if( diffSubproblem->bendersLinearConss )
580  {
581  bendersLinearConss = new ScipParaDiffSubproblemLinearCons();
582  bendersLinearConss->nLinearConss = diffSubproblem->bendersLinearConss->nLinearConss;
583  assert( bendersLinearConss->nLinearConss > 0 );
584  // std::cout << "bendersLinearConss->nLinearConss = " << bendersLinearConss->nLinearConss << std::endl;
585  bendersLinearConss->linearLhss = new SCIP_Real[bendersLinearConss->nLinearConss];
586  bendersLinearConss->linearRhss = new SCIP_Real[bendersLinearConss->nLinearConss];
587  bendersLinearConss->nLinearCoefs = new int[bendersLinearConss->nLinearConss];
588  bendersLinearConss->linearCoefs = new SCIP_Real*[bendersLinearConss->nLinearConss];
589  bendersLinearConss->idxLinearCoefsVars = new int*[bendersLinearConss->nLinearConss];
590  for( int c = 0; c < bendersLinearConss->nLinearConss; c++ )
591  {
592  bendersLinearConss->linearLhss[c] = diffSubproblem->bendersLinearConss->linearLhss[c];
593  bendersLinearConss->linearRhss[c] = diffSubproblem->bendersLinearConss->linearRhss[c];
594  bendersLinearConss->nLinearCoefs[c] = diffSubproblem->bendersLinearConss->nLinearCoefs[c];
595  bendersLinearConss->linearCoefs[c] = new SCIP_Real[bendersLinearConss->nLinearCoefs[c]];
596  bendersLinearConss->idxLinearCoefsVars[c] = new int[bendersLinearConss->nLinearCoefs[c]];
597  for( int v = 0; v < bendersLinearConss->nLinearCoefs[c]; v++ )
598  {
599  bendersLinearConss->linearCoefs[c][v] = diffSubproblem->bendersLinearConss->linearCoefs[c][v];
600  bendersLinearConss->idxLinearCoefsVars[c][v] = diffSubproblem->bendersLinearConss->idxLinearCoefsVars[c][v];
601  }
602  }
603  }
604 
605  if( diffSubproblem->boundDisjunctions )
606  {
607  boundDisjunctions = new ScipParaDiffSubproblemBoundDisjunctions();
608  boundDisjunctions->nBoundDisjunctions = diffSubproblem->boundDisjunctions->nBoundDisjunctions;
609  boundDisjunctions->nTotalVarsBoundDisjunctions = diffSubproblem->boundDisjunctions->nTotalVarsBoundDisjunctions;
610  boundDisjunctions->nVarsBoundDisjunction = new int[boundDisjunctions->nBoundDisjunctions];
611  boundDisjunctions->flagBoundDisjunctionInitial = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
612  boundDisjunctions->flagBoundDisjunctionSeparate = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
613  boundDisjunctions->flagBoundDisjunctionEnforce = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
614  boundDisjunctions->flagBoundDisjunctionCheck = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
615  boundDisjunctions->flagBoundDisjunctionPropagate = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
616  boundDisjunctions->flagBoundDisjunctionLocal = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
617  boundDisjunctions->flagBoundDisjunctionModifiable = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
618  boundDisjunctions->flagBoundDisjunctionDynamic = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
619  boundDisjunctions->flagBoundDisjunctionRemovable = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
620  boundDisjunctions->flagBoundDisjunctionStickingatnode = new SCIP_Bool[boundDisjunctions->nBoundDisjunctions];
621  boundDisjunctions->idxBoundDisjunctionVars = new int*[boundDisjunctions->nBoundDisjunctions];
622  boundDisjunctions->boundTypesBoundDisjunction = new SCIP_BOUNDTYPE*[boundDisjunctions->nBoundDisjunctions];
623  boundDisjunctions->boundsBoundDisjunction = new SCIP_Real*[boundDisjunctions->nBoundDisjunctions];
624  for( int i = 0; i < boundDisjunctions->nBoundDisjunctions; i++ )
625  {
626  boundDisjunctions->nVarsBoundDisjunction[i] = diffSubproblem->boundDisjunctions->nVarsBoundDisjunction[i];
627  boundDisjunctions->flagBoundDisjunctionInitial[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionInitial[i];
628  boundDisjunctions->flagBoundDisjunctionSeparate[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionSeparate[i];
629  boundDisjunctions->flagBoundDisjunctionEnforce[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionEnforce[i];
630  boundDisjunctions->flagBoundDisjunctionCheck[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionCheck[i];
631  boundDisjunctions->flagBoundDisjunctionPropagate[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionPropagate[i];
632  boundDisjunctions->flagBoundDisjunctionLocal[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionLocal[i];
633  boundDisjunctions->flagBoundDisjunctionModifiable[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionModifiable[i];
634  boundDisjunctions->flagBoundDisjunctionDynamic[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionDynamic[i];
635  boundDisjunctions->flagBoundDisjunctionRemovable[i] = diffSubproblem->boundDisjunctions->flagBoundDisjunctionRemovable[i];
637  boundDisjunctions->idxBoundDisjunctionVars[i] = diffSubproblem->boundDisjunctions->idxBoundDisjunctionVars[i];
638  if( boundDisjunctions->nVarsBoundDisjunction[i] > 0 )
639  {
640  boundDisjunctions->idxBoundDisjunctionVars[i] = new int[boundDisjunctions->nVarsBoundDisjunction[i]];
641  boundDisjunctions->boundTypesBoundDisjunction[i] = new SCIP_BOUNDTYPE[boundDisjunctions->nVarsBoundDisjunction[i]];
642  boundDisjunctions->boundsBoundDisjunction[i] = new SCIP_Real[boundDisjunctions->nVarsBoundDisjunction[i]];
643  for( int j = 0; j < boundDisjunctions->nVarsBoundDisjunction[i]; j++ )
644  {
645  boundDisjunctions->idxBoundDisjunctionVars[i][j] = diffSubproblem->boundDisjunctions->idxBoundDisjunctionVars[i][j];
646  boundDisjunctions->boundTypesBoundDisjunction[i][j] = diffSubproblem->boundDisjunctions->boundTypesBoundDisjunction[i][j];
647  boundDisjunctions->boundsBoundDisjunction[i][j] = diffSubproblem->boundDisjunctions->boundsBoundDisjunction[i][j];
648  }
649  }
650  }
651  }
652 
653 
654  if( diffSubproblem->varBranchStats )
655  {
656  varBranchStats = new ScipParaDiffSubproblemVarBranchStats();
657  varBranchStats->offset = diffSubproblem->varBranchStats->offset;
658  varBranchStats->nVarBranchStats = diffSubproblem->varBranchStats->nVarBranchStats;
659  varBranchStats->idxBranchStatsVars = new int[varBranchStats->nVarBranchStats];
660  varBranchStats->downpscost = new SCIP_Real[varBranchStats->nVarBranchStats];
661  varBranchStats->uppscost = new SCIP_Real[varBranchStats->nVarBranchStats];
662  varBranchStats->downvsids = new SCIP_Real[varBranchStats->nVarBranchStats];
663  varBranchStats->upvsids = new SCIP_Real[varBranchStats->nVarBranchStats];
664  varBranchStats->downconflen = new SCIP_Real[varBranchStats->nVarBranchStats];
665  varBranchStats->upconflen = new SCIP_Real[varBranchStats->nVarBranchStats];
666  varBranchStats->downinfer = new SCIP_Real[varBranchStats->nVarBranchStats];
667  varBranchStats->upinfer = new SCIP_Real[varBranchStats->nVarBranchStats];
668  varBranchStats->downcutoff = new SCIP_Real[varBranchStats->nVarBranchStats];
669  varBranchStats->upcutoff = new SCIP_Real[varBranchStats->nVarBranchStats];
670  for( int i = 0; i < varBranchStats->nVarBranchStats; ++i )
671  {
672  varBranchStats->idxBranchStatsVars[i] = diffSubproblem->varBranchStats->idxBranchStatsVars[i];
673  varBranchStats->downpscost[i] = diffSubproblem->varBranchStats->downpscost[i];
674  varBranchStats->uppscost[i] = diffSubproblem->varBranchStats->uppscost[i];
675  varBranchStats->downvsids[i] = diffSubproblem->varBranchStats->downvsids[i];
676  varBranchStats->upvsids[i] = diffSubproblem->varBranchStats->upvsids[i];
677  varBranchStats->downconflen[i] = diffSubproblem->varBranchStats->downconflen[i];
678  varBranchStats->upconflen[i] = diffSubproblem->varBranchStats->upconflen[i];
679  varBranchStats->downinfer[i] = diffSubproblem->varBranchStats->downinfer[i];
680  varBranchStats->upinfer[i] = diffSubproblem->varBranchStats->upinfer[i];
681  varBranchStats->downcutoff[i] = diffSubproblem->varBranchStats->downcutoff[i];
682  varBranchStats->upcutoff[i] = diffSubproblem->varBranchStats->upcutoff[i];
683  }
684  }
685 
686  if( diffSubproblem->varValues )
687  {
688  varValues = new ScipParaDiffSubproblemVarValues();
689  varValues->nVarValueVars = diffSubproblem->varValues->nVarValueVars;
690  varValues->nVarValues = diffSubproblem->varValues->nVarValues;
691  varValues->idxVarValueVars = new int[varValues->nVarValueVars];
692  varValues->nVarValueValues = new int[varValues->nVarValueVars];
693  varValues->varValue = new SCIP_Real*[varValues->nVarValueVars];
694  varValues->varValueDownvsids = new SCIP_Real*[varValues->nVarValueVars];
695  varValues->varVlaueUpvsids = new SCIP_Real*[varValues->nVarValueVars];
696  varValues->varValueDownconflen = new SCIP_Real*[varValues->nVarValueVars];
697  varValues->varValueUpconflen = new SCIP_Real*[varValues->nVarValueVars];
698  varValues->varValueDowninfer = new SCIP_Real*[varValues->nVarValueVars];
699  varValues->varValueUpinfer = new SCIP_Real*[varValues->nVarValueVars];
700  varValues->varValueDowncutoff = new SCIP_Real*[varValues->nVarValueVars];
701  varValues->varValueUpcutoff = new SCIP_Real*[varValues->nVarValueVars];
702  for( int i = 0; i < varValues->nVarValueVars; i++ )
703  {
704  varValues->idxVarValueVars[i] = diffSubproblem->varValues->idxVarValueVars[i];
705  varValues->nVarValueValues[i] = diffSubproblem->varValues->nVarValueValues[i];
706  if( varValues->nVarValueValues[i] > 0 )
707  {
708  varValues->varValue[i] = new SCIP_Real[varValues->nVarValueValues[i]];
709  varValues->varValueDownvsids[i] = new SCIP_Real[varValues->nVarValueValues[i]];
710  varValues->varVlaueUpvsids[i] = new SCIP_Real[varValues->nVarValueValues[i]];
711  varValues->varValueDownconflen[i] = new SCIP_Real[varValues->nVarValueValues[i]];
712  varValues->varValueUpconflen[i] = new SCIP_Real[varValues->nVarValueValues[i]];
713  varValues->varValueDowninfer[i] = new SCIP_Real[varValues->nVarValueValues[i]];
714  varValues->varValueUpinfer[i] = new SCIP_Real[varValues->nVarValueValues[i]];
715  varValues->varValueDowncutoff[i] = new SCIP_Real[varValues->nVarValueValues[i]];
716  varValues->varValueUpcutoff[i] = new SCIP_Real[varValues->nVarValueValues[i]];
717  for( int j = 0; j < varValues->nVarValueValues[i]; j++ )
718  {
719  varValues->varValue[i][j] = diffSubproblem->varValues->varValue[i][j];
720  varValues->varValueDownvsids[i][j] = diffSubproblem->varValues->varValueDownvsids[i][j];
721  varValues->varVlaueUpvsids[i][j] = diffSubproblem->varValues->varVlaueUpvsids[i][j];
722  varValues->varValueDownconflen[i][j] = diffSubproblem->varValues->varValueDownconflen[i][j];
723  varValues->varValueUpconflen[i][j] = diffSubproblem->varValues->varValueUpconflen[i][j];
724  varValues->varValueDowninfer[i][j] = diffSubproblem->varValues->varValueDowninfer[i][j];
725  varValues->varValueUpinfer[i][j] = diffSubproblem->varValues->varValueUpinfer[i][j];
726  varValues->varValueDowncutoff[i][j] = diffSubproblem->varValues->varValueDowncutoff[i][j];
727  varValues->varValueUpcutoff[i][j] = diffSubproblem->varValues->varValueUpcutoff[i][j];
728  }
729  }
730  }
731  }
732 #ifdef UG_DEBUG_SOLUTION
733  includeOptimalSol = diffSubproblem->includeOptimalSol;
734 #endif
735  }
736 
737  /** destractor */
739  {
740  if( indicesAmongSolvers ) delete[] indicesAmongSolvers;
741  if( branchBounds ) delete[] branchBounds;
742  if( boundTypes ) delete[] boundTypes;
743  if( branchLinearConss )
744  {
745  delete branchLinearConss;
746  }
747  if( branchSetppcConss )
748  {
749  delete branchSetppcConss;
750  }
751  if( linearConss )
752  {
753  delete linearConss;
754  }
755  if( bendersLinearConss )
756  {
757  delete bendersLinearConss;
758  }
759  if( boundDisjunctions )
760  {
761  delete boundDisjunctions;
762  }
763 
764  if( varBranchStats )
765  {
766  delete varBranchStats;
767  }
768  if( varValues )
769  {
770  delete varValues;
771  }
772  }
773 
774  int getNBoundChanges(){ return nBoundChanges; }
775  int getIndex(int i){ return indicesAmongSolvers[i]; }
776  SCIP_Real getBranchBound(int i){ return branchBounds[i]; }
777  SCIP_BOUNDTYPE getBoundType(int i){ return boundTypes[i]; }
778 
780  {
781  return branchLinearConss;
782  }
783 
785  {
786  return branchSetppcConss;
787  }
788 
790  {
791  if( branchLinearConss )
792  {
793  return branchLinearConss->nLinearConss;
794  }
795  else
796  {
797  return 0;
798  }
799  }
800 
801  SCIP_Real getBranchConsLinearLhs(int i)
802  {
803  assert(branchLinearConss);
804  return branchLinearConss->linearLhss[i];
805  }
806 
807  SCIP_Real getBranchConsLinearRhs(int i)
808  {
809  assert(branchLinearConss);
810  return branchLinearConss->linearRhss[i];
811  }
812 
814  {
815  assert(branchLinearConss);
816  return branchLinearConss->nLinearCoefs[i];
817  }
818 
819  SCIP_Real getBranchConsLinearCoefs(int i, int j)
820  {
821  assert(branchLinearConss);
822  return branchLinearConss->linearCoefs[i][j];
823  }
824 
826  {
827  assert(branchLinearConss);
828  return branchLinearConss->idxLinearCoefsVars[i][j];
829  }
830 
832  {
833  assert(branchLinearConss);
834  return branchLinearConss->lConsNames;
835  }
836 
838  {
839  char *name = branchLinearConss->consNames;
840  for( int j = 0; j < i; j++)
841  {
842  assert(*name);
843  name += (std::strlen(name) + 1);
844  }
845  assert(*name);
846  return name;
847  }
848 
849 
851  {
852  if( branchSetppcConss )
853  {
854  return branchSetppcConss->nSetppcConss;
855  }
856  else
857  {
858  return 0;
859  }
860  }
861 
863  {
864  assert(branchSetppcConss);
865  return branchSetppcConss->nSetppcVars[i];
866  }
867 
869  {
870  assert(branchSetppcConss);
871  return branchSetppcConss->setppcTypes[i];
872  }
873 
874  int getBranchConsSetppcVars(int i, int j)
875  {
876  assert(branchSetppcConss);
877  return branchSetppcConss->idxSetppcVars[i][j];
878  }
879 
881  {
882  assert(branchSetppcConss);
883  return branchSetppcConss->lConsNames;
884  }
885 
887  {
888  char *name = branchSetppcConss->consNames;
889  for( int j = 0; j < i; j++)
890  {
891  assert(*name);
892  name += (std::strlen(name) + 1);
893  }
894  assert(*name);
895  return name;
896  }
897 
898 
900  {
901  if( linearConss )
902  {
903  return linearConss->nLinearConss;
904  }
905  else
906  {
907  return 0;
908  }
909  }
910 
911 
912  SCIP_Real getLinearLhs(int i)
913  {
914  assert(linearConss);
915  return linearConss->linearLhss[i];
916  }
917 
918  SCIP_Real getLinearRhs(int i)
919  {
920  assert(linearConss);
921  return linearConss->linearRhss[i];
922  }
923 
924  int getNLinearCoefs(int i)
925  {
926  assert(linearConss);
927  return linearConss->nLinearCoefs[i];
928  }
929 
930  SCIP_Real getLinearCoefs(int i, int j)
931  {
932  assert(linearConss);
933  return linearConss->linearCoefs[i][j];
934  }
935 
936  int getIdxLinearCoefsVars(int i, int j)
937  {
938  assert(linearConss);
939  return linearConss->idxLinearCoefsVars[i][j];
940  }
941 
943  {
944  if( bendersLinearConss )
945  {
946  return bendersLinearConss->nLinearConss;
947  }
948  else
949  {
950  return 0;
951  }
952  }
953 
954  SCIP_Real getBendersLinearLhs(int i)
955  {
956  assert(bendersLinearConss);
957  return bendersLinearConss->linearLhss[i];
958  }
959 
960  SCIP_Real getBendersLinearRhs(int i)
961  {
962  assert(bendersLinearConss);
963  return bendersLinearConss->linearRhss[i];
964  }
965 
967  {
968  assert(bendersLinearConss);
969  return bendersLinearConss->nLinearCoefs[i];
970  }
971 
972  SCIP_Real getBendersLinearCoefs(int i, int j)
973  {
974  assert(bendersLinearConss);
975  return bendersLinearConss->linearCoefs[i][j];
976  }
977 
979  {
980  assert(bendersLinearConss);
981  return bendersLinearConss->idxLinearCoefsVars[i][j];
982  }
983 
985  {
986  if( boundDisjunctions )
987  {
988  return boundDisjunctions->nBoundDisjunctions;
989  }
990  else
991  {
992  return 0;
993  }
994  }
995 
997  {
998  assert(boundDisjunctions);
999  return boundDisjunctions->nTotalVarsBoundDisjunctions;
1000  }
1001 
1003  assert(boundDisjunctions);
1004  assert( boundDisjunctions->nVarsBoundDisjunction && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1005  return boundDisjunctions->nVarsBoundDisjunction[i];
1006  }
1008  {
1009  assert(boundDisjunctions);
1010  assert( boundDisjunctions->flagBoundDisjunctionInitial && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1011  return boundDisjunctions->flagBoundDisjunctionInitial[i];
1012  }
1014  {
1015  assert(boundDisjunctions);
1016  assert( boundDisjunctions->flagBoundDisjunctionSeparate && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1017  return boundDisjunctions->flagBoundDisjunctionSeparate[i];
1018  }
1020  {
1021  assert(boundDisjunctions);
1022  assert( boundDisjunctions->flagBoundDisjunctionEnforce && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1023  return boundDisjunctions->flagBoundDisjunctionEnforce[i];
1024  }
1026  {
1027  assert(boundDisjunctions);
1028  assert( boundDisjunctions->flagBoundDisjunctionCheck && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1029  return boundDisjunctions->flagBoundDisjunctionCheck[i];
1030  }
1032  {
1033  assert(boundDisjunctions);
1034  assert( boundDisjunctions->flagBoundDisjunctionPropagate && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1035  return boundDisjunctions->flagBoundDisjunctionPropagate[i];
1036  }
1038  {
1039  assert( boundDisjunctions->flagBoundDisjunctionLocal && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1040  return boundDisjunctions->flagBoundDisjunctionLocal[i];
1041  }
1043  {
1044  assert(boundDisjunctions);
1045  assert( boundDisjunctions->flagBoundDisjunctionModifiable && i >= 0 && i <boundDisjunctions->nBoundDisjunctions );
1046  return boundDisjunctions->flagBoundDisjunctionModifiable[i];
1047  }
1049  {
1050  assert(boundDisjunctions);
1051  assert( boundDisjunctions->flagBoundDisjunctionDynamic && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1052  return boundDisjunctions->flagBoundDisjunctionDynamic[i];
1053  }
1055  {
1056  assert(boundDisjunctions);
1057  assert( boundDisjunctions->flagBoundDisjunctionRemovable && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1058  return boundDisjunctions->flagBoundDisjunctionRemovable[i];
1059  }
1061  {
1062  assert(boundDisjunctions);
1063  assert( boundDisjunctions->flagBoundDisjunctionStickingatnode && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1064  return boundDisjunctions->flagBoundDisjunctionStickingatnode[i];
1065  }
1066 
1067  int getIdxBoundDisjunctionVars(int i, int j)
1068  {
1069  assert(boundDisjunctions);
1070  assert( boundDisjunctions->idxBoundDisjunctionVars && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1071  assert( boundDisjunctions->idxBoundDisjunctionVars[i] && j >= 0 && j < boundDisjunctions->nVarsBoundDisjunction[i] );
1072  return boundDisjunctions->idxBoundDisjunctionVars[i][j];
1073  }
1074  SCIP_BOUNDTYPE getBoundTypesBoundDisjunction(int i, int j)
1075  {
1076  assert(boundDisjunctions);
1077  assert( boundDisjunctions->boundTypesBoundDisjunction && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1078  assert( boundDisjunctions->boundTypesBoundDisjunction[i] && j >= 0 && j < boundDisjunctions->nVarsBoundDisjunction[i] );
1079  return boundDisjunctions->boundTypesBoundDisjunction[i][j];
1080  }
1081  SCIP_Real getBoundsBoundDisjunction(int i, int j)
1082  {
1083  assert(boundDisjunctions);
1084  assert( boundDisjunctions->boundsBoundDisjunction && i >= 0 && i < boundDisjunctions->nBoundDisjunctions );
1085  assert( boundDisjunctions->boundsBoundDisjunction[i] && j >= 0 && j < boundDisjunctions->nVarsBoundDisjunction[i] );
1086  return boundDisjunctions->boundsBoundDisjunction[i][j];
1087  }
1088 
1090  {
1091 
1092  if( varBranchStats )
1093  {
1094  return varBranchStats->nVarBranchStats;
1095  }
1096  else
1097  {
1098  return 0;
1099  }
1100  }
1101 
1103  {
1104  assert(varBranchStats);
1105  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1106  return varBranchStats->idxBranchStatsVars[i];
1107  }
1108 
1109  SCIP_Real getDownpscost(int i)
1110  {
1111  assert(varBranchStats);
1112  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1113  return varBranchStats->downpscost[i];
1114  }
1115 
1116  SCIP_Real getUppscost(int i)
1117  {
1118  assert(varBranchStats);
1119  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1120  return varBranchStats->uppscost[i];
1121  }
1122 
1123  SCIP_Real getDownvsids(int i)
1124  {
1125  assert(varBranchStats);
1126  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1127  return varBranchStats->downvsids[i];
1128  }
1129 
1130  SCIP_Real getUpvsids(int i)
1131  {
1132  assert(varBranchStats);
1133  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1134  return varBranchStats->upvsids[i];
1135  }
1136 
1137  SCIP_Real getDownconflen(int i)
1138  {
1139  assert(varBranchStats);
1140  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1141  return varBranchStats->downconflen[i];
1142  }
1143 
1144  SCIP_Real getUpconflen(int i)
1145  {
1146  assert(varBranchStats);
1147  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1148  return varBranchStats->upconflen[i];
1149  }
1150 
1151  SCIP_Real getDowninfer(int i)
1152  {
1153  assert(varBranchStats);
1154  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1155  return varBranchStats->downinfer[i];
1156  }
1157 
1158  SCIP_Real getUpinfer(int i)
1159  {
1160  assert(varBranchStats);
1161  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1162  return varBranchStats->upinfer[i];
1163  }
1164 
1165  SCIP_Real getDowncutoff(int i)
1166  {
1167  assert(varBranchStats);
1168  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1169  return varBranchStats->downcutoff[i];
1170  }
1171 
1172  SCIP_Real getUpcutoff(int i)
1173  {
1174  assert(varBranchStats);
1175  assert( i >= 0 && i <varBranchStats->nVarBranchStats );
1176  return varBranchStats->upcutoff[i];
1177  }
1178 
1179 
1181  {
1182  if( varValues )
1183  {
1184  return varValues->nVarValueVars;
1185  }
1186  else
1187  {
1188  return 0;
1189  }
1190  }
1191 
1193  {
1194  assert(varValues);
1195  return varValues->nVarValues;
1196  }
1197 
1199  {
1200  assert(varValues);
1201  assert(varValues->idxVarValueVars && i >= 0 && i < varValues->nVarValueVars );
1202  return varValues->idxVarValueVars[i];
1203  }
1204 
1206  {
1207  assert(varValues);
1208  assert(varValues->idxVarValueVars && i >= 0 && i < varValues->nVarValueVars );
1209  return varValues->nVarValueValues[i];
1210  }
1211 
1212  SCIP_Real getVarValue(int i, int j)
1213  {
1214  assert(varValues);
1215  assert(varValues->varValue && i >= 0 && i < varValues->nVarValueVars );
1216  assert(varValues->varValue[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1217  return varValues->varValue[i][j];
1218  }
1219 
1220  SCIP_Real getVarValueDownvsids(int i, int j)
1221  {
1222  assert(varValues);
1223  assert(varValues->varValueDownvsids && i >= 0 && i < varValues->nVarValueVars );
1224  assert(varValues->varValueDownvsids[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1225  return varValues->varValueDownvsids[i][j];
1226  }
1227 
1228  SCIP_Real getVarVlaueUpvsids(int i, int j)
1229  {
1230  assert(varValues);
1231  assert(varValues->varVlaueUpvsids && i >= 0 && i < varValues->nVarValueVars );
1232  assert(varValues->varVlaueUpvsids[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1233  return varValues->varVlaueUpvsids[i][j];
1234  }
1235 
1236  SCIP_Real getVarValueDownconflen(int i, int j)
1237  {
1238  assert(varValues);
1239  assert(varValues->varValueDownconflen && i >= 0 && i < varValues->nVarValueVars );
1240  assert(varValues->varValueDownconflen[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1241  return varValues->varValueDownconflen[i][j];
1242  }
1243 
1244  SCIP_Real getVarValueUpconflen(int i, int j)
1245  {
1246  assert(varValues);
1247  assert(varValues->varValueUpconflen && i >= 0 && i < varValues->nVarValueVars );
1248  assert(varValues->varValueUpconflen[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1249  return varValues->varValueUpconflen[i][j];
1250  }
1251 
1252  SCIP_Real getVarValueDowninfer(int i, int j)
1253  {
1254  assert(varValues);
1255  assert(varValues->varValueDowninfer && i >= 0 && i < varValues->nVarValueVars );
1256  assert(varValues->varValueDowninfer[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1257  return varValues->varValueDowninfer[i][j];
1258  }
1259 
1260  SCIP_Real getVarValueUpinfer(int i, int j)
1261  {
1262  assert(varValues);
1263  assert(varValues->varValueUpinfer && i >= 0 && i < varValues->nVarValueVars );
1264  assert(varValues->varValueUpinfer[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1265  return varValues->varValueUpinfer[i][j];
1266  }
1267 
1268  SCIP_Real getVarValueDowncutoff(int i, int j)
1269  {
1270  assert(varValues);
1271  assert(varValues->varValueDowncutoff && i >= 0 && i < varValues->nVarValueVars );
1272  assert(varValues->varValueDowncutoff[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1273  return varValues->varValueDowncutoff[i][j];
1274  }
1275 
1276  SCIP_Real getVarValueUpcutoff(int i, int j)
1277  {
1278  assert(varValues);
1279  assert(varValues->varValueUpcutoff && i >= 0 && i < varValues->nVarValueVars );
1280  assert(varValues->varValueUpcutoff[i] && j >= 0 && j < varValues->nVarValueValues[i] );
1281  return varValues->varValueUpcutoff[i][j];
1282  }
1283 
1284  void addBranchLinearConss(
1285  SCIP *scip,
1286  ScipParaSolver *scipParaSolver,
1287  int nLenarConss,
1288  int nAddedConss,
1289  SCIP_CONS **addedConss
1290  );
1291 
1292  void addBranchSetppcConss(
1293  SCIP *scip,
1294  ScipParaSolver *scipParaSolver,
1295  int nSetpartConss,
1296  int nAddedConss,
1297  SCIP_CONS **addedConss
1298  );
1299 
1300  void addLocalNodeInfo(
1301  SCIP *scip,
1302  ScipParaSolver *scipParaSolver
1303  );
1304 
1305  void addBoundDisjunctions(
1306  SCIP *scip,
1307  ScipParaSolver *scipParaSolver
1308  );
1309 
1310  void addBranchVarStats(
1311  SCIP *scip,
1312  ScipParaSolver *scipParaSolver
1313  );
1314 
1315  void addVarValueStats(
1316  SCIP *scip,
1317  ScipParaSolver *scipParaSolver
1318  );
1319 
1320  void addInitialBranchVarStats(
1321  int minDepth,
1322  int maxDepth,
1323  SCIP *scip
1324  );
1325 
1327  {
1328  assert(varBranchStats);
1329  return varBranchStats->offset;
1330  }
1331 
1332 #ifdef UG_WITH_ZLIB
1333  void write(gzstream::ogzstream &out);
1334  void read(UG::ParaComm *comm, gzstream::igzstream &in, bool onlyBoundChanges);
1335 #endif
1336 
1337  /** get fixed variables **/
1338  int getFixedVariables(
1339  UG::ParaInstance *instance,
1340  UG::BbParaFixedVariable **fixedVars );
1341 
1342  /** create new ParaDiffSubproblem using fixed variables information */
1343  BbParaDiffSubproblem* createDiffSubproblem(
1344  UG::ParaComm *comm,
1345  UG::ParaInitiator *initiator,
1346  int n,
1347  UG::BbParaFixedVariable *fixedVars );
1348 
1349  /** stringfy ParaCalculationState */
1350  const std::string toString(
1351  );
1352 
1353  /** stringfy statistics to log file */
1354  const std::string toStringStat(){
1355  std::ostringstream s;
1356  if (branchLinearConss)
1357  {
1358  s << ", blc: " << branchLinearConss->nLinearConss;
1359  s << "," << branchLinearConss->lConsNames;
1360  }
1361  else
1362  {
1363  s << ", blc: 0";
1364  }
1365  if (branchSetppcConss)
1366  {
1367  s << ", bsc: " << branchSetppcConss->nSetppcConss;
1368  s << "," << branchSetppcConss->lConsNames;
1369  }
1370  else
1371  {
1372  s << ", bsc: 0";
1373  }
1374  if( linearConss )
1375  {
1376  s << ", nl: " << linearConss->nLinearConss;
1377  }
1378  else
1379  {
1380  s << ", nl: 0";
1381  }
1382  if( bendersLinearConss )
1383  {
1384  s << ", bnl: " << bendersLinearConss->nLinearConss;
1385  }
1386  else
1387  {
1388  s << ", nl: 0";
1389  }
1390 
1391 
1392  if ( boundDisjunctions )
1393  {
1394  s << ", nbd: " << boundDisjunctions->nBoundDisjunctions << ", nbdt: " << boundDisjunctions->nTotalVarsBoundDisjunctions;
1395  }
1396  else
1397  {
1398  s << ", nbd: 0, nbdt: 0";
1399  }
1400 
1401  if( varBranchStats )
1402  {
1403  s << ", nbs: " << varBranchStats->nVarBranchStats;
1404  }
1405  else
1406  {
1407  s << ", nbs: 0";
1408  }
1409 
1410  if( varValues )
1411  {
1412  s << ", nvv: " << varValues->nVarValueVars << ", nvvt: " << varValues->nVarValues;
1413  }
1414  else
1415  {
1416  s << ", nvv: 0, nvvt: 0";
1417  }
1418  return s.str();
1419  }
1420 
1421 #ifdef UG_DEBUG_SOLUTION
1422  bool isOptimalSolIncluded(){ return (includeOptimalSol != 0); }
1423  void setOptimalSolIndicator(int i){ includeOptimalSol = i; }
1424 #endif
1425 
1426 };
1427 
1428 }
1429 
1430 #endif // __SCIP_PARA_DIFF_SUBPROBLEM_H__
1431 
ScipParaDiffSubproblemBranchLinearCons * getBranchLinearConss()
SCIP_Real getVarValueUpinfer(int i, int j)
static ScipParaCommTh * comm
Definition: fscip.cpp:73
SCIP_Real getVarValueDownconflen(int i, int j)
Fixed variable struct.
ScipParaDiffSubproblemVarValues * varValues
SCIP_BOUNDTYPE getBoundTypesBoundDisjunction(int i, int j)
SCIP_Real getVarValueDowninfer(int i, int j)
ScipParaDiffSubproblemBranchSetppcCons * getBranchSetppcConss()
ScipParaDiffSubproblemBoundDisjunctions * boundDisjunctions
SCIP_Real getVarValueUpconflen(int i, int j)
SCIP_Real getVarValueUpcutoff(int i, int j)
ScipParaDiffSubproblemLinearCons * linearConss
SCIP_Real getVarValueDowncutoff(int i, int j)
BranchConsSetppcInfo * BranchConsSetppcInfoPtr
Class for initiator.
Definition: paraInitiator.h:62
SCIP_Real getBendersLinearCoefs(int i, int j)
SCIP_Real getBoundsBoundDisjunction(int i, int j)
Base class of communicator for UG Framework.
SCIP_Real getVarVlaueUpvsids(int i, int j)
Class for the difference between instance and subproblem.
class for instance data
Definition: paraInstance.h:50
void read(ParaComm *comm, const char *filename)
read ParaParams from file
ScipParaDiffSubproblemVarBranchStats * varBranchStats
SCIP_Real getBranchConsLinearCoefs(int i, int j)
struct ParaSCIP::BranchConsLinearInfo_t BranchConsLinearInfo
SCIP_Real getVarValueDownvsids(int i, int j)
struct ParaSCIP::BranchConsSetppcInfo_t BranchConsSetppcInfo
ScipParaDiffSubproblemBranchLinearCons * branchLinearConss
BranchConsLinearInfo * BranchConsLinearInfoPtr
ScipParaDiffSubproblemLinearCons * bendersLinearConss
ScipParaDiffSubproblem(ScipParaDiffSubproblem *diffSubproblem)
Base class of communicator object.
Definition: paraComm.h:101
ScipParaDiffSubproblemBranchSetppcCons * branchSetppcConss