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

Commit

Permalink
Preserve information when construct a new problem
Browse files Browse the repository at this point in the history
  • Loading branch information
pgxiao authored and Matthias Koeppe committed Jun 24, 2016
1 parent 6f41037 commit e6404ab
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/sage/numerical/interactive_simplex_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,15 @@ def add_constraint(self, coefficients, new_b, new_constraint_type="<="):
c = self.Abcx()[2]
A = A.stack(matrix(coefficients))
b = vector(tuple(b) + (new_b,))
return InteractiveLPProblem(A, b, c, constraint_type=constraint_type)
if self._is_negative:
problem_type = "-" + self.problem_type()
else:
problem_type = self.problem_type()
return InteractiveLPProblem(A, b, c, x=self.Abcx()[3],
constraint_type=constraint_type,
variable_type=self.variable_types(),
problem_type=problem_type,
objective_constant_term=self.objective_constant_term())

def base_ring(self):
r"""
Expand Down Expand Up @@ -2070,6 +2078,20 @@ def add_constraint(self, coefficients, new_b, new_slack_variable):
G = list(R.gens())
slack = list(self.slack_variables())

if new_slack_variable is None:
new_slack_variable = default_variable_name("primal slack")
if style() == "UAlberta":
index = self.n() + self.m() + 1
elif style() == 'Vanderbei':
index = self.m() + 1
new_slack_variable = "{}{:d}".format(new_slack_variable, index)
if not isinstance(new_slack_variable, str):
new_slack_variable = str(new_slack_variable)
if self._is_negative:
problem_type = "-" + self.problem_type()
else:
problem_type = self.problem_type()

# Construct a larger ring for variables
G.append(new_slack_variable)
R1 = PolynomialRing(self.base_ring(), G, order="neglex")
Expand All @@ -2080,7 +2102,10 @@ def add_constraint(self, coefficients, new_b, new_slack_variable):
b = vector(tuple(b) + (new_b,))

return InteractiveLPProblemStandardForm(
A, b, c, slack_variables=slack)
A, b, c, x=self.Abcx()[3],
problem_type=problem_type,
slack_variables=slack,
objective_constant_term=self.objective_constant_term())

def auxiliary_problem(self, objective_name=None):
r"""
Expand Down

0 comments on commit e6404ab

Please sign in to comment.