Ortools Functionality in Google Colab?

1,561 views
Skip to first unread message

Elliot Brazil

unread,
Oct 9, 2019, 12:29:08 PM10/9/19
to or-tools-discuss
Hi there everyone, I am very new to using ortools but am very intrigued by the possibilities of use with it. I am interested in using it in a google Colab notebook for accessibility purposes to multiple members of my team.

I recently opened ortools_public.ipynb notebook (found here) with Colab and saved a copy into my own drive, but when I tried to run it I got the following error:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-1-fa2bd5f4c308> in <module>()
    189 
    190 if __name__ == '__main__':
--> 191   main()


1 frames
/usr/local/lib/python3.6/dist-packages/ortools/constraint_solver/pywrapcp.py in __init__(self, *args)
   3204 
   3205     def __init__(self, *args):
-> 3206         this = _pywrapcp.new_RoutingModel(*args)
   3207         try:
   3208             self.this.append(this)

NotImplementedError: Wrong number or type of arguments for overloaded function 'new_RoutingModel'.
  Possible C/C++ prototypes are:
    operations_research::RoutingModel::RoutingModel(operations_research::RoutingIndexManager const &)
    operations_research::RoutingModel::RoutingModel(operations_research::RoutingIndexManager const &,operations_research::RoutingModelParameters const &)




Presumably this error is being caused by something on my end as I'm using the code Google is providing as an example; any ideas?

Skander Hannachi

unread,
Oct 9, 2019, 12:36:14 PM10/9/19
to or-tools...@googlegroups.com
> Presumably this error is being caused by something on my end as I'm using the code Google is providing as an example; any ideas? 

Actually this isn't accurate: Colab is entirely hosted, and you are simply remotely accessing Google's computing resources from your browser. So the error will be on their side, not yours. 

Hive you tried running the same notebook on Google's Cloud's AI Hub? There is more flexibility with the notebooks in that environment (e.g. you can fix dependency problems, etc...) 

Cheers 
------------------------------------------------------------------------------------------------------------------------
M. Skander Hannachi, Ph. D
Retail Planning, Forecasting & Analytics
skander...@gmail.com
"6.44 It is not how things are in the world that is mystical, but that it exists." - L.W
------------------------------------------------------------------------------------------------------------------------


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/35361e6e-2da6-4e14-823e-c717b2c429ff%40googlegroups.com.

Elliot Brazil

unread,
Oct 9, 2019, 2:54:49 PM10/9/19
to or-tools-discuss
Hi Skander, thanks for the reply. I haven't tried using AI Hub before but will give that a shot. After putting the notebook into AI Hub would I subsequently run the thing in GCP?

E
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.

Xiang Chen

unread,
Oct 9, 2019, 3:23:59 PM10/9/19
to or-tools-discuss
Hi!

Took a look and the error has nothing to do with Colab, this example is pretty old and broken.
It uses ortools==6.7.4973 so it doesn't even work locally with the latest version of OR-Tools.

You can fix it by using that version (!pip install ortools==6.7.4973) but I think you should definitely search for a more recent example here: https://github.com/google/or-tools/tree/stable/examples/python

Cheers

Xiang

Parfait Atchadé

unread,
May 15, 2023, 8:19:49 PM5/15/23
to or-tools-discuss
Hi, all,

How to downgrade ortools to 8.2.8710 in google colab?

Many thanks
Parfait

Mizux Seiha

unread,
May 16, 2023, 3:24:15 AM5/16/23
to or-tools-discuss
if using https://colab.research.google.com/ the python runtime is 3.10

note: simply use `!python --version` cell
Python 3.10.11

When we released the 8.2, python 3.10 was not available so this version only support up to cp39
see: https://pypi.org/project/ortools/8.2.8710/#files

note: Since ortools is a native python library, our wheel packages are version dependent and must be build for each version supported.

Why you don't want to use the last version ?
If using your own jupyter server with your own local runtime and you have python 3.9 you could install 8.2 locally using the command:
`!pip install ortools==8.2.8710`

Parfait Atchadé

unread,
May 16, 2023, 7:33:56 AM5/16/23
to or-tools...@googlegroups.com

Many thanks, Mizux! 

Make sense to me what you are saying. 


I faced difficulties while executing this project. https://github.com/Wadaboa/3d-bpp on the Colab. In my local with ortools==8.2.8710 with python 3.9, the baseline worked, but with the last version of the ortools, this part of the code crashed! This is why I made the question, but if this can not be possible, I would like to think about how to fix the potential problem.


Many thanks.

Best,

Parfait


Parfait Atchadé
Tel Spain: 0034661205543
Tel Deutsch: 00491706659017



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/4f65e80f-9bf6-4679-9bf8-cf850d279a50n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages