infiniteopt / InfiniteOpt.jl

An intuitive modeling interface for infinite-dimensional optimization problems.
https://infiniteopt.github.io/InfiniteOpt.jl/stable
MIT License
251 stars 17 forks source link

Inconsistent result in farmer problem #269

Closed sebacea closed 2 years ago

sebacea commented 2 years ago

Describe the bug I tried to reproduced the example of the farmer in the documentation

To Reproduce I ran the same code you give in the example

Expected behavior The expected output that is given in the example is:

Land Allocations: [48.56, 214.77, 236.67]
Expected Profit: $57099.53

What I obtained is

Land Allocations: [221.74, 55.67, 222.58]
Expected Profit: $132751.07

Desktop (please complete the following information):

sebacea commented 2 years ago

For the CVAR case is the same

Land Allocations: [93.54, 83.44, 323.02]
Expected Profit: $53781.29
pulsipher commented 2 years ago

Hi @sebacea, thanks for posting an issue. This behavior is actually expected since the random infinite parameters in the farmer problem use random samples; hence, each time the problem is solved different samples will be used which will lead to a different answer. Moreover, since only 10 samples are used the results can vary by quite a bit. In practice, many more samples should be used (e.g., 1,000) and the Random.seed! function can be used to seed the random number generator such that the same samples are used each time the script is run.

I will refine the example to make this more clear.

sebacea commented 2 years ago

Ouch. You are right. I forgot that some parameterd were random. Sorry.

Le jeu. 9 juin 2022 à 13:26, Joshua Pulsipher @.***> a écrit :

Hi @sebacea https://github.com/sebacea, thanks for posting an issue. This behavior is actually expected since the random infinite parameters in the farmer problem use random samples; hence, each time the problem is solved different samples will be used which will lead to a different answer. Moreover, since only 10 samples are used the results can vary by quite a bit. In practice, many more samples should be used (e.g., 1,000) and the Random.seed! function can be used to seed the random number generator such that the same samples are used each time the script is run.

I will refine the example to make this more clear.

— Reply to this email directly, view it on GitHub https://github.com/pulsipher/InfiniteOpt.jl/issues/269#issuecomment-1151401442, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4RMZBQRRVYJVUOOKWQLNTVOISKNANCNFSM5YKU6JKA . You are receiving this because you were mentioned.Message ID: @.***>

pulsipher commented 2 years ago

No need to apologize, these type of questions help us to improve the documentation.

Does this update clear things up? https://pulsipher.github.io/InfiniteOpt.jl/previews/PR270/examples/Stochastic%20Optimization/farmer/

sebacea commented 2 years ago

Absolutely, many thanks!