Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocation should return same strategy if a model is run twice #1709

Open
3 tasks
Jingru923 opened this issue Aug 9, 2024 · 3 comments · May be fixed by #1927
Open
3 tasks

Allocation should return same strategy if a model is run twice #1709

Jingru923 opened this issue Aug 9, 2024 · 3 comments · May be fixed by #1927
Labels
allocation Allocation layer improvement Improvements of the usability of existing functionality

Comments

@Jingru923
Copy link
Contributor

What
When building up benchmark for Ribasim, it has come to attention that if I run a model with allocation twice, I will get different water balance. This is because some optimization problems have unlimited solutions and the solver returns a random one. Therefore the output of allocation model is always different. This should be investigated.

How

  • Investigate JuMP and its solvers. Given an optimization problem with non-unique solution, the solver should return the same solution every time.
  • Run model with allocation twice, and see if the output is the same
  • Update the benchmark for allocation models.
@Jingru923 Jingru923 added allocation Allocation layer improvement Improvements of the usability of existing functionality labels Aug 9, 2024
@Jingru923
Copy link
Contributor Author

Jingru923 commented Aug 9, 2024

In the regression_test.jl, these tests should be added to the testitem for regression_ode_solvers_allocation.

                # TODO @test all(q -> abs(q) < 12.0, basin.storage - basin_bench.storage)
                # TODO @test all(
                #     q -> abs(q) < 100.0,
                #     basin.storage[(end - 16):end] - basin_bench.storage[(end - 16):end],
                # )
                # TODO @test all(
                #     q -> abs(q) < 2.0,
                #     basin.level[(end - 16):end] - basin_bench.level[(end - 16):end],
                # )
                # TODO @test all(q -> abs(q) < 1e-1, basin.balance_error)
                # TODO @test all(q -> abs(q) < 30.0, basin.relative_error)

@Huite
Copy link
Contributor

Huite commented Aug 9, 2024

Given an optimization problem with non-unique solution, the solver should return the same solution every time

Wouldn't it be better to make sure you have a unique solution? I.e. we should make it so that the optimization problem is well defined?

@SouthEndMusic
Copy link
Collaborator

Yes, that's what upcoming issues for allocation are for, especially optimizing per source individually. Still, it's weird that the optimizer is not deterministic.

visr added a commit that referenced this issue Sep 23, 2024
Fixes #1833

HWS output looks like this before, and no output after.
The `invalid_unstable` test model still logs though, as captured by
tests.

```

┌ Info: Convergence bottlenecks in descending order of severity:
│   Pump #2019 = NaN
│   Pump #2130 = NaN
│   Pump #2315 = NaN
│   Pump #2637 = NaN
│   Pump #3995 = NaN
│   Pump #4536 = NaN
│   Pump #6128 = NaN
│   Pump #6866 = NaN
│   Pump #9633 = NaN
│   Pump #10704 = NaN
│   Pump #10710 = NaN
│   Pump #10711 = NaN
│   Pump #10712 = NaN
│   Pump #10713 = NaN
│   Pump #10714 = NaN
│   Pump #10715 = NaN
│   Pump #10716 = NaN
│   Pump #10717 = NaN
│   Outlet #6692 = NaN
│   Outlet #7679 = NaN
│   Outlet #10702 = NaN
│   Outlet #10703 = NaN
│   UserDemand #1000015 = NaN
│   UserDemand #1000016 = NaN
│   UserDemand #1000017 = NaN
│   UserDemand #1000018 = NaN
│   UserDemand #1000019 = NaN
│   UserDemand #1000020 = NaN
│   UserDemand #1000021 = NaN
│   UserDemand #1000022 = NaN
│   UserDemand #1000038 = NaN
│   UserDemand #1000040 = NaN
│   UserDemand #1000042 = NaN
│   Basin #529 = NaN
│   Basin #670 = NaN
│   Basin #905 = NaN
│   Basin #1041 = NaN
│   Basin #1340 = NaN
│   Basin #1369 = NaN
│   Basin #1514 = NaN
│   Basin #1676 = NaN
│   Basin #1709 = NaN
│   Basin #1873 = NaN
│   Basin #2028 = NaN
│   Basin #2232 = NaN
│   Basin #2255 = NaN
│   Basin #2323 = NaN
│   Basin #2336 = NaN
│   Basin #2381 = NaN
│   Basin #2468 = NaN
│   Basin #2496 = NaN
│   Basin #2522 = NaN
│   Basin #2590 = NaN
│   Basin #2749 = NaN
│   Basin #2968 = NaN
│   Basin #3016 = NaN
│   Basin #3090 = NaN
│   Basin #3302 = NaN
│   Basin #3364 = NaN
│   Basin #3448 = NaN
│   Basin #3543 = NaN
│   Basin #3584 = NaN
│   Basin #3721 = NaN
│   Basin #3899 = NaN
│   Basin #4024 = NaN
│   Basin #4134 = NaN
│   Basin #4184 = NaN
│   Basin #4279 = NaN
│   Basin #4339 = NaN
│   Basin #4473 = NaN
│   Basin #4570 = NaN
│   Basin #4714 = NaN
│   Basin #4796 = NaN
│   Basin #4830 = NaN
│   Basin #4838 = NaN
│   Basin #5048 = NaN
│   Basin #5097 = NaN
│   Basin #5207 = NaN
│   Basin #5322 = NaN
│   Basin #5371 = NaN
│   Basin #5381 = NaN
│   Basin #5472 = NaN
│   Basin #5498 = NaN
│   Basin #5505 = NaN
│   Basin #5530 = NaN
│   Basin #5616 = NaN
│   Basin #5909 = NaN
│   Basin #5978 = NaN
│   Basin #5999 = NaN
│   Basin #6017 = NaN
│   Basin #6077 = NaN
│   Basin #6101 = NaN
│   Basin #6164 = NaN
│   Basin #6224 = NaN
│   Basin #6273 = NaN
│   Basin #6327 = NaN
│   Basin #6364 = NaN
│   Basin #6401 = NaN
│   Basin #6419 = NaN
│   Basin #6428 = NaN
│   Basin #6437 = NaN
│   Basin #6473 = NaN
│   Basin #6503 = NaN
│   Basin #6582 = NaN
│   Basin #6757 = NaN
│   Basin #6885 = NaN
│   Basin #6926 = NaN
│   Basin #6945 = NaN
│   Basin #6972 = NaN
│   Basin #7053 = NaN
│   Basin #7087 = NaN
│   Basin #7101 = NaN
│   Basin #7117 = NaN
│   Basin #7164 = NaN
│   Basin #7214 = NaN
│   Basin #7310 = NaN
│   Basin #7385 = NaN
│   Basin #7400 = NaN
│   Basin #7417 = NaN
│   Basin #7484 = NaN
│   Basin #7597 = NaN
│   Basin #7615 = NaN
│   Basin #7668 = NaN
│   Basin #7706 = NaN
│   Basin #7843 = NaN
│   Basin #7909 = NaN
│   Basin #8014 = NaN
│   Basin #8020 = NaN
│   Basin #8049 = NaN
│   Basin #8059 = NaN
│   Basin #8071 = NaN
│   Basin #8234 = NaN
│   Basin #8257 = NaN
│   Basin #8340 = NaN
│   Basin #8364 = NaN
│   Basin #8559 = NaN
│   Basin #8685 = NaN
│   Basin #8717 = NaN
│   Basin #8757 = NaN
│   Basin #8786 = NaN
│   Basin #8817 = NaN
│   Basin #8921 = NaN
│   Basin #9033 = NaN
│   Basin #9086 = NaN
│   Basin #9123 = NaN
│   Basin #9144 = NaN
│   Basin #9185 = NaN
│   Basin #9209 = NaN
│   Basin #9358 = NaN
│   Basin #9406 = NaN
│   Basin #9430 = NaN
│   Basin #9484 = NaN
│   Basin #9586 = NaN
│   Basin #9627 = NaN
│   Basin #9830 = NaN
│   Basin #9885 = NaN
│   Basin #9899 = NaN
│   Basin #9906 = NaN
│   Basin #9954 = NaN
│   Basin #10040 = NaN
│   Basin #10107 = NaN
│   Basin #10184 = NaN
│   Basin #10202 = NaN
│   Basin #10308 = NaN
│   Basin #10321 = NaN
│   Basin #10343 = NaN
│   Basin #10583 = NaN
│   Basin #10587 = NaN
│   Basin #10634 = NaN
└   Basin #10659 = NaN
```
@SouthEndMusic SouthEndMusic linked a pull request Nov 6, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
allocation Allocation layer improvement Improvements of the usability of existing functionality
Projects
Status: To do
Development

Successfully merging a pull request may close this issue.

3 participants