Skip to content

Mosek error with newest gpkit version #1442

Closed

Description

@courtin

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.

Activity

  1. bqpd commented on Oct 7, 2019

    @bqpd
    Contributor
  2. courtin commented on Oct 7, 2019

    @courtin
    Author

    That worked - thanks

  3. vignesh99 commented on Feb 18, 2020

    @vignesh99

    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

  4. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    Does gpkit work after that? :p

    What is the exact command you are running?

  5. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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

  6. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

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

  7. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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.

  8. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

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

  9. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    or did you change it in baked_ctypesgen.py?

  10. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    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

  11. vignesh99 commented on Feb 19, 2020

    @vignesh99

    or did you change it in baked_ctypesgen.py?

    Yes, I changed it here.

  12. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    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.

  13. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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?

  14. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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?

  15. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    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).

  16. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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!!

  17. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor
  18. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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!!

  19. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor
  20. vignesh99 commented on Feb 19, 2020

    @vignesh99

    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.

  21. 1ozturkbe commented on Feb 19, 2020

    @1ozturkbe
    Contributor

    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.

  22. 1ozturkbe commented on Feb 19, 2020

    @1ozturkbe
    Contributor

    @vignesh99 check this out.

  23. bqpd commented on Feb 19, 2020

    @bqpd
    Contributor

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions