# Fixing the amount of variable in Gurobi - Python as a parameter for another model

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.

• What I can suggest is to define $x_2$ in the second model as a parameter, rather than a variable. If you post the code we can see how you are doing this and help you. Feb 6 at 13:31

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$$

• 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. Feb 6 at 11:48