added two example notebooks: energy-resource-build and sudoku#356
Conversation
13ab7c0 to
df82c3b
Compare
for more information, see https://pre-commit.ci
|
Closes #348 Sorry if I messed up the formatting stuff on the PR |
|
What happened to this PR? I took a brief look at sudoku example, it can be made more tidy, not all power of linopy got utilised. Whenever for loop is used it is unnecessary operation in linopy like tools where broadcast and group by operations exists |
Merging this PR will not alter performance
Comparing Footnotes
|
Replace the sudoku notebook's loops with idiomatic linopy: groupby for the square constraints, a broadcast MultiIndex-free mask for the hints, and a weighted sum for the grid reconstruction (aligns with v1 no-MultiIndex, PyPSA#803). Add nblink files and toctree entries for the energy-resource-build and sudoku examples. Square groupby uses use_fallback=True pending PyPSA#823.
Teach the why, not just the what: motivate the binary on/off encoding as a linearization, map each sum-constraint to its Sudoku rule, explain the groupby dimension collapse and the hint-mask broadcast, and frame use_fallback=True as a temporary PyPSA#823 workaround. Drop the unused square_index_3d and define the variable directly; trim the random-data 3D plot; fix typos and terminology.
for more information, see https://pre-commit.ci
|
Note Generated by Claude Pushed follow-up work on top of the two notebooks:
|
for more information, see https://pre-commit.ci
- Use freq='ME' instead of deprecated 'M' in pd.date_range - Replace legacy np.random.seed/randn with np.random.default_rng (NPY002) Notebook re-executes end-to-end.
for more information, see https://pre-commit.ci
|
@tpu-brunkhorst I know this took ages but I now got the time to look at this. I will push one more commit on the energy resource nb and then merge this. thanks for the contribution |
Hi - I added two notebooks to the examples folder. I didn't add links to these in the TOC or anything - up to you how you want to link them. Thanks for a great project!