convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Mosek error with newest gpkit version #1442

Closed courtin closed 5 years ago

courtin commented 5 years ago

After upgrading to the latest version of gpkit I get the following error when using mosek as the solver, running the simple test case from the documentation:

">> python gptest.py Traceback (most recent call last): File "gptest.py", line 16, in sol = m.solve(verbosity=0, solver = 'mosek') File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/prog_factories.py", line 124, in solvefn result = progsolve(solver, verbosity, **kwargs) File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/gp.py", line 148, in solve solverfn, solvername = _get_solver(solver, kwargs) File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/gp.py", line 39, in _get_solver from .._mosek import expopt File "/Users/chriscourtin/dev/gpkit/gpkit/_mosek/expopt.py", line 96, in MSK = ModuleShortener("MSK", load_library(settings["mosek_lib_path"]), KeyError: u'mosek_lib_path' "

As far as I can tell the mosek installation is still working; python is able to load the solver outside of gpkit, and the license file is active.

bqpd commented 5 years ago

oh, yes. I'll add in an auto-rebuild, but in the meantime run "from gpkit.build import build; build()" to fix it

On Mon, Oct 7, 2019, 14:17 courtin notifications@github.com wrote:

After upgrading to the latest version of gpkit I get the following error when using mosek as the solver, running the simple test case from the documentation:

">> python gptest.py Traceback (most recent call last): File "gptest.py", line 16, in sol = m.solve(verbosity=0, solver = 'mosek') File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/prog_factories.py", line 124, in solvefn result = progsolve(solver, verbosity, **kwargs) File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/gp.py", line 148, in solve solverfn, solvername = _get_solver(solver, kwargs) File "/Users/chriscourtin/dev/gpkit/gpkit/constraints/gp.py", line 39, in _get_solver from .._mosek import expopt File "/Users/chriscourtin/dev/gpkit/gpkit/_mosek/expopt.py", line 96, in MSK = ModuleShortener("MSK", load_library(settings["mosek_lib_path"]), KeyError: u'mosek_lib_path' "

As far as I can tell the mosek installation is still working; python is able to load the solver outside of gpkit, and the license file is active.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/issues/1442?email_source=notifications&email_token=AALKAGEAAUB6MZ4OSSZG2YTQNN4LDA5CNFSM4I6IBA52YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQEP6WA, or mute the thread https://github.com/notifications/unsubscribe-auth/AALKAGALTT6JRTR2KFXUHJDQNN4LDANCNFSM4I6IBA5Q .

courtin commented 5 years ago

That worked - thanks

vignesh99 commented 4 years ago

I am getting the same error as mentioned here. I tried to run "from gpkit.build import build; build()" on the terminal (Ubuntu 18.04). After I do so, it is waiting for me to give a command, what should I do then? Also I am using python 3.6.9 version Thanks

bqpd commented 4 years ago

Does gpkit work after that? :p

What is the exact command you are running?

vignesh99 commented 4 years ago

Does gpkit work after that? :p

What is the exact command you are running?

When I run "python3 mycode" I get the error mentioned at the beginning of this thread (i.e. KeyError: 'mosek_lib_path'). After that I ran the command you mentioned i.e. "from gpkit.build import build; build()". This is creating some sort of bash which is expecting me to give commands to it. (as shown in the picture) What should I do after this? If I exit from the bash and try to run my test code it is still not working.

Screenshot from 2020-02-19 13-11-58

bqpd commented 4 years ago

oh! run python3 -c "from gpkit.build import build; build()" so as to run that command in python.

vignesh99 commented 4 years ago

oh! run python3 -c "from gpkit.build import build; build()" so as to run that command in python.

Thank you. After this I was able to add mosek solver onto gpkit in python3. I got still got an error saying "unicode is not defined", so I changed wherever file had 'unicode' to 'bytes'. Now I am getting an error saying "Traceback (most recent call last): File "/home/vignesh/.local/lib/python3.6/site-packages/gpkit/_mosek/baked_ctypesgen.py", line 227, in init self.data = str(obj) TypeError: bytes or integer address expected instead of str instance"

Same error is coming if I change 'unicode' to 'str' or 'int' as well. The line 227 is right after the line where the keyword 'unicode' was present. Is there a way to fix this bug? Also do people use mosek in python3, cause I have had to make decent amount of changes in the libraries due to python2 things not working in python3.

bqpd commented 4 years ago

Which files included unicode()? Was it the gpkit_test.py file you reference above?

bqpd commented 4 years ago

or did you change it in baked_ctypesgen.py?

bqpd commented 4 years ago

per https://github.com/convexengineering/gpkit/blob/master/gpkit/globals.py#L24, using the mosek solver interface is not recommended in Python3; just use mosek_cli instead, it's just as fast

vignesh99 commented 4 years ago

or did you change it in baked_ctypesgen.py?

Yes, I changed it here.

bqpd commented 4 years ago

I believe your problem is in a direct call to the "mosek" solver. I recommend not specifying a solver, and instead letting each install use its default solver (mosek_cli or mosek_conif). You can also change "mosek" to "mosek_cli" manually if you wish to specify a solver.

vignesh99 commented 4 years ago

per https://github.com/convexengineering/gpkit/blob/master/gpkit/globals.py#L24, using the mosek solver interface is not recommended in Python3; just use mosek_cli instead, it's just as fast

Oh this worked, thanks! This does not require the mosek license is it?

vignesh99 commented 4 years ago

I believe your problem is in a direct call to the "mosek" solver. I recommend not specifying a solver, and instead letting each install use its default solver (mosek_cli or mosek_conif). You can also change "mosek" to "mosek_cli" manually if you wish to specify a solver.

But can I know which solver it used to solve the GP?

bqpd commented 4 years ago

But can I know which solver it used to solve the GP?

yup, it'll print that out if you solve with any verbosity above 0!

This does not require the mosek license is it?

mosek_cli does require using a MOSEK license, just as mosek does. cvxopt is the solver you'll want if you don't have a license (though academic MOSEK licenses are easy enough).

vignesh99 commented 4 years ago

But can I know which solver it used to solve the GP?

yup, it'll print that out if you solve with any verbosity above 0!

This does not require the mosek license is it?

mosek_cli does require using a MOSEK license, just as mosek does. cvxopt is the solver you'll want if you don't have a license (though academic MOSEK licenses are easy enough).

Oh ok. Thank you very much for your help!!

bqpd commented 4 years ago

sure thing! what are you hoping to use GPkit for, by the way, and how did you hear about us?

On Wed, Feb 19, 2020 at 11:18 AM vignesh99 notifications@github.com wrote:

But can I know which solver it used to solve the GP?

yup, it'll print that out if you solve with any verbosity above 0!

This does not require the mosek license is it?

mosek_cli does require using a MOSEK license, just as mosek does. cvxopt is the solver you'll want if you don't have a license (though academic MOSEK licenses are easy enough).

Oh ok. Thank you very much for your help!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/issues/1442?email_source=notifications&email_token=AALKAGEUHJMWK2JW4VU4LULRDWAK7A5CNFSM4I6IBA52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMJDSJY#issuecomment-588396839, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGHBUMFMYDA5MCTOP6TRDWAK7ANCNFSM4I6IBA5Q .

vignesh99 commented 4 years ago

sure thing! what are you hoping to use GPkit for, by the way, and how did you hear about us? On Wed, Feb 19, 2020 at 11:18 AM vignesh99 @.***> wrote: But can I know which solver it used to solve the GP? yup, it'll print that out if you solve with any verbosity above 0! This does not require the mosek license is it? mosek_cli does require using a MOSEK license, just as mosek does. cvxopt is the solver you'll want if you don't have a license (though academic MOSEK licenses are easy enough). Oh ok. Thank you very much for your help!! — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1442?email_source=notifications&email_token=AALKAGEUHJMWK2JW4VU4LULRDWAK7A5CNFSM4I6IBA52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMJDSJY#issuecomment-588396839>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGHBUMFMYDA5MCTOP6TRDWAK7ANCNFSM4I6IBA5Q .

Oh, I wanted to solve some GPs for some circuit analysis problems. I prefer using python and I was suggested from my University to use mosek. But directly coding in mosek was complicated in python, so I was searching for easier ways. And that's how I landed across GPkit!!

bqpd commented 4 years ago

fabulous :) don't hesitate to create new issues on GitHub as they arise!

vignesh99 commented 4 years ago

fabulous :) don't hesitate to create new issues on GitHub as they arise!

Also one more thing, I assume GPkit fails to recognize the mosek 9.1 (or anything after 8 I guess). I think I would not have faced any issues during installation if it was able to do so.

1ozturkbe commented 4 years ago

Should have seen this issue coming. @bqpd I think we need to add to the documentation that we recognize mosek9 if the python specific install has been made using setup.py from the directory.

1ozturkbe commented 4 years ago

@vignesh99 check this out.

bqpd commented 4 years ago

yeah I think if you do pip install mosek it'll download & install mosek9 in a way we can use

edit: nvm, check out @1ozturkbe's link; they're not in pypi