adamgreenhall / minpower

power systems tools made beautiful
adamgreenhall.github.io/minpower
71 stars 33 forks source link

Can't get minpower to work #21

Closed ayeosq closed 6 years ago

ayeosq commented 8 years ago

These are copied from my terminal.

arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower$ which glpsol /usr/bin/glpsol arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower$ pip freeze adium-theme-ubuntu==0.3.4 appdirs==1.4.0 beautifulsoup4==4.4.1 chardet==2.3.0 cycler==0.9.0 decorator==4.0.9 glpk==0.4.52 html5lib==0.999 lxml==3.5.0 matplotlib==1.5.1 minpower==4.4.0 networkx==1.11 nose==1.3.7 numpy==1.9.1 PAM==0.4.2 pandas==0.18.1 pexpect==4.0.1 Pillow==3.1.2 ply==3.8 ptyprocess==0.5 pygobject==3.20.0 pyinotify==0.9.6 Pyomo==4.3.11377 pyparsing==2.0.3 PYPOWER==5.0.1 pypsa==0.4.1 python-dateutil==2.5.3 pytz==2016.4 PyUtilib==5.3.5 scipy==0.17.0 six==1.10.0 unity-lens-photos==1.0 arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower$ minpower uc minpower: command not found arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower$ python minpower uc python: can't open file 'minpower': [Errno 2] No such file or directory arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower$ cd ~/.local/lib/python2.7/site-packages/ arthur@arthur-linux:~/.local/lib/python2.7/site-packages$ minpower ucminpower: command not found arthur@arthur-linux:~/.local/lib/python2.7/site-packages$ python minpower uc/usr/bin/python: can't find 'main' module in 'minpower' arthur@arthur-linux:~/.local/lib/python2.7/site-packages$

Clearly, I have installed minpower along with glpk and directory in ~/.bash is pathed right. However, when I follow the instruction of type "minpower uc" in terminal, expect a case is loaded and solved. Not happening for me, can any experienced minpower user assist me?

Thank you

jcd000 commented 8 years ago

Just today i started trying to use minpower myself (facing stiff opposition due to incompatibilites with later versions of matplotlib, numpy) but i think i can help on this. Check the "~/.local/lib/python2.7/site-packages/minpower-4.4.0-py2.7.egg-info/installed-files.txt" It should contain the location of the binary file. mine is "../../../../bin/minpower" which puts it in my /bin directory. From then, either add that directory to your $PATH, or do a softlink of the exectuable to /bin

ayeosq commented 8 years ago

Please pardon if I asked an obvious question, am new to linux. Anyway, am I right to said what you mean by "add that directory to your $PATH" is to add this line, export PATH=$PATH:/usr/bin/minpower to ~/.bashrc?

This is what happened after I do a echo of PATH: arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower/tests$ echo "$PATH" /bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/bin/minpower:/usr/bin/glpsol

Initially, I did this and realise that uc is in the tests direction, arthur@arthur-linux:~$ minpower uc minpower: command not found

So I navigate to the directory of uc folder: arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower/tests$ minpower uc minpower: command not found

jcd000 commented 8 years ago

The "/usr/bin/minpower" address that you added to $PATH is bound to not be a valid place. You actually want to add the path of the minpower binary to that path. If i understand correctly, the binary in your case should be ~./local/bin/minpower Verify that, and if it is true, you can either softlink that binary to /bin/minpower, or just add that path to $PATH like so:

Instead of all this mess, you could just run minpower with /path/to/minpower/binary uc Make sure you are one level above the uc test or it won't find the uc - you could also give it the whole path leading to uc, eg:

PS. Warning: Afaiu, adding ~/.local/bin/ to $PATH is not very safe, because anyone with your permissions could hijack a binary by adding an identically named one to that folder. I'm intermediate with linux though, so i could be wrong.

ayeosq commented 8 years ago

Thanks for your help, I am getting further with this. However, this happened:

I changed my directory to the uc folder which is one level on top of the files: arthur@arthur-linux:~$ cd /home/arthur/.local/lib/python2.7/site-packages/minpower/tests

Then I did a minpower uc and these happened: arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower/tests$ minpower uc Traceback (most recent call last): File "/home/arthur/.local/bin/minpower", line 9, in load_entry_point('minpower==4.4.0', 'console_scripts', 'minpower')() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 542, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2569, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2229, in load return self.resolve() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2235, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/solve.py", line 19, in import powersystems File "/home/arthur/.local/lib/python2.7/site-packages/minpower/powersystems.py", line 14, in from optimization import value, OptimizationObject, OptimizationProblem, OptimizationError File "/home/arthur/.local/lib/python2.7/site-packages/minpower/optimization.py", line 9, in from pyomo import environ as pyomo File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 76, in import_packages() File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 69, in import_packages raise ImportError(msg) ImportError: pyomo.environ failed to import pyomo.pysp.plugins: Original ImportError: cannot import name extractComponentIndices Traceback: File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 59, in import_packages do_import(pname) File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 44, in do_import import(pname, globals(), locals(), [], -1) File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/pysp/init.py", line 14, in from pyomo.pysp.scenariotree import File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/pysp/scenariotree/init.py", line 11, in from pyomo.pysp.scenariotree.tree_structure import File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/pysp/scenariotree/tree_structure.py", line 30, in from pyomo.pysp.phutils import (BasicSymbolMap,

What do you think about this?

jcd000 commented 8 years ago

"ImportError: pyomo.environ failed to import pyomo.pysp.plugins: Original ImportError: cannot import name extractComponentIndices"

There seems to be an error with pyomo. I'd wager the pyomo version you are running is incompatible. Did you install with pip? Mine downgraded pandas & numpy & installed the correct pyomo. You could also find what is the pyomo version needed (in one of the build files) and manually install that one.

ayeosq commented 8 years ago

Just did a downgrade of pyomo and pandas to the required version: pyomo==4.0.9682 numpy==1.9.1 pandas==0.16

arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower/tests$ minpower uc Traceback (most recent call last): File "/home/arthur/.local/bin/minpower", line 9, in load_entry_point('minpower==4.4.0', 'console_scripts', 'minpower')() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 542, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2569, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2229, in load return self.resolve() File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2235, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/solve.py", line 19, in import powersystems File "/home/arthur/.local/lib/python2.7/site-packages/minpower/powersystems.py", line 14, in from optimization import value, OptimizationObject, OptimizationProblem, OptimizationError File "/home/arthur/.local/lib/python2.7/site-packages/minpower/optimization.py", line 9, in from pyomo import environ as pyomo File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 76, in import_packages() File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/environ/init.py", line 73, in import_packages pkg.load() File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/solvers/plugins/init.py", line 13, in load import pyomo.solvers.plugins.solvers File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/solvers/plugins/solvers/init.py", line 16, in import pyomo.solvers.plugins.solvers.glpk_direct File "/home/arthur/.local/lib/python2.7/site-packages/pyomo/solvers/plugins/solvers/glpk_direct.py", line 21, in from glpk import File "/usr/lib/python2.7/dist-packages/glpk/init.py", line 26, in from glpk_parser import File "/usr/lib/python2.7/dist-packages/glpk/glpk_parser.py", line 352, in yacc.yacc(write_tables=0, debug=0) File "/home/arthur/.local/lib/python2.7/site-packages/ply/yacc.py", line 3264, in yacc read_signature = lr.read_table(tabmodule) File "/home/arthur/.local/lib/python2.7/site-packages/ply/yacc.py", line 1967, in read_table if parsetab._tabversion != tabversion: AttributeError: 'module' object has no attribute '_tabversion'

ayeosq commented 8 years ago

After hours, I found the author simple test uc files on his web.

arthur@arthur-linux:~/Downloads/uc$ ls generators.csv initial.csv loads.csv smallLoad.csv wildHorse.csv

anyway, the new problem is : arthur@arthur-linux:~/Downloads$ minpower uc Traceback (most recent call last): File "/home/arthur/.local/bin/minpower", line 9, in load_entry_point('minpower==4.4.0', 'console_scripts', 'minpower')() File "/home/arthur/.local/lib/python2.7/site-packages/minpower/solve.py", line 297, in main solve_problem(directory) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/solve.py", line 147, in solve_problem generators, loads, lines, times, scenario_tree, data = get_data.parsedir() File "/home/arthur/.local/lib/python2.7/site-packages/minpower/get_data.py", line 201, in parsedir lines_data, init_data) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/get_data.py", line 137, in _parse_raw_data generators_data, loads_data) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/get_data.py", line 377, in setup_times timeseries[name] = get_schedule(joindir(datadir, load[fcol])) * \ File "/home/arthur/.local/lib/python2.7/site-packages/minpower/schedule.py", line 11, in get_schedule return ts_from_csv(filename) File "/home/arthur/.local/lib/python2.7/site-packages/minpower/commonscripts.py", line 106, in ts_from_csv df = pd.read_csv(filename, index_col=index_col, squeeze=squeeze, _kwargs) File "/home/arthur/.local/lib/python2.7/site-packages/pandas/io/parsers.py", line 470, in parser_f return _read(filepath_or_buffer, kwds) File "/home/arthur/.local/lib/python2.7/site-packages/pandas/io/parsers.py", line 246, in _read parser = TextFileReader(filepath_or_buffer, _kwds) File "/home/arthur/.local/lib/python2.7/site-packages/pandas/io/parsers.py", line 562, in init self._make_engine(self.engine) File "/home/arthur/.local/lib/python2.7/site-packages/pandas/io/parsers.py", line 699, in _make_engine self._engine = CParserWrapper(self.f, self.options) File "/home/arthur/.local/lib/python2.7/site-packages/pandas/io/parsers.py", line 1066, in init self._reader = _parser.TextReader(src, kwds) File "pandas/parser.pyx", line 350, in pandas.parser.TextReader.cinit (pandas/parser.c:3163) File "pandas/parser.pyx", line 583, in pandas.parser.TextReader._setup_parser_source (pandas/parser.c:5779) IOError: File uc/smallLoad.csv does not exist

jcd000 commented 8 years ago

Can't comment on the last error msg. Sounds like a probem with the csv's you found. But i faced the glpk error myself. After a bit of search in the net, i found that current glpk versions have an incompatibitity with minpower. The cbc solver (https://projects.coin-or.org/Cbc) works perfectly though. After installing it (and having it in $PATH) use it like so:

ayeosq commented 8 years ago

This is what I did to make sure I have latest installed: sudo apt-get install glpkdoc glpk-utils libglpk-dev python-glpk

Finally, I managed to run minpower uc, seems like not having libglpk-dev might be the cause.

Hence to try if minpower really works, I did the following: arthur@arthur-linux:~/.local/lib/python2.7/site-packages/minpower/tests$ python run_all_cases.py testing: uc-gen-min-down-time-initial had error testing: opf-line-Pmax had error testing: ed-gen-Pmax had error testing: stochastic_shedding_wind_case Unknown option 'scenarioinstance' specified in call to ScenarioTree constructor had error testing: stochastic_short_case had error testing: uc-stochastic-rolling Unknown option 'scenarioinstance' specified in call to ScenarioTree constructor had error testing: ed-custom-bidding-points had error testing: ed testing: uc-WW-5-2 had error testing: ed-WW-3-7 testing: stochastic_cvar_case Unknown option 'scenarioinstance' specified in call to ScenarioTree constructor had error testing: scuc had error testing: uc testing: uc-rolling-shedding had error testing: ed-gen-Pmin had error testing: expected_observed_cost had error testing: uc-gen-ramp-rate had error testing: uc-reserve had error testing: stochastic_shedding_case Unknown option 'scenarioinstance' specified in call to ScenarioTree constructor had error testing: deterministic_perfect_difference had error testing: opf testing: uc-stochastic had error testing: opf-2bus had error testing: uc-gen-min-up-time had error testing: uc-gen-min-down-time had error testing: stochastic_mock_case Unknown option 'scenarioinstance' specified in call to ScenarioTree constructor had error testing: uc-rolling testing: uc-gen-min-up-time-initial had error

Thanks for your help jcd000, seems like there are still some stuff to clear up to ensure minpower is properly running.