I have solved a very simple mathematical model ( 2 variables) using Gurobi in Python and now I want to fix the amount of the variable in another model and solve it, for example, consider the variable $x_2$ is solved and it is equal to $2$, and now I want to add it to another mathematical programming as an input (parameter) the problem is, Gurobi expects the $x_2$ to be a variable, not a parameter wich finally gives the error "Variable not in model", I would appreciate it if anyone can help me with this issue.
1 Answer
Let $x_2^1$ be the variable in the first model, and $x_2^2$ be the corresponding variable in the second model. Also, let $\hat{x}_2^1$ be the optimal value of $x_2^1$, after solving the first model.
So if you want to add the optimal value of $x_2^1$ in the second model, use the constraint $$ x_2^2 = \hat{x}_2^1 $$
-
$\begingroup$ Thanks for answering, the point is, it actually expects x22 being implemented as something in the model, if I implement it as a variable, it gives an error of not being a PSD ( Positive Semi Definite ), because the structure is somehow Nonlinear, so now I want to add it as a parameter in the model, and I don't know-how. $\endgroup$ Feb 6, 2021 at 11:48