Support for the GSCOPT package (graphs of convex sets) #2889
Replies: 3 comments 2 replies
-
|
Canonicalization of our support function atom already has an approach to 2.
Its approach will probably be much faster than creating more expression
trees with substituted variables.
β¦On Fri, Aug 8, 2025 at 2:59β―PM William Zijie Zhang ***@***.***> wrote:
Hello all,
I am starting a thread here after having an in-person discussion at ICCOPT
2025 with @TobiaMarcucci <https://github.com/TobiaMarcucci> and
@AlexandreAmice <https://github.com/AlexandreAmice>.
In particular, there were two major pain-points/feature requests that the
gcs team talked about:
1. support for taking the perspective of a set
2. the ability to define a convex set as a list of cones (perhaps this
can be a new constraint) and enforcing that a new variable belongs in this
set.
Some context for 1.
There is already an implementation for taking the perspective of a scalar
expression. see the PR <#1867>, atom
<https://github.com/cvxpy/cvxpy/blob/master/cvxpy/atoms/perspective.py>
and canonicalization
<https://github.com/cvxpy/cvxpy/blob/master/cvxpy/reductions/dcp2cone/canonicalizers/perspective_canon.py#L25>
.
However taking the perspective of a set seems to require a different
approach. I recall @TobiaMarcucci <https://github.com/TobiaMarcucci>
mentioned that it amounts to scaling the right hand-side (b) of the conic
constraint with the scalar parameter s. There was also a mention that the
scalar parameter s should not be restricted to be positive, but rather
another method can be used to ensure that the scaling of the perspective
function is in the positive direction. (maybe I am misremembering
completely though). @TobiaMarcucci <https://github.com/TobiaMarcucci>,
could you provide more details of this perspective of a set formulation?
(and references if possible!) I would like to read more about it to
formalize things. Let me know if I said anything incorrectly above.
Some context for 2.
The difficulty of implementing this is that constraint objects are
instantiated with the original variables as their arguments (say x), thus
it is probably necessary to loop over all constraint arguments and replace
any instance of x with the new variable w. @AlexandreAmice
<https://github.com/AlexandreAmice> shared a code snippet which does the
above. This could be a good starting point (for future reference), if we
ever decide to add this feature to cvxpy.
def substitute_variables_in_expression(expr, substitution_dict):
if isinstance(expr, Number):
return expr
for key, value in substitution_dict.items():
if not isinstance(key, Leaf):
raise ValueError(f"Key {key} must be of cvxpy Leaf Type")
if not isinstance(value, Leaf):
raise ValueError(f"Value {value} at key {key} must be of cvxpy Leaf Type")
expr = expr.tree_copy()
return _substitute_variables_in_expression_impl(expr, substitution_dict)
def _substitute_variables_in_expression_impl(expr, substitution_dict):
if isinstance(expr, Leaf):
return substitution_dict.get(expr, expr)
else:
pass
for i in range(len(expr.args)):
expr.args[i] = _substitute_variables_in_expression_impl(
expr.args[i], substitution_dict
)
return expr
I think it would be awesome to get some feedback on these two potential
new features, do you have any comments and thoughts? We should also discuss
about the API for these features.
β
Reply to this email directly, view it on GitHub
<#2889>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRLIFEX5PG4LWULI27KECD3MUMVLAVCNFSM6AAAAACDO7BL4SVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZYG4YDGOBZHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you for starting this discussion and sorry for the slow response! Regarding the first point. The perspective of a convex set The cool thing is that if the set So the proposal is that we write a function that, given a list of cvxpy constraints that describe the set Two comments on this:
I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for restarting this conversation! Just to note it here, since someone scooped the name gcspy on PyPi, I renamed the project gcsopt: https://github.com/TobiaMarcucci/gcsopt |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I am starting a thread here after having an in-person discussion at ICCOPT 2025 with @TobiaMarcucci and @AlexandreAmice.
In particular, there were two major pain-points/feature requests that the gcs team talked about:
Some context for 1.
There is already an implementation for taking the perspective of a scalar expression. see the PR, atom and canonicalization.
However taking the perspective of a set seems to require a different approach. I recall @TobiaMarcucci mentioned that it amounts to scaling the right hand-side (
b) of the conic constraint with the scalar parameters. There was also a mention that the scalar parametersshould not be restricted to be positive, but rather another method can be used to ensure that the scaling of the perspective function is in the positive direction. (maybe I am misremembering completely though). @TobiaMarcucci, could you provide more details of this perspective of a set formulation? (and references if possible!) I would like to read more about it to formalize things. Let me know if I said anything incorrectly above.Some context for 2.
The difficulty of implementing this is that constraint objects are instantiated with the original variables as their arguments (say
x), thus it is probably necessary to loop over all constraint arguments and replace any instance ofxwith the new variablew. @AlexandreAmice shared a code snippet which does the above. This could be a good starting point (for future reference), if we ever decide to add this feature to cvxpy.I think it would be awesome to get some feedback on these two potential new features, do you have any comments and thoughts? We should also discuss about the API for these features.
Beta Was this translation helpful? Give feedback.
All reactions