Hello all,

I would like to add a stochastic component to my optimization. More precisely, I would like to make the demand parameter B stochastic. It should fluctuate around the predefined value, which comes from the input GDX file, with a defined maximum percentage deviation.

Now my question which adjustments do I have to make in my model to make this possible?

I am a complete beginner in the field of stochastic optimization. If you have any questions, please contact me.

I am happy about help or suggestions

Many greetings

Janisch

## Stochastic AUGMECON Method Topic is solved

### Stochastic AUGMECON Method

Last edited by Janisch 6 days ago, edited 2 times in total.

### Re: Stochastic AUGMECON Method

So I tried to get the model to run using emp notations. Now a syntax error appears that I don't understand:

Error Cannot open parameter file

Error Error code = 2

I have attached the adapted code and the error message. I hope somebody can help me with this error

Error Cannot open parameter file

Error Error code = 2

I have attached the adapted code and the error message. I hope somebody can help me with this error

### Re: Stochastic AUGMECON Method

You were almost there: a) select a EMP-SP solver to solve the EMP model: option emp=de; b) add "scenario dict" to the solve statement to indicate that this is a SP-EMP model: Solve mod_payoff using emp maximizing obj scenario dict; The second solve statement of model mod_epsmethod had this already on. If you don't want to solve mod_payoff solved as a stochastic model, change the model type to MIP. c) The equation ObjFunction was not marked as second stage but contains second stage variables, hence DE complained. After adding ObjFunction to the list of second stage objects in the EMP file everything worked.

-Michael

-Michael

### Re: Stochastic AUGMECON Method

Great, thanks for your help.

My problem is also that only the ObjFunction("Cost") depends on ud. How can I force that at least the lowest demand is served, if I optimize for example the time as objective function? Because otherwise the individual optimization of the time and the CO2e will not route any transports through the network.

And how can I set the time limit for the individual calculations in CPLEX to a maximum of 40 sec?

Thanks already for your help!

My problem is also that only the ObjFunction("Cost") depends on ud. How can I force that at least the lowest demand is served, if I optimize for example the time as objective function? Because otherwise the individual optimization of the time and the CO2e will not route any transports through the network.

And how can I set the time limit for the individual calculations in CPLEX to a maximum of 40 sec?

Thanks already for your help!

### Re: Stochastic AUGMECON Method

Can't you just add a constraint DemandMin that uses the smallest bf (bfMin=0.5) but has no recourse/slack variable ud but must be satisfied? There is now the chance the the model can go infeasible if circumstances are that this min demand requirement can't be fulfilled and no other "slack" is in the system. You can even have this single constraint in the first stage. I have attached the model to be clear what I mean.

-Michael

-Michael

### Re: Stochastic AUGMECON Method

Thanks already!

The new constraint works well. But I still have the problem that my ObjFunction should not be in Stage 2. I have kept to the example Transport_Stochastic. In this formulation the target function is also not in Stage 2.

How can I reformulate my model so that the equation is assigned to ObjFunction in Stage 1? Only ObjFunction("Cost") contains ud. So far it makes no difference at all which probabilities I enter. The result is always the same. Why?

Why sink the unsatisfied demand for Berlin, when the demand factor is increasing? This does not make sense to me. Is there an explanation for this? I have attached my model and the example.

Thanks for your time and help

Janisch

The new constraint works well. But I still have the problem that my ObjFunction should not be in Stage 2. I have kept to the example Transport_Stochastic. In this formulation the target function is also not in Stage 2.

How can I reformulate my model so that the equation is assigned to ObjFunction in Stage 1? Only ObjFunction("Cost") contains ud. So far it makes no difference at all which probabilities I enter. The result is always the same. Why?

Why sink the unsatisfied demand for Berlin, when the demand factor is increasing? This does not make sense to me. Is there an explanation for this? I have attached my model and the example.

Thanks for your time and help

Janisch

### Re: Stochastic AUGMECON Method

The objective function is

To answer the other questions one would have to emerge in your model. Can't help with that. Sorry.

-Michael

**always**in the second stage, therefore it does not need to be specified in the EMP info file as 2nd stage. Your constraint ObjFunction, even though called like this, is not (at least not directly) the objective function, so no implicit assignment of the stage for this constraint.To answer the other questions one would have to emerge in your model. Can't help with that. Sorry.

-Michael

### Re: Stochastic AUGMECON Method

Thanks for your answer

Now it works. I had a thinking error when assigning the stages

But i have a second question:

Is it possible to read in the distribution probabilities and the corresponding discrete demand quantities from Excel? Because these have to be written directly in the following code lines:

How can I implement this?

Thank you and many greetings

Janisch

Now it works. I had a thinking error when assigning the stages

But i have a second question:

Is it possible to read in the distribution probabilities and the corresponding discrete demand quantities from Excel? Because these have to be written directly in the following code lines:

Code: Select all

```
file emp / '%emp.info%' /; put emp '* problem %gams.i%'/;
$onput
randvar bf discrete 0.3 0.95
0.5 1.00
0.2 1.05
$offput
putclose emp;
```

Thank you and many greetings

Janisch