NETWORK.LOPF()

483 views
Skip to first unread message

ltua...@gmail.com

unread,
Feb 1, 2018, 3:28:50 AM2/1/18
to pypsa
Hello,

I am trying to run a code and I am not sure why I am getting the following error. I am trying to just solve for the 'p_nom_opt' for the generators.

Any help would be greatly appreciated. Apologies for the simple question, I am fairly new to Python and have limited Electrical Engineering knowledge.

network.lopf(network.snapshots[0:60],solver_name="glpk",keep_files=True)
INFO:pypsa.pf:Slack bus for sub-network 0 is HiepHoa
INFO:pypsa.opf:Performed preliminary steps
INFO:pypsa.opf:Building pyomo model using `angles` formulation
INFO:pypsa.opf:Solving model using glpk
-----------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-6-bbaf404c21f3> in <module>()
----> 1 network.lopf(network.snapshots[0:60],solver_name="glpk",keep_files=True)

~\Anaconda3\envs\pypsa\lib\site-packages\pypsa\opf.py in network_lopf(network, snapshots, solver_name, solver_io, skip_pre, extra_functionality, solver_options, keep_files, formulation, ptdf_tolerance, free_memory)
   1483     network_lopf_prepare_solver(network, solver_name=solver_name, solver_io=solver_io)
   1484 
-> 1485     return network_lopf_solve(network, snapshots, formulation=formulation, solver_options=solver_options, keep_files=keep_files, free_memory=free_memory)

~\Anaconda3\envs\pypsa\lib\site-packages\pypsa\opf.py in network_lopf_solve(network, snapshots, formulation, solver_options, keep_files, free_memory)
   1408             network.results = network.opt.solve(*args, suffixes=["dual"], keepfiles=keep_files, options=solver_options)
   1409     else:
-> 1410         network.results = network.opt.solve(*args, suffixes=["dual"], keepfiles=keep_files, options=solver_options)
   1411 
   1412     if logger.isEnabledFor(logging.INFO):

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\opt\base\solvers.py in solve(self, *args, **kwds)
    594             initial_time = time.time()
    595 
--> 596             self._presolve(*args, **kwds)
    597 
    598             presolve_completion_time = time.time()

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\opt\solver\shellcmd.py in _presolve(self, *args, **kwds)
    194         self._keepfiles = kwds.pop("keepfiles", False)
    195 
--> 196         OptSolver._presolve(self, *args, **kwds)
    197 
    198         #

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\opt\base\solvers.py in _presolve(self, *args, **kwds)
    691                                       self._problem_format,
    692                                       self._valid_problem_formats,
--> 693                                       **kwds)
    694             total_time = time.time() - write_start_time
    695             if self._report_timing:

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\opt\base\solvers.py in _convert_problem(self, args, problem_format, valid_problem_formats, **kwds)
    762                                valid_problem_formats,
    763                                self.has_capability,
--> 764                                **kwds)
    765 
    766     def _default_results_format(self, prob_format):

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\opt\base\convert.py in convert_problem(args, target_problem_type, valid_problem_types, has_capability, **kwds)
    108                     tmpkw = kwds
    109                     tmpkw['capabilities'] = has_capability
--> 110                     problem_files, symbol_map = converter.apply(*tmp, **tmpkw)
    111                     return problem_files, ptype, symbol_map
    112 

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\solvers\plugins\converter\model.py in apply(self, *args, **kwds)
     94                             format=ProblemFormat.cpxlp,
     95                             solver_capability=capabilities,
---> 96                             io_options=io_options)
     97                 return (problem_filename,), symbol_map_id
     98             else:

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\core\base\block.py in write(self, filename, format, solver_capability, io_options)
   1645                                           filename,
   1646                                           solver_capability,
-> 1647                                           io_options)
   1648         smap_id = id(smap)
   1649         if not hasattr(self, 'solutions'):

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\repn\plugins\cpxlp.py in __call__(self, model, output_filename, solver_capability, io_options)
    174                     skip_trivial_constraints=skip_trivial_constraints,
    175                     force_objective_constant=force_objective_constant,
--> 176                     include_all_variable_bounds=include_all_variable_bounds)
    177 
    178         self._referenced_variable_ids.clear()

~\Anaconda3\envs\pypsa\lib\site-packages\pyomo\repn\plugins\cpxlp.py in _print_model_LP(self, model, output_file, solver_capability, labeler, output_fixed_variable_bounds, file_determinism, row_order, column_order, skip_trivial_constraints, force_objective_constant, include_all_variable_bounds)
    735             if constraint_data.equality:
    736                 assert value(constraint_data.lower) == \
--> 737                     value(constraint_data.upper)
    738                 label = 'c_e_' + con_symbol + '_'
    739                 alias_symbol_func(symbol_map, constraint_data, label)

ltua...@gmail.com

unread,
Feb 1, 2018, 3:35:55 AM2/1/18
to pypsa


Vào 15:28:50 UTC+7 Thứ Năm, ngày 01 tháng 2 năm 2018, ltua...@gmail.com đã viết:
Tuan_VN_500_47_bus (1).html

ltua...@gmail.com

unread,
Feb 1, 2018, 3:44:18 AM2/1/18
to pypsa
my DATA
2020vn2.rar

Tom Brown

unread,
Feb 1, 2018, 4:46:14 AM2/1/18
to py...@googlegroups.com
Hi there,

It's failing because some of your load data is null/NaN.

E.g.

In [38]: n.loads_t.p_set.iloc[1]["DongAnh"]
Out[38]: nan

You can replace these values with 0:

n.loads_t.p_set = n.loads_t.p_set.fillna(0.)

and it will work.


@Jonas, me: Note for future: include check for load isnull in
network.consistency_check().

Best,

Tom



On 01/02/18 09:44, ltua...@gmail.com wrote:
> my DATA
>
> --
> You received this message because you are subscribed to the Google
> Groups "pypsa" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pypsa+un...@googlegroups.com
> <mailto:pypsa+un...@googlegroups.com>.
> To post to this group, send email to py...@googlegroups.com
> <mailto:py...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pypsa/0572879b-d1a3-4954-ae48-28fada4cb008%40googlegroups.com
> <https://groups.google.com/d/msgid/pypsa/0572879b-d1a3-4954-ae48-28fada4cb008%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
Tom Brown
Postdoctoral Researcher
Frankfurt Institute for Advanced Studies
https://fias.uni-frankfurt.de/physics/schramm/renewable-energy-system-and-network-analysis/
Personal site: https://www.nworbmot.org
Phone: +49 69 798 47693

ltua...@gmail.com

unread,
Feb 2, 2018, 9:18:25 AM2/2/18
to pypsa
thank you so much. it"s working

Vào 16:46:14 UTC+7 Thứ Năm, ngày 01 tháng 2 năm 2018, Tom Brown đã viết:
Reply all
Reply to author
Forward
0 new messages