Variable constraints #252
-
Hello, I've managed to finally solve the minimum time maneuvering problem we discussed previously. Without going too much into the details, we have a variable -allowed_track_width ≤ n ≤ allowed_track_width, Infinite(s) However I would like for Is there a way to do this, either in @variables or in @Constraints? Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
These results look awesome! Yes, you can let the track width vary as a function of In this case, a simple example would be: using InfiniteOpt
model = InfiniteModel()
@infinite_parameter(model, s in [0, 1])
my_func(s) = sin(s) # TODO replace with desired function
@parameter_function(model, allowed_track_width == my_func(s))
@variable(model, n, Infinite(s))
@constraint(model, -allowed_track_width <= n)
@constraint(model, n <= allowed_track_width) |
Beta Was this translation helpful? Give feedback.
-
It all works beautifully. I must sound quite repetitive by now, but InfiniteOpt is just awesome 😉 |
Beta Was this translation helpful? Give feedback.
These results look awesome!
Yes, you can let the track width vary as a function of
s
. The easiest way to do this would be using the@parameter_function
macro which enables us to embed arbitrary Julia functions (that only depend on infinite parameters) in InfiniteOpt expressions. The syntax details are given here. Note however, that the bounds syntax in@variable
currently supports only constants (though perhaps we could generalize this). So, you'll need to enforce the limits via@constraint
.In this case, a simple example would be: