Skip to content

Conversation

takshakmudgal
Copy link

@takshakmudgal takshakmudgal commented Apr 6, 2023

📚 Description

Adding the missing remove_constraint method to the CVXPYBackend library. The remove_constraint method takes an index of the constraint to remove. It removes the corresponding row from the matrix, as well as the lower and upper bounds and the constraint name. Finally, it updates the problem attribute of the solver with a new list of constraints.

Fixes #35369

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 9, 2023

I am getting

[sagelib-10.0.beta8]     Error compiling Cython file:
[sagelib-10.0.beta8]     ------------------------------------------------------------
[sagelib-10.0.beta8]     ...
[sagelib-10.0.beta8]             if value is not False:
[sagelib-10.0.beta8]                 self.col_lower_bound[index] = value
[sagelib-10.0.beta8]             else:
[sagelib-10.0.beta8]                 return self.col_lower_bound[index]
[sagelib-10.0.beta8] 
[sagelib-10.0.beta8]         cpdef remove_constraint(self, index):
[sagelib-10.0.beta8]              ^
[sagelib-10.0.beta8]     ------------------------------------------------------------
[sagelib-10.0.beta8] 
[sagelib-10.0.beta8]     sage/numerical/backends/cvxpy_backend.pyx:936:10: Signature not compatible with previous declaration
[sagelib-10.0.beta8] 
[sagelib-10.0.beta8]     Error compiling Cython file:
[sagelib-10.0.beta8]     ------------------------------------------------------------
[sagelib-10.0.beta8]     ...
[sagelib-10.0.beta8]         cpdef objective_constant_term(self, d=*)
[sagelib-10.0.beta8]         cpdef set_objective(self, list coeff, d=*)
[sagelib-10.0.beta8]         cpdef set_verbosity(self, int level)
[sagelib-10.0.beta8]         cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=*)
[sagelib-10.0.beta8]         cpdef add_linear_constraint_vector(self, degree, coefficients, lower_bound, upper_bound, name=*)
[sagelib-10.0.beta8]         cpdef remove_constraint(self, int)
[sagelib-10.0.beta8]                                ^
[sagelib-10.0.beta8]     ------------------------------------------------------------

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 9, 2023

The Lint errors are unrelated; ignore.

@github-actions
Copy link

Documentation preview for this PR is ready! 🎉
Built with commit: aecb190

@takshakmudgal takshakmudgal closed this by deleting the head repository Jul 17, 2023
@kwankyu
Copy link
Collaborator

kwankyu commented Jul 23, 2023

What happened to this PR? Please add an appropriate resolution label.

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 6, 2023

It has been merged into #35368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CVXPYBackend: Implement method remove_constraint

3 participants