Skip to content

Zero devision error #91

@djs0109

Description

@djs0109

Please describe the bug
When running optimization, ZeroDivisionError occurs.

What are the steps to reproduce the bug?

  1. Create .env with following settings (the rest vars are not important for this issue)
TIMERESOLUTION=3600
# 604800 seconds = 1 week
CLUSTERLENGTH=604800
CLUSTERNUMBER=8
# 3600 seconds = 1 hour
DATARESOLUTION=3600
# 31536000 seconds = 1 year
DATALENGTH=31536000
  1. Run e8_scenario_evaluation.py while using the created .env, for example,
    data = Datahandler(scenario_name = "example",
                       env_path=r"D:\Git\districtgenerator\.env")
  1. Following error should occur (if not try run it again :) )
...
  File "D:\Git\districtgenerator\districtgenerator\functions\opti_central.py", line 473, in run_opti_central
    model.addConstr(cool_dom["CC"][n][t] == power_dom["CC"][n][t] * param_dec_devs["CC"]["grade"]
  File "src/gurobipy/linexpr.pxi", line 574, in gurobipy._core.LinExpr.__truediv__
ZeroDivisionError: float division

Suggestion
Seems like following constraint is causing problem

# Compression chiller
model.addConstr(cool_dom["CC"][n][t] == power_dom["CC"][n][t] * param_dec_devs["CC"]["grade"]
* (273.15 + 5) / (T_e[t] - 5),
name="CC_energybalance_cooling_" + str(n) + "_" + str(t))

Adding a small number, like (T_e[t] - 5 + 1e-6), can avoid the problem when (T_e[t] - 5) is exactly 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions