SpineOpt.jl icon indicating copy to clipboard operation
SpineOpt.jl copied to clipboard

Bug with reduced stochastic structures.

Open Tasqu opened this issue 2 years ago • 4 comments

Mostly a TODO for myself, but if anyone else wants to tackle this, be my guest.

There seems to be a bug if providing a model with input data defining a branching stochastic structure. E.g. defining

parent_stochastic_scenario__child_stochastic_scenario:
realization -> {optimistic, mean, pessimistic}

but limiting the branching on the stochastic_structure__stochastic_scenario stage seems to result in a couple of issues, e.g.

stochastic_structure__stochastic_scenario:
deterministic -> {realization, mean}

Essentially, the structure is intended to use only the mean scenario forecast and discard the optimistic and pessimistic. At the moment, this seems to result in the following issues:

  1. Error when processing the stochastic structure in stochastic_structure.jl:149-151 when child_relative_weight is not defined for non-existing scenarios.
  2. Even if this is fixed, seems like the model comes out as infeasible or unbounded for some currently unknown reason.

Current workaround is to disable the unused stochastic_scenarios with the is_active feature.

Tasqu avatar Feb 28 '23 13:02 Tasqu

We could e.g. check for scenarios not used in the stochastic structure and filter them out in preprocessing. Also, I think at the moment each stochastic structure needs to be connected to each stochastic scenario, which can be tedious. We could hence first filter out scenarios that don't appear in any structure, and then add "half-missing" scenarios. That latter part is somewhat more tricky I believe, but it felt a bit odd to having to create a "deterministic" structure that has all the child scenarios.

mihlema avatar Mar 07 '23 04:03 mihlema

There is actually some filtering in the code it attempts to do, but it doesn't seem to do a sufficiently thorough job to avoid errors.

Also, I think at the moment each stochastic structure needs to be connected to each stochastic scenario, which can be tedious. We could hence first filter out scenarios that don't appear in any structure, and then add "half-missing" scenarios. That latter part is somewhat more tricky I believe, but it felt a bit odd to having to create a "deterministic" structure that has all the child scenarios.

@mihlema I don't think this is true? (At least I've gotten this to work without this?) All stochastic scenarios need to be mentioned in the parent_stochastic_scenario__child_stochastic_scenario relationship (if they are to be used anywhere), but stochastic_structure__stochastic_scenario only needs to account for the ones it actually includes. However, at the moment with this filtering being a little unreliable, I there are cases where one needs to filter out unused stochastic scenarios with the is_active flag from the database.

Tasqu avatar Mar 08 '23 07:03 Tasqu

@Tasqu What's the current status of this? Is it still relevant / is it necessary / is it nice to have?

clizbe avatar Nov 20 '23 13:11 clizbe

@clizbe I honestly had forgotten all about this 😅 It's probably still relevant, as I imagine no-one has happened to fix this by accident. I don't imagine I'll have the time and/or a reason to fix this in the near-term, though.

Tasqu avatar Nov 21 '23 13:11 Tasqu