martinbiel / StochasticPrograms.jl

Julia package for formulating and analyzing stochastic recourse models.
MIT License
75 stars 25 forks source link

Problem in get WS'values #21

Closed bigadolfo closed 3 years ago

bigadolfo commented 3 years ago

Hello everyone:

In the example of: https://martinbiel.github.io/StochasticPrograms.jl/dev/manual/quickstart/ there are 2 scenarios (ξ₁ and ξ₂), for each I can obtain the formulation: ws1 = WS(sp, ξ₁) print(ws1) and ws2 = WS(sp, ξ₂) print(ws2) all is ok

Using print (ws1) and print (ws2) and later of coding them in Julia by my own, I can obtain the EWS. So value of ws1 is 37.5 and ws2 -2556.25 , all ok.

But to take advantage of wait_and_see_decision, I can obtain values of x₁ and x₂ correctly using x₁ = wait_and_see_decision(sp, ξ₁)
x₂ = wait_and_see_decision(sp, ξ₂)
However, value of ws1 and value of ws2 are not correct when I use: ws1 = evaluate_decision(sp, x₁) #---the result is -762.5 ws2 = evaluate_decision(sp, x₂) #---the result is -626.25 and these are not the correct values....

What's going on? , Can you help me?

Thanks in advance, Adolfo

martinbiel commented 3 years ago

The optimal value of a given wait-and-see problem is not the same as the expected value of the corresponding wait-and-see decision. For example, 37.5 is the optimal value if ξ₁ is the actual scenario AND the actor knows it is before taking the decision. This yields the decision x₁. Now, if you evaluate this decision, you measure the expected result of taking this decision across ALL scenarios (both ξ₁ and ξ₂). This means solving both subproblems with the first-stage decisions fixed to x₁, which does not yield the same value as the wait-and-see value for only ξ₁.

bigadolfo commented 3 years ago

Hi Martin Biel

Thanks for your prompt response.

Use these sentences are not correct and understand: ws1 = evaluate_decision(sp, x₁) #---the result is -762.5ws2 = evaluate_decision(sp, x₂) #---the result is -626.25

At this point in time, I thought to solve with this: ws1 = evaluate_decision(sp, x₁, ξ1) #---the result is 8400 ws2 = evaluate_decision(sp, x₂, ξ2)#---the result is 16775 but these results are not correct.

Could you help me, what is the way to obtain the correct values of 37.5 and -2556.25 using some method, function,.. of StochasticPrograms package? (without having to do it in a separate program -my own code as I told you before-)

Thank in advance, Adolfo -----Original Message----- From: "Martin Biel" notifications@github.com Sent: Thursday, November 12, 2020 3:56am To: "martinbiel/StochasticPrograms.jl" StochasticPrograms.jl@noreply.github.com Cc: "bigadolfo" asaavedra@ibestsolutions.biz, "Author" author@noreply.github.com Subject: Re: [martinbiel/StochasticPrograms.jl] Problem in get WS'values (#21)

The optimal value of a given wait-and-see problem is not the same as the expected value of the corresponding wait-and-see decision. For example, 37.5 is the optimal value if ξ₁ is the actual scenario AND the actor knows it is before taking the decision. This yields the decision x₁. Now, if you evaluate this decision, you measure the expected result of taking this decision across ALL scenarios (both ξ₁ and ξ₂). This means solving both subproblems with the first-stage decisions fixed to x₁, which does not yield the same value as the wait-and-see value for only ξ₁. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .

martinbiel commented 3 years ago
ws = WS(sp, ξ₁, optimizer = GLPK.Optimizer)
optimize!(ws)
objective_value(ws)

should give 37.5 in this case. evaluate_decision(sp, x₁, ξ₁) should actually give the same thing, but I just noticed that this function does not properly factor in the first-stage cost. I will fix this in a future release.

bigadolfo commented 3 years ago

Ok. Thanks, all is correct.

martinbiel commented 3 years ago

The first-stage cost is used correctly in the evaluation now, so evaluate_decision(sp, x₁, ξ₁) gives 37.5 in this case as expected. Closing this.