Skip to content

Commit

Permalink
Merge pull request #9 from jurgen-lentz/master
Browse files Browse the repository at this point in the history
rename GCGModel to Model
  • Loading branch information
jurgen-lentz authored Feb 5, 2022
2 parents 911bfdc + 2e1ca06 commit 26d63f0
Show file tree
Hide file tree
Showing 15 changed files with 780 additions and 11,296 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
### Changed
### Removed

## v0.1.4
### Changed
* rename GCGModel to Model
### Removed
* pyscipopt.Model not importable with pygcgopt.Model anymore
## v0.1.3
### Added
* Initial public release
5 changes: 0 additions & 5 deletions docs/api/gcgmodel.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ API Reference

.. toctree::

gcgmodel.rst
model.rst
decomposition.rst
detprobdata.rst
detector.rst
Expand Down
5 changes: 5 additions & 0 deletions docs/api/model.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Model
*************

.. autoclass:: pygcgopt.gcg.Model
:members:
1,093 changes: 483 additions & 610 deletions examples/alldecomps/alldecomps.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10,738 changes: 77 additions & 10,661 deletions examples/cpmp/cpmp.ipynb

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/pygcgopt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.1.3'
__version__ = '0.1.4'

# required for Python 3.8 on Windows
import os
Expand All @@ -8,7 +8,6 @@

# Expose pyscipopt object through pygcgopt
from pyscipopt import multidict
from pyscipopt import Model
from pyscipopt import Benders
from pyscipopt import Benderscut
from pyscipopt import Branchrule
Expand Down Expand Up @@ -42,5 +41,5 @@
from pyscipopt import SCIP_ROWORIGINTYPE

# export user-relevant objects
from pygcgopt.gcg import GCGModel, Detector, PricingSolver
from pygcgopt.gcg import Model, Detector, PricingSolver
from pygcgopt.gcg import PY_GCG_PRICINGSTATUS as GCG_PRICINGSTATUS
2 changes: 1 addition & 1 deletion src/pygcgopt/detector.pxi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cdef class Detector:
"""Base class of the Detector Plugin"""
cdef public Model model
cdef public SCIPModel model
cdef public str detectorname

def freeDetector(self):
Expand Down
2 changes: 1 addition & 1 deletion src/pygcgopt/detprobdata.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ cdef class DetProbData:
:return: the corresponding Model instance wrapping scip data structure.
"""
cdef SCIP * scip = self.thisptr.getScip()
return Model.create(scip)
return SCIPModel.create(scip)

def getSortedCandidatesNBlocks(DetProbData self, object candidates):
"""gets the candidates for number of blocks added by the user followed by the found ones sorted in descending order by how often a candidate was proposed
Expand Down
17 changes: 9 additions & 8 deletions src/pygcgopt/gcg.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# distutils: language = c++

from pyscipopt.scip import PY_SCIP_CALL
from pyscipopt.scip cimport Model, Variable, Constraint, Solution, SCIP_RESULT, SCIP_DIDNOTRUN, SCIPgetStage, SCIP_STAGE, SCIP_STAGE_PRESOLVED, SCIP_OKAY, SCIPvarSetData, SCIPgetBestSol
from pyscipopt.scip cimport Model as SCIPModel
from pyscipopt.scip cimport Variable, Constraint, Solution, SCIP_RESULT, SCIP_DIDNOTRUN, SCIPgetStage, SCIP_STAGE, SCIP_STAGE_PRESOLVED, SCIP_OKAY, SCIPvarSetData, SCIPgetBestSol

from cpython cimport Py_INCREF, Py_DECREF

Expand Down Expand Up @@ -50,7 +51,7 @@ cdef class PY_GCG_PRICINGSTATUS:
UNBOUNDED = GCG_PRICINGSTATUS_UNBOUNDED


cdef class GCGModel(Model):
cdef class Model(SCIPModel):
"""Main class for interaction with the GCG solver."""

def includeDefaultPlugins(self):
Expand Down Expand Up @@ -183,16 +184,16 @@ cdef class GCGModel(Model):
c_desc = str_conversion(desc)

PY_SCIP_CALL(GCGpricerIncludeSolver(
(<Model>self.getMasterProb())._scip, c_solvername, c_desc, priority, heuristicEnabled, exactEnabled, PyPricingSolverUpdate,
(<SCIPModel>self.getMasterProb())._scip, c_solvername, c_desc, priority, heuristicEnabled, exactEnabled, PyPricingSolverUpdate,
PyPricingSolverSolve, PyPricingSolverSolveHeur, PyPricingSolverFree, PyPricingSolverInit, PyPricingSolverExit,
PyPricingSolverInitSol, PyPricingSolverExitSol, <GCG_SOLVERDATA*>pricingSolver))

pricingSolver.model = <Model>weakref.proxy(self)
pricingSolver.model = <SCIPModel>weakref.proxy(self)
pricingSolver.solvername = solvername
Py_INCREF(pricingSolver)

def listPricingSolvers(self):
cdef Model mp = <Model>self.getMasterProb()
cdef SCIPModel mp = <SCIPModel>self.getMasterProb()
cdef int n_pricing_solvers = GCGpricerGetNSolvers(mp._scip)
cdef GCG_SOLVER** pricing_solvers = GCGpricerGetSolvers(mp._scip)

Expand Down Expand Up @@ -257,7 +258,7 @@ cdef class GCGModel(Model):
PyDetectorExit, PyDetectorPropagatePartialdec, PyDetectorFinishPartialdec, PyDetectorPostprocessPartialdec,
PyDetectorSetParamAggressive, PyDetectorSetParamDefault, PyDetectorSetParamFast))

detector.model = <Model>weakref.proxy(self)
detector.model = <SCIPModel>weakref.proxy(self)
detector.detectorname = detectorname
Py_INCREF(detector)

Expand Down Expand Up @@ -348,7 +349,7 @@ cdef class GCGModel(Model):
PY_SCIP_CALL(DECwriteAllDecomps(self._scip, c_directory, c_extension, original, presolved))


cdef class GCGPricingModel(Model):
cdef class GCGPricingModel(SCIPModel):
@staticmethod
cdef create(SCIP* scip):
"""Creates a pricing problem model and appropriately assigns the scip and bestsol parameters
Expand Down Expand Up @@ -388,7 +389,7 @@ cdef class GCGPricingModel(Model):
return pyGCGCol


cdef class GCGMasterModel(Model):
cdef class GCGMasterModel(SCIPModel):
@staticmethod
cdef create(SCIP* scip):
"""Creates a pricing problem model and appropriately assigns the scip and bestsol parameters
Expand Down
2 changes: 1 addition & 1 deletion src/pygcgopt/pricing_solver.pxi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cdef class PricingSolver:
"""Base class of the Pricing Solver Plugin"""

cdef public Model model
cdef public SCIPModel model
cdef public str solvername

def freeSolver(self):
Expand Down
8 changes: 3 additions & 5 deletions tests/test_pricing_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
from functools import reduce
from collections import defaultdict

from pygcgopt import GCGModel, quicksum, PricingSolver, GCG_PRICINGSTATUS
from pygcgopt import Model, PricingSolver, GCG_PRICINGSTATUS

from ortools.algorithms import pywrapknapsack_solver

from test_cpmp import build_model

import pytest

import os
Expand Down Expand Up @@ -151,7 +149,7 @@ def test_pypricer_fast(lp_file, dec_file):
lp_file = os.path.join(dirname, lp_file)
dec_file = os.path.join(dirname, dec_file)

m = GCGModel()
m = Model()
m.readProblem(lp_file)
m.readProblem(dec_file)

Expand All @@ -161,7 +159,7 @@ def test_pypricer_fast(lp_file, dec_file):

gcg_pricer_sol_obj_val = m.getSolObjVal(m.getBestSol())

m = GCGModel()
m = Model()
m.readProblem(lp_file)
m.readProblem(dec_file)

Expand Down

0 comments on commit 26d63f0

Please sign in to comment.