IBMDecisionOptimization / docplex-examples

These samples demonstrate how to use the DOcplex library to model and solve optimization problems.
https://ibmdecisionoptimization.github.io/
Apache License 2.0
396 stars 228 forks source link

Problem size limits exceeded, CPLEX code=1016 #40

Closed mariaeileen closed 3 years ago

mariaeileen commented 3 years ago

Hi, I have installed the Academic version of CPLEX_Studio1210, but get the following error message: Problem size limits exceeded, CPLEX code=1016

I have followed the guidelines provided by IBM by implying $ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx in the terminal before the command python setup.py install.

I have typed in "pip uninstall cplex" as I have tried to install the free version earlier. However, I get the following message in terminal: $ pip uninstall cplex Found existing installation: cplex 12.10.0.0 ERROR: Cannot uninstall 'cplex'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Is this the reason for why it does not work? That I am unable to uninstall cplex? I highly appreciate your advice:)

vlkong commented 3 years ago

Hi,

You have that error because recent versions of pip are just unable to uninstall cplex installed by older versions of pip. Please install cplex using:

$ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx
$ python setup.py --ignore-installed install

This should just override the files and you should be set.

Best regards

mariaeileen commented 3 years ago

Hmm I tried that, but it didn't seem to make any difference. Here is the full error message, might there be something wrong with site-packages?

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/cplex_engine.py", line 1906, in solve cpx.solve() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/init.py", line 1329, in solve _proc.mipopt(self._env._e, self._lp) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/_internal/_procedural.py", line 692, in mipopt check_status(env, status) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/_internal/_procedural.py", line 236, in call raise CplexSolverError(error_string, env, status) cplex.exceptions.errors.CplexSolverError: CPLEX Error 1016: Community Edition. Problem size limits exceeded. Purchase at http://ibm.biz/error1016.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 99, in print(solve_it(input_data)) File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 62, in solveit obj,assignments, = instance.optimize(params["mipTimeLimit"]) File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/sjekkas.py", line 41, in optimize return self.optimizeCPLEX(timeLimit) File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/sjekkas.py", line 115, in optimizeCPLEX solution = self.model.solve(log_output=self.DEBUG_MESSAGES) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 4394, in solve return self._solve_local(context, used_clean_before_solve, lex_timelimits, lex_mipgaps) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 4516, in _solve_local raise docpx_e File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 4507, in _solve_local lex_mipgaps=lex_mipgaps) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/cplex_engine.py", line 1938, in solve self._model.fatal_ce_limits() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 948, in fatal_ce_limits self._error_handler.fatal_limits_exceeded() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/error_handler.py", line 215, in fatal_limits_exceeded raise DOcplexLimitsExceeded() docplex.mp.utils.DOcplexLimitsExceeded: **** Promotional version. Problem size limits exceeded, CPLEX code=1016

Thanks for responding on my issue.

mariaeileen commented 3 years ago

This is the output in the terminal when I type your suggestion: $ python setup.py --ignore-installed install usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help

error: option --ignore-installed not recognized

vlkong commented 3 years ago

cplex installation only add files in one directory. So what you can do is just manually remove the existing cplex with: rm -rf /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex/ - then you can python setup.py install. Can you please try that ?

mariaeileen commented 3 years ago

Thanks for your response Now I get the following error message with several traceback error messages: import cplex #@UnresolvedImport ModuleNotFoundError: No module named 'cplex'

Traceback (most recent call last): File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 99, in print(solve_it(input_data)) File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/solver7.py", line 62, in solveit obj,assignments, = instance.optimize(params["mipTimeLimit"]) File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/sjekkas.py", line 40, in optimize self.createModelCPLEX() File "/Users/mariaeileenhubbuck/Documents/Discrete Optimization/facility/sjekkas.py", line 75, in createModelCPLEX self.model = cpx.Model(self.instanceName) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 400, in init self._environment = self._make_environment() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/model.py", line 175, in _make_environment env = Environment.get_default_env() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 427, in get_default_env Environment._default_env = Environment.make_new_configured_env() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 422, in make_new_configured_env return Environment(start_auto_configure=True) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 84, in init self.auto_configure(logger=logger) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 220, in auto_configure self.check_cplex(logger=logger) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 328, in check_cplex cplex = self.get_cplex_module(logger=logger) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 314, in get_cplex_module cplex = load_cplex_from_cos_root(loc) if loc else None File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 286, in load_cplex_from_cos_root return load_cplex(full_path, version=version) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/docplex/mp/environment.py", line 261, in load_cplex raise FileNotFoundError("Could not load module from %s" % module_location) FileNotFoundError: Could not load module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/cplex/init.py

mariaeileen commented 3 years ago

Sorry, I realise that the previous comment is not my problem as that was run in python 3.8.

The error message I get for python 3.7 is: AttributeError: module 'cplex' has no attribute 'Cplex'

mariaeileen commented 3 years ago

This is my pythonpath. As the IBM webpage informs, it should not be necessary to change the pythonpath for only one version of CPLEX, do you have any thoughts regarding my pythonpath?

for p in sys.path: print(p)

/Users/mariaeileenhubbuck/Documents /Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

vlkong commented 3 years ago

Please let me know the values of:

which python

Then

echo $PYTHONPATH

Then:

ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex

AttributeError: module 'cplex' has no attribute 'Cplex' means that there is a cplex directory but something was mis-installed. I've also seen that error when cplex has been installed using pip install cplex or python setup.py install AND it is in PYTHONPATH as well.

Note: I will be off for Christmas and New Year vacations for 2 weeks, I will not be able to answer until my return.

mariaeileen commented 3 years ago

Hi! Here is the output. As shown below, the output for "echo $PYTHONPATH" is nothing, only an empty line:

(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ which python /Users/mariaeileenhubbuck/opt/anaconda3/bin/python

(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ echo $PYTHONPATH

(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex total 0 drwxr-xr-x 3 mariaeileenhubbuck admin 96 Dec 20 12:45 . drwxrwxr-x 46 root admin 1472 Dec 20 12:45 .. drwxr-xr-x 3 mariaeileenhubbuck admin 96 Dec 20 12:45 lib

mariaeileen commented 3 years ago

I implemented the following command to change the Pythonpath:

export PYTHONPATH="/usr/local/Cellar/python/3.7.0/bin/python3:$PYTHONPATH" (base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ echo $PYTHONPATH /usr/local/Cellar/python/3.7.0/bin/python3:

vlkong commented 3 years ago

Your /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex must be empty. There is a lib directory here that does not look like anything cplex could have installed here ? This is why you have the AttributeError: module 'cplex' has no attribute 'Cplex' message.

Please remove that directory: rm -rf /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex (please check there is nothing here, ls -al /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cplex should end up with an error like directory not found, then install the CPLEX wrappers:

(base) $ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/
(base) $ python setup.py install

Can you please copy the output of python setup.py install so that we can check what went wrong, if it does not work ?

Thanks

mariaeileen commented 3 years ago

Hi, I tried the above, but it didn't work. However, the error message now changed to FileNotFoundError: Could not load module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/cplex/init.py

(base) Marias-MacBook-Pro:~ mariaeileenhubbuck$ cd /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64_osx/ (base) Marias-MacBook-Pro:x86-64_osx mariaeileenhubbuck$ python setup.py install running install running build running build_py running install_lib running install_egg_info Removing /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages/cplex-12.10.0.0-py3.7.egg-info Writing /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages/cplex-12.10.0.0-py3.7.egg-info (base) Marias-MacBook-Pro:x86-64_osx mariaeileenhubbuck$

vlkong commented 3 years ago

As long as you have Could not load module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/cplex/init.py, it means that somehow your python interpreter is trying to load a module from /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/ - This is only possible if that directory is in your PYTHONPATH. How do you run your programs, are you using an IDE ?

mariaeileen commented 3 years ago

Thanks for your response, I'm using IDLE for Python 3.7.

vlkong commented 3 years ago

From your shell environment, we know that you did not add /Applications/CPLEX_Studio1210/cplex/python/3.7/x86-64osx/ in your PYTHONPATH. However, given your error, I believe that your IDE (IDLE) is adding that directory in your PYTHONPATH. Please check the configuration of your IDE and remove that directory from the python path added by the IDE.

Note also that there is a configuration problem I think.

You have some error stack referring to /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages which is the location were system python install libraries.

Now your installation log says that cplex has been installed in /Users/mariaeileenhubbuck/opt/anaconda3/lib/python3.7/site-packages, and your shell starts with (base) something, which is the sign that you are using anaconda.

So it looks like you installed cplex with one python interpreter (anaconda ?) then your IDE is trying to use python from another interpreter (the system 3.7 ?).

Please first make sure that all your tools are using the same interpreter, otherwise there is just no way for me to help you if your python configuration is not right.

Thanks.

mariaeileen commented 3 years ago

Ok thanks! I will look into the use of different interpreters!