Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
SCIPBackend.__copy__: Use Model(sourceModel=...) for copying
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jan 4, 2023
1 parent 48cf104 commit 953198e
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/sage/numerical/backends/scip_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,27 +1160,10 @@ cdef class SCIPBackend(GenericBackend):
6.0
"""
cdef SCIPBackend cp = type(self)(maximization=self.is_maximization())
cp.model = Model(sourceModel=self.model)
cp.problem_name(self.problem_name())
for i, v in enumerate(self.variables):
vtype = v.vtype()
cp.add_variable(self.variable_lower_bound(i),
self.variable_upper_bound(i),
binary=vtype == 'BINARY',
continuous=vtype == 'CONTINUOUS',
integer=vtype == 'INTEGER',
obj=self.objective_coefficient(i),
name=self.col_name(i))
assert self.ncols() == cp.ncols()

for i in range(self.nrows()):
coefficients = zip(*self.row(i))
lower_bound, upper_bound = self.row_bounds(i)
name = self.row_name(i)
cp.add_linear_constraint(coefficients,
lower_bound,
upper_bound,
name=name)
assert self.nrows() == cp.nrows()
cp.obj_constant_term = self.obj_constant_term
cp.variables = cp.model.getVars()
return cp

cpdef solver_parameter(self, name, value=None):
Expand Down

0 comments on commit 953198e

Please sign in to comment.