ValueError: cannot set a frame with no defined index and a scalar

536 views
Skip to first unread message

Daniele Mosso

unread,
Jan 11, 2022, 11:25:51 AM1/11/22
to Temoa Project
Hello everyone and thanks in advance for those who will try to help me.
I've wrote a very simple model of the italian energy system but, when i try to solve the optimization problem, i get these lines:
1 .db DD file(s) converted

-------------------------
              Config file: C:\Users\Daniele\PycharmProjects\temoa-energysystem\temoa_model\config_sample
               Input file: C:\Users\Daniele\PycharmProjects\temoa-energysystem\data_files\Temoa_Italy.dat
              Output file: C:\Users\Daniele\PycharmProjects\temoa-energysystem\data_files\Temoa_Italy.sqlite
                 Scenario: test_run
       Spreadsheet output: True
            Myopic scheme: False
             Myopic years: 0
  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.09] Reading data files.
[    0.36] Creating Temoa model instance.
[    0.38] Solving.
[        ] Calculating reporting variables and formatting results.Exception found in solve_temoa_instance
cannot set a frame with no defined index and a scalarcannot set a frame with no defined index and a scalar
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 247, in solveWithoutMGA
    for k in temoaInstance1.solve_temoa_instance():
  File "temoa_model\temoa_run.py", line 417, in solve_temoa_instance
    raise model_exc
  File "temoa_model\temoa_run.py", line 396, in solve_temoa_instance
    formatted_results = pformat_results( self.instance, self.result, self.options )
  File "temoa_model\pformat_results.py", line 379, in pformat_results
    duals = collect_result_data( Cons, con_info, epsilon=1e-9 )
  File "temoa_model\pformat_results.py", line 123, in collect_result_data
    duals.loc[:,'scenario'] = options.scenario
  File "C:\ProgramData\Anaconda3\envs\temoa-py3\lib\site-packages\pandas\core\indexing.py", line 723, in __setitem__
    iloc._setitem_with_indexer(indexer, value, self.name)
  File "C:\ProgramData\Anaconda3\envs\temoa-py3\lib\site-packages\pandas\core\indexing.py", line 1658, in _setitem_with_indexer
    "cannot set a frame with no "
ValueError: cannot set a frame with no defined index and a scalar.

I have found similar problems of github but they talk of re-allocating the cpu and doing strange things which i'm not able to do.


I am solving using GLPK and writing the command from the anaconda prompt. I attach here my script.

Thanks to everyone for the attention!
TEM_ITA_SIMPLIFIED.sql
Complete_OutputLog.log

Temoa Project

unread,
Jan 11, 2022, 4:17:32 PM1/11/22
to Temoa Project
Hi Daniele,

Could you share the .sqlite file that raised this error? When I tried to compile and test with the .sql file that you shared, I ran into some database errors. 
We also, very recently, added some code to deal with an error similar to what you encountered. Could you check if you are working with the most recent commits in the repository?

Best,
Aranya

Daniele Mosso

unread,
Jan 12, 2022, 8:25:40 AM1/12/22
to Temoa Project
Hi Arania
Thanks for your answer,
This is my .sqlite file, but i've found that when i open it with a database visualizator (DB Browser in my case) the file seems empty. This is quite strange because the database connection and the preprocessing phase have ran without problems. Also, before getting the  before mentioned ValueError i solved some database common error, so it seems that there is something inside the .sqlite, even if DB Browser doesn't find anything.
Regarding the version, i'm pretty sure i'm using the last one. But since i don't remember when i downloaded it, i'll try to re-download the new one and update you on the outcome.
Best,
Daniele
Temoa_Italy.sqlite

Temoa Project

unread,
Jan 18, 2022, 3:26:42 PM1/18/22
to Temoa Project
Hi Daniele,

Thanks for bringing this to our attention. It seems that certain open-source solvers do not report dual variables based on the optimal solution for some databases: the solver that you used (glpk) seems to be one of them.
We've added some code in the most recent commit to the repository that handles these cases.
Hopefully using the most recent version of Temoa fixes the issue for you. 

Best,
Aranya

Daniele Mosso

unread,
Jan 19, 2022, 8:28:14 AM1/19/22
to Temoa Project
Thank you Aranya,
by running the model with the gurobi solver and with the new temoa version i've found on the repository all works properly.
Best,
Daniele

Reply all
Reply to author
Forward
0 new messages