When running the example at the bottom of the Cryptarithmetic optimization examples - https://developers.google.com/optimization/cp/cryptarithmetic under python2 I get the expected solution, under python3, I receive the following error:
Traceback (most recent call last):
File "ZZZ.py", line 78, in <module>
CPIsFun()
File "ZZZ.py", line 36, in CPIsFun
c = solver.IntVar(digits_without_zero, 'C');
File "XXX/.local/lib/python3.5/site-packages/ortools/constraint_solver/pywrapcp.py", line 307, in IntVar
return _pywrapcp.Solver_IntVar(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'Solver_IntVar'.
Possible C/C++ prototypes are:
operations_research::Solver::MakeIntVar(int64,int64,std::string const &)
operations_research::Solver::MakeIntVar(std::vector< int64 > const &,std::string const &)
operations_research::Solver::MakeIntVar(std::vector< int > const &,std::string const &)
operations_research::Solver::MakeIntVar(int64,int64)
operations_research::Solver::MakeIntVar(std::vector< int64 > const &)
operations_research::Solver::MakeIntVar(std::vector< int > const &)
The issue is raised by the definition of a range ie,
# Decision variables.
digits = range(0, kBase)
digits_without_zero = range(1, kBase)
c = solver.IntVar(digits_without_zero, 'C');
ortools.__version__ : 7.0.6546
--
Python 2.7.12
Python 3.5.2 and 3.6
Hi,
Can you give me the output of:
python3 -m pip show ortools and python2 -m pip show ortools ?
I think you have an old version of ortools package running in python2...
BTW Thanks for the feedback !
note: This code is located in a HTML on the site and may be out of sync with the v7.0 API...
note2: I'm in the process of porting all site examples to github and in all languages to avoid this kind of issues...
Thanks for the package. A good set of examples and explanations is clearly useful (you can have a look at http://theory.stanford.edu/~nikolaj/programmingz3.html for inspiration :) and for comparison )
python3 -m pip show ortools
Name: ortools
Version: 7.0.6546
Summary: Google OR-Tools python libraries and modules
Home-page: https://developers.google.com/optimization/
Author: Google Inc
Author-email: [email protected]
License: Apache 2.0
Location: /home/user/.local/lib/python3.5/site-packages
Requires: six, protobuf
Required-by:
python2 -m pip show ortools
/home/user/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Name: ortools
Version: 7.0.6546
Summary: Google OR-Tools python libraries and modules
Home-page: https://developers.google.com/optimization/
Author: Google Inc
Author-email: [email protected]
License: Apache 2.0
Location: /home/user/.local/lib/python2.7/site-packages
Requires: protobuf, six
Required-by:
It looks to be as if they are the same version.
I was searching to make a PR to fix some other HTML issues, but couldn't find them in the repo.
i.e.
1) bullet points here: https://developers.google.com/optimization/reference/constraint_solver/routing/
2.a) in https://developers.google.com/optimization/cp/cryptarithmetic - there are at least 2 occurrences of print letters that should be print(letters) in the code examples
2.b) On the same page as above, there are multiple ; that could be removed from the python code (I assume the converter script forgot to strip them)
edit: The issue can be reproduced within the colab env.
maybe you'll be interested in using the SAT solver -> https://github.com/google/or-tools/blob/stable/ortools/sat/samples/cp_is_fun_sat.py
Thanks for the link, I was navigating between
https://github.com/google/or-tools/blob/master/ortools/sat/python/cp_model.py
https://github.com/google/or-tools/blob/master/ortools/sat/doc/reference.md
https://github.com/google/or-tools/blob/master/ortools/sat/doc/solver.md
Surprising there isn't a python API section in the dev.google page.
Unrelated to the issue - is it expected model.AddNoOverlap2D to be failing with NotSupported: model.GetIntervalIndex(...) i.e.
https://colab.research.google.com/drive/1crpDBzq1ZxvWH3eEsXJTgpguYiDtKqYd#scrollTo=B6NEHnIOqPkw
You need intervals
See:
https://github.com/google/or-tools/blob/stable/ortools/sat/doc/scheduling.md
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mer. 1 mai 2019 Ã 03:03, Daniel Angelov notifications@github.com a
écrit :
Thanks for the link, I was navigating between
https://github.com/google/or-tools/blob/master/ortools/sat/python/cp_model.py
https://github.com/google/or-tools/blob/master/ortools/sat/doc/reference.md
https://github.com/google/or-tools/blob/master/ortools/sat/doc/solver.md
Surprising there isn't a python API section in the dev.google page.Unrelated to the issue - is it expected model.AddNoOverlap2D to be
failing with NotSupported: model.GetIntervalIndex(...) i.e.https://colab.research.google.com/drive/1crpDBzq1ZxvWH3eEsXJTgpguYiDtKqYd#scrollTo=B6NEHnIOqPkw
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1231#issuecomment-488167000,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3LECE3XED3GQ2UTKWLPTDT5PANCNFSM4HJMCEUQ
.
Anyway, I looked at the original question.
To use python 3, you need to change the definition of the domains
# Decision variables.
digits = list(range(0, kBase))
digits_without_zero = list(range(1, kBase))
We will update the code.
Closing for now.