I have two trigonometric variables (i.e., cs_fr and si_fr) in my code and at the same time, there are two trigonometric terms (i.e., cs_to and si_to) which linearly depend on cs_fr and si_fr. I have defined cs_fr and si_fr as variables with their corresponding bounds. I also defined expressions for cs_to and si_to as follows.

I also separately defined bounds for cs_to and si_to as follows.

sin_max_to = E
sin_min_to = F
sin_max_to = G
sin_min_to = H

I wanted to confine cs_to and si_to within their bounds through the following constraints but I got an error (i.e., ERROR: UndefVarError: si_to not defined). It seems that defining these terms by @expression doesn’t count!

I don’t want to increase the number of variables in my code by defining new variables for cs_to and si_to because they can be defined based on cs_fr and si_fr by expressions. Can you please let me know how I can define cs_to and si_to and confine them within their bounds through the expression macro? Thanks in advance!

Thanks for the response! The question is, variable x has its own lower and upper bounds thus the bounds on"my_expr" must be defined automatically based on the bounds on “x” and the linear relationship between “my_expr” and “x”. Are we allowed to restrict “my_expr” again (i.e., last line in the code)?

using JuMP
model = Model()
@variable(model, x)
@expression(model, my_expr, 2x + 1)
@constraint(model, 0 <= my_expr <= 1)

JuMP expressions just get expanded into the constraints where they appear. They are intended as a helper if you are re-using the same expression in different constraints.

using JuMP
model = Model()
@variable(model, x)
@expression(model, my_expr, 2x + 1)
@constraint(model, 0 <= my_expr <= 1) # is equivalent to
@constraint(model, 0 <= 2x + 1 <= 1)

You can add whatever bounds on x that you like. (Of course, this may make your problem infeasible.)

I am looking for a command that gives me the bounds on an expression. Let suppose the expression has a linear relationship with two different variables.

Now I wanna get the bounds on my_expr. I do know that the bounds on “my_expr” depend on the bounds on x and y variables. However, I don’t want to write a piece of script to compute my_expr’s bounds based on the bounds on “x” and “y” variables. In other words, is there any way to extract my_expr’s bounds directly?