Scippy

UG

Ubiquity Generator framework

ScipParaInstanceMpi Class Reference

#include <scipParaInstanceMpi.h>

Inheritance diagram for ScipParaInstanceMpi:
ScipParaInstance BbParaInstance BbParaInstance ParaInstance ParaInstance

Public Member Functions

 ScipParaInstanceMpi ()
 
 ScipParaInstanceMpi (SCIP *scip, int method)
 
 ~ScipParaInstanceMpi ()
 
void copyScipEnvironment (SCIP **scip)
 
SCIP * getScip ()
 
void setFileName (const char *inFileName)
 
int bcast (UG::ParaComm *comm, int rank, int method)
 
int getVarIndexRange ()
 
bool isCopyIncreasedVariables ()
 
void copyIncrasedVariables ()
 
- Public Member Functions inherited from ScipParaInstance
 ScipParaInstance ()
 
 ScipParaInstance (SCIP *scip, int method)
 
virtual ~ScipParaInstance ()
 
double convertToExternalValue (double internalValue)
 
double convertToInternalValue (double externalValue)
 
void getSolValuesForOriginalProblem (ScipParaSolution *sol, SCIP_Real *vals)
 
void createProblem (SCIP *scip, int method, bool noPreprocessingInLC, bool usetRootNodeCuts, ScipDiffParamSet *scipDiffParamSetRoot, ScipDiffParamSet *scipDiffParamSet, char *settingsNameLC, char *isolname)
 
const std::string toString ()
 
bool isOriginalIndeciesMap ()
 
bool isSolverLocalIndeciesMap ()
 
int getOrigProbIndex (int index)
 
const char * getProbName ()
 
void freeMemory ()
 
int getNVars ()
 
int getVarIndexRange ()
 
SCIP_Real getVarLb (int i)
 
SCIP_Real getVarUb (int i)
 
SCIP_Real getObjCoef (int i)
 
int getVarType (int i)
 
const char * getVarName (int i)
 
int getNConss ()
 
SCIP_Real getLhsLinear (int i)
 
SCIP_Real getRhsLinear (int i)
 
int getNVarsLinear (int i)
 
int getIdxLinearCoefVar (int i, int j)
 
SCIP_Real * getLinearCoefs (int i)
 
const char * getConsName (int i)
 
SCIP * getScip ()
 
void setUserPlugins (ScipUserPlugins *inUi)
 
void includeUserPlugins (SCIP *inScip)
 
virtual void setFileName (const char *fileName)=0
 
int * extractOrigProbIndexMap ()
 
int * extractSolverLocalIndexMap ()
 
SCIP * getParaInstanceScip ()
 
int getOrigObjSense ()
 
virtual bool isCopyIncreasedVariables ()=0
 
virtual void copyIncrasedVariables ()=0
 
 ScipParaInstance ()
 
 ScipParaInstance (SCIP *inScip)
 
virtual ~ScipParaInstance ()
 
double convertToExternalValue (double internalValue)
 
double convertToInternalValue (double externalValue)
 
void getSolValuesForOriginalProblem (ScipParaSolution *sol, SCIP_Real *vals)
 
void copyScipEnvironment (SCIP **scip)
 
SCIP * getScip ()
 
void createProblem (SCIP *scip, int method, bool noPreprocessingInLC, bool usetRootNodeCuts, ScipDiffParamSet *scipDiffParamSetRoot, ScipDiffParamSet *scipDiffParamSet, char *settingsNameLC, char *isolname)
 
const std::string toString ()
 
const char * getProbName ()
 
int getNVars ()
 
int getVarIndexRange ()
 
SCIP_Real getVarLb (int i)
 
SCIP_Real getVarUb (int i)
 
int getVarType (int i)
 
SCIP_Real getObjCoef (int i)
 
const char * getVarName (int i)
 
int getNConss ()
 
SCIP_Real getLhsLinear (int i)
 
SCIP_Real getRhsLinear (int i)
 
int getNVarsLinear (int i)
 
int getIdxLinearCoefVar (int i, int j)
 
SCIP_Real * getLinearCoefs (int i)
 
const char * getConsName (int i)
 
void setUserPlugins (ScipUserPlugins *inUi)
 
void includeUserPlugins (SCIP *inScip)
 
virtual void setFileName (const char *file)=0
 
bool isOriginalIndeciesMap ()
 
bool isSolverLocalIndeciesMap ()
 
int getOrigProbIndex (int index)
 
int * extractOrigProbIndexMap ()
 
int * extractSolverLocalIndexMap ()
 
SCIP * getParaInstanceScip ()
 
int getOrigObjSense ()
 
bool isCopyIncreasedVariables ()
 
void copyIncrasedVariables ()
 
- Public Member Functions inherited from BbParaInstance
 BbParaInstance ()
 DO NOT HAVE DATA MEMBER!! More...
 
virtual ~BbParaInstance ()
 destructor More...
 
virtual int getVarIndexRange ()=0
 get variable index range TODO: this function should be in inherited class More...
 
- Public Member Functions inherited from ParaInstance
 ParaInstance ()
 DO NOT HAVE DATA MEMBER!! More...
 
virtual ~ParaInstance ()
 destructor More...
 
virtual const char * getProbName ()=0
 get problem name More...
 
virtual int bcast (ParaComm *comm, int rank, int method)=0
 broadcast function to all solvers More...
 
virtual const std::string toString ()=0
 Stringfy this object. More...
 

Private Member Functions

MPI_Datatype createDatatype1 ()
 
MPI_Datatype createDatatype2 (bool memAllocNecessary)
 
MPI_Datatype createDatatype3 (bool memAllocNecessary)
 
void allocateMemoryForDatatype2 ()
 
void allocateMemoryForDatatype3 ()
 
const char * getFileName ()
 

Private Attributes

int dummyToKeepStartPos
 
const char * fileName
 

Additional Inherited Members

- Protected Member Functions inherited from ScipParaInstance
void allocateMemoryForOrdinaryConstraints ()
 
void addOrdinaryConstraintName (int c, SCIP_CONS *cons)
 
void setLinearConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createLinearConstraintsInSCIP (SCIP *scip)
 
void setSetppcConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createSetppcConstraintsInSCIP (SCIP *scip)
 
void setLogicorConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createLogicorConstraintsInSCIP (SCIP *scip)
 
void setKnapsackConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createKnapsackConstraintsInSCIP (SCIP *scip)
 
void setVarboundConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createVarboundConstraintsInSCIP (SCIP *scip)
 
void setBoundDisjunctionConstraint (SCIP *scip, int c, SCIP_CONS *cons)
 
void createBoundDisjunctionConstraintInSCIP (SCIP *scip)
 
void setSos1Constraint (SCIP *scip, int c, SCIP_CONS *cons, SCIP_CONS **consSOS1)
 
void createSos1ConstraintsInSCIP (SCIP *scip)
 
void setSos2Constraint (SCIP *scip, int c, SCIP_CONS *cons, SCIP_CONS **consSOS2)
 
void createSos2ConstraintsInSCIP (SCIP *scip)
 
void getActiveVariables (SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
 
void collectAggregatedVars (SCIP *scip, int nvars, SCIP_VAR **vars, int *nAggregatedVars, SCIP_VAR ***aggregatedVars, SCIP_HASHTABLE **varAggregated)
 
void setAggregatedConstraint (SCIP *scip, int c, const char *constName, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhsAndrhs)
 
void setAggregatedConstrains (SCIP *scip, int nvars, int nAggregatedVars, SCIP_VAR **aggregatedVars)
 
void createAggregatedVarsAndConstrainsInSCIP (SCIP *scip)
 
virtual const char * getFileName ()=0
 
bool addRootNodeCuts (SCIP *scip, ScipDiffParamSet *scipDiffParamSetRoot)
 
virtual const char * getFileName ()=0
 
- Protected Attributes inherited from ScipParaInstance
SCIP * orgScip
 
SCIP * paraInstanceScip
 
int lProbName
 
char * probName
 
int nCopies
 
int origObjSense
 
SCIP_Real objScale
 
SCIP_Real objOffset
 
int nVars
 
int varIndexRange
 
SCIP_Real * varLbs
 
SCIP_Real * varUbs
 
SCIP_Real * objCoefs
 
int * varTypes
 
size_t lVarNames
 
char * varNames
 
int * posVarNames
 
int * mapToOriginalIndecies
 
int * mapToSolverLocalIndecies
 
int nConss
 
int lConsNames
 
char * consNames
 
int * posConsNames
 
bool copyIncreasedVariables
 
int nLinearConss
 
int * idxLinearConsNames
 
SCIP_Real * linearLhss
 
SCIP_Real * linearRhss
 
int * nLinearCoefs
 
SCIP_Real ** linearCoefs
 
int ** idxLinearCoefsVars
 
int nSetppcConss
 
int * idxSetppcConsNames
 
int * nIdxSetppcVars
 
int * setppcTypes
 
int ** idxSetppcVars
 
int nLogicorConss
 
int * idxLogicorConsNames
 
int * nIdxLogicorVars
 
int ** idxLogicorVars
 
int nKnapsackConss
 
int * idxKnapsackConsNames
 
SCIP_Longint * capacities
 
int * nLKnapsackCoefs
 
SCIP_Longint ** knapsackCoefs
 
int ** idxKnapsackCoefsVars
 
int nVarboundConss
 
int * idxVarboundConsNames
 
SCIP_Real * varboundLhss
 
SCIP_Real * varboundRhss
 
int * idxVarboundCoefVar1s
 
SCIP_Real * varboundCoef2s
 
int * idxVarboundCoefVar2s
 
int nVarBoundDisjunctionConss
 
int * idxBoundDisjunctionConsNames
 
int * nVarsBoundDisjunction
 
int ** idxVarBoundDisjunction
 
SCIP_BOUNDTYPE ** boundTypesBoundDisjunction
 
SCIP_Real ** boundsBoundDisjunction
 
int nSos1Conss
 
int * idxSos1ConsNames
 
int * nSos1Coefs
 
SCIP_Real ** sos1Coefs
 
int ** idxSos1CoefsVars
 
int nSos2Conss
 
int * idxSos2ConsNames
 
int * nSos2Coefs
 
SCIP_Real ** sos2Coefs
 
int ** idxSos2CoefsVars
 
int nAggregatedConss
 
int lAggregatedVarNames
 
char * aggregatedVarNames
 
int * posAggregatedVarNames
 
int lAggregatedConsNames
 
char * aggregatedConsNames
 
int * posAggregatedConsNames
 
SCIP_Real * aggregatedLhsAndLhss
 
int * nAggregatedCoefs
 
SCIP_Real ** aggregatedCoefs
 
int ** idxAggregatedCoefsVars
 
ScipUserPluginsuserPlugins
 
SCIP * scip
 

Detailed Description

ScipInstanceMpi

Definition at line 50 of file scipParaInstanceMpi.h.

Constructor & Destructor Documentation

◆ ScipParaInstanceMpi() [1/2]

constructor

Definition at line 70 of file scipParaInstanceMpi.h.

◆ ScipParaInstanceMpi() [2/2]

ScipParaInstanceMpi ( SCIP *  scip,
int  method 
)

constructor : only called from ScipInitiator

assert(n > nVars); mapToOriginalIndecies = new int[SCIPgetNTotalVars(tempScip)]; // need to allocate enough for SCIPvarGetIndex(copyvar) mapToSolverLocalIndecies = new int[SCIPgetNTotalVars(tempScip)]; for( int i = 0; i < SCIPgetNTotalVars(tempScip); i++ ) { mapToOriginalIndecies[i] = -1; mapToSolverLocalIndecies[i] = -1; } SCIP_VAR **tempVars = SCIPgetVars(tempScip); for( int i = 0; i < n; i++ ) { mapToOriginalIndecies[SCIPvarGetIndex(tempVars[i])] = i; mapToSolverLocalIndecies[i] = SCIPvarGetIndex(tempVars[i]); }

orgScip = scip; nVars = n; varIndexRange = SCIPgetNTotalVars(tempScip); paraInstanceScip = tempScip;

if( SCIPgetNConss(scip) > 0 ) { SCIPhashmapFree(&conssmap); } if( SCIPgetNVars(scip) > 0 ) { SCIPhashmapFree(&varmap); } SCIP_CALL_ABORT( SCIPtransformProb(paraInstanceScip)); nCopies = 2; std::cout << "** ParaScipInstance is copied twice. **" << std::endl;

Definition at line 77 of file scipParaInstanceMpi.h.

References ScipParaInstance::copyIncreasedVariables, ScipParaInstance::lVarNames, ScipParaInstance::nCopies, ScipParaInstance::nVars, ScipParaInstance::objCoefs, ScipParaInstance::paraInstanceScip, ScipParaInstance::posVarNames, ScipParaInstance::scip, ScipParaInstance::varIndexRange, ScipParaInstance::varLbs, ScipParaInstance::varNames, ScipParaInstance::varTypes, and ScipParaInstance::varUbs.

◆ ~ScipParaInstanceMpi()

Member Function Documentation

◆ allocateMemoryForDatatype2()

void allocateMemoryForDatatype2 ( )
private

Definition at line 178 of file scipParaInstanceMpi.cpp.

References ScipParaInstance::aggregatedConsNames, ScipParaInstance::aggregatedLhsAndLhss, ScipParaInstance::aggregatedVarNames, ScipParaInstance::capacities, ScipParaInstance::consNames, ScipParaInstance::idxBoundDisjunctionConsNames, ScipParaInstance::idxKnapsackConsNames, ScipParaInstance::idxLinearConsNames, ScipParaInstance::idxLogicorConsNames, ScipParaInstance::idxSetppcConsNames, ScipParaInstance::idxSos1ConsNames, ScipParaInstance::idxSos2ConsNames, ScipParaInstance::idxVarboundCoefVar1s, ScipParaInstance::idxVarboundCoefVar2s, ScipParaInstance::idxVarboundConsNames, ScipParaInstance::lAggregatedConsNames, ScipParaInstance::lAggregatedVarNames, ScipParaInstance::lConsNames, ScipParaInstance::linearLhss, ScipParaInstance::linearRhss, ScipParaInstance::lProbName, ScipParaInstance::lVarNames, ScipParaInstance::nAggregatedCoefs, ScipParaInstance::nAggregatedConss, ScipParaInstance::nConss, ScipParaInstance::nIdxLogicorVars, ScipParaInstance::nIdxSetppcVars, ScipParaInstance::nKnapsackConss, ScipParaInstance::nLinearCoefs, ScipParaInstance::nLinearConss, ScipParaInstance::nLKnapsackCoefs, ScipParaInstance::nLogicorConss, ScipParaInstance::nSetppcConss, ScipParaInstance::nSos1Coefs, ScipParaInstance::nSos1Conss, ScipParaInstance::nSos2Coefs, ScipParaInstance::nSos2Conss, ScipParaInstance::nVarboundConss, ScipParaInstance::nVarBoundDisjunctionConss, ScipParaInstance::nVars, ScipParaInstance::nVarsBoundDisjunction, ScipParaInstance::objCoefs, ScipParaInstance::posAggregatedConsNames, ScipParaInstance::posAggregatedVarNames, ScipParaInstance::posConsNames, ScipParaInstance::posVarNames, ScipParaInstance::probName, ScipParaInstance::setppcTypes, THROW_LOGICAL_ERROR1, ScipParaInstance::varboundCoef2s, ScipParaInstance::varboundLhss, ScipParaInstance::varboundRhss, ScipParaInstance::varLbs, ScipParaInstance::varNames, ScipParaInstance::varTypes, and ScipParaInstance::varUbs.

Referenced by ScipParaInstanceMpi::createDatatype2().

◆ allocateMemoryForDatatype3()

◆ bcast()

◆ copyIncrasedVariables()

void copyIncrasedVariables ( )
virtual

Implements ScipParaInstance.

Definition at line 301 of file scipParaInstanceMpi.h.

References ScipParaInstance::copyIncreasedVariables.

◆ copyScipEnvironment()

void copyScipEnvironment ( SCIP **  scip)

create presolved problem instance that is solved by ParaSCIP form scip environment in this object

this routine for Pthread version. So, this should not be used

Definition at line 271 of file scipParaInstanceMpi.h.

◆ createDatatype1()

◆ createDatatype2()

MPI_Datatype createDatatype2 ( bool  memAllocNecessary)
private

create scipDiffParamSetPreType

create ScipInstancePreDatatype

Definition at line 258 of file scipParaInstanceMpi.cpp.

References ScipParaInstance::aggregatedConsNames, ScipParaInstance::aggregatedLhsAndLhss, ScipParaInstance::aggregatedVarNames, ScipParaInstanceMpi::allocateMemoryForDatatype2(), ScipParaInstance::capacities, ScipParaInstance::consNames, ScipParaInstance::idxBoundDisjunctionConsNames, ScipParaInstance::idxKnapsackConsNames, ScipParaInstance::idxLinearConsNames, ScipParaInstance::idxLogicorConsNames, ScipParaInstance::idxSetppcConsNames, ScipParaInstance::idxSos1ConsNames, ScipParaInstance::idxSos2ConsNames, ScipParaInstance::idxVarboundCoefVar1s, ScipParaInstance::idxVarboundCoefVar2s, ScipParaInstance::idxVarboundConsNames, ScipParaInstance::lAggregatedConsNames, ScipParaInstance::lAggregatedVarNames, ScipParaInstance::lConsNames, ScipParaInstance::linearLhss, ScipParaInstance::linearRhss, ScipParaInstance::lProbName, ScipParaInstance::lVarNames, MPI_CALL, ScipParaInstance::nAggregatedCoefs, ScipParaInstance::nAggregatedConss, ScipParaInstance::nConss, ScipParaInstance::nIdxLogicorVars, ScipParaInstance::nIdxSetppcVars, ScipParaInstance::nKnapsackConss, ScipParaInstance::nLinearCoefs, ScipParaInstance::nLinearConss, ScipParaInstance::nLKnapsackCoefs, ScipParaInstance::nLogicorConss, ScipParaInstance::nSetppcConss, ScipParaInstance::nSos1Coefs, ScipParaInstance::nSos1Conss, ScipParaInstance::nSos2Coefs, ScipParaInstance::nSos2Conss, ScipParaInstance::nVarboundConss, ScipParaInstance::nVarBoundDisjunctionConss, ScipParaInstance::nVars, ScipParaInstance::nVarsBoundDisjunction, ScipParaInstance::objCoefs, ScipParaInstance::posAggregatedConsNames, ScipParaInstance::posAggregatedVarNames, ScipParaInstance::posConsNames, ScipParaInstance::posVarNames, ScipParaInstance::probName, ScipParaInstance::setppcTypes, ScipParaInstance::varboundCoef2s, ScipParaInstance::varboundLhss, ScipParaInstance::varboundRhss, ScipParaInstance::varLbs, ScipParaInstance::varNames, ScipParaInstance::varTypes, and ScipParaInstance::varUbs.

Referenced by ScipParaInstanceMpi::bcast().

◆ createDatatype3()

◆ getFileName()

const char * getFileName ( )
privatevirtual

Implements ScipParaInstance.

Definition at line 66 of file scipParaInstanceMpi.h.

References ScipParaInstanceMpi::fileName.

◆ getScip()

SCIP * getScip ( )

this routine for Pthread version. So, this should not be used

Definition at line 279 of file scipParaInstanceMpi.h.

◆ getVarIndexRange()

int getVarIndexRange ( )
virtual

Reimplemented from ScipParaInstance.

Definition at line 294 of file scipParaInstanceMpi.h.

References ScipParaInstance::varIndexRange.

◆ isCopyIncreasedVariables()

bool isCopyIncreasedVariables ( )
virtual

Implements ScipParaInstance.

Definition at line 296 of file scipParaInstanceMpi.h.

References ScipParaInstance::copyIncreasedVariables.

◆ setFileName()

void setFileName ( const char *  inFileName)
virtual

Implements ScipParaInstance.

Definition at line 286 of file scipParaInstanceMpi.h.

References ScipParaInstanceMpi::fileName.

Referenced by main().

Member Data Documentation

◆ dummyToKeepStartPos

int dummyToKeepStartPos
private

◆ fileName

const char* fileName
private