jckantor/ND-Pyomo-Cookbook

04.03: error in lambda expression

lgnam opened this issue · 3 comments

lgnam commented

In the example showing the 'minimum number of days' after editing the line stating the applied model to m = maintenance_planning_ramp(c, T, M, P) the following error popped up in Colab:

ERROR: Rule failed when generating expression for constraint sprd with index
    1: NameError: name 's' is not defined
ERROR: Constructing component 'sprd' from data=None failed: NameError: name
    's' is not defin
```ed

Unfortunately, I have little experience with lambda-expression and could not resolve it.

best,
lukas

I've rerun this notebook on Google Colab, and everything seems to run fine as written. You mention editing a line .. could you specify what edit you made that led to the error message you've observed?

lgnam commented

In section 'Ramping Constraints' as well as insection 'Introducing a Minimum Number of Operational Days between Maintenance Periods' I changed the line m = maintenance_planning_gdp(c, T, M, P) to m = maintenance_planning_ramp(c, T, M, P), so that your adapted function is used (line numbers are 37 in the first section and 38 in the second). The error only occurs in the last section 'Introducing a Minimum Number of Operational Days between Maintenance Periods'.

Hi Lukas ... I've done a pretty thorough rewrite of notebook 04.03. The problem you encountered was because I had mistakenly indexed twice over time which introduced many redundant constraints as well as invalid indices in some expressions. Also, thanks for pointing the use of the wrong function in the sections you mentioned. Thanks! Let me know if there are any further issues.