Scippy

UG

Ubiquity Generator framework

scipParaDiffSubproblemMpi.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 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 scipParaDiffSubproblemMpi.cpp
27  * @brief ScipParaDiffSubproblem extension for MPI communication.
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 <mpi.h>
38 #include "scipParaCommMpi.h"
40 
41 using namespace UG;
42 using namespace ParaSCIP;
43 
44 /** create ScipDiffSubproblemDatatype1 */
45 /************************************************
46  * Currently, Datatype1 is not necessary. *
47  * I create this code for the future extension. *
48  ************************************************/
49 MPI_Datatype
50 ScipParaDiffSubproblemMpi::createDatatypeCounters(
51  )
52 {
53 
54  int nBlocks = 0;
55 
56  MPI_Datatype datatype;
57 
58  MPI_Aint startAddress = 0;
59  MPI_Aint address = 0;
60 
61 #ifndef UG_DEBUG_SOLUTION
62  int blockLengths[9];
63  MPI_Aint displacements[9];
64  MPI_Datatype types[9];
65 #else
66  int blockLengths[10];
67  MPI_Aint displacements[10];
68  MPI_Datatype types[10];
69 #endif
70 
71  MPI_CALL(
72  MPI_Get_address( &localInfoIncluded, &startAddress )
73  );
74  blockLengths[nBlocks] = 1;
75  displacements[nBlocks] = 0;
76  types[nBlocks] = MPI_INT;
77  nBlocks++;
78 
79  MPI_CALL(
80  MPI_Get_address( &nBoundChanges, &address )
81  );
82  blockLengths[nBlocks] = 1;
83  displacements[nBlocks] = address - startAddress;
84  types[nBlocks] = MPI_INT;
85  nBlocks++;
86 
87  MPI_CALL(
88  MPI_Get_address( &nBranchLinearConss, &address )
89  );
90  blockLengths[nBlocks] = 1;
91  displacements[nBlocks] = address - startAddress;
92  types[nBlocks] = MPI_INT;
93  nBlocks++;
94 
95  MPI_CALL(
96  MPI_Get_address( &nBranchSetppcConss, &address )
97  );
98  blockLengths[nBlocks] = 1;
99  displacements[nBlocks] = address - startAddress;
100  types[nBlocks] = MPI_INT;
101  nBlocks++;
102 
103  MPI_CALL(
104  MPI_Get_address( &nLinearConss, &address )
105  );
106  blockLengths[nBlocks] = 1;
107  displacements[nBlocks] = address - startAddress;
108  types[nBlocks] = MPI_INT;
109  nBlocks++;
110 
111  MPI_CALL(
112  MPI_Get_address( &nBendersLinearConss, &address )
113  );
114  blockLengths[nBlocks] = 1;
115  displacements[nBlocks] = address - startAddress;
116  types[nBlocks] = MPI_INT;
117  nBlocks++;
118 
119  MPI_CALL(
120  MPI_Get_address( &nBoundDisjunctions, &address )
121  );
122  blockLengths[nBlocks] = 1;
123  displacements[nBlocks] = address - startAddress;
124  types[nBlocks] = MPI_INT;
125  nBlocks++;
126 
127  MPI_CALL(
128  MPI_Get_address( &nVarBranchStats, &address )
129  );
130  blockLengths[nBlocks] = 1;
131  displacements[nBlocks] = address - startAddress;
132  types[nBlocks] = MPI_INT;
133  nBlocks++;
134 
135  MPI_CALL(
136  MPI_Get_address( &nVarValueVars, &address )
137  );
138  blockLengths[nBlocks] = 1;
139  displacements[nBlocks] = address - startAddress;
140  types[nBlocks] = MPI_INT;
141  nBlocks++;
142 
143 #ifdef UG_DEBUG_SOLUTION
144  MPI_CALL(
145  MPI_Get_address( &includeOptimalSol, &address )
146  );
147  blockLengths[nBlocks] = 1;
148  displacements[nBlocks] = address - startAddress;
149  types[nBlocks] = MPI_INT;
150  nBlocks++;
151  assert( nBlocks == 10 );
152 #else
153  assert( nBlocks == 9 );
154 #endif
155 
156  MPI_CALL(
157  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
158  );
159 
160  return datatype;
161 }
162 
163 /** create ScipDiffSubproblemDatatype */
164 MPI_Datatype
165 ScipParaDiffSubproblemMpi::createDatatypeBoundChnages(
166  bool memAllocNecessary
167  )
168 {
169  assert( nBoundChanges > 0 );
170 
171  int nBlocks = 0;
172 
173  MPI_Datatype datatype;
174 
175  MPI_Aint startAddress = 0;
176  MPI_Aint address = 0;
177 
178  int blockLengths[3]; // reserve maximum number of elements
179  MPI_Aint displacements[3]; // reserve maximum number of elements
180  MPI_Datatype types[3]; // reserve maximum number of elements
181 
182 
183  if( memAllocNecessary )
184  {
185  indicesAmongSolvers = new int[nBoundChanges];
186  branchBounds = new SCIP_Real[nBoundChanges];
187  boundTypes = new SCIP_BOUNDTYPE[nBoundChanges];
188  }
189 
190  MPI_CALL(
191  MPI_Get_address( indicesAmongSolvers, &startAddress )
192  );
193  displacements[nBlocks] = 0;
194  blockLengths[nBlocks] = nBoundChanges;
195  types[nBlocks] = MPI_INT;
196  nBlocks++;
197 
198  MPI_CALL(
199  MPI_Get_address( branchBounds, &address )
200  );
201  displacements[nBlocks] = address - startAddress;
202  blockLengths[nBlocks] = nBoundChanges;
203  types[nBlocks] = MPI_DOUBLE;
204  nBlocks++;
205 
206  MPI_CALL(
207  MPI_Get_address( boundTypes, &address )
208  );
209  displacements[nBlocks] = address - startAddress;
210  blockLengths[nBlocks] = nBoundChanges;
211  types[nBlocks] = MPI_INT;
212  nBlocks++;
213 
214  MPI_CALL(
215  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
216  );
217 
218  return datatype;
219 }
220 
221 /** create ScipDiffSubproblemDatatype */
222 MPI_Datatype
223 ScipParaDiffSubproblemMpi::createDatatypeBranchLinearConss1(
224  bool memAllocNecessary
225  )
226 {
227  assert(nBranchLinearConss > 0);
228 
229  int nBlocks = 0;
230 
231  MPI_Datatype datatype;
232 
233  MPI_Aint startAddress = 0;
234  MPI_Aint address = 0;
235 
236  int blockLengths[4]; // reserve maximum number of elements
237  MPI_Aint displacements[4]; // reserve maximum number of elements
238  MPI_Datatype types[4]; // reserve maximum number of elements
239 
240  if( memAllocNecessary )
241  {
242  branchLinearConss = new ScipParaDiffSubproblemBranchLinearCons();
243  branchLinearConss->nLinearConss = nBranchLinearConss;
244  branchLinearConss->linearLhss = new SCIP_Real[nBranchLinearConss];
245  branchLinearConss->linearRhss = new SCIP_Real[nBranchLinearConss];
246  branchLinearConss->nLinearCoefs = new int[nBranchLinearConss];
247  }
248  MPI_CALL(
249  MPI_Get_address( branchLinearConss->linearLhss, &startAddress )
250  );
251  displacements[nBlocks] = 0;
252  blockLengths[nBlocks] = branchLinearConss->nLinearConss;
253  types[nBlocks] = MPI_DOUBLE;
254  nBlocks++;
255 
256  MPI_CALL(
257  MPI_Get_address( branchLinearConss->linearRhss, &address )
258  );
259  displacements[nBlocks] = address - startAddress;;
260  blockLengths[nBlocks] = branchLinearConss->nLinearConss;
261  types[nBlocks] = MPI_DOUBLE;
262  nBlocks++;
263 
264  MPI_CALL(
265  MPI_Get_address( branchLinearConss->nLinearCoefs, &address )
266  );
267  displacements[nBlocks] = address - startAddress;;
268  blockLengths[nBlocks] = branchLinearConss->nLinearConss;
269  types[nBlocks] = MPI_INT;
270  nBlocks++;
271 
272  MPI_CALL(
273  MPI_Get_address( &(branchLinearConss->lConsNames), &address )
274  );
275  displacements[nBlocks] = address - startAddress;;
276  blockLengths[nBlocks] = 1;
277  types[nBlocks] = MPI_INT;
278  nBlocks++;
279 
280  MPI_CALL(
281  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
282  );
283 
284  return datatype;
285 }
286 
287 /** create ScipDiffSubproblemDatatype */
288 MPI_Datatype
289 ScipParaDiffSubproblemMpi::createDatatypeBranchLinearConss2(
290  bool memAllocNecessary
291  )
292 {
293  assert(nBranchLinearConss > 0 && branchLinearConss);
294 
295  int nBlocks = 0;
296 
297  MPI_Datatype datatype;
298 
299  MPI_Aint startAddress = 0;
300  MPI_Aint address = 0;
301 
302  int nTotalBlocks = (nBranchLinearConss*2) + 1;
303  int *blockLengths = new int[nTotalBlocks];
304  MPI_Aint *displacements = new MPI_Aint[nTotalBlocks];
305  MPI_Datatype *types = new MPI_Datatype[nTotalBlocks];
306 
307  if( memAllocNecessary )
308  {
309  branchLinearConss->linearCoefs = new SCIP_Real*[nBranchLinearConss];
310  branchLinearConss->idxLinearCoefsVars = new int*[nBranchLinearConss];
311  branchLinearConss->consNames = new char[branchLinearConss->lConsNames];
312  }
313 
314  for(int i = 0; i < nBranchLinearConss; i++ )
315  {
316  if( memAllocNecessary )
317  {
318  branchLinearConss->linearCoefs[i] = new SCIP_Real[branchLinearConss->nLinearCoefs[i]];
319  branchLinearConss->idxLinearCoefsVars[i] = new int[branchLinearConss->nLinearCoefs[i]];
320  }
321  if( i == 0 )
322  {
323  MPI_CALL(
324  MPI_Get_address( branchLinearConss->linearCoefs[i], &startAddress )
325  );
326  displacements[nBlocks] = 0;
327  blockLengths[nBlocks] = branchLinearConss->nLinearCoefs[i];
328  types[nBlocks] = MPI_DOUBLE;
329  nBlocks++;
330  }
331  else
332  {
333  MPI_CALL(
334  MPI_Get_address( branchLinearConss->linearCoefs[i], &address )
335  );
336  displacements[nBlocks] = address - startAddress;
337  blockLengths[nBlocks] = branchLinearConss->nLinearCoefs[i];
338  types[nBlocks] = MPI_DOUBLE;
339  nBlocks++;
340  }
341 
342  MPI_CALL(
343  MPI_Get_address( branchLinearConss->idxLinearCoefsVars[i], &address )
344  );
345  displacements[nBlocks] = address - startAddress;
346  blockLengths[nBlocks] = branchLinearConss->nLinearCoefs[i];
347  types[nBlocks] = MPI_INT;
348  nBlocks++;
349  }
350  MPI_CALL(
351  MPI_Get_address( branchLinearConss->consNames, &address )
352  );
353  displacements[nBlocks] = address - startAddress;
354  blockLengths[nBlocks] = branchLinearConss->lConsNames;
355  types[nBlocks] = MPI_CHAR;
356  nBlocks++;
357 
358  MPI_CALL(
359  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
360  );
361 
362  delete [] blockLengths;
363  delete [] displacements;
364  delete [] types;
365 
366  return datatype;
367 }
368 
369 /** create ScipDiffSubproblemDatatype */
370 MPI_Datatype
371 ScipParaDiffSubproblemMpi::createDatatypeBranchSetppcConss1(
372  bool memAllocNecessary
373  )
374 {
375  assert(nBranchSetppcConss > 0);
376 
377  int nBlocks = 0;
378 
379  MPI_Datatype datatype;
380 
381  MPI_Aint startAddress = 0;
382  MPI_Aint address = 0;
383 
384  int blockLengths[3]; // reserve maximum number of elements
385  MPI_Aint displacements[3]; // reserve maximum number of elements
386  MPI_Datatype types[3]; // reserve maximum number of elements
387 
388  if( memAllocNecessary )
389  {
390  branchSetppcConss = new ScipParaDiffSubproblemBranchSetppcCons();
391  branchSetppcConss->nSetppcConss = nBranchSetppcConss;
392  branchSetppcConss->nSetppcVars = new int[nBranchSetppcConss];
393  branchSetppcConss->setppcTypes = new int[nBranchSetppcConss];
394  }
395  MPI_CALL(
396  MPI_Get_address( branchSetppcConss->nSetppcVars, &startAddress )
397  );
398  displacements[nBlocks] = 0;
399  blockLengths[nBlocks] = branchSetppcConss->nSetppcConss;
400  types[nBlocks] = MPI_INT;
401  nBlocks++;
402 
403  MPI_CALL(
404  MPI_Get_address( branchSetppcConss->setppcTypes, &address )
405  );
406  displacements[nBlocks] = address - startAddress;
407  blockLengths[nBlocks] = branchSetppcConss->nSetppcConss;
408  types[nBlocks] = MPI_INT;
409  nBlocks++;
410 
411  MPI_CALL(
412  MPI_Get_address( &(branchSetppcConss->lConsNames), &address )
413  );
414  displacements[nBlocks] = address - startAddress;
415  blockLengths[nBlocks] = 1;
416  types[nBlocks] = MPI_INT;
417  nBlocks++;
418 
419  MPI_CALL(
420  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
421  );
422 
423  return datatype;
424 }
425 
426 /** create ScipDiffSubproblemDatatype */
427 MPI_Datatype
428 ScipParaDiffSubproblemMpi::createDatatypeBranchSetppcConss2(
429  bool memAllocNecessary
430  )
431 {
432  assert(nBranchSetppcConss > 0 && branchSetppcConss);
433 
434  int nBlocks = 0;
435 
436  MPI_Datatype datatype;
437 
438  MPI_Aint startAddress = 0;
439  MPI_Aint address = 0;
440 
441  int nTotalBlocks = nBranchSetppcConss + 1;
442  int *blockLengths = new int[nTotalBlocks];
443  MPI_Aint *displacements = new MPI_Aint[nTotalBlocks];
444  MPI_Datatype *types = new MPI_Datatype[nTotalBlocks];
445 
446  if( memAllocNecessary )
447  {
448  assert(branchSetppcConss);
449  branchSetppcConss->idxSetppcVars = new int*[nBranchSetppcConss];
450  branchSetppcConss->consNames = new char[branchSetppcConss->lConsNames];
451  }
452 
453  for(int i = 0; i < nBranchSetppcConss; i++ )
454  {
455  if( memAllocNecessary )
456  {
457  branchSetppcConss->idxSetppcVars[i] = new int[branchSetppcConss->nSetppcVars[i]];
458  }
459  if( i == 0 )
460  {
461  MPI_CALL(
462  MPI_Get_address( branchSetppcConss->idxSetppcVars[i], &startAddress )
463  );
464  displacements[nBlocks] = 0;
465  blockLengths[nBlocks] = branchSetppcConss->nSetppcVars[i];
466  types[nBlocks] = MPI_INT;
467  nBlocks++;
468  }
469  else
470  {
471  MPI_CALL(
472  MPI_Get_address( branchSetppcConss->idxSetppcVars[i], &address )
473  );
474  displacements[nBlocks] = address - startAddress;
475  blockLengths[nBlocks] = branchSetppcConss->nSetppcVars[i];
476  types[nBlocks] = MPI_INT;
477  nBlocks++;
478  }
479  }
480  MPI_CALL(
481  MPI_Get_address( branchSetppcConss->consNames, &address )
482  );
483  displacements[nBlocks] = address - startAddress;
484  blockLengths[nBlocks] = branchSetppcConss->lConsNames;
485  types[nBlocks] = MPI_CHAR;
486  nBlocks++;
487 
488  MPI_CALL(
489  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
490  );
491 
492  delete [] blockLengths;
493  delete [] displacements;
494  delete [] types;
495 
496  return datatype;
497 }
498 
499 /** create ScipDiffSubproblemDatatype */
500 MPI_Datatype
501 ScipParaDiffSubproblemMpi::createDatatypeLinearConss1(
502  bool memAllocNecessary
503  )
504 {
505  assert(nLinearConss > 0);
506 
507  int nBlocks = 0;
508 
509  MPI_Datatype datatype;
510 
511  MPI_Aint startAddress = 0;
512  MPI_Aint address = 0;
513 
514  int blockLengths[3]; // reserve maximum number of elements
515  MPI_Aint displacements[3]; // reserve maximum number of elements
516  MPI_Datatype types[3]; // reserve maximum number of elements
517 
518  if( memAllocNecessary )
519  {
520  linearConss = new ScipParaDiffSubproblemLinearCons();
521  linearConss->nLinearConss = nLinearConss;
522  linearConss->linearLhss = new SCIP_Real[nLinearConss];
523  linearConss->linearRhss = new SCIP_Real[nLinearConss];
524  linearConss->nLinearCoefs = new int[nLinearConss];
525  }
526  MPI_CALL(
527  MPI_Get_address( linearConss->linearLhss, &startAddress )
528  );
529  displacements[nBlocks] = 0;
530  blockLengths[nBlocks] = linearConss->nLinearConss;
531  types[nBlocks] = MPI_DOUBLE;
532  nBlocks++;
533 
534  MPI_CALL(
535  MPI_Get_address( linearConss->linearRhss, &address )
536  );
537  displacements[nBlocks] = address - startAddress;
538  blockLengths[nBlocks] = linearConss->nLinearConss;
539  types[nBlocks] = MPI_DOUBLE;
540  nBlocks++;
541 
542  MPI_CALL(
543  MPI_Get_address( linearConss->nLinearCoefs, &address )
544  );
545  displacements[nBlocks] = address - startAddress;
546  blockLengths[nBlocks] = linearConss->nLinearConss;
547  types[nBlocks] = MPI_INT;
548  nBlocks++;
549 
550  MPI_CALL(
551  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
552  );
553 
554  return datatype;
555 }
556 
557 /** create ScipDiffSubproblemDatatype */
558 MPI_Datatype
559 ScipParaDiffSubproblemMpi::createDatatypeLinearConss2(
560  bool memAllocNecessary
561  )
562 {
563  assert(nLinearConss > 0 && linearConss);
564 
565  int nBlocks = 0;
566 
567  MPI_Datatype datatype;
568 
569  MPI_Aint startAddress = 0;
570  MPI_Aint address = 0;
571 
572  int nTotalBlocks = nLinearConss*2;
573  int *blockLengths = new int[nTotalBlocks];
574  MPI_Aint *displacements = new MPI_Aint[nTotalBlocks];
575  MPI_Datatype *types = new MPI_Datatype[nTotalBlocks];
576 
577  if( memAllocNecessary )
578  {
579  linearConss->linearCoefs = new SCIP_Real*[nLinearConss];
580  linearConss->idxLinearCoefsVars = new int*[nLinearConss];
581  }
582 
583  for(int i = 0; i < nLinearConss; i++ )
584  {
585  if( memAllocNecessary )
586  {
587  linearConss->linearCoefs[i] = new SCIP_Real[linearConss->nLinearCoefs[i]];
588  linearConss->idxLinearCoefsVars[i] = new int[linearConss->nLinearCoefs[i]];
589  }
590  if( i == 0 )
591  {
592  MPI_CALL(
593  MPI_Get_address( linearConss->linearCoefs[i], &startAddress )
594  );
595  displacements[nBlocks] = 0;
596  blockLengths[nBlocks] = linearConss->nLinearCoefs[i];
597  types[nBlocks] = MPI_DOUBLE;
598  nBlocks++;
599  }
600  else
601  {
602  MPI_CALL(
603  MPI_Get_address( linearConss->linearCoefs[i], &address )
604  );
605  displacements[nBlocks] = address - startAddress;
606  blockLengths[nBlocks] = linearConss->nLinearCoefs[i];
607  types[nBlocks] = MPI_DOUBLE;
608  nBlocks++;
609  }
610 
611 
612  MPI_CALL(
613  MPI_Get_address( linearConss->idxLinearCoefsVars[i], &address )
614  );
615  displacements[nBlocks] = address - startAddress;
616  blockLengths[nBlocks] = linearConss->nLinearCoefs[i];
617  types[nBlocks] = MPI_INT;
618  nBlocks++;
619  }
620 
621  MPI_CALL(
622  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
623  );
624 
625  delete [] blockLengths;
626  delete [] displacements;
627  delete [] types;
628 
629  return datatype;
630 }
631 
632 /** create ScipDiffSubproblemDatatype */
633 MPI_Datatype
634 ScipParaDiffSubproblemMpi::createDatatypeBendersLinearConss1(
635  bool memAllocNecessary
636  )
637 {
638  assert(nBendersLinearConss > 0);
639 
640  int nBlocks = 0;
641 
642  MPI_Datatype datatype;
643 
644  MPI_Aint startAddress = 0;
645  MPI_Aint address = 0;
646 
647  int blockLengths[3]; // reserve maximum number of elements
648  MPI_Aint displacements[3]; // reserve maximum number of elements
649  MPI_Datatype types[3]; // reserve maximum number of elements
650 
651  if( memAllocNecessary )
652  {
653  bendersLinearConss = new ScipParaDiffSubproblemLinearCons();
654  bendersLinearConss->nLinearConss = nBendersLinearConss;
655  bendersLinearConss->linearLhss = new SCIP_Real[nBendersLinearConss];
656  bendersLinearConss->linearRhss = new SCIP_Real[nBendersLinearConss];
657  bendersLinearConss->nLinearCoefs = new int[nBendersLinearConss];
658  }
659  MPI_CALL(
660  MPI_Get_address( bendersLinearConss->linearLhss, &startAddress )
661  );
662  displacements[nBlocks] = 0;
663  blockLengths[nBlocks] = bendersLinearConss->nLinearConss;
664  types[nBlocks] = MPI_DOUBLE;
665  nBlocks++;
666 
667  MPI_CALL(
668  MPI_Get_address( bendersLinearConss->linearRhss, &address )
669  );
670  displacements[nBlocks] = address - startAddress;
671  blockLengths[nBlocks] = bendersLinearConss->nLinearConss;
672  types[nBlocks] = MPI_DOUBLE;
673  nBlocks++;
674 
675  MPI_CALL(
676  MPI_Get_address( bendersLinearConss->nLinearCoefs, &address )
677  );
678  displacements[nBlocks] = address - startAddress;
679  blockLengths[nBlocks] = bendersLinearConss->nLinearConss;
680  types[nBlocks] = MPI_INT;
681  nBlocks++;
682 
683  MPI_CALL(
684  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
685  );
686 
687  return datatype;
688 }
689 
690 /** create ScipDiffSubproblemDatatype */
691 MPI_Datatype
692 ScipParaDiffSubproblemMpi::createDatatypeBendersLinearConss2(
693  bool memAllocNecessary
694  )
695 {
696  assert(nBendersLinearConss > 0 && bendersLinearConss);
697 
698  int nBlocks = 0;
699 
700  MPI_Datatype datatype;
701 
702  MPI_Aint startAddress = 0;
703  MPI_Aint address = 0;
704 
705  int nTotalBlocks = nBendersLinearConss*2;
706  int *blockLengths = new int[nTotalBlocks];
707  MPI_Aint *displacements = new MPI_Aint[nTotalBlocks];
708  MPI_Datatype *types = new MPI_Datatype[nTotalBlocks];
709 
710  if( memAllocNecessary )
711  {
712  bendersLinearConss->linearCoefs = new SCIP_Real*[nBendersLinearConss];
713  bendersLinearConss->idxLinearCoefsVars = new int*[nBendersLinearConss];
714  }
715 
716  for(int i = 0; i < nBendersLinearConss; i++ )
717  {
718  if( memAllocNecessary )
719  {
720  bendersLinearConss->linearCoefs[i] = new SCIP_Real[bendersLinearConss->nLinearCoefs[i]];
721  bendersLinearConss->idxLinearCoefsVars[i] = new int[bendersLinearConss->nLinearCoefs[i]];
722  }
723  if( i == 0 )
724  {
725  MPI_CALL(
726  MPI_Get_address( bendersLinearConss->linearCoefs[i], &startAddress )
727  );
728  displacements[nBlocks] = 0;
729  blockLengths[nBlocks] = bendersLinearConss->nLinearCoefs[i];
730  types[nBlocks] = MPI_DOUBLE;
731  nBlocks++;
732  }
733  else
734  {
735  MPI_CALL(
736  MPI_Get_address( bendersLinearConss->linearCoefs[i], &address )
737  );
738  displacements[nBlocks] = address - startAddress;
739  blockLengths[nBlocks] = bendersLinearConss->nLinearCoefs[i];
740  types[nBlocks] = MPI_DOUBLE;
741  nBlocks++;
742  }
743 
744 
745  MPI_CALL(
746  MPI_Get_address( bendersLinearConss->idxLinearCoefsVars[i], &address )
747  );
748  displacements[nBlocks] = address - startAddress;
749  blockLengths[nBlocks] = bendersLinearConss->nLinearCoefs[i];
750  types[nBlocks] = MPI_INT;
751  nBlocks++;
752  }
753 
754  MPI_CALL(
755  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
756  );
757 
758  delete [] blockLengths;
759  delete [] displacements;
760  delete [] types;
761 
762  return datatype;
763 }
764 
765 /** create ScipDiffSubproblemDatatype */
766 MPI_Datatype
767 ScipParaDiffSubproblemMpi::createDatatypeBoundDisjunctions1(
768  bool memAllocNecessary
769  )
770 {
771  assert( nBoundDisjunctions > 0 );
772 
773  int nBlocks = 0;
774 
775  MPI_Datatype datatype;
776 
777  MPI_Aint startAddress = 0;
778  MPI_Aint address = 0;
779 
780  int blockLengths[12]; // reserve maximum number of elements
781  MPI_Aint displacements[12]; // reserve maximum number of elements
782  MPI_Datatype types[12]; // reserve maximum number of elements
783 
784  if( memAllocNecessary )
785  {
786  boundDisjunctions = new ScipParaDiffSubproblemBoundDisjunctions();
787  boundDisjunctions->nBoundDisjunctions = nBoundDisjunctions;
788  boundDisjunctions->nVarsBoundDisjunction = new int[nBoundDisjunctions];
789  boundDisjunctions->flagBoundDisjunctionInitial = new SCIP_Bool[nBoundDisjunctions];
790  boundDisjunctions->flagBoundDisjunctionSeparate = new SCIP_Bool[nBoundDisjunctions];
791  boundDisjunctions->flagBoundDisjunctionEnforce = new SCIP_Bool[nBoundDisjunctions];
792  boundDisjunctions->flagBoundDisjunctionCheck = new SCIP_Bool[nBoundDisjunctions];
793  boundDisjunctions->flagBoundDisjunctionPropagate = new SCIP_Bool[nBoundDisjunctions];
794  boundDisjunctions->flagBoundDisjunctionLocal = new SCIP_Bool[nBoundDisjunctions];
795  boundDisjunctions->flagBoundDisjunctionModifiable = new SCIP_Bool[nBoundDisjunctions];
796  boundDisjunctions->flagBoundDisjunctionDynamic = new SCIP_Bool[nBoundDisjunctions];
797  boundDisjunctions->flagBoundDisjunctionRemovable = new SCIP_Bool[nBoundDisjunctions];
798  boundDisjunctions->flagBoundDisjunctionStickingatnode = new SCIP_Bool[nBoundDisjunctions];
799  }
800  MPI_CALL(
801  MPI_Get_address( &(boundDisjunctions->nTotalVarsBoundDisjunctions), &startAddress )
802  );
803  displacements[nBlocks] = 0;
804  blockLengths[nBlocks] = 1;
805  types[nBlocks] = MPI_INT;
806  nBlocks++;
807 
808  MPI_CALL(
809  MPI_Get_address( boundDisjunctions->nVarsBoundDisjunction, &address )
810  );
811  displacements[nBlocks] = address - startAddress;
812  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
813  types[nBlocks] = MPI_UNSIGNED;
814  nBlocks++;
815 
816  MPI_CALL(
817  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionInitial, &address )
818  );
819  displacements[nBlocks] = address - startAddress;
820  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
821  types[nBlocks] = MPI_UNSIGNED;
822  nBlocks++;
823 
824  MPI_CALL(
825  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionSeparate, &address )
826  );
827  displacements[nBlocks] = address - startAddress;
828  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
829  types[nBlocks] = MPI_UNSIGNED;
830  nBlocks++;
831 
832  MPI_CALL(
833  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionEnforce, &address )
834  );
835  displacements[nBlocks] = address - startAddress;
836  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
837  types[nBlocks] = MPI_UNSIGNED;
838  nBlocks++;
839 
840  MPI_CALL(
841  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionCheck, &address )
842  );
843  displacements[nBlocks] = address - startAddress;
844  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
845  types[nBlocks] = MPI_UNSIGNED;
846  nBlocks++;
847 
848  MPI_CALL(
849  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionPropagate, &address )
850  );
851  displacements[nBlocks] = address - startAddress;
852  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
853  types[nBlocks] = MPI_UNSIGNED;
854  nBlocks++;
855 
856  MPI_CALL(
857  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionLocal, &address )
858  );
859  displacements[nBlocks] = address - startAddress;
860  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
861  types[nBlocks] = MPI_UNSIGNED;
862  nBlocks++;
863 
864  MPI_CALL(
865  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionModifiable, &address )
866  );
867  displacements[nBlocks] = address - startAddress;
868  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
869  types[nBlocks] = MPI_UNSIGNED;
870  nBlocks++;
871 
872  MPI_CALL(
873  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionDynamic, &address )
874  );
875  displacements[nBlocks] = address - startAddress;
876  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
877  types[nBlocks] = MPI_UNSIGNED;
878  nBlocks++;
879 
880  MPI_CALL(
881  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionRemovable, &address )
882  );
883  displacements[nBlocks] = address - startAddress;
884  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
885  types[nBlocks] = MPI_UNSIGNED;
886  nBlocks++;
887 
888  MPI_CALL(
889  MPI_Get_address( boundDisjunctions->flagBoundDisjunctionStickingatnode, &address )
890  );
891  displacements[nBlocks] = address - startAddress;
892  blockLengths[nBlocks] = boundDisjunctions->nBoundDisjunctions;
893  types[nBlocks] = MPI_UNSIGNED;
894  nBlocks++;
895 
896  assert(nBlocks == 12);
897 
898  MPI_CALL(
899  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
900  );
901 
902  return datatype;
903 }
904 
905 /** create ScipDiffSubproblemDatatype */
906 MPI_Datatype
907 ScipParaDiffSubproblemMpi::createDatatypeBoundDisjunctions2(
908  bool memAllocNecessary
909  )
910 {
911  assert( nBoundDisjunctions > 0 && boundDisjunctions );
912 
913  int nBlocks = 0;
914 
915  MPI_Datatype datatype;
916 
917  MPI_Aint startAddress = 0;
918  MPI_Aint address = 0;
919 
920  int nTotalBlocks = nBoundDisjunctions*3;
921  int *blockLengths = new int[nTotalBlocks];
922  MPI_Aint *displacements = new MPI_Aint[nTotalBlocks];
923  MPI_Datatype *types = new MPI_Datatype[nTotalBlocks];
924 
925  if( memAllocNecessary )
926  {
927  boundDisjunctions->idxBoundDisjunctionVars = new int*[nBoundDisjunctions];
928  boundDisjunctions->boundTypesBoundDisjunction = new SCIP_BOUNDTYPE*[nBoundDisjunctions];
929  boundDisjunctions->boundsBoundDisjunction = new SCIP_Real*[nBoundDisjunctions];
930  }
931 
932  for( int i = 0; i < nBoundDisjunctions; i++ )
933  {
934  if( memAllocNecessary )
935  {
936  boundDisjunctions->idxBoundDisjunctionVars[i] = new int[boundDisjunctions->nVarsBoundDisjunction[i]];
937  boundDisjunctions->boundTypesBoundDisjunction[i] = new SCIP_BOUNDTYPE[boundDisjunctions->nVarsBoundDisjunction[i]];
938  boundDisjunctions->boundsBoundDisjunction[i] = new SCIP_Real[boundDisjunctions->nVarsBoundDisjunction[i]];
939  }
940  if( i == 0 )
941  {
942  MPI_CALL(
943  MPI_Get_address( boundDisjunctions->idxBoundDisjunctionVars[i], &startAddress )
944  );
945  displacements[nBlocks] = 0;
946  blockLengths[nBlocks] = boundDisjunctions->nVarsBoundDisjunction[i];
947  assert( blockLengths[nBlocks] > 0 );
948  types[nBlocks] = MPI_INT;
949  nBlocks++;
950  }
951  else
952  {
953  MPI_CALL(
954  MPI_Get_address( boundDisjunctions->idxBoundDisjunctionVars[i], &address )
955  );
956  displacements[nBlocks] = address - startAddress;
957  blockLengths[nBlocks] = boundDisjunctions->nVarsBoundDisjunction[i];
958  assert( blockLengths[nBlocks] > 0 );
959  types[nBlocks] = MPI_INT;
960  nBlocks++;
961  }
962 
963 
964  MPI_CALL(
965  MPI_Get_address( boundDisjunctions->boundTypesBoundDisjunction[i], &address )
966  );
967  displacements[nBlocks] = address - startAddress;
968  blockLengths[nBlocks] = boundDisjunctions->nVarsBoundDisjunction[i];
969  assert( blockLengths[nBlocks] > 0 );
970  assert(sizeof(SCIP_BOUNDTYPE) == sizeof(unsigned int));
971  types[nBlocks] = MPI_UNSIGNED; // actual SCIP_BoundType is enum
972  nBlocks++;
973 
974  MPI_CALL(
975  MPI_Get_address( boundDisjunctions->boundsBoundDisjunction[i], &address )
976  );
977  displacements[nBlocks] = address - startAddress;
978  blockLengths[nBlocks] = boundDisjunctions->nVarsBoundDisjunction[i];
979  assert( blockLengths[nBlocks] > 0 );
980  types[nBlocks] = MPI_DOUBLE;
981  nBlocks++;
982  }
983 
984  MPI_CALL(
985  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
986  );
987 
988  delete [] blockLengths;
989  delete [] displacements;
990  delete [] types;
991 
992  return datatype;
993 }
994 
995 /** create ScipDiffSubproblemDatatype */
996 MPI_Datatype
997 ScipParaDiffSubproblemMpi::createDatatypeVarBranchStats(
998  bool memAllocNecessary
999  )
1000 {
1001  assert( nVarBranchStats > 0 );
1002 
1003  int nBlocks = 0;
1004 
1005  MPI_Datatype datatype;
1006 
1007  MPI_Aint startAddress = 0;
1008  MPI_Aint address = 0;
1009 
1010  int blockLengths[12]; // reserve maximum number of elements
1011  MPI_Aint displacements[12]; // reserve maximum number of elements
1012  MPI_Datatype types[12]; // reserve maximum number of elements
1013 
1014  if( memAllocNecessary )
1015  {
1016  varBranchStats = new ScipParaDiffSubproblemVarBranchStats();
1017  varBranchStats->nVarBranchStats = nVarBranchStats;
1018  varBranchStats->idxBranchStatsVars = new int[nVarBranchStats];
1019  varBranchStats->downpscost = new SCIP_Real[nVarBranchStats];
1020  varBranchStats->uppscost = new SCIP_Real[nVarBranchStats];
1021  varBranchStats->downvsids = new SCIP_Real[nVarBranchStats];
1022  varBranchStats->upvsids = new SCIP_Real[nVarBranchStats];
1023  varBranchStats->downconflen = new SCIP_Real[nVarBranchStats];
1024  varBranchStats->upconflen = new SCIP_Real[nVarBranchStats];
1025  varBranchStats->downinfer = new SCIP_Real[nVarBranchStats];
1026  varBranchStats->upinfer = new SCIP_Real[nVarBranchStats];
1027  varBranchStats->downcutoff = new SCIP_Real[nVarBranchStats];
1028  varBranchStats->upcutoff = new SCIP_Real[nVarBranchStats];
1029  }
1030 
1031  MPI_CALL(
1032  MPI_Get_address( &(varBranchStats->offset), &startAddress )
1033  );
1034  displacements[nBlocks] = 0;
1035  blockLengths[nBlocks] = 1;
1036  types[nBlocks] = MPI_INT;
1037  nBlocks++;
1038 
1039  MPI_CALL(
1040  MPI_Get_address( varBranchStats->idxBranchStatsVars, &address )
1041  );
1042  displacements[nBlocks] = address - startAddress;
1043  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1044  types[nBlocks] = MPI_INT;
1045  nBlocks++;
1046 
1047  MPI_CALL(
1048  MPI_Get_address( varBranchStats->downpscost, &address )
1049  );
1050  displacements[nBlocks] = address - startAddress;
1051  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1052  types[nBlocks] = MPI_DOUBLE;
1053  nBlocks++;
1054 
1055  MPI_CALL(
1056  MPI_Get_address( varBranchStats->uppscost, &address )
1057  );
1058  displacements[nBlocks] = address - startAddress;
1059  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1060  types[nBlocks] = MPI_DOUBLE;
1061  nBlocks++;
1062 
1063  MPI_CALL(
1064  MPI_Get_address( varBranchStats->downvsids, &address )
1065  );
1066  displacements[nBlocks] = address - startAddress;
1067  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1068  types[nBlocks] = MPI_DOUBLE;
1069  nBlocks++;
1070 
1071  MPI_CALL(
1072  MPI_Get_address( varBranchStats->upvsids, &address )
1073  );
1074  displacements[nBlocks] = address - startAddress;
1075  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1076  types[nBlocks] = MPI_DOUBLE;
1077  nBlocks++;
1078 
1079  MPI_CALL(
1080  MPI_Get_address( varBranchStats->downconflen, &address )
1081  );
1082  displacements[nBlocks] = address - startAddress;
1083  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1084  types[nBlocks] = MPI_DOUBLE;
1085  nBlocks++;
1086 
1087  MPI_CALL(
1088  MPI_Get_address( varBranchStats->upconflen, &address )
1089  );
1090  displacements[nBlocks] = address - startAddress;
1091  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1092  types[nBlocks] = MPI_DOUBLE;
1093  nBlocks++;
1094 
1095  MPI_CALL(
1096  MPI_Get_address( varBranchStats->downinfer, &address )
1097  );
1098  displacements[nBlocks] = address - startAddress;
1099  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1100  types[nBlocks] = MPI_DOUBLE;
1101  nBlocks++;
1102 
1103  MPI_CALL(
1104  MPI_Get_address( varBranchStats->upinfer, &address )
1105  );
1106  displacements[nBlocks] = address - startAddress;
1107  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1108  types[nBlocks] = MPI_DOUBLE;
1109  nBlocks++;
1110 
1111  MPI_CALL(
1112  MPI_Get_address( varBranchStats->downcutoff, &address )
1113  );
1114  displacements[nBlocks] = address - startAddress;
1115  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1116  types[nBlocks] = MPI_DOUBLE;
1117  nBlocks++;
1118 
1119  MPI_CALL(
1120  MPI_Get_address( varBranchStats->upcutoff, &address )
1121  );
1122  displacements[nBlocks] = address - startAddress;
1123  blockLengths[nBlocks] = varBranchStats->nVarBranchStats;
1124  types[nBlocks] = MPI_DOUBLE;
1125  nBlocks++;
1126 
1127  assert( nBlocks == 12 );
1128 
1129  MPI_CALL(
1130  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
1131  );
1132 
1133  return datatype;
1134 }
1135 
1136 /** create ScipDiffSubproblemDatatype */
1137 MPI_Datatype
1138 ScipParaDiffSubproblemMpi::createDatatypeVarValueVars1(
1139  bool memAllocNecessary
1140  )
1141 {
1142  assert( nVarValueVars > 0 );
1143 
1144  int nBlocks = 0;
1145 
1146  MPI_Datatype datatype;
1147 
1148  MPI_Aint startAddress = 0;
1149  MPI_Aint address = 0;
1150 
1151  int blockLengths[3]; // reserve maximum number of elements
1152  MPI_Aint displacements[3]; // reserve maximum number of elements
1153  MPI_Datatype types[3]; // reserve maximum number of elements
1154 
1155  if( memAllocNecessary )
1156  {
1157  varValues = new ScipParaDiffSubproblemVarValues();
1158  varValues->nVarValueVars = nVarValueVars;
1159  varValues->idxVarValueVars = new int[nVarValueVars];
1160  varValues->nVarValueValues = new int[nVarValueVars];
1161  }
1162 
1163  MPI_CALL(
1164  MPI_Get_address( &(varValues->nVarValues), &startAddress )
1165  );
1166  displacements[nBlocks] = 0;
1167  blockLengths[nBlocks] = 1;
1168  types[nBlocks] = MPI_INT;
1169  nBlocks++;
1170 
1171  MPI_CALL(
1172  MPI_Get_address( varValues->idxVarValueVars, &address )
1173  );
1174  displacements[nBlocks] = address - startAddress;;
1175  blockLengths[nBlocks] = varValues->nVarValueVars;
1176  types[nBlocks] = MPI_INT;
1177  nBlocks++;
1178 
1179  MPI_CALL(
1180  MPI_Get_address( varValues->nVarValueValues, &address )
1181  );
1182  displacements[nBlocks] = address - startAddress;;
1183  blockLengths[nBlocks] = varValues->nVarValueVars;
1184  types[nBlocks] = MPI_INT;
1185  nBlocks++;
1186 
1187  assert( nBlocks == 3);
1188 
1189  MPI_CALL(
1190  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
1191  );
1192 
1193  return datatype;
1194 }
1195 
1196 /** create ScipDiffSubproblemDatatype */
1197 MPI_Datatype
1198 ScipParaDiffSubproblemMpi::createDatatypeVarValueVars2(
1199  bool memAllocNecessary
1200  )
1201 {
1202  assert( nVarValueVars > 0 && varValues);
1203 
1204  int nBlocks = 0;
1205 
1206  MPI_Datatype datatype;
1207 
1208  MPI_Aint startAddress = 0;
1209  MPI_Aint address = 0;
1210 
1211  int nVarValueBlock = 0;
1212  if( nVarValueVars > 0 )
1213  {
1214  for(int i = 0; i < varValues->nVarValueVars; i++ )
1215  {
1216  if( varValues->nVarValueValues[i] > 0 )
1217  {
1218  nVarValueBlock += 9;
1219  }
1220  }
1221  }
1222 
1223  int *blockLengths = new int[nVarValueBlock + 1];
1224  MPI_Aint *displacements = new MPI_Aint[nVarValueBlock + 1];
1225  MPI_Datatype *types = new MPI_Datatype[nVarValueBlock + 1];
1226 
1227  /* this duplicate send of &nVarValueVars is a dummy to get startAddress */
1228  MPI_CALL(
1229  MPI_Get_address( &nVarValueVars, &startAddress )
1230  );
1231  blockLengths[nBlocks] = 1;
1232  displacements[nBlocks] = 0;
1233  types[nBlocks] = MPI_INT;
1234  nBlocks++;
1235 
1236  if( memAllocNecessary )
1237  {
1238  assert(varValues);
1239  varValues->varValue = new SCIP_Real*[nVarValueVars];
1240  varValues->varValueDownvsids = new SCIP_Real*[nVarValueVars];
1241  varValues->varVlaueUpvsids = new SCIP_Real*[nVarValueVars];
1242  varValues->varValueDownconflen = new SCIP_Real*[nVarValueVars];
1243  varValues->varValueUpconflen = new SCIP_Real*[nVarValueVars];
1244  varValues->varValueDowninfer = new SCIP_Real*[nVarValueVars];
1245  varValues->varValueUpinfer = new SCIP_Real*[nVarValueVars];
1246  varValues->varValueDowncutoff = new SCIP_Real*[nVarValueVars];
1247  varValues->varValueUpcutoff = new SCIP_Real*[nVarValueVars];
1248  }
1249 
1250  for(int i = 0; i < nVarValueVars; i++ )
1251  {
1252  if(varValues-> nVarValueValues[i] > 0 )
1253  {
1254  if( memAllocNecessary )
1255  {
1256  varValues->varValue[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1257  varValues->varValueDownvsids[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1258  varValues->varVlaueUpvsids[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1259  varValues->varValueDownconflen[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1260  varValues->varValueUpconflen[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1261  varValues->varValueDowninfer[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1262  varValues->varValueUpinfer[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1263  varValues->varValueDowncutoff[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1264  varValues->varValueUpcutoff[i] = new SCIP_Real[varValues->nVarValueValues[i]];
1265  }
1266 
1267  MPI_CALL(
1268  MPI_Get_address( varValues->varValue[i], &address )
1269  );
1270  displacements[nBlocks] = address - startAddress;
1271  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1272  types[nBlocks] = MPI_DOUBLE;
1273  nBlocks++;
1274 
1275  MPI_CALL(
1276  MPI_Get_address( varValues->varValueDownvsids[i], &address )
1277  );
1278  displacements[nBlocks] = address - startAddress;
1279  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1280  types[nBlocks] = MPI_DOUBLE;
1281  nBlocks++;
1282 
1283  MPI_CALL(
1284  MPI_Get_address( varValues->varVlaueUpvsids[i], &address )
1285  );
1286  displacements[nBlocks] = address - startAddress;
1287  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1288  types[nBlocks] = MPI_DOUBLE;
1289  nBlocks++;
1290 
1291  MPI_CALL(
1292  MPI_Get_address( varValues->varValueDownconflen[i], &address )
1293  );
1294  displacements[nBlocks] = address - startAddress;
1295  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1296  types[nBlocks] = MPI_DOUBLE;
1297  nBlocks++;
1298 
1299  MPI_CALL(
1300  MPI_Get_address( varValues->varValueUpconflen[i], &address )
1301  );
1302  displacements[nBlocks] = address - startAddress;
1303  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1304  types[nBlocks] = MPI_DOUBLE;
1305  nBlocks++;
1306 
1307  MPI_CALL(
1308  MPI_Get_address( varValues->varValueDowninfer[i], &address )
1309  );
1310  displacements[nBlocks] = address - startAddress;
1311  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1312  types[nBlocks] = MPI_DOUBLE;
1313  nBlocks++;
1314 
1315  MPI_CALL(
1316  MPI_Get_address( varValues->varValueUpinfer[i], &address )
1317  );
1318  displacements[nBlocks] = address - startAddress;
1319  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1320  types[nBlocks] = MPI_DOUBLE;
1321  nBlocks++;
1322 
1323  MPI_CALL(
1324  MPI_Get_address( varValues->varValueDowncutoff[i], &address )
1325  );
1326  displacements[nBlocks] = address - startAddress;
1327  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1328  types[nBlocks] = MPI_DOUBLE;
1329  nBlocks++;
1330 
1331  MPI_CALL(
1332  MPI_Get_address( varValues->varValueUpcutoff[i], &address )
1333  );
1334  displacements[nBlocks] = address - startAddress;
1335  blockLengths[nBlocks] = varValues->nVarValueValues[i];
1336  types[nBlocks] = MPI_DOUBLE;
1337  nBlocks++;
1338 
1339  }
1340  }
1341 
1342  MPI_CALL(
1343  MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
1344  );
1345 
1346  delete [] blockLengths;
1347  delete [] displacements;
1348  delete [] types;
1349 
1350  return datatype;
1351 }
1352 
1353 int
1354 ScipParaDiffSubproblemMpi::bcast(ParaComm *comm, int root)
1355 {
1356  DEF_PARA_COMM( commMpi, comm);
1357 
1358  if( branchLinearConss )
1359  {
1360  nBranchLinearConss = branchLinearConss->nLinearConss;
1361  }
1362  if( branchSetppcConss )
1363  {
1364  nBranchSetppcConss = branchSetppcConss->nSetppcConss;
1365  }
1366  if( linearConss )
1367  {
1368  nLinearConss = linearConss->nLinearConss;
1369  }
1370  if( bendersLinearConss )
1371  {
1372  nBendersLinearConss = bendersLinearConss->nLinearConss;
1373  }
1374  if( boundDisjunctions )
1375  {
1376  nBoundDisjunctions = boundDisjunctions->nBoundDisjunctions;
1377  }
1378  if( varBranchStats )
1379  {
1380  nVarBranchStats = varBranchStats->nVarBranchStats;
1381  }
1382  if( varValues )
1383  {
1384  nVarValueVars = varValues->nVarValueVars;
1385  }
1386 
1387  MPI_Datatype datatypeCounters;
1388  datatypeCounters = createDatatypeCounters();
1389  MPI_CALL(
1390  MPI_Type_commit( &datatypeCounters )
1391  );
1393  commMpi->ubcast(&localInfoIncluded, 1, datatypeCounters, root)
1394  );
1395  MPI_CALL(
1396  MPI_Type_free( &datatypeCounters )
1397  );
1398 
1399  if( nBoundChanges > 0 )
1400  {
1401  MPI_Datatype datatypeBoundChanges;
1402  if( comm->getRank() == root )
1403  {
1404  datatypeBoundChanges = createDatatypeBoundChnages(false);
1405  }
1406  else
1407  {
1408  datatypeBoundChanges = createDatatypeBoundChnages(true);
1409  }
1410  MPI_CALL(
1411  MPI_Type_commit( &datatypeBoundChanges )
1412  );
1414  commMpi->ubcast(indicesAmongSolvers, 1, datatypeBoundChanges, root)
1415  );
1416 
1417  MPI_CALL(
1418  MPI_Type_free( &datatypeBoundChanges )
1419  );
1420  }
1421 
1422  if( nBranchLinearConss > 0 )
1423  {
1424  MPI_Datatype datatypeBranchLinearConss1;
1425  if( comm->getRank() == root )
1426  {
1427  datatypeBranchLinearConss1 = createDatatypeBranchLinearConss1(false);
1428  }
1429  else
1430  {
1431  datatypeBranchLinearConss1 = createDatatypeBranchLinearConss1(true);
1432  }
1433  MPI_CALL(
1434  MPI_Type_commit( &datatypeBranchLinearConss1 )
1435  );
1437  commMpi->ubcast(branchLinearConss->linearLhss, 1, datatypeBranchLinearConss1, root)
1438  );
1439 
1440  MPI_CALL(
1441  MPI_Type_free( &datatypeBranchLinearConss1 )
1442  );
1443 
1444  MPI_Datatype datatypeBranchLinearConss2;
1445  if( comm->getRank() == root )
1446  {
1447  datatypeBranchLinearConss2 = createDatatypeBranchLinearConss2(false);
1448  }
1449  else
1450  {
1451  datatypeBranchLinearConss2 = createDatatypeBranchLinearConss2(true);
1452  }
1453  MPI_CALL(
1454  MPI_Type_commit( &datatypeBranchLinearConss2 )
1455  );
1457  commMpi->ubcast(branchLinearConss->linearCoefs[0], 1, datatypeBranchLinearConss2, root)
1458  );
1459 
1460  MPI_CALL(
1461  MPI_Type_free( &datatypeBranchLinearConss2 )
1462  );
1463  }
1464 
1465  if( nBranchSetppcConss > 0 )
1466  {
1467  MPI_Datatype datatypeBranchSetppcConss1;
1468  if( comm->getRank() == root )
1469  {
1470  datatypeBranchSetppcConss1 = createDatatypeBranchSetppcConss1(false);
1471  }
1472  else
1473  {
1474  datatypeBranchSetppcConss1 = createDatatypeBranchSetppcConss1(true);
1475  }
1476  MPI_CALL(
1477  MPI_Type_commit( &datatypeBranchSetppcConss1 )
1478  );
1480  commMpi->ubcast(branchSetppcConss->nSetppcVars, 1, datatypeBranchSetppcConss1, root)
1481  );
1482 
1483  MPI_CALL(
1484  MPI_Type_free( &datatypeBranchSetppcConss1 )
1485  );
1486 
1487  MPI_Datatype datatypeBranchSetppcConss2;
1488  if( comm->getRank() == root )
1489  {
1490  datatypeBranchSetppcConss2 = createDatatypeBranchSetppcConss2(false);
1491  }
1492  else
1493  {
1494  datatypeBranchSetppcConss2 = createDatatypeBranchSetppcConss2(true);
1495  }
1496  MPI_CALL(
1497  MPI_Type_commit( &datatypeBranchSetppcConss2 )
1498  );
1500  commMpi->ubcast(branchSetppcConss->idxSetppcVars[0], 1, datatypeBranchSetppcConss2, root)
1501  );
1502 
1503  MPI_CALL(
1504  MPI_Type_free( &datatypeBranchSetppcConss2 )
1505  );
1506  }
1507 
1508  if( nLinearConss > 0 )
1509  {
1510  MPI_Datatype datatypeLinearConss1;
1511  if( comm->getRank() == root )
1512  {
1513  datatypeLinearConss1 = createDatatypeLinearConss1(false);
1514  }
1515  else
1516  {
1517  datatypeLinearConss1 = createDatatypeLinearConss1(true);
1518  }
1519  MPI_CALL(
1520  MPI_Type_commit( &datatypeLinearConss1 )
1521  );
1523  commMpi->ubcast(linearConss->linearLhss, 1, datatypeLinearConss1, root)
1524  );
1525 
1526  MPI_CALL(
1527  MPI_Type_free( &datatypeLinearConss1 )
1528  );
1529 
1530  MPI_Datatype datatypeLinearConss2;
1531  if( comm->getRank() == root )
1532  {
1533  datatypeLinearConss2 = createDatatypeLinearConss2(false);
1534  }
1535  else
1536  {
1537  datatypeLinearConss2 = createDatatypeLinearConss2(true);
1538  }
1539  MPI_CALL(
1540  MPI_Type_commit( &datatypeLinearConss2 )
1541  );
1543  commMpi->ubcast(linearConss->linearCoefs[0], 1, datatypeLinearConss2, root)
1544  );
1545 
1546  MPI_CALL(
1547  MPI_Type_free( &datatypeLinearConss2 )
1548  );
1549  }
1550 
1551  if( nBendersLinearConss > 0 )
1552  {
1553  MPI_Datatype datatypeBendersLinearConss1;
1554  if( comm->getRank() == root )
1555  {
1556  datatypeBendersLinearConss1 = createDatatypeBendersLinearConss1(false);
1557  }
1558  else
1559  {
1560  datatypeBendersLinearConss1 = createDatatypeBendersLinearConss1(true);
1561  }
1562  MPI_CALL(
1563  MPI_Type_commit( &datatypeBendersLinearConss1 )
1564  );
1566  commMpi->ubcast(bendersLinearConss->linearLhss, 1, datatypeBendersLinearConss1, root)
1567  );
1568 
1569  MPI_CALL(
1570  MPI_Type_free( &datatypeBendersLinearConss1 )
1571  );
1572 
1573  MPI_Datatype datatypeBendersLinearConss2;
1574  if( comm->getRank() == root )
1575  {
1576  datatypeBendersLinearConss2 = createDatatypeBendersLinearConss2(false);
1577  }
1578  else
1579  {
1580  datatypeBendersLinearConss2 = createDatatypeBendersLinearConss2(true);
1581  }
1582  MPI_CALL(
1583  MPI_Type_commit( &datatypeBendersLinearConss2 )
1584  );
1586  commMpi->ubcast(bendersLinearConss->linearCoefs[0], 1, datatypeBendersLinearConss2, root)
1587  );
1588 
1589  MPI_CALL(
1590  MPI_Type_free( &datatypeBendersLinearConss2 )
1591  );
1592  }
1593 
1594  if( nBoundDisjunctions > 0 )
1595  {
1596  MPI_Datatype datatypeBoundDisjunctions1;
1597  if( comm->getRank() == root )
1598  {
1599  datatypeBoundDisjunctions1 = createDatatypeBoundDisjunctions1(false);
1600  }
1601  else
1602  {
1603  datatypeBoundDisjunctions1 = createDatatypeBoundDisjunctions1(true);
1604  }
1605  MPI_CALL(
1606  MPI_Type_commit( &datatypeBoundDisjunctions1 )
1607  );
1609  commMpi->ubcast(&(boundDisjunctions->nTotalVarsBoundDisjunctions), 1, datatypeBoundDisjunctions1, root)
1610  );
1611 
1612  MPI_CALL(
1613  MPI_Type_free( &datatypeBoundDisjunctions1 )
1614  );
1615 
1616  MPI_Datatype datatypeBoundDisjunctions2;
1617  if( comm->getRank() == root )
1618  {
1619  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(false);
1620  }
1621  else
1622  {
1623  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(true);
1624  }
1625  MPI_CALL(
1626  MPI_Type_commit( &datatypeBoundDisjunctions2 )
1627  );
1629  commMpi->ubcast(boundDisjunctions->idxBoundDisjunctionVars[0], 1, datatypeBoundDisjunctions2, root)
1630  );
1631 
1632  MPI_CALL(
1633  MPI_Type_free( &datatypeBoundDisjunctions2 )
1634  );
1635  }
1636 
1637  if( nVarBranchStats > 0 )
1638  {
1639  MPI_Datatype datatypeVarBranchStats;
1640  if( comm->getRank() == root )
1641  {
1642  datatypeVarBranchStats = createDatatypeVarBranchStats(false);
1643  }
1644  else
1645  {
1646  datatypeVarBranchStats = createDatatypeVarBranchStats(true);
1647  }
1648  MPI_CALL(
1649  MPI_Type_commit( &datatypeVarBranchStats )
1650  );
1652  commMpi->ubcast(&(varBranchStats->offset), 1, datatypeVarBranchStats, root)
1653  );
1654 
1655  MPI_CALL(
1656  MPI_Type_free( &datatypeVarBranchStats )
1657  );
1658  }
1659 
1660  if( nVarValueVars > 0 )
1661  {
1662  MPI_Datatype datatypeVarValueVars1;
1663  if( comm->getRank() == root )
1664  {
1665  datatypeVarValueVars1 = createDatatypeVarValueVars1(false);
1666  }
1667  else
1668  {
1669  datatypeVarValueVars1 = createDatatypeVarValueVars1(true);
1670  }
1671  MPI_CALL(
1672  MPI_Type_commit( &datatypeVarValueVars1 )
1673  );
1675  commMpi->ubcast(&(varValues->nVarValues), 1, datatypeVarValueVars1, root)
1676  );
1677 
1678  MPI_CALL(
1679  MPI_Type_free( &datatypeVarValueVars1 )
1680  );
1681 
1682  MPI_Datatype datatypeBoundDisjunctions2;
1683  if( comm->getRank() == root )
1684  {
1685  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(false);
1686  }
1687  else
1688  {
1689  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(true);
1690  }
1691  MPI_CALL(
1692  MPI_Type_commit( &datatypeBoundDisjunctions2 )
1693  );
1695  commMpi->ubcast(&nVarValueVars, 1, datatypeBoundDisjunctions2, root)
1696  );
1697 
1698  MPI_CALL(
1699  MPI_Type_free( &datatypeBoundDisjunctions2 )
1700  );
1701  }
1702 
1703  return 0;
1704 }
1705 
1706 int
1707 ScipParaDiffSubproblemMpi::send(ParaComm *comm, int dest)
1708 {
1709  DEF_PARA_COMM( commMpi, comm);
1710 
1711  if( branchLinearConss )
1712  {
1713  nBranchLinearConss = branchLinearConss->nLinearConss;
1714  }
1715  if( branchSetppcConss )
1716  {
1717  nBranchSetppcConss = branchSetppcConss->nSetppcConss;
1718  }
1719  if( linearConss )
1720  {
1721  nLinearConss = linearConss->nLinearConss;
1722  }
1723  if( bendersLinearConss )
1724  {
1725  nBendersLinearConss = bendersLinearConss->nLinearConss;
1726  }
1727  if( boundDisjunctions )
1728  {
1729  nBoundDisjunctions = boundDisjunctions->nBoundDisjunctions;
1730  }
1731  if( varBranchStats )
1732  {
1733  nVarBranchStats = varBranchStats->nVarBranchStats;
1734  }
1735  if( varValues )
1736  {
1737  nVarValueVars = varValues->nVarValueVars;
1738  }
1739 
1740 
1741  MPI_Datatype datatypeCounters;
1742  datatypeCounters = createDatatypeCounters();
1743  MPI_CALL(
1744  MPI_Type_commit( &datatypeCounters )
1745  );
1747  commMpi->usend(&localInfoIncluded, 1, datatypeCounters, dest, TagDiffSubproblem)
1748  );
1749  MPI_CALL(
1750  MPI_Type_free( &datatypeCounters )
1751  );
1752 
1753  if( nBoundChanges > 0 )
1754  {
1755  MPI_Datatype datatypeBoundChanges;
1756  datatypeBoundChanges = createDatatypeBoundChnages(false);
1757  MPI_CALL(
1758  MPI_Type_commit( &datatypeBoundChanges )
1759  );
1761  commMpi->usend(indicesAmongSolvers, 1, datatypeBoundChanges, dest, TagDiffSubproblem1)
1762  );
1763 
1764  MPI_CALL(
1765  MPI_Type_free( &datatypeBoundChanges )
1766  );
1767  }
1768 
1769  if( nBranchLinearConss > 0 )
1770  {
1771  MPI_Datatype datatypeBranchLinearConss1;
1772  datatypeBranchLinearConss1 = createDatatypeBranchLinearConss1(false);
1773  MPI_CALL(
1774  MPI_Type_commit( &datatypeBranchLinearConss1 )
1775  );
1777  commMpi->usend(branchLinearConss->linearLhss, 1, datatypeBranchLinearConss1, dest, TagDiffSubproblem2)
1778  );
1779 
1780  MPI_CALL(
1781  MPI_Type_free( &datatypeBranchLinearConss1 )
1782  );
1783 
1784  MPI_Datatype datatypeBranchLinearConss2;
1785  datatypeBranchLinearConss2 = createDatatypeBranchLinearConss2(false);
1786  MPI_CALL(
1787  MPI_Type_commit( &datatypeBranchLinearConss2 )
1788  );
1790  commMpi->usend(branchLinearConss->linearCoefs[0], 1, datatypeBranchLinearConss2, dest, TagDiffSubproblem3)
1791  );
1792 
1793  MPI_CALL(
1794  MPI_Type_free( &datatypeBranchLinearConss2 )
1795  );
1796  }
1797 
1798  if( nBranchSetppcConss > 0 )
1799  {
1800  MPI_Datatype datatypeBranchSetppcConss1;
1801  datatypeBranchSetppcConss1 = createDatatypeBranchSetppcConss1(false);
1802  MPI_CALL(
1803  MPI_Type_commit( &datatypeBranchSetppcConss1 )
1804  );
1806  commMpi->usend(branchSetppcConss->nSetppcVars, 1, datatypeBranchSetppcConss1, dest, TagDiffSubproblem4)
1807  );
1808 
1809  MPI_CALL(
1810  MPI_Type_free( &datatypeBranchSetppcConss1 )
1811  );
1812 
1813  MPI_Datatype datatypeBranchSetppcConss2;
1814  datatypeBranchSetppcConss2 = createDatatypeBranchSetppcConss2(false);
1815  MPI_CALL(
1816  MPI_Type_commit( &datatypeBranchSetppcConss2 )
1817  );
1819  commMpi->usend(branchSetppcConss->idxSetppcVars[0], 1, datatypeBranchSetppcConss2, dest, TagDiffSubproblem5)
1820  );
1821 
1822  MPI_CALL(
1823  MPI_Type_free( &datatypeBranchSetppcConss2 )
1824  );
1825  }
1826 
1827  if( nLinearConss > 0 )
1828  {
1829  MPI_Datatype datatypeLinearConss1;
1830  datatypeLinearConss1 = createDatatypeLinearConss1(false);
1831  MPI_CALL(
1832  MPI_Type_commit( &datatypeLinearConss1 )
1833  );
1835  commMpi->usend(linearConss->linearLhss, 1, datatypeLinearConss1, dest, TagDiffSubproblem6)
1836  );
1837 
1838  MPI_CALL(
1839  MPI_Type_free( &datatypeLinearConss1 )
1840  );
1841 
1842  MPI_Datatype datatypeLinearConss2;
1843  datatypeLinearConss2 = createDatatypeLinearConss2(false);
1844  MPI_CALL(
1845  MPI_Type_commit( &datatypeLinearConss2 )
1846  );
1848  commMpi->usend(linearConss->linearCoefs[0], 1, datatypeLinearConss2, dest, TagDiffSubproblem7)
1849  );
1850 
1851  MPI_CALL(
1852  MPI_Type_free( &datatypeLinearConss2 )
1853  );
1854  }
1855 
1856  if( nBendersLinearConss > 0 )
1857  {
1858  MPI_Datatype datatypeBendersLinearConss1;
1859  datatypeBendersLinearConss1 = createDatatypeBendersLinearConss1(false);
1860  MPI_CALL(
1861  MPI_Type_commit( &datatypeBendersLinearConss1 )
1862  );
1864  commMpi->usend(bendersLinearConss->linearLhss, 1, datatypeBendersLinearConss1, dest, TagDiffSubproblem8)
1865  );
1866 
1867  MPI_CALL(
1868  MPI_Type_free( &datatypeBendersLinearConss1 )
1869  );
1870 
1871  MPI_Datatype datatypeBendersLinearConss2;
1872  datatypeBendersLinearConss2 = createDatatypeBendersLinearConss2(false);
1873  MPI_CALL(
1874  MPI_Type_commit( &datatypeBendersLinearConss2 )
1875  );
1877  commMpi->usend(bendersLinearConss->linearCoefs[0], 1, datatypeBendersLinearConss2, dest, TagDiffSubproblem9)
1878  );
1879 
1880  MPI_CALL(
1881  MPI_Type_free( &datatypeBendersLinearConss2 )
1882  );
1883  }
1884 
1885  if( nBoundDisjunctions > 0 )
1886  {
1887  MPI_Datatype datatypeBoundDisjunctions1;
1888  datatypeBoundDisjunctions1 = createDatatypeBoundDisjunctions1(false);
1889  MPI_CALL(
1890  MPI_Type_commit( &datatypeBoundDisjunctions1 )
1891  );
1893  commMpi->usend(&(boundDisjunctions->nTotalVarsBoundDisjunctions), 1, datatypeBoundDisjunctions1, dest, TagDiffSubproblem10)
1894  );
1895 
1896  MPI_CALL(
1897  MPI_Type_free( &datatypeBoundDisjunctions1 )
1898  );
1899 
1900  MPI_Datatype datatypeBoundDisjunctions2;
1901  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(false);
1902  MPI_CALL(
1903  MPI_Type_commit( &datatypeBoundDisjunctions2 )
1904  );
1906  commMpi->usend(boundDisjunctions->idxBoundDisjunctionVars[0], 1, datatypeBoundDisjunctions2, dest, TagDiffSubproblem11)
1907  // commMpi->usend(&(boundDisjunctions->idxBoundDisjunctionVars[0]), 1, datatypeBoundDisjunctions2, dest, TagDiffSubproblem11)
1908  );
1909 
1910  MPI_CALL(
1911  MPI_Type_free( &datatypeBoundDisjunctions2 )
1912  );
1913  }
1914 
1915  if( nVarBranchStats > 0 )
1916  {
1917  MPI_Datatype datatypeVarBranchStats;
1918  datatypeVarBranchStats = createDatatypeVarBranchStats(false);
1919  MPI_CALL(
1920  MPI_Type_commit( &datatypeVarBranchStats )
1921  );
1923  commMpi->usend(&(varBranchStats->offset), 1, datatypeVarBranchStats, dest, TagDiffSubproblem12)
1924  );
1925 
1926  MPI_CALL(
1927  MPI_Type_free( &datatypeVarBranchStats )
1928  );
1929  }
1930 
1931  if( nVarValueVars > 0 )
1932  {
1933  MPI_Datatype datatypeVarValueVars1;
1934  datatypeVarValueVars1 = createDatatypeVarValueVars1(false);
1935  MPI_CALL(
1936  MPI_Type_commit( &datatypeVarValueVars1 )
1937  );
1939  commMpi->usend(&(varValues->nVarValues), 1, datatypeVarValueVars1, dest, TagDiffSubproblem13)
1940  );
1941 
1942  MPI_CALL(
1943  MPI_Type_free( &datatypeVarValueVars1 )
1944  );
1945 
1946  MPI_Datatype datatypeBoundDisjunctions2;
1947  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(false);
1948  MPI_CALL(
1949  MPI_Type_commit( &datatypeBoundDisjunctions2 )
1950  );
1952  commMpi->usend(&nVarValueVars, 1, datatypeBoundDisjunctions2, dest, TagDiffSubproblem14)
1953  );
1954 
1955  MPI_CALL(
1956  MPI_Type_free( &datatypeBoundDisjunctions2 )
1957  );
1958  }
1959  return 0;
1960 }
1961 
1962 int
1963 ScipParaDiffSubproblemMpi::receive(ParaComm *comm, int source)
1964 {
1965  DEF_PARA_COMM( commMpi, comm);
1966 
1967  MPI_Datatype datatypeCounters;
1968  datatypeCounters = createDatatypeCounters();
1969  MPI_CALL(
1970  MPI_Type_commit( &datatypeCounters )
1971  );
1973  commMpi->ureceive(&localInfoIncluded, 1, datatypeCounters, source, TagDiffSubproblem)
1974  );
1975  MPI_CALL(
1976  MPI_Type_free( &datatypeCounters )
1977  );
1978 
1979  if( nBoundChanges > 0 )
1980  {
1981  MPI_Datatype datatypeBoundChanges;
1982  datatypeBoundChanges = createDatatypeBoundChnages(true);
1983  MPI_CALL(
1984  MPI_Type_commit( &datatypeBoundChanges )
1985  );
1987  commMpi->ureceive(indicesAmongSolvers, 1, datatypeBoundChanges, source, TagDiffSubproblem1)
1988  );
1989 
1990  MPI_CALL(
1991  MPI_Type_free( &datatypeBoundChanges )
1992  );
1993  }
1994 
1995  if( nBranchLinearConss > 0 )
1996  {
1997  MPI_Datatype datatypeBranchLinearConss1;
1998  datatypeBranchLinearConss1 = createDatatypeBranchLinearConss1(true);
1999  MPI_CALL(
2000  MPI_Type_commit( &datatypeBranchLinearConss1 )
2001  );
2003  commMpi->ureceive(branchLinearConss->linearLhss, 1, datatypeBranchLinearConss1, source, TagDiffSubproblem2)
2004  );
2005 
2006  MPI_CALL(
2007  MPI_Type_free( &datatypeBranchLinearConss1 )
2008  );
2009 
2010  MPI_Datatype datatypeBranchLinearConss2;
2011  datatypeBranchLinearConss2 = createDatatypeBranchLinearConss2(true);
2012  MPI_CALL(
2013  MPI_Type_commit( &datatypeBranchLinearConss2 )
2014  );
2016  commMpi->ureceive(branchLinearConss->linearCoefs[0], 1, datatypeBranchLinearConss2, source, TagDiffSubproblem3)
2017  );
2018 
2019  MPI_CALL(
2020  MPI_Type_free( &datatypeBranchLinearConss2 )
2021  );
2022  }
2023 
2024  if( nBranchSetppcConss > 0 )
2025  {
2026  MPI_Datatype datatypeBranchSetppcConss1;
2027  datatypeBranchSetppcConss1 = createDatatypeBranchSetppcConss1(true);
2028  MPI_CALL(
2029  MPI_Type_commit( &datatypeBranchSetppcConss1 )
2030  );
2032  commMpi->ureceive(branchSetppcConss->nSetppcVars, 1, datatypeBranchSetppcConss1, source, TagDiffSubproblem4)
2033  );
2034 
2035  MPI_CALL(
2036  MPI_Type_free( &datatypeBranchSetppcConss1 )
2037  );
2038 
2039  MPI_Datatype datatypeBranchSetppcConss2;
2040  datatypeBranchSetppcConss2 = createDatatypeBranchSetppcConss2(true);
2041  MPI_CALL(
2042  MPI_Type_commit( &datatypeBranchSetppcConss2 )
2043  );
2045  commMpi->ureceive(branchSetppcConss->idxSetppcVars[0], 1, datatypeBranchSetppcConss2, source, TagDiffSubproblem5)
2046  );
2047 
2048  MPI_CALL(
2049  MPI_Type_free( &datatypeBranchSetppcConss2 )
2050  );
2051  }
2052 
2053  if( nLinearConss > 0 )
2054  {
2055  MPI_Datatype datatypeLinearConss1;
2056  datatypeLinearConss1 = createDatatypeLinearConss1(true);
2057  MPI_CALL(
2058  MPI_Type_commit( &datatypeLinearConss1 )
2059  );
2061  commMpi->ureceive(linearConss->linearLhss, 1, datatypeLinearConss1, source, TagDiffSubproblem6)
2062  );
2063 
2064  MPI_CALL(
2065  MPI_Type_free( &datatypeLinearConss1 )
2066  );
2067 
2068  MPI_Datatype datatypeLinearConss2;
2069  datatypeLinearConss2 = createDatatypeLinearConss2(true);
2070  MPI_CALL(
2071  MPI_Type_commit( &datatypeLinearConss2 )
2072  );
2074  commMpi->ureceive(linearConss->linearCoefs[0], 1, datatypeLinearConss2, source, TagDiffSubproblem7)
2075  );
2076 
2077  MPI_CALL(
2078  MPI_Type_free( &datatypeLinearConss2 )
2079  );
2080  }
2081 
2082  if( nBendersLinearConss > 0 )
2083  {
2084  MPI_Datatype datatypeBendersLinearConss1;
2085  datatypeBendersLinearConss1 = createDatatypeBendersLinearConss1(true);
2086  MPI_CALL(
2087  MPI_Type_commit( &datatypeBendersLinearConss1 )
2088  );
2090  commMpi->ureceive(bendersLinearConss->linearLhss, 1, datatypeBendersLinearConss1, source, TagDiffSubproblem8)
2091  );
2092 
2093  MPI_CALL(
2094  MPI_Type_free( &datatypeBendersLinearConss1 )
2095  );
2096 
2097  MPI_Datatype datatypeBendersLinearConss2;
2098  datatypeBendersLinearConss2 = createDatatypeBendersLinearConss2(true);
2099  MPI_CALL(
2100  MPI_Type_commit( &datatypeBendersLinearConss2 )
2101  );
2103  commMpi->ureceive(bendersLinearConss->linearCoefs[0], 1, datatypeBendersLinearConss2, source, TagDiffSubproblem9)
2104  );
2105 
2106  MPI_CALL(
2107  MPI_Type_free( &datatypeBendersLinearConss2 )
2108  );
2109  }
2110 
2111  if( nBoundDisjunctions > 0 )
2112  {
2113  MPI_Datatype datatypeBoundDisjunctions1;
2114  datatypeBoundDisjunctions1 = createDatatypeBoundDisjunctions1(true);
2115  MPI_CALL(
2116  MPI_Type_commit( &datatypeBoundDisjunctions1 )
2117  );
2119  commMpi->ureceive(&(boundDisjunctions->nTotalVarsBoundDisjunctions), 1, datatypeBoundDisjunctions1, source, TagDiffSubproblem10)
2120  );
2121 
2122  MPI_CALL(
2123  MPI_Type_free( &datatypeBoundDisjunctions1 )
2124  );
2125 
2126  MPI_Datatype datatypeBoundDisjunctions2;
2127  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(true);
2128  MPI_CALL(
2129  MPI_Type_commit( &datatypeBoundDisjunctions2 )
2130  );
2132  commMpi->ureceive(boundDisjunctions->idxBoundDisjunctionVars[0], 1, datatypeBoundDisjunctions2, source, TagDiffSubproblem11)
2133  // commMpi->ureceive(&(boundDisjunctions->idxBoundDisjunctionVars[0]), 1, datatypeBoundDisjunctions2, source, TagDiffSubproblem11)
2134  );
2135 
2136  MPI_CALL(
2137  MPI_Type_free( &datatypeBoundDisjunctions2 )
2138  );
2139  }
2140 
2141  if( nVarBranchStats > 0 )
2142  {
2143  MPI_Datatype datatypeVarBranchStats;
2144  datatypeVarBranchStats = createDatatypeVarBranchStats(true);
2145  MPI_CALL(
2146  MPI_Type_commit( &datatypeVarBranchStats )
2147  );
2149  commMpi->ureceive(&(varBranchStats->offset), 1, datatypeVarBranchStats, source, TagDiffSubproblem12)
2150  );
2151 
2152  MPI_CALL(
2153  MPI_Type_free( &datatypeVarBranchStats )
2154  );
2155  }
2156 
2157  if( nVarValueVars > 0 )
2158  {
2159  MPI_Datatype datatypeVarValueVars1;
2160  datatypeVarValueVars1 = createDatatypeVarValueVars1(true);
2161  MPI_CALL(
2162  MPI_Type_commit( &datatypeVarValueVars1 )
2163  );
2165  commMpi->ureceive(&(varValues->nVarValues), 1, datatypeVarValueVars1, source, TagDiffSubproblem13)
2166  );
2167 
2168  MPI_CALL(
2169  MPI_Type_free( &datatypeVarValueVars1 )
2170  );
2171 
2172  MPI_Datatype datatypeBoundDisjunctions2;
2173  datatypeBoundDisjunctions2 = createDatatypeBoundDisjunctions2(true);
2174  MPI_CALL(
2175  MPI_Type_commit( &datatypeBoundDisjunctions2 )
2176  );
2178  commMpi->ureceive(&nVarValueVars, 1, datatypeBoundDisjunctions2, source, TagDiffSubproblem14)
2179  );
2180 
2181  MPI_CALL(
2182  MPI_Type_free( &datatypeBoundDisjunctions2 )
2183  );
2184  }
2185 
2186  return 0;
2187 }
2188 
2189 /** create clone of this object */
2191 ScipParaDiffSubproblemMpi::clone(ParaComm *comm)
2192 {
2193  return( new ScipParaDiffSubproblemMpi(this) );
2194 
2195 }
static ScipParaCommTh * comm
Definition: fscip.cpp:73
SCIP ParaComm extension for MPI communication.
#define PARA_COMM_CALL(paracommcall)
Definition: paraComm.h:47
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
#define DEF_PARA_COMM(para_comm, comm)
ScipParaDiffSubproblem extension for MPI communication.
static const int TagDiffSubproblem
Definition: paraTagDef.h:49
#define MPI_CALL(mpicall)
Definition: paraCommMpi.h:68
Base class of communicator object.
Definition: paraComm.h:101