Or-tools Google

0 views
Skip to first unread message

Jenn Smotherman

unread,
Aug 4, 2024, 8:10:51 PM8/4/24
to cirlatingsand
Youguys are doing it wrong This is an example of 1500 nodes solved in PHP on my home PC I need to do some more verifications before claiming anything, but it looks like it can be solved in n^2, instead of n!. A pain to validate though.

I should fix some issues (eg. point uniqueness - I believe some points might be duplicate and end up being visited twice here). Anyway this is what the currently very rough script does in under a second on my old PC

tsp_1500_nodes800800 24.4 KB


Another thing I did was scaling the distance matrix (also recommended by google) seeing as or-tools only works with integers and rounding by 0.5 when the values are small produces a very big rounding error. Simply multiplied everything by 1000 so 0.5 becomes negligible.


I work with a CNC router, and apart from closed curves (which I easily sort by sorting the starting/end points) I also have open curves which obviously start and end at different points so if I take that into consideration the sorting is more accurate. Optimising is my obsesion at work.


BUT it is worth to mention, that one set of points is not enough for doing benchmarks for heurstic algorithms, cause they highly depend on an input, so for other sets of points (for other types of graphs) different algorithms will came up with better results


Join our dynamic live online Large Language Model (LLM) Courses, crafted for all proficiency levels. Enjoy flexibility and hands-on learning as we simplify complex concepts for your clear understanding.


Google OR-Tools is a software suite for optimization and constraint programming. It includes several optimization algorithms such as linear programming, mixed-integer programming, and constraint programming. These algorithms can be used to solve a wide range of problems, including scheduling problems, such as nurse scheduling.


OR-Tools can also be used to solve other types of scheduling problems, such as vehicle routing, production scheduling, and sports schedules. Additionally, OR-Tools can be used to solve other types of optimization problems, such as portfolio optimization and resource allocation.


In this example, num_nurses and num_shifts are the number of nurses and the number of shifts, respectively. The variables shifts [i, j] are binary variables that represent whether nurse i is assigned to shift j. The constraints ensure that each shift is covered, each nurse works no more than max_shifts_per_week, and each nurse has at least one day off per week. The objective is to minimize the number of shifts worked.


The above solution is a simplified problem, and based on the specific requirements of your problem, you may need to add more constraints or objective functions. This is a basic illustration of how or-tools could be used in nurse scheduling, and you can use it as a starting point to create your specific problem solution.


In any case, Google OR-Tools can be a valuable tool for solving nurse scheduling problems and can help you optimize your schedule and ensure that your nurses are working efficiently and effectively.


The or-tools library is a set of operations research tools developed at Google.If you have no ideawhat operations research is, you still can use ourlibrary to solve common small problems withthe help of our Constraint Programming (CP) solver.If you do know what operations researchis and how difficult it is sometimes to find efficient, easy to use and open source code, we hopeyou will enjoy using our library. We have put a lot of efforts in order to make it user friendly andcontinue to improve it on a daily basis. Furthermore, we encourage interactivity and are alwaysopen to suggestions. See the section How to reach us? below. If you have comments about thismanual or the documentation in general, see the section Do you have comments?.


This manual is intended to give you the necessary knowledge to use the library and explore thereference manual by yourself. We describe the basic concepts but also how to customize yoursearch in Constraint Programming (CP). One of the strength of our library is its routing solver inCP to solve node- and vehicle routing problems with constraints. We describe how to customize yourrouting algorithms. After reading this manual, you will be able to understand our way of codingand how to use the full potential of our library.


This document will not describe how to use the library (and the syntactic sugar introduced whenpossible) with Python, Java nor C#. This could possibly change in the future. The tutorial examples(see below) exist also in Python, Java and C# though.


You could read this document from cover to cover but we have put a lot of efforts to make eachchapter stands on its own. The best way to read this manual is to look for a specific answer, usethe index or the table of contents to find a reference to that information. If you aremissing some requirements to understand a section, you can always backtrack on prerequisiteknowledge. For each chapter, we list those prerequisites. This non-linear way of reading isprobably the most efficient and rewarding one!


That said, the manual is kept short so that you can read it in its entirety. The first part (Basics)is an introduction on how to use the CP solver to solve small problems. For real problems, youneed to customize your search and this is explained in the second part (Customization). If you areinterested in the routing part of the library, the third part is for you (Routing). Finally, some utilitiesand tricks are described in the last part (Technicalities).


This manual is written with two types of readers in mind. First, someone who is not familiar with Constraint Programmingnor is she a professional programmer. Second, an educated reader who masters Constraint Programming and isquite at ease withoutnecessarily mastering one of the supported computer languages.


In this example, the parameters of the function MakeBaseLine2() are stripped as are the contentof this method and the code lines that follow the definition of this function. The purpose of thisexample is to show that the code is written inside the namespace operations_research.


If you prefer to code in Python, Java or C#, we have translated (will translate) all the examples in yourfavourite language. You can find the complete examples on the documentation hub or under thedirectories:

3a8082e126
Reply all
Reply to author
Forward
0 new messages