V_CAPACITY ERROR

63 views
Skip to the first unread message

Riccardo Susini

unread,
7 Oct 2021, 06:55:1907/10/2021
to Temoa Project
(temoa-py3) (venv) C:\Users\ricca\PycharmProjects\TEMOApythonProject\temoa-energysystem>python temoa_model/ --config=temoa_model/config_sample

1 .db DD file(s) converted

-------------------------
              Config file: C:\Users\ricca\PycharmProjects\TEMOApythonProject\temoa-energysystem\temoa_model\config_sample
               Input file: C:\Users\ricca\PycharmProjects\TEMOApythonProject\temoa-energysystem\data_files\tuscany_res_BAU.dat
              Output file: C:\Users\ricca\PycharmProjects\TEMOApythonProject\temoa-energysystem\data_files\tuscany_res_BAU.sqlite
                 Scenario: test_run
       Spreadsheet output: True
            Myopic scheme: False
  Retain myopic databases: False

-------------------------
   Citation output status: None
              NEOS status: False
    Version output status: False

-------------------------
   Selected solver status: glpk
   Solver LP write status: False
    Pyomo LP write status: False

-------------------------
          MGA slack value: None
      MGA # of iterations: None
     MGA weighting method: None
**NOTE: If you are performing MGA runs, navigate to the DAT file and make any modifications to the MGA sets before proceeding.
Please press enter to continue or Ctrl+C to quit.
Notice: Using the GLPK solver interface.
Continue Operation? [Press enter to continue or CTRL+C to abort]

[    0.15] Reading data files.
[        ] Creating Temoa model instance.
Warning: ('Tuscany', 'DSL_VCS', 2000) specified as ExistingCapacity, but its LifetimeProcess parameter does not extend past the beginning of time_future.  (i.e. useless parameter)
        Lifetime:     20
        First period: 2020

Warning: ('Tuscany', 'GSL_VCS', 2005) specified as ExistingCapacity, but its LifetimeProcess parameter does not extend past the beginning of time_future.  (i.e. useless parameter)
        Lifetime:     15
        First period: 2020
Warning: ('Tuscany', 'LPG_VCS', 2005) has a specified Efficiency, but does not have any existing install base (ExistingCapacity).
ERROR: Rule failed when generating expression for constraint
    ExistingCapacityConstraint with index ('Tuscany', 'DSL_VCS', 2000):
    KeyError: "Index '('Tuscany', 'DSL_VCS', 2000)' is not valid for indexed
    component 'V_Capacity'"
ERROR: Constructing component 'ExistingCapacityConstraint' from data=None
    failed:
        KeyError: "Index '('Tuscany', 'DSL_VCS', 2000)' is not valid for
        indexed component 'V_Capacity'"
Exeception found in create_temoa_instance
"Index '('Tuscany', 'DSL_VCS', 2000)' is not valid for indexed component 'V_Capacity'""Index '('Tuscany', 'DSL_VCS', 2000)' is not valid for indexed component 'V_Capacity'"
Exiting Temoa ...
Traceback (most recent call last):
  File "temoa_model\temoa_run.py", line 275, in createAndSolve
    for k in self.solveWithoutMGA():
  File "temoa_model\temoa_run.py", line 243, in solveWithoutMGA
    for k in temoaInstance1.create_temoa_instance():
  File "temoa_model\temoa_run.py", line 361, in create_temoa_instance
    raise model_exc
  File "temoa_model\temoa_run.py", line 349, in create_temoa_instance
    self.instance = self.model.create_instance( modeldata )
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\PyomoModel.py", line 723, in create_instance
    profile_memory=profile_memory )
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\PyomoModel.py", line 806, in load
    profile_memory=profile_memory)
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\PyomoModel.py", line 870, in _load_model_data
    self._initialize_component(modeldata, namespaces, component_name, profile_memory)
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\PyomoModel.py", line 925, in _initialize_component
    declaration.construct(data)
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\constraint.py", line 793, in construct
    ndx)
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\misc.py", line 57, in apply_indexed_rule
    return rule(model, *index)
  File "temoa_model\temoa_rules.py", line 228, in ExistingCapacity_Constraint
    expr = M.V_Capacity[r, t, v] == M.ExistingCapacity[r, t, v]
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\indexed_component.py", line 543, in __getitem__
    index = self._validate_index(index)
  File "C:\Users\ricca\anaconda3\envs\temoa-py3\lib\site-packages\pyomo\core\base\indexed_component.py", line 695, in _validate_index
    % ( idx, self.name, ))
KeyError: "Index '('Tuscany', 'DSL_VCS', 2000)' is not valid for indexed component 'V_Capacity'"

Hi Joe,
the error here seems to be related to the existing capacity constraint. Indeed I have imposed an existing capacity in some vintage years but due to lifetime parameter, this existing capacity needs to be replaced in the first future year. I have done it hoping that the program replaces this capacity in the simulation. I have also imposed an efficiency for all those years (I can see it thanks to SQLbrowser). However, the program gives me this error and I don't know why because I have understood that it is always related to a missing in the efficiency table that in this case seems to be to not exist. Can you help me? Maybe the program warnings need to be solved and bring errors? 

I attach to you also the SQL and SQLite files. 
Thank you. 
(I have not calibrated with min/max activity anything due to the fact that I am not able to obtain any results using this strategy)

Temoa Project

unread,
7 Oct 2021, 09:37:1207/10/2021
to Temoa Project
Hi Riccardo,
Happy to try and help. Could you please send over the sql files again? I wasn't able to access them in your previous email.

Best,
Aranya

Riccardo Susini

unread,
12 Oct 2021, 10:24:4412/10/2021
to Temoa Project
tuscany_res_BAU.sqlite

Riccardo Susini

unread,
12 Oct 2021, 10:24:4712/10/2021
to Temoa Project
Now I have solved my errors, but Temoa is not able to find any solutions and I don't know why. I am truly desperate. 

Il giorno giovedì 7 ottobre 2021 alle 15:37:12 UTC+2 Temoa Project ha scritto:

Temoa Project

unread,
12 Oct 2021, 10:28:3612/10/2021
to Temoa Project
Hi Riccardo,

I see a few issues with the database that you had shared in your previous email:
1) It looks like the values specified in the MinCapacity table for a few technologies are higher than the MaxCapacity values for those same technologies. This will definitely cause an infeasibility error.
2) You also have several rows defined in the MinActivity table. It looks like for some technologies/output commodity combinations, the MinActivity specified is perhaps greater than the demand. This will also lead to infeasibility issues. I tried deleting all the rows in this table and was able to solve the database.
3) This database was missing the Output_Duals table - you will need to add this before you can solve without any errors.

I hope this helps! Let me know if you have any further questions. 

Best,
Aranya

Riccardo Susini

unread,
13 Oct 2021, 12:17:0113/10/2021
to Temoa Project
tuscany_res_BAU.sqlite

Riccardo Susini

unread,
13 Oct 2021, 12:17:0813/10/2021
to Temoa Project
Hi   Aranya,
thank you very much for your answer. 
I delete all the capacity and activity constraints due to the fact that they give me a lot of problems. Indeed if I had some activity constraints, the model was not able to find solution even if the values are in some sense OK. 
As regards the Output_Duals table, I never see it. Is it in temoa_schema?
I send my last version of the sqlite. It seems well in a graphical point of view but it was not able to have any activity from technologies that provide ELC_SC(electricity). 

I hope you can help me, best regards.
Riccardo.

aranya.venkatesh

unread,
18 Oct 2021, 11:51:0118/10/2021
to Temoa Project
Hi Riccardo,
Yes, you can find the Output_Duals table in temoa_schema. 

The version of the database that you just sent over still runs into infeasibilities, likely because of data in the MinActivity table. I would suggest taking a careful look at that table - if you specify a minimum level of activity for technologies that is greater than the total demand for the output commodity from that technology, you will observe infeasibilities.

Once I deleted that entire table and added the Output_Duals table, I was able to solve the database. In this version of results, I did observe some activity from technologies that provide ELC_SC. 

I hope this helps.

Best,
Aranya

Riccardo Susini

unread,
21 Oct 2021, 09:33:5021/10/2021
to Temoa Project
The problem is that by doing as you said in my Excel doesn't exist the activity_electric which should contain the production of energy by power plants. I send you the excel to show this problem. All the electricity is provided by imports but I want to limit that; doing like this I will get in troubles. 
Riccardo 

test_run.xlsx

Riccardo Susini

unread,
21 Oct 2021, 09:33:5321/10/2021
to Temoa Project
Thank you very much Aranya. 
But if I have an ELC_FD of 100, how is it possible that the system doesn't accept constraints on max_activity in the order of 10?
ELC_FD is connected with ELC_SC through the distribution system. 
Anyway, thank you very much for your answering.
Riccardo.

Il giorno lunedì 18 ottobre 2021 alle 17:51:01 UTC+2 aranya.venkatesh ha scritto:

aranya.venkatesh

unread,
21 Oct 2021, 09:40:3221/10/2021
to Temoa Project
Hi Riccardo,

From what I can tell, your imported electricity technology (OFF_PP) has no associated costs. So the model chooses to use this 'free' electricity to meet all downstream demand instead of local generation.  
In my opinion, it would be important to assign an appropriate variable cost to this technology to ensure that local generation can compete with electricity imports. 
Secondly, your ELC_FD demand values are greater than 100 only in year 2050. If you assign a MinActivity of 100 to the prior years, more ELC_SC will be generated compared to demand, which results in the infeasibility error that you are seeing. (Note that the issue is with the MinActivity table rather than the MaxActivity table). 

I hope this helps. 

Best,
Aranya

Riccardo Susini

unread,
24 Oct 2021, 10:06:1424/10/2021
to Temoa Project
Hi Aranyia,
OFF_PP are wind offshore power plants in my schema.
IMP_ELC was the imported electricity which has only a variable costs also higher than other imports.
Unfortunately the constraints which I imposed are maximum activity of 10 of IMP_ELC and minimum activity of maximum 5.
I don't understand the reason for which the system was not able to find solution.
Best regards,
Riccardo.

Temoa Project

unread,
24 Oct 2021, 10:14:5224/10/2021
to Temoa Project
Hi Riccardo,

There seem to be several remaining issues with how the database is defined. 
For example, the MinCapacity for WIND_PP in 2025 is greater than the MaxCapacity. This would definitely cause an error.
Further, I was able to isolate the error to the MinActivity table for the techs that meet the TRS_VCS_FD demand. It could be that the MinActivities specified for techs  are greater than demand for TRS_VCS_FD. Or it could be some issue with the fact that you have MinActivities for GSL_VCS and HYBRID_VCS, but they are also connected to each other by techinputsplit. 

Here's a working version of the database, FYI, where I adjusted the values for HYBRID_VCS lower in the MinActivity table and fixed the WIND_PP MaxCapacity issue. You will probably have better insight about the errors now and how you need to adjust them, since you are most familiar with the energy system that you are modeling. 

I hope this helps.

Best,
Aranya

tuscany_res_BAU_orig_mod.sqlite

Riccardo Susini

unread,
25 Oct 2021, 10:12:2925/10/2021
to Temoa Project
Can you send me the related sql file?
Because I have some trouble with the emission activity table. 
Thank you very much, 
Riccardo

Riccardo Susini

unread,
25 Oct 2021, 10:12:3325/10/2021
to Temoa Project
I made an error and I was not able to solve it. The emission activity table that I build doesn't consider that the emissions are made only by imports(and this is right and that is what I want) but includes all the plants which use the commodity that emits. 

Temoa Project

unread,
25 Oct 2021, 10:14:1125/10/2021
to Temoa Project
If you use DB Browser to view .sqlite files, you should be able to export a .sql file from a .sqlite file. Here it is, attached.
Good luck debugging the emissions activity table!

Best,
Aranya

tuscany_res_BAU_orig_mod.sql

Riccardo Susini

unread,
9 Nov 2021, 06:57:2209/11/2021
to Temoa Project
Thank you very much for the time consumed by you to help me.
Reply all
Reply to author
Forward
0 new messages