# stochastic

• 5 replies
• 145 views

• Newcomer
• 27 replies

Dear,

I have a binary variable in my model X(i,j,k,s) and I want that it assumes a value that I calculated in the deterministic model. For example I want that X(i,j,k,s)=X('Yorkshire and the Humber','MEA',k,s);
How can I write this in aimms?
I tried to write a constraint but after the run of the programme I don't have results for this variable.

### 5 replies

Userlevel 5 +4

You could add a constraint with definition:

``X(i,j,k,s) = X('Yorkshire and the Humber','MEA',k,s).level``

If you use

``X(i,j,k,s)=X('Yorkshire and the Humber','MEA',k,s)``

then the term on the right-hand-side is also considered a variable in the math program, and therefore not fixed to a value.

Dear @Marcel Hunting

in this way the model it is not working, I don’t have any results for X.

I thought to convert X in a parameter and then to fix the value that it should be have.

Is it correct?

Userlevel 5 +4

You can also fix X('Yorkshire and the Humber','MEA',k,s) to a certain value by using the .nonvar suffix, so add the statement:

``X('Yorkshire and the Humber','MEA',k,s).nonvar := 1;``

before the second solve. And use a constraint:

``X(i,j,k,s)=X('Yorkshire and the Humber','MEA',k,s)``

You have to make sure that you do not empty or change the values of X between the deterministic and stochastic solve. If X is still empty then likely the model has either become infeasible or you are emptying X before the stochastic solve.

Hi @graleo ,

Best Regards

Dear @Andrew

do you habe any other solution?
Best