Model¶
- class pygcgopt.gcg.Model¶
Main class for interaction with the GCG solver.
- addDecomposition(self, PartialDecomposition partialdec)¶
Adds a user specified decomposition to GCG.
The passed PartialDecomposition can be partial or finnished. A partial decomposition will be completed by GCG using its detector loop. If a finnished decomposition is passed, GCG will skip the detection loop and use the provided decomposition right away.
- addDecompositionFromConss(self, master_conss, *block_conss)¶
Adds a user specified decomposition to GCG based on constraints.
- Parameters:
master_conss – An iterable of Constraint objects. Can be the empty list.
block_conss – Any number of lists. The Constraints from each list will be turned into their own block. (optional)
- Returns:
The created PartialDecomposition object
Creates a PartialDecomposition object using createDecomposition(). Fixes the master constraints with fixMasterConss() and the block constraints with fixBlockConss(). The decomposition is added with addDecomposition().
- addPreexistingPartialDecomposition(self, PartialDecomposition partialdec)¶
- addVar(self, *args, **kwargs)¶
- createDecomposition(self)¶
Creates a new empty PartialDecomposition.
The created PartialDecomposition object can be used to fix constraints and variables. Afterwards, it can be passed to the model through addPreexistingPartialDecomposition().
- detect(self)¶
Detect the problem.
Can be executed before or after presolving. If executed before presolving, the structure is detected on the original problem and presolving is skiped when solving the problem later.
See also
- getDetprobdataOrig(self)¶
returns the detprobdata for unpresolved problem
- getDetprobdataPresolved(self)¶
returns the detprobdata for presolved problem
- getDualbound(self)¶
Retrieve the best dual bound.
This retrieves the same dual bound that GCG reports in the console log. The dual bound is based on the objective value of the optimized linear programming relaxation at the current node.
Note
The dual bound at the root node is not always equal to the solution of the restricted master problem LP relaxation. This can be due to master cuts or abortion of the pricing loop before the restricted master problem is optimal.
- Returns:
The best dual bound of the current node.
- getMasterProb(self)¶
Provides access to the GCG master problem.
- Returns:
An instance of scip#Model that represents the master problem.
- getMastervars(self, var)¶
Returns the master variables corresponding to the variable of original problem
- Parameters:
var – Variable of original problem
- Returns:
List of master variables
- getNConsClassifiers(self)¶
returns the number of all constraint classifiers
- Returns:
number of constraint classifiers
- Return type:
int
- getNVarClassifiers(self)¶
returns the number of all variable classifiers
- Returns:
number of variable classifiers
- Return type:
int
- getPartDecompFromID(self, id)¶
returns a partial decomposition regarding to the given partialdecomp id
- Parameters:
id – patial decomposition id as int
- Returns:
PartialDecomposition object
- includeConsClassifier(self, ConsClassifier consclassifier, consclassifiername, desc, priority=0, enabled=True)¶
includes a constraint classifier
- Parameters:
consclassifier – an object of a subclass of consclassifier#ConsClassifier.
consclassifiername – name of constraint classifier
desc – description of constraint classifier
- includeDefaultPlugins(self)¶
Includes all default plug-ins of GCG into SCIP
Called automatically during initialization of the model.
- includeDetector(self, Detector detector, detectorname, decchar, desc, freqcallround=1, maxcallround=INT_MAX, mincallround=0, freqcallroundoriginal=1, maxcallroundoriginal=INT_MAX, mincallroundoriginal=0, priority=0, enabled=True, enabledfinishing=False, enabledpostprocessing=False, skip=False, usefulrecall=False)¶
includes a detector
- Parameters:
detector – An object of a subclass of detector#Detector.
detectorname – name of detector
desc – description of detector
For an explanation for all arguments, see
GCGincludeDetector()
.
- includePricingSolver(self, PricingSolver pricingSolver, solvername, desc, priority=0, heuristicEnabled=False, exactEnabled=False)¶
- includeScore(self, Score score, scorename, shortname, desc)¶
includes a score
- Parameters:
detector – An object of a subclass of detector#Detector.
detectorname – name of the detector
For an explanation for all arguments, see
GCGincludeDetector()
.
- includeVarClassifier(self, VarClassifier varclassifier, varclassifiername, desc, priority=0, enabled=True)¶
includes a variable classifier
- Parameters:
varclassifier – an object of a subclass of varclassifier#VarClassifier.
varclassifiername – name of variable classifier
desc – description of variable classifier
- listConsClassifiers(self)¶
lists all constraint classifiers that are currently included
- Returns:
list of strings of the constraint classifier names
- listDecompositions(self)¶
Lists all finnished decompositions found during the detection loop or provided by the user.
- listDetectors(self)¶
Lists all detectors that are currently included
- Returns:
A list of strings of the detector names
Note
The detectors can be enabled or disabled using the appropriate methods by passing the name.
- listPricingSolvers(self)¶
- listScores(self)¶
Lists all scores that are currently included
- Returns:
A list of strings of the score names
- listVarClassifiers(self)¶
lists all variable classifiers that are currently included
- Returns:
list of strings of the variable classifier names
- optimize(self)¶
Optimize the problem.
This will transform, presolve and detect the problem if neccessary. Otherwise, GCG will solve the problem directly.
- presolve(self)¶
Presolve the problem.
- printStatistics(self)¶
Print solving statistics of GCG to stdout.
- printVersion(self)¶
Print version, copyright information and compile mode of GCG and SCIP
- setDetectorEnabled(self, detector_name, is_enabled=True)¶
Enables or disables a detector for detecting partial decompositions.
- Parameters:
detector_name – The name of the detector.
is_enabled – Decides weather the detector should be enabled or diabled.
This is a convenience method to access the boolean parameter “detection/detectors/<name>/enabled”.
Note
Disabling a detector using this method is not enough to ensure that it will not run. In addition setDetectorFinishingEnabled() and setDetectorPostProcessingEnabled() have to be used.
Use listDetectors() to obtain a list of all detectors.
- setDetectorFinishingEnabled(self, detector_name, is_enabled=True)¶
Enables or disables a detector for finishing partial decompositions.
- Parameters:
detector_name – The name of the detector.
is_enabled – Decides weather the detector should be enabled or diabled.
This is a convenience method to access the boolean parameter “detection/detectors/<name>/finishingenabled”.
See also
- setDetectorPostprocessingEnabled(self, detector_name, is_enabled=True)¶
Enables or disables a detector for postprocessing partial decompositions.
- Parameters:
detector_name – The name of the detector.
is_enabled – Decides weather the detector should be enabled or diabled.
This is a convenience method to access the boolean parameter “detection/detectors/<name>/postprocessingenabled”.
See also
- setGCGSeparating(self, setting)¶
Sets parameter settings of all separators
- Parameters:
setting – the parameter settings (SCIP_PARAMSETTING)
- setPricingSolverEnabled(self, pricing_solver_name, is_enabled=True)¶
Enables or disables exact and heuristic solving for the specified pricing solver.
- Parameters:
pricing_solver_name – The name of the pricing solver.
is_enabled – Decides weather the pricing solver should be enabled or diabled.
This is a convenience method to access the boolean parameters “pricingsolver/<name>/exactenabled” and “pricingsolver/<name>/heurenabled”.
Use
listPricingSolvers()
to obtain a list of all pricing solvers.
- setPricingSolverExactEnabled(self, pricing_solver_name, is_enabled=True)¶
Enables or disables exact solving for the specified pricing solver.
- Parameters:
pricing_solver_name – The name of the pricing solver.
is_enabled – Decides weather the pricing solver should be enabled or diabled.
This is a convenience method to access the boolean parameter “pricingsolver/<name>/exactenabled”.
Use
listPricingSolvers()
to obtain a list of all pricing solvers.
- setPricingSolverHeuristicEnabled(self, pricing_solver_name, is_enabled=True)¶
Enables or disables heuristic solving for the specified pricing solver.
- Parameters:
pricing_solver_name – The name of the pricing solver.
is_enabled – Decides weather the pricing solver should be enabled or diabled.
This is a convenience method to access the boolean parameter “pricingsolver/<name>/heurenabled”.
Use
listPricingSolvers()
to obtain a list of all pricing solvers.
- setVarClassifierEnabled(self, varclassifier_name, is_enabled=True)¶
enables or disables a variable classifier
- Parameters:
varclassifier_name – the name of the variable classifier
is_enabled – decides weather the variable classifier should be enabled or diabled.
This is a convenience method to access the boolean parameter “detection/classification/varclassifier/<name>/enabled”.
- writeAllDecomps(self, directory=u'alldecompositions/', extension=u'dec', bool original=True, bool presolved=True, createDirectory=True)¶
Writes all decompositions to disk
- Parameters:
directory – A path to a folder where to store the decomposition files
extension – Extension without a dot. Decides the output format. Use “dec” to output decomposition files
createDirectory – Automatically create the directory specified in
directory
if it does not exist