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().
- createPartialDecomposition(self)¶
- 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
- 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
- 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 the detector
For an explanation for all arguments, see
DECincludeDetector()
.
- includePricingSolver(self, PricingSolver pricingSolver, solvername, desc, priority=0, heuristicEnabled=False, exactEnabled=False)¶
- listDecompositions(self) List[PartialDecomposition] ¶
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)¶
- 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.
- 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