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

fix: replace capacity limit values for existing generators with '.' #82

Merged
merged 1 commit into from
May 27, 2021

Conversation

danielolsen
Copy link
Contributor

Pull Request doc

Purpose

Avoid generating an infeasible model

What the code is doing

We change the code so that entries in the gen_capacity_limit_mw column of the generation_projects_info.csv file for existing generators are filled with ".", rather than the default capacity limits from const.py. This avoids generating an infeasible problem, I think because we do not constrain the existing coal plants to be zero capacity, which conflicts with their non-zero capacities from the gen_build_predetermined.csv file. The original issue for generating this file (#1) was ambiguous as to what should be in these entries, and we made a mistake in porting the logic from the original script in #35.

Testing

Tested manually. Before: the solver returns Infeasible in 1-2 minutes. After: the solver keeps running much longer than that.

Time estimate

5-10 minutes.

@danielolsen danielolsen self-assigned this May 26, 2021
@danielolsen danielolsen added the bug Something isn't working label May 26, 2021
Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the conversation on Slack and it does exactly what we intend to.

Copy link
Collaborator

@rouille rouille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it runs, I am happy

@danielolsen
Copy link
Contributor Author

It runs... sort of:

dolsen@becompute01:~/switchwrapper_test$ ~/.local/bin/switch solve --verbose --s
olver gurobi --suffixes dual

=======================================================================
Switch 2.0.6, http://switch-model.org
=======================================================================
Arguments:
logs_dir='logs', inputs_dir='inputs', suffixes=['dual'], solver='gurobi', solver_manager='serial', outputs_dir='outputs', verbose=True
Modules:
switch_model, switch_model.timescales, switch_model.financials, switch_model.balancing.load_zones, switch_model.energy_sources.properties, switch_model.generators.core.build, switch_model.generators.core.dispatch, switch_model.generators.core.no_commit, switch_model.energy_sources.fuel_costs.simple, switch_model.transmission.local_td, switch_model.transmission.transport.build, switch_model.transmission.transport.dispatch, switch_model.reporting, switch_model.solve
=======================================================================

Model created in 0.24 s.
Loading inputs...
Data read in 3.67 s.

Instance created from data in 161.02 s.

Total time spent constructing model: 164.69 s.

Solving model...
Solved model. Total time spent in solver: 140.247918 s.

Optimization termination condition was optimal.
Solver message: Model was solved to optimality (subject to tolerances), and an optimal solution is available.

Saved results in 22.09 s.
Executing post solve functions...
ERROR: evaluating object as numeric value: BuildTx[88607ac,2030]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object BuildTx[88607ac,2030]
ERROR: evaluating object as numeric value: TxCapacityNameplate[88607ac,2030]
        (object: <class 'pyomo.core.base.expression._GeneralExpressionData'>)
    No value for uninitialized NumericValue object BuildTx[88607ac,2030]
Traceback (most recent call last):
  File "/home/dolsen/.local/bin/switch", line 8, in <module>
    sys.exit(main())
  File "/home/dolsen/.local/lib/python3.8/site-packages/switch_model/main.py", line 39, in main
    main()
  File "/home/dolsen/.local/lib/python3.8/site-packages/switch_model/solve.py", line 183, in main
    instance.post_solve()
  File "/home/dolsen/.local/lib/python3.8/site-packages/switch_model/utilities.py", line 252, in post_solve
    module.post_solve(instance, outputs_dir)
  File "/home/dolsen/.local/lib/python3.8/site-packages/switch_model/transmission/transport/build.py", line 336, in post_solve
    normalized_dat = [
  File "/home/dolsen/.local/lib/python3.8/site-packages/switch_model/transmission/transport/build.py", line 346, in <listcomp>
    "TxCapacityNameplate": value(mod.TxCapacityNameplate[tx,p]),
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/numvalue.py", line 226, in value
    tmp = obj(exception=True)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/base/expression.py", line 54, in __call__
    return self.expr(exception=exception)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/numeric_expr.py", line 223, in __call__
    return evaluate_expression(self, exception)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/visitor.py", line 974, in evaluate_expression
    return visitor.dfs_postorder_stack(exp)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/visitor.py", line 519, in dfs_postorder_stack
    flag, value = self.visiting_potential_leaf(_sub)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/visitor.py", line 894, in visiting_potential_leaf
    return True, value(node)
  File "/home/dolsen/.local/lib/python3.8/site-packages/pyomo/core/expr/numvalue.py", line 228, in value
    raise ValueError(
ValueError: No value for uninitialized NumericValue object BuildTx[88607ac,2030]

We do have the results.pickle file in the expected location, and it is 132 MB (i.e. not empty), so maybe we have everything we need...

@danielolsen danielolsen merged commit 622bca7 into mvp May 27, 2021
@danielolsen danielolsen deleted the daniel/gen_capacity_limit_mw_fix branch May 27, 2021 00:00
@rouille rouille added the v0.1 label May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants