Scippy

UG

Ubiquity Generator framework

scipParaSolutionTh.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-2024 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 scipParaSolutionTh.cpp
27 * @brief ScipParaSolution extension for threads 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 "scipParaSolutionTh.h"
38
39using namespace UG;
40using namespace ParaSCIP;
41
42/** create clone of this object */
44ScipParaSolutionTh::clone(UG::ParaComm *comm)
45{
47}
48
49/** create ScipDiffSubproblemPreDatatype */
53 )
54{
55 return clone(comm);
56}
57
58/** send solution data to the rank */
59void
61{
62 DEF_PARA_COMM( commTh, comm);
63
64 if( commTh->getRank() == root )
65 {
66 for( int i = 0; i < commTh->getSize(); i++ )
67 {
68 if( i != root )
69 {
71 commTh->uTypeSend((void *)createDatatype(comm), ParaSolutionType, i, TagSolution)
72 );
73 }
74 }
75 }
76 else
77 {
78 ScipParaSolutionTh *received;
80 commTh->uTypeReceive((void **)&received, ParaSolutionType, root, TagSolution)
81 );
82
84 nVars = received->nVars;
85 indicesAmongSolvers = new int[nVars];
86 values = new SCIP_Real[nVars];
87 for( int i = 0; i < nVars; i++ )
88 {
90 values[i] = received->values[i];
91 }
92 delete received;
93 }
94}
95
96/** send solution data to the rank */
97void
99{
100 DEF_PARA_COMM( commTh, comm);
102 commTh->uTypeSend((void *)createDatatype(comm), ParaSolutionType, destination, TagSolution)
103 );
104}
105
106/** receive solution data from the source rank */
107void
109{
110 DEF_PARA_COMM( commTh, comm);
111
112 ScipParaSolutionTh *received;
114 commTh->uTypeReceive((void **)&received, ParaSolutionType, source, TagSolution)
115 );
116
118 nVars = received->nVars;
119 indicesAmongSolvers = new int[nVars];
120 values = new SCIP_Real[nVars];
121 for( int i = 0; i < nVars; i++ )
122 {
124 values[i] = received->values[i];
125 }
126 delete received;
127
128}
ScipParaSolutionTh * clone(UG::ParaComm *comm)
ScipParaSolutionTh * createDatatype(UG::ParaComm *comm)
void send(UG::ParaComm *comm, int destination)
void bcast(UG::ParaComm *comm, int root)
void receive(UG::ParaComm *comm, int source)
Base class of communicator object.
Definition: paraComm.h:102
static ScipParaCommTh * comm
Definition: fscip.cpp:73
static const int TagSolution
Definition: paraTagDef.h:51
static const int ParaSolutionType
Definition: paraCommCPP11.h:99
#define DEF_PARA_COMM(para_comm, comm)
#define PARA_COMM_CALL(paracommcall)
Definition: paraComm.h:47
ScipParaSolution extension for threads communication.