diff --git a/documentation/changes_list.txt b/documentation/changes_list.txt index d1908e8dbc..eacdc39cd7 100644 --- a/documentation/changes_list.txt +++ b/documentation/changes_list.txt @@ -1,4 +1,33 @@ +v.0.1.3: (2012-04-20 11:29:46) +------------------------------ +* Minor enhancements to the manual: + - preface added (suggested by Hakan). + - parts introduced: + + basics, + + customization, + + routing, + + appendices. + - no more unnecessary empty pages in the LaTeX version (still "belle page"). + - two pages mode. + - chapter about "Modeling tricks" put at the end in the appendices. + - few corrections. + - chap2: suggestions from Hakan (thank you) applied: + + typos. + + nqueens -> n-queens. + + chap2: solution in same format as problem. + + lots of small improvements. + - tables centred. + - tags "draft" and "final" added in Sphinx for conditional compilation. +* Minor enhancements to the slides: + - chap2: few typos, better layout (thank you Dania). +* FAQ on the documentation extended. +* Tutorial examples: + - code directories changed (now they all start with lower case letter). + - minor corrections in the C++ code. + - Csharp examples for chap2 added. + - Java examples for chap2 added. + v.0.1.2: (2012-03-30 21:13:04) ------------------------------ * Minor enhancements to the manual: diff --git a/documentation/documentation_hub.html b/documentation/documentation_hub.html index f535ba92fd..5095086cf7 100644 --- a/documentation/documentation_hub.html +++ b/documentation/documentation_hub.html @@ -39,8 +39,7 @@
Please, think twice before printing. Be green, read on the screen! (Don't do like those guys!)
-

We are working hard to provide useful documentation. The documentation is distributed in several documents: - +

We are working hard to provide useful documentation. The documentation is distributed in several documents:

-

+ +

You can find more details about these documents in the foreword of the manual.

+

The or-tools documentation is covered by the Apache License 2.0.


What's new?


-

Here is a little summary: -

v.0.1.2: (2012-03-30 21:13:04)
+

Here is a little summary:

+
v.0.1.3: (2012-04-20 11:29:46)
 ------------------------------
 * Minor enhancements to the manual:
-  - conditional compilation in LaTeX:
-      code doesn't overflow anymore in A4 mode...
+  - preface added (suggested by Hakan).
+  - parts introduced:
+    + basics,
+    + customization,
+    + routing,
+    + appendices.
+  - no more unnecessary empty pages in the LaTeX version (still "belle page").
+  - two pages mode.
+  - chapter about "Modeling tricks" put at the end in the appendices.
   - few corrections.
-* Hub: 
-  - we recommend calibre as Cross-platform ebook viewer.
-* Tutorials:
-  - tutorial_all_examples.zip added.
-* Lab sessions:
-  - chap2 added.
-
-
-

- -

This is the list of changes.

+ - chap2: suggestions from Hakan (thank you) applied: + + typos. + + nqueens -> n-queens. + + chap2: solution in same format as problem. + + lots of small improvements. + - tables centred. + - tags "draft" and "final" added in Sphinx for conditional compilation. +* Minor enhancements to the slides: + - chap2: few typos, better layout (thank you Dania). +* FAQ on the documentation extended. +* Tutorial examples: + - code directories changed (now they all start with lower case letter). + - minor corrections in the C++ code. + - Csharp examples for chap2 added. + - Java examples for chap2 added. +

The User's Manual


The epub version is still experimental. We recommend calibre to view the epub version. With this version, you should be able to convert the manual to the right format for your preferred handheld device.

+ +

Progress at a glance

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Part I: Basics
Chap1: Introduction +
+
+ 5% +
+
+
Chap2: First steps with or-tools +
+
+ 82% +
+
+
Chap3: Using objectives +
+
+ 63% +
+
+
Chap4: Search primitives +
+
+ 9% +
+
+
Part II: Customization
Chap5: Large Neighbourhood Search +
+
+ 0% +
+
+
Chap6: Local Search operators +
+
+ 0% +
+
+
Chap7: Custom constraints +
+
+ 0% +
+
+
Part III: Routing
Chap8: TSP with constraints +
+
+ 0% +
+
+
Chap9: VRP with constraints +
+
+ 0% +
+
+
Part IV: Appendices
Chap10: Utilities +
+
+ 2% +
+
+
Chap11: Modeling tricks +
+
+ 0% +
+
+
+ +

The manual

-


The tutorial examples


-

You can download all the code at once or pick a single file in the list below. All files are encoded in UTF-8 and we use LF (Unix) newlines.

+

You can download all the code at once or pick a single file in the list below. All files are encoded in UTF-8 and we use LF (Unix) newlines (the code is cross-platform though).

+

The code is not well documented inside the source files as we explain it in great details in the user's manual. Some files don't have corresponding +files in some languages as the features implemented just don't have an equivalent in that languages (for instance, the Google gflags library is missing in Java and C#).

+
Coding styles we follow:
+

+

+
C++
Google C++ Style Guide
+
Python
Google Python Style Guide
+
+

+
Coding styles we try to follow:
+

+

+
Java
Android Code Style Rules
+
C#
google-api-dotnet-client Coding standards
+
+

+ +
Code:
+

Everything: tutorial_all_examples.zip

- -

Languages:

diff --git a/documentation/faq/faq/CPsolver.html b/documentation/faq/faq/CPsolver.html index b8e6a2f9b5..a6cf3b783b 100644 --- a/documentation/faq/faq/CPsolver.html +++ b/documentation/faq/faq/CPsolver.html @@ -108,8 +108,8 @@ diff --git a/documentation/faq/faq/documentation.html b/documentation/faq/faq/documentation.html index 877a8b8e99..8ad13a62b8 100644 --- a/documentation/faq/faq/documentation.html +++ b/documentation/faq/faq/documentation.html @@ -60,6 +60,12 @@
  • I’d like to improve a section in the documentation. How do I contribute?
  • How do I compile and run the examples in the tutorial section?
  • I’ve spotted strangely formulated sentences in the documention. How come?
  • +
  • How can I generate the documentation?
  • +
  • What tools do you use to generate the documentation?
  • +
  • Isn’t the page layout sometimes rough?
  • +
  • What about the first chapter?
  • +
  • Does the search tool return pertinent results?
  • +
  • When do you expect to finish?
  • Help! I’m lost. Where can I get some help?

    @@ -73,30 +79,55 @@ the documentation. Did you visit it?

    I’d like to improve a section in the documentation. How do I contribute?

    -

    For the moment, contact us on the mailing list. We will implement -an interactive documentation... if we have enough time. First we document, than we improve the documentation. ;-)

    +

    Send us your comments, suggestions, corrections, feedback, ... to ortools.doc at gmail.com. Thank you very much.

    How do I compile and run the examples in the tutorial section?

    -

    We give you the easiest solutions to compile and run the examples or your -code in any directory you want.

    - +

    Makefiles are (will be) provided to compile the examples (soon).

    I’ve spotted strangely formulated sentences in the documention. How come?

    Maybe becauze it iz my third language? We are always trying to improve our work. If you have comments, suggestions, corrections,... -see I’d like to improve a section in the documentation. How do I contribute?

    +see I’d like to improve a section in the documentation. How do I contribute?.

    +
    +

    How can I generate the documentation?

    +

    All the necessary steps are explained in the little manual howto.pdf in the directory documentation/doc of the or-tools project. The document itself is written +in LaTeX and can be generated with pdflatex.

    +
    +
    +

    What tools do you use to generate the documentation?

    +

    The documentation is written for the most part in reStructuredText (see http://docutils.sourceforge.net/rst.html) +and transformed with the help of the following great open source tools:

    + +

    You will find more details in the little manual howto.pdf in the directory documentation/doc of the or-tools project.

    +
    +
    +

    Isn’t the page layout sometimes rough?

    +

    We are more focused on the content for the moment. Writing documentation is a two-step process: first, we write the documentation, +then we format the documents.

    +

    You can send us your comments about the layout (see I’d like to improve a section in the documentation. How do I contribute?). We might not correct the layout right away but we’ll +keep your suggestions for later.

    +
    +
    +

    What about the first chapter?

    +

    This is probably the most difficult to write chapter and will be written last.

    +

    This chapter will be an introduction to Constraint Programming and... the manual. Expect to see some common concepts explained here. If +you see important notions in the other chapters that are not explained, this is because we will detail them in this first chapter.

    +
    +
    +

    Does the search tool return pertinent results?

    +

    Not for the moment. +Give us some time. For the moment, the structure of the documentation is still changing and the documentation is quite empty.

    +
    +
    +

    When do you expect to finish?

    +

    15 th of June... 2012!

    +You can see the overal progress here.
    @@ -149,8 +180,8 @@ see IR diff --git a/documentation/faq/faq/installation.html b/documentation/faq/faq/installation.html index 8e4291168b..951e74ea0f 100644 --- a/documentation/faq/faq/installation.html +++ b/documentation/faq/faq/installation.html @@ -125,8 +125,8 @@ We suggest you to use a Makefile< diff --git a/documentation/faq/faq/library.html b/documentation/faq/faq/library.html index 881965abc4..97aab2672a 100644 --- a/documentation/faq/faq/library.html +++ b/documentation/faq/faq/library.html @@ -81,6 +81,10 @@

    Do you use this library at Google?

    +

    Yes! The code we have released is a subset of all the OR tools we are +developing at Google. This code is used internally. We will maintain +this open-source branch in sync with our internal code and will likely +contribute more tools, more technology.

    @@ -134,8 +138,8 @@ diff --git a/documentation/faq/genindex.html b/documentation/faq/genindex.html index 3358708dc4..b4da62a1dc 100644 --- a/documentation/faq/genindex.html +++ b/documentation/faq/genindex.html @@ -103,8 +103,8 @@ diff --git a/documentation/faq/index.html b/documentation/faq/index.html index 4472742508..b66ce7226b 100644 --- a/documentation/faq/index.html +++ b/documentation/faq/index.html @@ -111,8 +111,8 @@ diff --git a/documentation/static/documentation_hub.css b/documentation/static/documentation_hub.css index 3a748e690c..a2bc6fc407 100644 --- a/documentation/static/documentation_hub.css +++ b/documentation/static/documentation_hub.css @@ -42,6 +42,9 @@ h2 { margin:10px 0px 10px 0px; } +.empty { + color: #D8D8D8; +} .rightmenu { float:right; @@ -84,6 +87,30 @@ dd.examples_list { font-weight: bold; } + +/* Progress bars */ + +.progress_background { + padding:0px; + background:#F2F1F0; /* #F5F5F5; #F1F1F1; */ +} + + +.progress_foreground_green { + /* background:#00FF00; */ + background: #98FB98; /* #C0EF4A; */ + text-align:center; +} + +.progress_foreground_red { + /* background:#FF0000; */ + background:#FE8181; /* #FF4500; #FEEFB3;*/ + text-align:center; +} + + +/* Admonitions */ + .seealso, .warning, .note, .topic, .safe_trees { border: 1px solid; margin: 10px 0px; diff --git a/documentation/tutorials/c++/chap2/.kdev_include_paths b/documentation/tutorials/c++/chap2/.kdev_include_paths new file mode 100644 index 0000000000..b594b2e2c1 --- /dev/null +++ b/documentation/tutorials/c++/chap2/.kdev_include_paths @@ -0,0 +1 @@ +/home/nikolaj/Documents/RESEARCH/google/or-tools-read-only/src/ diff --git a/documentation/tutorials/C++/chap2/cp_is_fun1.cc b/documentation/tutorials/c++/chap2/cp_is_fun1.cc similarity index 98% rename from documentation/tutorials/C++/chap2/cp_is_fun1.cc rename to documentation/tutorials/c++/chap2/cp_is_fun1.cc index fc7590b6ea..3cb06fd638 100644 --- a/documentation/tutorials/C++/chap2/cp_is_fun1.cc +++ b/documentation/tutorials/c++/chap2/cp_is_fun1.cc @@ -73,7 +73,7 @@ IntVar* const MakeBaseLine4(Solver* s, } void CPIsFun() { - // Constraint programming engine + // Constraint Programming engine Solver solver("CP is fun!"); const int64 kBase = 10; @@ -122,7 +122,7 @@ void CPIsFun() { solver.AddConstraint(solver.MakeEquality(sum_terms, sum)); - + // Decision Builder: hot to scour the search tree DecisionBuilder* const db = solver.MakePhase(letters, Solver::CHOOSE_FIRST_UNBOUND, Solver::ASSIGN_MIN_VALUE); diff --git a/documentation/tutorials/C++/chap2/cp_is_fun2.cc b/documentation/tutorials/c++/chap2/cp_is_fun2.cc similarity index 98% rename from documentation/tutorials/C++/chap2/cp_is_fun2.cc rename to documentation/tutorials/c++/chap2/cp_is_fun2.cc index aa219b322d..5d279bbdb7 100644 --- a/documentation/tutorials/C++/chap2/cp_is_fun2.cc +++ b/documentation/tutorials/c++/chap2/cp_is_fun2.cc @@ -26,8 +26,6 @@ #include "base/logging.h" #include "constraint_solver/constraint_solver.h" -DEFINE_int64(base, 10, "Base used to solve the problem."); - namespace operations_research { // helper functions diff --git a/documentation/tutorials/C++/chap2/cp_is_fun3.cc b/documentation/tutorials/c++/chap2/cp_is_fun3.cc similarity index 100% rename from documentation/tutorials/C++/chap2/cp_is_fun3.cc rename to documentation/tutorials/c++/chap2/cp_is_fun3.cc diff --git a/documentation/tutorials/C++/chap2/cp_is_fun4.cc b/documentation/tutorials/c++/chap2/cp_is_fun4.cc similarity index 99% rename from documentation/tutorials/C++/chap2/cp_is_fun4.cc rename to documentation/tutorials/c++/chap2/cp_is_fun4.cc index d9bc97b8fe..e9b6e09782 100644 --- a/documentation/tutorials/C++/chap2/cp_is_fun4.cc +++ b/documentation/tutorials/c++/chap2/cp_is_fun4.cc @@ -22,6 +22,7 @@ // Use of Solve(). // Use of gflags to choose the base. // Change the time limit of the solver. +// Use of ExportProfilingOverview(). #include diff --git a/documentation/tutorials/C++/chap3/golomb1.cc b/documentation/tutorials/c++/chap3/golomb1.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb1.cc rename to documentation/tutorials/c++/chap3/golomb1.cc diff --git a/documentation/tutorials/C++/chap3/golomb2.cc b/documentation/tutorials/c++/chap3/golomb2.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb2.cc rename to documentation/tutorials/c++/chap3/golomb2.cc diff --git a/documentation/tutorials/C++/chap3/golomb3.cc b/documentation/tutorials/c++/chap3/golomb3.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb3.cc rename to documentation/tutorials/c++/chap3/golomb3.cc diff --git a/documentation/tutorials/C++/chap3/golomb4.cc b/documentation/tutorials/c++/chap3/golomb4.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb4.cc rename to documentation/tutorials/c++/chap3/golomb4.cc diff --git a/documentation/tutorials/C++/chap3/golomb5.cc b/documentation/tutorials/c++/chap3/golomb5.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb5.cc rename to documentation/tutorials/c++/chap3/golomb5.cc diff --git a/documentation/tutorials/C++/chap3/golomb6.cc b/documentation/tutorials/c++/chap3/golomb6.cc similarity index 100% rename from documentation/tutorials/C++/chap3/golomb6.cc rename to documentation/tutorials/c++/chap3/golomb6.cc diff --git a/documentation/tutorials/csharp/chap2/cp_is_fun1.cs b/documentation/tutorials/csharp/chap2/cp_is_fun1.cs new file mode 100644 index 0000000000..8ff3d6578f --- /dev/null +++ b/documentation/tutorials/csharp/chap2/cp_is_fun1.cs @@ -0,0 +1,106 @@ +/* +Copyright 2012 Google +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Cryptoarithmetic puzzle + +First attempt to solve equation CP + IS + FUN = TRUE +where each letter represents a unique digit. + +This problem has 72 different solutions in base 10. + +Use of NewSearch. +*/ +using System; +using Google.OrTools.ConstraintSolver; + + +public class cp_is_fun1 +{ + // We don't need helper functions here + // Csharp syntax is easier than C++ syntax! + + private static void CPisFun () + { + // Constraint Programming engine + Solver solver = new Solver ("CP is fun!"); + + const int kBase = 10; + + // Decision variables + IntVar c = solver.MakeIntVar (1, kBase - 1, "C"); + IntVar p = solver.MakeIntVar (0, kBase - 1, "P"); + IntVar i = solver.MakeIntVar (1, kBase - 1, "I"); + IntVar s = solver.MakeIntVar (0, kBase - 1, "S"); + IntVar f = solver.MakeIntVar (1, kBase - 1, "F"); + IntVar u = solver.MakeIntVar (0, kBase - 1, "U"); + IntVar n = solver.MakeIntVar (0, kBase - 1, "N"); + IntVar t = solver.MakeIntVar (1, kBase - 1, "T"); + IntVar r = solver.MakeIntVar (0, kBase - 1, "R"); + IntVar e = solver.MakeIntVar (0, kBase - 1, "E"); + + // We need to group variables in a vector to be able to use + // the global constraint AllDifferent + IntVar[] letters = new IntVar[] { c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + if (kBase < letters.Length) { + throw new Exception("kBase < letters.Length"); + } + + // Constraints + solver.Add (letters.AllDifferent ()); + + // CP + IS + FUN = TRUE + solver.Add (p + s + n + kBase * (c + i + u) + kBase * kBase * f == + e + kBase * u + kBase * kBase * r + kBase * kBase * kBase * t); + + // Decision Builder: hot to scour the search tree + DecisionBuilder db = solver.MakePhase (letters, + Solver.CHOOSE_FIRST_UNBOUND, + Solver.ASSIGN_MIN_VALUE); + solver.NewSearch (db); + + if (solver.NextSolution ()) { + Console.WriteLine ("Solution found:"); + Console.Write ("C=" + c.Value () + " P=" + p.Value ()); + Console.Write (" I=" + i.Value () + " S=" + s.Value ()); + Console.Write (" F=" + f.Value () + " U=" + u.Value ()); + Console.Write (" N=" + n.Value () + " T=" + t.Value ()); + Console.Write (" R=" + r.Value () + " E=" + e.Value ()); + Console.WriteLine (); + + // Is CP + IS + FUN = TRUE? + if (p.Value () + s.Value () + n.Value() + + kBase * (c.Value () + i.Value () + u.Value()) + + kBase * kBase * f.Value () != + e.Value () + kBase * u.Value () + + kBase * kBase * r.Value () + + kBase * kBase * kBase * t.Value ()) { + throw new Exception("CP + IS + FUN != TRUE"); + } + } else { + Console.WriteLine ("Cannot solve problem."); + } // if (solver.NextSolution()) + + solver.EndSearch (); + + } + + public static void Main (String[] args) + { + CPisFun (); + } +} diff --git a/documentation/tutorials/csharp/chap2/cp_is_fun2.cs b/documentation/tutorials/csharp/chap2/cp_is_fun2.cs new file mode 100644 index 0000000000..394be6ff4f --- /dev/null +++ b/documentation/tutorials/csharp/chap2/cp_is_fun2.cs @@ -0,0 +1,103 @@ +/* +Copyright 2012 Google +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Cryptoarithmetic puzzle + +First attempt to solve equation CP + IS + FUN = TRUE +where each letter represents a unique digit. + +This problem has 72 different solutions in base 10. + +Use of SolutionCollectors. +Use of Solve(). +*/ +using System; +using Google.OrTools.ConstraintSolver; + + +public class cp_is_fun1 +{ + // We don't need helper functions here + // Csharp syntax is easier than C++ syntax! + + private static void CPisFun (int kBase) + { + // Constraint Programming engine + Solver solver = new Solver ("CP is fun!"); + + // Decision variables + IntVar c = solver.MakeIntVar (1, kBase - 1, "C"); + IntVar p = solver.MakeIntVar (0, kBase - 1, "P"); + IntVar i = solver.MakeIntVar (1, kBase - 1, "I"); + IntVar s = solver.MakeIntVar (0, kBase - 1, "S"); + IntVar f = solver.MakeIntVar (1, kBase - 1, "F"); + IntVar u = solver.MakeIntVar (0, kBase - 1, "U"); + IntVar n = solver.MakeIntVar (0, kBase - 1, "N"); + IntVar t = solver.MakeIntVar (1, kBase - 1, "T"); + IntVar r = solver.MakeIntVar (0, kBase - 1, "R"); + IntVar e = solver.MakeIntVar (0, kBase - 1, "E"); + + // We need to group variables in a vector to be able to use + // the global constraint AllDifferent + IntVar[] letters = new IntVar[] { c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + if (kBase < letters.Length) { + throw new Exception("kBase < letters.Length"); + } + + // Constraints + solver.Add (letters.AllDifferent ()); + + // CP + IS + FUN = TRUE + solver.Add (p + s + n + kBase * (c + i + u) + kBase * kBase * f == + e + kBase * u + kBase * kBase * r + kBase * kBase * kBase * t); + + SolutionCollector all_solutions = solver.MakeAllSolutionCollector(); + // Add the interesting variables to the SolutionCollector + all_solutions.Add(c); + all_solutions.Add(p); + // Create the variable kBase * c + p + IntVar v1 = solver.MakeSum(solver.MakeProd(c, kBase), p).Var(); + // Add it to the SolutionCollector + all_solutions.Add(v1); + + // Decision Builder: hot to scour the search tree + DecisionBuilder db = solver.MakePhase (letters, + Solver.CHOOSE_FIRST_UNBOUND, + Solver.ASSIGN_MIN_VALUE); + solver.Solve(db, all_solutions); + + // Retrieve the solutions + int numberSolutions = all_solutions.SolutionCount(); + Console.WriteLine ("Number of solutions: " + numberSolutions); + + for (int index = 0; index < numberSolutions; ++index) { + Assignment solution = all_solutions.Solution(index); + Console.WriteLine ("Solution found:"); + Console.WriteLine ("v1=" + solution.Value(v1)); + } + } + + public static void Main (String[] args) + { + int kBase = 10; + if (args.Length > 0) { + kBase = Convert.ToInt32(args[0]); + } + CPisFun(kBase); + } +} diff --git a/documentation/tutorials/csharp/chap2/cp_is_fun4.cs b/documentation/tutorials/csharp/chap2/cp_is_fun4.cs new file mode 100644 index 0000000000..a361a95dda --- /dev/null +++ b/documentation/tutorials/csharp/chap2/cp_is_fun4.cs @@ -0,0 +1,132 @@ +/* +Copyright 2012 Google +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Cryptoarithmetic puzzle + +First attempt to solve equation CP + IS + FUN = TRUE +where each letter represents a unique digit. + +This problem has 72 different solutions in base 10. + +Use of SolutionCollectors. +Use of Solve(). +Change the time limit of the solver. +Use of ExportProfilingOverview(). +*/ +using System; +using Google.OrTools.ConstraintSolver; + + +public class cp_is_fun1 +{ + // We don't need helper functions here + // Csharp syntax is easier than C++ syntax! + + private static void CPisFun (int kBase, int time_limit_param, bool print) + { + + // Use some profiling and change the default parameters of the solver + SolverParameters solver_params = new SolverParameters(); + // Change the profile level + solver_params.profile_level = SolverParameters.NORMAL_PROFILING; + + // Constraint Programming engine + Solver solver = new Solver ("CP is fun!", solver_params); + + // Decision variables + IntVar c = solver.MakeIntVar (1, kBase - 1, "C"); + IntVar p = solver.MakeIntVar (0, kBase - 1, "P"); + IntVar i = solver.MakeIntVar (1, kBase - 1, "I"); + IntVar s = solver.MakeIntVar (0, kBase - 1, "S"); + IntVar f = solver.MakeIntVar (1, kBase - 1, "F"); + IntVar u = solver.MakeIntVar (0, kBase - 1, "U"); + IntVar n = solver.MakeIntVar (0, kBase - 1, "N"); + IntVar t = solver.MakeIntVar (1, kBase - 1, "T"); + IntVar r = solver.MakeIntVar (0, kBase - 1, "R"); + IntVar e = solver.MakeIntVar (0, kBase - 1, "E"); + + // We need to group variables in a vector to be able to use + // the global constraint AllDifferent + IntVar[] letters = new IntVar[] { c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + if (kBase < letters.Length) { + throw new Exception("kBase < letters.Length"); + } + + // Constraints + solver.Add (letters.AllDifferent ()); + + // CP + IS + FUN = TRUE + solver.Add (p + s + n + kBase * (c + i + u) + kBase * kBase * f == + e + kBase * u + kBase * kBase * r + kBase * kBase * kBase * t); + + SolutionCollector all_solutions = solver.MakeAllSolutionCollector(); + // Add the interesting variables to the SolutionCollector + all_solutions.Add(letters); + + // Decision Builder: hot to scour the search tree + DecisionBuilder db = solver.MakePhase (letters, + Solver.CHOOSE_FIRST_UNBOUND, + Solver.ASSIGN_MIN_VALUE); + + // Add some time limit + SearchLimit time_limit = solver.MakeTimeLimit(time_limit_param); + + solver.Solve(db, all_solutions, time_limit); + + // Retrieve the solutions + int numberSolutions = all_solutions.SolutionCount(); + Console.WriteLine ("Number of solutions: " + numberSolutions); + + if (print) { + for (int index = 0; index < numberSolutions; ++index) { + Console.Write ("C=" + all_solutions.Value(index, c)); + Console.Write (" P=" + all_solutions.Value(index, p)); + Console.Write (" I=" + all_solutions.Value(index, i)); + Console.Write (" S=" + all_solutions.Value(index, s)); + Console.Write (" F=" + all_solutions.Value(index, f)); + Console.Write (" U=" + all_solutions.Value(index, u)); + Console.Write (" N=" + all_solutions.Value(index, n)); + Console.Write (" T=" + all_solutions.Value(index, t)); + Console.Write (" R=" + all_solutions.Value(index, r)); + Console.Write (" E=" + all_solutions.Value(index, e)); + Console.WriteLine (); + } + } + + // Save profile in file + solver.ExportProfilingOverview("profile.txt"); + } + + public static void Main (String[] args) + { + int kBase = 10; + int kTimeLimit = 10000; + bool kPrintAllSolutions = false; + + if (args.Length > 0) { + kBase = Convert.ToInt32(args[0]); + if (args.Length > 1) { + kTimeLimit = Convert.ToInt32(args[1]); + if (args.Length > 2) { + kPrintAllSolutions = Convert.ToBoolean(args[2]); + } + } + } + CPisFun(kBase, kTimeLimit, kPrintAllSolutions); + } +} diff --git a/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun1.java b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun1.java new file mode 100644 index 0000000000..d4345e6c04 --- /dev/null +++ b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun1.java @@ -0,0 +1,140 @@ +// Copyright 2012 Google +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Cryptoarithmetic puzzle +// +// First attempt to solve equation CP + IS + FUN = TRUE +// where each letter represents a unique digit. +// +// This problem has 72 different solutions in base 10. +// +// Use of NewSearch. +package com.google.ortools.tutorial.chap2; + +import com.google.ortools.constraintsolver.*; + +public class CpIsFun1 { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + private static final int kBase = 10; + + // helper functions + static IntVar makeBaseLine2(Solver s, + IntVar v1, + IntVar v2, + int base) { + return s.makeSum(s.makeProd(v1, base).var(), v2).var(); + } + + static IntVar makeBaseLine3(Solver s, + IntVar v1, + IntVar v2, + IntVar v3, + int base) { + IntVar[] tmp_vars = {v1, v2, v3}; + int[] coefficients = {base * base, base, 1}; + + return s.makeScalProd(tmp_vars, coefficients).var(); + } + + // We introduce the generic version + static IntVar makeBaseLine(Solver s, + IntVar[] vars, + int base) { + int len = vars.length; + int coeff = 1; + int[] coeffs = new int[len]; + for(int i = len-1; i >= 0; --i) { + coeffs[i] = coeff; + coeff *= base; + } + + return s.makeScalProd(vars, coeffs).var(); + } + + + private static void CPIsFun() { + + Solver solver = new Solver("Cp is fun!"); + + IntVar c = solver.makeIntVar(1, kBase - 1, "C"); + IntVar p = solver.makeIntVar(0, kBase - 1, "P"); + IntVar i = solver.makeIntVar(1, kBase - 1, "I"); + IntVar s = solver.makeIntVar(0, kBase - 1, "S"); + IntVar f = solver.makeIntVar(1, kBase - 1, "F"); + IntVar u = solver.makeIntVar(0, kBase - 1, "U"); + IntVar n = solver.makeIntVar(0, kBase - 1, "N"); + IntVar t = solver.makeIntVar(1, kBase - 1, "T"); + IntVar r = solver.makeIntVar(0, kBase - 1, "R"); + IntVar e = solver.makeIntVar(0, kBase - 1, "E"); + + // We need to group variables in an array to be able to use + // the global constraint AllDifferent + IntVar[] letters = {c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + assert(letters.length <= kBase); + + // Constraints + solver.addConstraint(solver.makeAllDifferent(letters)); + + // CP + IS + FUN = TRUE + IntVar term1 = makeBaseLine2(solver, c, p, kBase); + IntVar term2 = makeBaseLine2(solver, i, s, kBase); + IntVar term3 = makeBaseLine3(solver, f, u, n, kBase); + IntVar sum_terms = solver.makeSum(solver.makeSum(term1,term2).var(), + term3).var(); + + IntVar[] sum_vars = {t, r, u, e}; + IntVar sum = makeBaseLine(solver, sum_vars, kBase); + + solver.addConstraint(solver.makeEquality(sum_terms, sum)); + + + DecisionBuilder db = solver.makePhase(letters, + solver.CHOOSE_FIRST_UNBOUND, + solver.ASSIGN_MIN_VALUE); + + solver.newSearch(db); + + if (solver.nextSolution()) { + System.out.println("Solution found:"); + System.out.println("C=" + c.value() + " " + "P=" + p.value() + " " + + "I=" + i.value() + " " + "S=" + s.value() + " " + + "F=" + f.value() + " " + "U=" + u.value() + " " + + "N=" + n.value() + " " + "T=" + t.value() + " " + + "R=" + r.value() + " " + "E=" + e.value()); + // Is CP + IS + FUN = TRUE? + assert(p.value() + s.value() + n.value() + + kBase * (c.value() + i.value() + u.value()) + + kBase * kBase * f.value() == + e.value() + + kBase * u.value() + + kBase * kBase * r.value() + + kBase * kBase * kBase * t.value()); + + } else { + System.out.println("Cannot solve problem."); + } // if (solver.nextSolution()) + + solver.endSearch(); + + } + + public static void main(String[] args) throws Exception { + CpIsFun1.CPIsFun(); + } +} diff --git a/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun2.java b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun2.java new file mode 100644 index 0000000000..5b197c84df --- /dev/null +++ b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun2.java @@ -0,0 +1,137 @@ +// Copyright 2012 Google +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Cryptoarithmetic puzzle +// +// First attempt to solve equation CP + IS + FUN = TRUE +// where each letter represents a unique digit. +// +// This problem has 72 different solutions in base 10. +// +// Use of SolutionCollectors. +// Use of Solve(). +package com.google.ortools.tutorial.chap2; + +import com.google.ortools.constraintsolver.*; + +public class CpIsFun2 { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + private static final int kBase = 10; + + // helper functions + static IntVar makeBaseLine2(Solver s, + IntVar v1, + IntVar v2, + int base) { + return s.makeSum(s.makeProd(v1, base).var(), v2).var(); + } + + static IntVar makeBaseLine3(Solver s, + IntVar v1, + IntVar v2, + IntVar v3, + int base) { + IntVar[] tmp_vars = {v1, v2, v3}; + int[] coefficients = {base * base, base, 1}; + + return s.makeScalProd(tmp_vars, coefficients).var(); + } + + // We introduce the generic version + static IntVar makeBaseLine(Solver s, + IntVar[] vars, + int base) { + int len = vars.length; + int coeff = 1; + int[] coeffs = new int[len]; + for(int i = len-1; i >= 0; --i) { + coeffs[i] = coeff; + coeff *= base; + } + + return s.makeScalProd(vars, coeffs).var(); + } + + + private static void CPIsFun() { + + Solver solver = new Solver("Cp is fun!"); + + IntVar c = solver.makeIntVar(1, kBase - 1, "C"); + IntVar p = solver.makeIntVar(0, kBase - 1, "P"); + IntVar i = solver.makeIntVar(1, kBase - 1, "I"); + IntVar s = solver.makeIntVar(0, kBase - 1, "S"); + IntVar f = solver.makeIntVar(1, kBase - 1, "F"); + IntVar u = solver.makeIntVar(0, kBase - 1, "U"); + IntVar n = solver.makeIntVar(0, kBase - 1, "N"); + IntVar t = solver.makeIntVar(1, kBase - 1, "T"); + IntVar r = solver.makeIntVar(0, kBase - 1, "R"); + IntVar e = solver.makeIntVar(0, kBase - 1, "E"); + + // We need to group variables in an array to be able to use + // the global constraint AllDifferent + IntVar[] letters = {c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + assert(kBase >= letters.length); + + // Constraints + solver.addConstraint(solver.makeAllDifferent(letters)); + + // CP + IS + FUN = TRUE + IntVar term1 = makeBaseLine2(solver, c, p, kBase); + IntVar term2 = makeBaseLine2(solver, i, s, kBase); + IntVar term3 = makeBaseLine3(solver, f, u, n, kBase); + IntVar sum_terms = solver.makeSum(solver.makeSum(term1,term2).var(), + term3).var(); + + IntVar[] sum_vars = {t, r, u, e}; + IntVar sum = makeBaseLine(solver, sum_vars, kBase); + + solver.addConstraint(solver.makeEquality(sum_terms, sum)); + + SolutionCollector all_solutions = solver.makeAllSolutionCollector(); + // Add the interesting variables to the SolutionCollector + all_solutions.add(c); + all_solutions.add(p); + // Create the variable kBase * c + p + IntVar v1 = solver.makeSum(solver.makeProd(c, kBase), p).var(); + // Add it to the SolutionCollector + all_solutions.add(v1); + + + DecisionBuilder db = solver.makePhase(letters, + solver.CHOOSE_FIRST_UNBOUND, + solver.ASSIGN_MIN_VALUE); + + solver.solve(db, all_solutions); + + // Retrieve the solutions + final int numberSolutions = all_solutions.solutionCount(); + System.out.println("Number of solutions: " + numberSolutions); + + for (int index = 0; index < numberSolutions; ++index) { + Assignment solution = all_solutions.solution(index); + System.out.println("Solution found:"); + System.out.println("v1=" + solution.value(v1)); + } + } + + public static void main(String[] args) throws Exception { + CpIsFun2.CPIsFun(); + } +} diff --git a/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun4.java b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun4.java new file mode 100644 index 0000000000..b3dde785e4 --- /dev/null +++ b/documentation/tutorials/java/com/google/ortools/tutorial/chap2/CpIsFun4.java @@ -0,0 +1,192 @@ +// Copyright 2012 Google +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Cryptoarithmetic puzzle +// +// First attempt to solve equation CP + IS + FUN = TRUE +// where each letter represents a unique digit. +// +// This problem has 72 different solutions in base 10. +// +// Use of SolutionCollectors. +// Use of Solve(). +// Use of gflags to choose the base. +// Change the time limit of the solver. +// Use of ExportProfilingOverview(). +package com.google.ortools.tutorial.chap2; + +import com.google.ortools.constraintsolver.*; + +public class CpIsFun4 { + + static { + System.loadLibrary("jniconstraintsolver"); + } + +// private static final int kBase = 10; + + // helper functions + static IntVar makeBaseLine2(Solver s, + IntVar v1, + IntVar v2, + int base) { + return s.makeSum(s.makeProd(v1, base).var(), v2).var(); + } + + static IntVar makeBaseLine3(Solver s, + IntVar v1, + IntVar v2, + IntVar v3, + int base) { + IntVar[] tmp_vars = {v1, v2, v3}; + int[] coefficients = {base * base, base, 1}; + + return s.makeScalProd(tmp_vars, coefficients).var(); + } + + // We introduce the generic version + static IntVar makeBaseLine(Solver s, + IntVar[] vars, + int base) { + int len = vars.length; + int coeff = 1; + int[] coeffs = new int[len]; + for(int i = len-1; i >= 0; --i) { + coeffs[i] = coeff; + coeff *= base; + } + + return s.makeScalProd(vars, coeffs).var(); + } + + + private static void CPIsFun(int base, long time_limit, boolean print) { + + // Use some profiling and change the default parameters of the solver + SolverParameters solver_params = new SolverParameters(); + // Change the profile level + solver_params.setProfile_level(SolverParameters.NORMAL_PROFILING); + + // Constraint programming engine + Solver solver = new Solver("Cp is fun!", solver_params); + + IntVar c = solver.makeIntVar(1, base - 1, "C"); + IntVar p = solver.makeIntVar(0, base - 1, "P"); + IntVar i = solver.makeIntVar(1, base - 1, "I"); + IntVar s = solver.makeIntVar(0, base - 1, "S"); + IntVar f = solver.makeIntVar(1, base - 1, "F"); + IntVar u = solver.makeIntVar(0, base - 1, "U"); + IntVar n = solver.makeIntVar(0, base - 1, "N"); + IntVar t = solver.makeIntVar(1, base - 1, "T"); + IntVar r = solver.makeIntVar(0, base - 1, "R"); + IntVar e = solver.makeIntVar(0, base - 1, "E"); + + // We need to group variables in an array to be able to use + // the global constraint AllDifferent + IntVar[] letters = {c, p, i, s, f, u, n, t, r, e}; + + // Check if we have enough digits + assert(base >= letters.length); + + // Constraints + solver.addConstraint(solver.makeAllDifferent(letters)); + + // CP + IS + FUN = TRUE + IntVar term1 = makeBaseLine2(solver, c, p, base); + IntVar term2 = makeBaseLine2(solver, i, s, base); + IntVar term3 = makeBaseLine3(solver, f, u, n, base); + IntVar sum_terms = solver.makeSum(solver.makeSum(term1,term2).var(), + term3).var(); + + IntVar[] sum_vars = {t, r, u, e}; + IntVar sum = makeBaseLine(solver, sum_vars, base); + + solver.addConstraint(solver.makeEquality(sum_terms, sum)); + + SolutionCollector all_solutions = solver.makeAllSolutionCollector(); + // Add the interesting variables to the SolutionCollector + all_solutions.add(letters); + + DecisionBuilder db = solver.makePhase(letters, + solver.CHOOSE_FIRST_UNBOUND, + solver.ASSIGN_MIN_VALUE); + + // Add some time limit + SearchLimit t_limit = solver.makeTimeLimit(time_limit); + solver.solve(db, all_solutions, t_limit); + + // Retrieve the solutions + final int numberSolutions = all_solutions.solutionCount(); + System.out.println("Number of solutions: " + numberSolutions); + + if (print) { + for (int index = 0; index < numberSolutions; ++index) { + System.out.println("C=" + all_solutions.value(index, c) + + " P=" + all_solutions.value(index, p) + + " I=" + all_solutions.value(index, i) + + " S=" + all_solutions.value(index, s) + + " F=" + all_solutions.value(index, f) + + " U=" + all_solutions.value(index, u) + + " N=" + all_solutions.value(index, n) + + " T=" + all_solutions.value(index, t) + + " R=" + all_solutions.value(index, r) + + " E=" + all_solutions.value(index, e) + ); + // Is CP + IS + FUN = TRUE? + assert(all_solutions.value(index, p) + all_solutions.value(index, s) + + all_solutions.value(index, n) + + base * (all_solutions.value(index, c) + + all_solutions.value(index, i) + + all_solutions.value(index, u)) + + base * base * all_solutions.value(index, f) == + all_solutions.value(index, e) + + base * all_solutions.value(index, u) + + base * base * all_solutions.value(index, r) + + base * base * base * all_solutions.value(index, t)); + } + } + + } + + public static void main(String[] args) throws Exception { + int kBase = 10; + long kTimeLimit = 10000; + boolean kPrintSolution = false; + if (args.length > 0) { + try { + kBase = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + System.err.println("First argument must be an integer (base)"); + System.exit(1); + } + if (args.length > 1) { + try { + kTimeLimit = Long.parseLong(args[1]); + } catch (NumberFormatException e) { + System.err.println("Second argument must be an integer" + + " (time limit in ms)"); + System.exit(1); + } + if (args.length > 2) { + try { + kPrintSolution = Boolean.parseBoolean(args[2]); + } catch (NumberFormatException e) { + System.err.println("Thrid argument must be a boolean (print?)"); + System.exit(1); + } + } + } + } + CpIsFun4.CPIsFun(kBase, kTimeLimit, kPrintSolution); + } +} diff --git a/documentation/tutorials/Python/chap2/cp_is_fun1.py b/documentation/tutorials/python/chap2/cp_is_fun1.py similarity index 100% rename from documentation/tutorials/Python/chap2/cp_is_fun1.py rename to documentation/tutorials/python/chap2/cp_is_fun1.py diff --git a/documentation/tutorials/Python/chap2/cp_is_fun2.py b/documentation/tutorials/python/chap2/cp_is_fun2.py similarity index 100% rename from documentation/tutorials/Python/chap2/cp_is_fun2.py rename to documentation/tutorials/python/chap2/cp_is_fun2.py diff --git a/documentation/tutorials/Python/chap2/cp_is_fun3.py b/documentation/tutorials/python/chap2/cp_is_fun3.py similarity index 100% rename from documentation/tutorials/Python/chap2/cp_is_fun3.py rename to documentation/tutorials/python/chap2/cp_is_fun3.py diff --git a/documentation/tutorials/Python/chap2/cp_is_fun4.py b/documentation/tutorials/python/chap2/cp_is_fun4.py similarity index 100% rename from documentation/tutorials/Python/chap2/cp_is_fun4.py rename to documentation/tutorials/python/chap2/cp_is_fun4.py diff --git a/documentation/user_manual/_images/anatomy1.png b/documentation/user_manual/_images/anatomy1.png index 91b1669896..9bf50db843 100644 Binary files a/documentation/user_manual/_images/anatomy1.png and b/documentation/user_manual/_images/anatomy1.png differ diff --git a/documentation/user_manual/_images/anatomy2.png b/documentation/user_manual/_images/anatomy2.png index d06fffa6b5..73b7de157c 100644 Binary files a/documentation/user_manual/_images/anatomy2.png and b/documentation/user_manual/_images/anatomy2.png differ diff --git a/documentation/user_manual/_images/rarr.png b/documentation/user_manual/_images/rarr.png new file mode 100644 index 0000000000..3c47fe8df4 Binary files /dev/null and b/documentation/user_manual/_images/rarr.png differ diff --git a/documentation/user_manual/_static/basic.css b/documentation/user_manual/_static/basic.css index c4aee2893f..49171110d2 100644 --- a/documentation/user_manual/_static/basic.css +++ b/documentation/user_manual/_static/basic.css @@ -317,6 +317,7 @@ table.docutils { border: 0; border-collapse: collapse; align: center; + margin: auto; } table.docutils td, table.docutils th { diff --git a/documentation/user_manual/_static/default.css b/documentation/user_manual/_static/default.css index 7da04566d6..27b38ca516 100644 --- a/documentation/user_manual/_static/default.css +++ b/documentation/user_manual/_static/default.css @@ -125,6 +125,15 @@ div.sphinxsidebar h4 { padding: 0; } +div.sphinxsidebar h5 { + font-family: 'Trebuchet MS', sans-serif; + color: #9A0303; + font-size: 1em; + font-weight: normal; + margin: 7px 0 0 0; + padding: 0; +} + div.sphinxsidebar p { color: #909090; } diff --git a/documentation/user_manual/genindex.html b/documentation/user_manual/genindex.html index 9ef998f79e..106b11cb63 100644 --- a/documentation/user_manual/genindex.html +++ b/documentation/user_manual/genindex.html @@ -10,7 +10,7 @@ - Index — or-tools User's Manual' + Index — or-tools User's Manual @@ -28,7 +28,7 @@ - + @@ -341,6 +341,10 @@ + -
    +
    n-queens problem +
    + +
    namespace
    @@ -351,20 +355,16 @@
    +
    NewSearch()
    -
    NextSolution()
    - -
    NQueen problem -
    -
    @@ -579,9 +579,9 @@

    Welcome

    @@ -593,8 +593,8 @@ @@ -610,7 +610,7 @@
  • index
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -92,9 +92,9 @@

    Welcome

    @@ -106,28 +106,38 @@

    Chapters

    - +
    Part I: Basics
    +

    +1. Introduction to CP
    +2. First steps with or-tools
    +3. Using objectives
    +4. Search primitives +

    +
    Part II: Customization
    +

    +5. Large Neighbourhood Search
    +6. Local Search operators
    +7. Custom constraints +

    +
    Part III: Routing
    +

    +8. TSP with constraints
    +9. VRP with constraints +

    +
    Part IV: Technicalities
    +

    +10. Utilities
    +11. Modeling tricks +

    @@ -144,7 +154,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -139,12 +149,12 @@ index
  • - next |
  • - previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -139,12 +149,12 @@ index
  • - next |
  • - previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -92,9 +92,9 @@

    Welcome

    @@ -106,28 +106,38 @@

    Chapters

    - +
    Part I: Basics
    +

    +1. Introduction to CP
    +2. First steps with or-tools
    +3. Using objectives
    +4. Search primitives +

    +
    Part II: Customization
    +

    +5. Large Neighbourhood Search
    +6. Local Search operators
    +7. Custom constraints +

    +
    Part III: Routing
    +

    +8. TSP with constraints
    +9. VRP with constraints +

    +
    Part IV: Technicalities
    +

    +10. Utilities
    +11. Modeling tricks +

    @@ -139,12 +149,12 @@ index
  • - next |
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -218,9 +228,9 @@ steps to write a basic program.

    next |
  • - previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -75,7 +75,7 @@ in more details.

    The header logging.h is needed for some logging facilities and some assert-like macros. The header constraint_solver.h is the main entry point -to the CP solver and must be included whenever you intend to use it.

    +to the CP solver and must be includedfootnote{Directly or indirectly when it is included in another header you include.} whenever you intend to use it.

    2.3.3. The namespace operations_research

    @@ -114,7 +114,7 @@ the function CPIsFun()

    2.3.4. The CP solver

    -

    The CP solver is the main engine to solve an +

    The CP solver is the main engine to solve a problem instance. It is also responsible for the creation of the model. It has a very rich Application Programming Interface (API) and provides a lots of functionalities.

    @@ -153,8 +153,15 @@ them appropriately.

    Warning

    Never delete explicitly an object created by -a factory method!

    +a factory method! First, the solver deletes all the objects for you. +Second, deleting a pointer twice in C++ gives undefined behaviour[2]!

    + + + + + +
    [2]It is possible to bypass the undefined behaviour but you don’t know what the solver needs to do, so keep your hands off of the object pointers! ;-)

    Beside integer variables, the solver provides factory methods to create interval variables (IntervalVar), sequence variables (SequenceVar) and variables to encapsulate objectives (OptimizeVar).

    @@ -177,11 +184,11 @@ Aborted

    In Asserting, we cover assert-like macros in more details.

    -

    2.3.7. Constraints

    +

    2.3.7. Constraints

    To create a integer linear constraint, we need to know how to multiply an integer variable with an integer constant and how to add two integer variables. We have seen that the solver creates a variable and only provides a pointer to that variable. -The solver provides also factory methods to multiply an integer coefficient by +The solver also provides factory methods to multiply an integer coefficient by an IntVar given by a pointer:

    IntVar* const var1 = solver.MakeIntVar(0, 1, "Var1");
     IntVar* const var2 = solver.MakeProd(var1,36)->Var();
    @@ -202,7 +209,7 @@ again a factory method:

    Is the call to Var() really necessary?

    Yes! Var() not only transforms a constraint into a variable but also a stateless expression into a stateful and monotonic variable.

    -

    Variables are stateful objects that provide a rich API. On the other hand, subclasses of BaseIntExpr represent range-only stateless objects. That is, MakeMin(MakeSum(A,B),a) is recomputed each time as MakeMin(A,a) + MakeMin(B,a). Furthermore, sometimes the propagation on an expression is not complete. For instance, if A is an IntVar with domain [0 .. 5], and B another IntVar with domain [0 .. 5] then MakeSum(A, B) has domain [0, 10]. If we apply MakeMax(MakeSum(A, B), 4)) then we will deduce that both A and B will have domain [0 .. 4]. In that case, the max of MakeMax(MakeSum(A, B),4) is 8 and not 4. To get back monotonicity, we need to cast the expression into a variable using the Var() method: MakeMax(MakeSum(A, B),4)->Var(). The resulting variable is stateful and monotonic.

    +

    Variables are stateful objects that provide a rich API. On the other hand, subclasses of BaseIntExpr represent range-only stateless objects. That is, MakeMin(MakeSum(A,B),a) is recomputed each time as MakeMin(A,a) + MakeMin(B,a). Furthermore, sometimes the propagation on an expression is not complete. For instance, if A is an IntVar with domain [0..5], and B another IntVar with domain [0..5] then MakeSum(A, B) has domain [0, 10]. If we apply MakeMax(MakeSum(A, B), 4)) then we will deduce that both A and B will have domain [0..4]. In that case, the max of MakeMax(MakeSum(A, B),4) is 8 and not 4. To get back monotonicity, we need to cast the expression into a variable using the Var() method: MakeMax(MakeSum(A, B),4)->Var(). The resulting variable is stateful and monotonic.

    Warning

    @@ -218,7 +225,7 @@ also a stateless expression into a stateful and monotonic variable.

    IntVar* const term2 = solver.MakeSum(solver.MakeProd(i,kBase),s)->Var();
    -

    No need to cast the result of MakeProd(c,kBbase) into an IntVar because +

    There is no need to cast the result of MakeProd(c,kBbase) into an IntVar because MakeSum() takes two pointers to an IntExpr.

    The combination of MakeSum() and MakeProd() can quickly become tedious. We use helper functions to construct sums. For example, to construct the first @@ -329,7 +336,15 @@ a solution was found and false<< "F=" << f->Value() << " " << "U=" << u->Value() << " " << "N=" << n->Value() << " " << "T=" << t->Value() << " " << "R=" << r->Value() << " " << "E=" << e->Value(); -... + + // Is CP + IS + FUN = TRUE? + CHECK_EQ(p->Value() + s->Value() + n->Value() + + kBase * (c->Value() + i->Value() + u->Value()) + + kBase * kBase * f->Value(), + e->Value() + + kBase * u->Value() + + kBase * kBase * r->Value() + + kBase * kBase * kBase * t->Value()); } else { LOG(INFO) << "Cannot solve problem."; } // if (solver.NextSolution()) @@ -340,6 +355,8 @@ a solution was found and false

    +

    We check the validity of the solution after printing: if the solution is not valid, we can see what +was found by the solver.

    To obtain all the solutions, NextSolution() can be called repeatedly:

    while (solver.NextSolution()) {
       // Do something with the current solution
    @@ -394,9 +411,9 @@ $[23:51:34] examples/cp_is_fun1.cc:133: C=2 P=3 I=7 S=4 F=9 U=6 N=8 T=1
       

    Welcome

    @@ -408,8 +425,8 @@ $[23:51:34] examples/cp_is_fun1.cc:133: C=2 P=3 I=7 S=4 F=9 U=6 N=8 T=1 @@ -448,7 +465,7 @@ $[23:51:34] examples/cp_is_fun1.cc:133: C=2 P=3 I=7 S=4 F=9 U=6 N=8 T=1
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/cryptarithmetic.html b/documentation/user_manual/manual/first_steps/cryptarithmetic.html index d55dcc6dc5..c832541c8c 100644 --- a/documentation/user_manual/manual/first_steps/cryptarithmetic.html +++ b/documentation/user_manual/manual/first_steps/cryptarithmetic.html @@ -8,7 +8,7 @@ - 2.2. The Cryptarithmetic Puzzle Problem and a first model — or-tools User's Manual' + 2.2. The Cryptarithmetic Puzzle Problem and a first model — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -73,8 +73,15 @@ goal is to find the digits such that a given mathematical equation is verified.< = T R U E
    -

    One solution is C=2 P=3 I=7 S=4 F=9 U=6 N=8 T=1 R=0 E=5 because -23+74+968 = 1065. Ideally, a good cryptarithmetic puzzle must have only +

    One solution is C=2 P=3 I=7 S=4 F=9 U=6 N=8 T=1 R=0 E=5 because

    +
          2 3
    ++     7 4
    ++   9 6 8
    +---------
    += 1 0 6 5
    +
    +
    +

    Ideally, a good cryptarithmetic puzzle must have only one solution[1]. We derogate from this tradition. The above example has multiple solutions. We use it to show you how to collect all solutions of a problem.

    @@ -194,9 +201,9 @@ A default basic strategy will do for the moment.

    Welcome

    @@ -208,8 +215,8 @@ A default basic strategy will do for the moment.

    @@ -245,7 +252,7 @@ A default basic strategy will do for the moment.

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/getting_started.html b/documentation/user_manual/manual/first_steps/getting_started.html index 9666874d20..75535ae8b0 100644 --- a/documentation/user_manual/manual/first_steps/getting_started.html +++ b/documentation/user_manual/manual/first_steps/getting_started.html @@ -8,7 +8,7 @@ - 2.1. Getting started — or-tools User's Manual' + 2.1. Getting started — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -141,9 +141,9 @@ is probably the last section to be documented.

    Welcome

    @@ -155,8 +155,8 @@ is probably the last section to be documented.

    @@ -206,7 +206,7 @@ is probably the last section to be documented.

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/monitors.html b/documentation/user_manual/manual/first_steps/monitors.html index 3c715665dd..f53109c06e 100644 --- a/documentation/user_manual/manual/first_steps/monitors.html +++ b/documentation/user_manual/manual/first_steps/monitors.html @@ -8,7 +8,7 @@ - 2.4. SolutionCollectors and Assignments to collect solutions — or-tools User's Manual' + 2.4. SolutionCollectors and Assignments to collect solutions — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -61,7 +61,7 @@

    You can find the code in the file tutorials/C++/chap2/cp_is_fun2.cc.

    2.4.1. SolutionCollectors

    -

    A SolutionCollector class is one of several specialized SearchMonitors classes. i.e. SolutionCollector +

    The SolutionCollector class is one of several specialized SearchMonitors classes. i.e. SolutionCollector inherits from SearchMonitors. SearchMonitors provides a set of callbacks to monitor all search events. We will learn more about them in the next chapter.

    To collect solutions, several SolutionCollector are available:

    @@ -79,7 +79,7 @@ We will learn more about them in the next chapter.

  • MakeAllSolutionCollector().
  • The simplest way to use a SolutionCollector -is to use it as is. This can be handy if you are only interested in global +is to use it as is without any parameter. This can be handy if you are only interested in global results such as the number of solutions:

    SolutionCollector* const all_solutions =
                                           solver.MakeAllSolutionCollector();
    @@ -99,13 +99,13 @@ the Solve() method:

    In case you are curious about the number of solutions, there are 72 of them in base 10.

    -

    To effectively store some solutions in a SolutionCollector, you have to declare the variables you are interested in. +

    To effectively store some solutions in a SolutionCollector, you have to add the variables you are interested in. Let’s say you would like to know what the value of variable c is in the first solution found. First, you create a SolutionCollector:

    FirstSolutionCollector* const first_solution =
                                         solver.MakeFirstSolutionCollector();
     
    -

    Then you declare the variable you are interested in:

    +

    Then you add the variable you are interested in:

    first_solution->Add(c);
     
    @@ -181,7 +181,9 @@ to the solver, i.e. you will not be able to retrieve its value by

    2.4.2. Assignments

    -

    The or-tools library provides the class Assignment to store the solution (in parts or as a whole):

    +

    The or-tools library provides the class Assignment to store the solution (in parts or as a whole). +The class Assignment has a rich API that allows you to retrieve not only the values of the variables in a solution but +also additional information. You can also act on some of the variables for instance to disable them during a search. We will see this class in more details in chapter XXX.

    SolutionCollector* const all_solutions =
                                           solver.MakeAllSolutionCollector();
     //  Add the interesting variables to the SolutionCollector
    @@ -204,8 +206,6 @@ to the solver, i.e. you will not be able to retrieve its value by }
     
    -

    The class Assignment has a rich API that allows you to retrieve not only the values of the variables in a solution but -also additional information. You can also act on some of the variables for instance to disable them during a search. We will see this class in more details in the next chapter.

    In Serializing, we’ll use it to serialize a solution.

    What is the difference between NewSearch() and Solve()?

    @@ -263,9 +263,9 @@ More importantly, you can interfere with the search.

    Welcome

    @@ -277,8 +277,8 @@ More importantly, you can interfere with the search.

    @@ -309,7 +309,7 @@ More importantly, you can interfere with the search.

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/parameters.html b/documentation/user_manual/manual/first_steps/parameters.html index c4cb1d0089..e35cfebe13 100644 --- a/documentation/user_manual/manual/first_steps/parameters.html +++ b/documentation/user_manual/manual/first_steps/parameters.html @@ -8,7 +8,7 @@ - 2.5. Parameters — or-tools User's Manual' + 2.5. Parameters — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -92,7 +92,7 @@ a help string.

    Note that argc and argv are passed as pointers so that ParseCommandLineFlags() is able to modify them.

    -

    All defined flags are accessible as normal variables with the prefix Flags_ prepended:

    +

    All defined flags are accessible as normal variables with the prefix FLAGS_ prepended:

    const int64 kBase = FLAGS_base;
     
    @@ -114,6 +114,8 @@ a help string.

    2.5.2. CP Solver‘s parameters

    You’ll find the code in the file tutorials/C++/chap2/cp_is_fun4.cc.

    Parameters can be transferred to the solver in several ways.

    +
    +

    2.5.2.1. The SolverParameters struct

    First, you can invoke the constructor of the Solver that takes a SolverParameters struct:

    // Use some profiling and change the default parameters of the solver
    @@ -130,7 +132,11 @@ the constructor of the Solversolver.ExportProfilingOverview("profile.txt");
     
    +

    We will see how to profile more in details in the section Profiling.

    The SolverParameters struct mainly deals with the internal usage of memory and is for advanced users.

    +
    +
    +

    2.5.2.2. SearchMonitors

    Second, you can use SearchMonitors. We have already seen how to use them to collect solutions in SolutionCollectors and Assignments to collect solutions.

    Suppose we want to limit the available time to solve a problem. To pass this parameter on the command line, @@ -148,9 +154,13 @@ we define a time_limit

    The search time is now limited to time_limit milliseconds.

    + +
    +

    2.5.2.3. The DefaultPhaseParameters struct

    A third way is to pass parameters through the DefaultPhaseParameters struct and call MakeDefaultPhase() but we delay the discussion of this topic until the chapter Defining search primitives in Constraint Programming.

    + @@ -189,9 +199,9 @@ we delay the discussion of this topic until the chapter or-tools
  • Documentation's hub
  • Back to main page
  • - @@ -203,8 +213,8 @@ we delay the discussion of this topic until the chapter C++
  • Python
  • -
  • Java
  • -
  • C#
  • +
  • Java
  • +
  • C#
  • @@ -214,7 +224,12 @@ we delay the discussion of this topic until the chapter 2.5. Parameters @@ -235,7 +250,7 @@ we delay the discussion of this topic until the chapter previous | -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/summary.html b/documentation/user_manual/manual/first_steps/summary.html index 4bc796edab..e070ae6a04 100644 --- a/documentation/user_manual/manual/first_steps/summary.html +++ b/documentation/user_manual/manual/first_steps/summary.html @@ -8,7 +8,7 @@ - 2.7. Summary — or-tools User's Manual' + 2.7. Summary — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -95,9 +95,9 @@

    Welcome

    @@ -109,8 +109,8 @@ @@ -132,7 +132,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/first_steps/supported_languages.html b/documentation/user_manual/manual/first_steps/supported_languages.html index 78fd6437b0..4451e1a475 100644 --- a/documentation/user_manual/manual/first_steps/supported_languages.html +++ b/documentation/user_manual/manual/first_steps/supported_languages.html @@ -8,7 +8,7 @@ - 2.6. Other supported languages — or-tools User's Manual' + 2.6. Other supported languages — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • @@ -106,9 +106,9 @@

    Welcome

    @@ -120,8 +120,8 @@ @@ -154,7 +154,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 2. First steps with or-tools: cryptarithmetic puzzles »
  • diff --git a/documentation/user_manual/manual/introduction.html b/documentation/user_manual/manual/introduction.html index ec6a8a6852..d39d742c72 100644 --- a/documentation/user_manual/manual/introduction.html +++ b/documentation/user_manual/manual/introduction.html @@ -8,7 +8,7 @@ - 1. Introduction to constaint programming — or-tools User's Manual' + 1. Introduction to constraint programming — or-tools User's Manual @@ -26,9 +26,9 @@ - - - + + + @@ -52,17 +52,16 @@
    - -
    - -
    -only search or-tools documentation
    -
    - - - -
    - -

    Welcome

    - - - - - - - -

    Tutorial examples

    - - - - - - - - -
    - - - - - \ No newline at end of file diff --git a/documentation/user_manual/manual/introduction/or_tools.html b/documentation/user_manual/manual/introduction/or_tools.html index ab9d5ee883..0b3e64a2ca 100644 --- a/documentation/user_manual/manual/introduction/or_tools.html +++ b/documentation/user_manual/manual/introduction/or_tools.html @@ -8,7 +8,7 @@ - 1.6. The Google or-tools library — or-tools User's Manual' + 1.6. The Google or-tools library — or-tools User's Manual @@ -26,9 +26,9 @@ - - - + + + @@ -39,13 +39,13 @@ index
  • - next |
  • previous |
  • -
  • User's Manual »
  • -
  • 1. Introduction to constaint programming »
  • +
  • or-tools User's Manual »
  • +
  • 1. Introduction to constraint programming »
  • @@ -94,9 +94,9 @@

    Welcome

    @@ -108,8 +108,8 @@ @@ -126,13 +126,13 @@ index
  • - next |
  • previous |
  • -
  • User's Manual »
  • -
  • 1. Introduction to constaint programming »
  • +
  • or-tools User's Manual »
  • +
  • 1. Introduction to constraint programming »
  • @@ -94,9 +94,9 @@

    Welcome

    @@ -108,8 +108,8 @@ @@ -131,8 +131,8 @@
  • previous |
  • -
  • User's Manual »
  • -
  • 1. Introduction to constaint programming »
  • +
  • or-tools User's Manual »
  • +
  • 1. Introduction to constraint programming »
  • @@ -94,9 +94,9 @@

    Welcome

    @@ -108,8 +108,8 @@ @@ -131,8 +131,8 @@
  • previous |
  • -
  • User's Manual »
  • -
  • 1. Introduction to constaint programming »
  • +
  • or-tools User's Manual »
  • +
  • 1. Introduction to constraint programming »
  • @@ -94,9 +94,9 @@

    Welcome

    @@ -108,8 +108,8 @@ @@ -131,8 +131,8 @@
  • previous |
  • -
  • User's Manual »
  • -
  • 1. Introduction to constaint programming »
  • +
  • or-tools User's Manual »
  • +
  • 1. Introduction to constraint programming »
  • @@ -139,12 +145,9 @@ index
  • - next |
  • -
  • - previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -75,7 +75,7 @@ disregarding/visiting the rest of the search tree.

    Prerequisites:

    Remark:

    @@ -173,9 +173,9 @@ assign it a value (ASSIGN_MIN_VAL

    Welcome

    @@ -187,28 +187,38 @@ assign it a value (ASSIGN_MIN_VAL

    Chapters

    - +
    Part I: Basics
    +

    +1. Introduction to CP
    +2. First steps with or-tools
    +3. Using objectives
    +4. Search primitives +

    +
    Part II: Customization
    +

    +5. Large Neighbourhood Search
    +6. Local Search operators
    +7. Custom constraints +

    +
    Part III: Routing
    +

    +8. TSP with constraints
    +9. VRP with constraints +

    +
    Part IV: Technicalities
    +

    +10. Utilities
    +11. Modeling tricks +

    @@ -225,7 +235,7 @@ assign it a value (ASSIGN_MIN_VAL
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -89,7 +89,7 @@ the object you just constructed, Var<(Y_1(1..24) + Y_0(1..24))>(2..48))>(3..72))>(4..96) -

    These are exactly the constraints listed in Figure Inner structure of a Golomb ruler of order 5..

    +

    These are exactly the constraints listed in Figure Inner structure of a Golomb ruler of order 5..

    3.4.2. Use the default flags

    @@ -222,9 +222,9 @@ Aborted

    Welcome

    @@ -236,8 +236,8 @@ Aborted @@ -268,7 +268,7 @@ Aborted
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/data_search.html b/documentation/user_manual/manual/objectives/data_search.html index 5d15677efc..ba994ec920 100644 --- a/documentation/user_manual/manual/objectives/data_search.html +++ b/documentation/user_manual/manual/objectives/data_search.html @@ -8,7 +8,7 @@ - 3.5. Some global data about the search — or-tools User's Manual' + 3.5. Some global data about the search — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -129,9 +129,9 @@ library offers a basic but portable timer. This timer starts to measure the time

    Welcome

    @@ -143,8 +143,8 @@ library offers a basic but portable timer. This timer starts to measure the time @@ -176,7 +176,7 @@ library offers a basic but portable timer. This timer starts to measure the time
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/first_implementation.html b/documentation/user_manual/manual/objectives/first_implementation.html index 83b1c9b3f2..10a7ab0386 100644 --- a/documentation/user_manual/manual/objectives/first_implementation.html +++ b/documentation/user_manual/manual/objectives/first_implementation.html @@ -8,7 +8,7 @@ - 3.3. An implementation of the first model — or-tools User's Manual' + 3.3. An implementation of the first model — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -187,9 +187,9 @@ in

    Welcome

    @@ -201,8 +201,8 @@ in

    @@ -233,7 +233,7 @@ in

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/golomb_first_model.html b/documentation/user_manual/manual/objectives/golomb_first_model.html index 65041ffda7..3310ace2d4 100644 --- a/documentation/user_manual/manual/objectives/golomb_first_model.html +++ b/documentation/user_manual/manual/objectives/golomb_first_model.html @@ -8,7 +8,7 @@ - 3.2. The Golomb Ruler Problem and a first model — or-tools User's Manual' + 3.2. The Golomb Ruler Problem and a first model — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -67,7 +67,7 @@ the next sections.

    of two integers in the sequence is distinct. Conceptually, this is similar to construct a ruler in such a way that no two pairs of marks measure the same distance. The number of marks (elements in the sequence) is called the order of the Golomb ruler.

    -

    Figure A non optimal Golomb ruler of order 4. +

    Figure A non optimal Golomb ruler of order 4. illustrates a Golomb ruler of order 4 and all its - distinct - differences.

    A non optimal Golomb ruler of order 4. @@ -181,7 +181,7 @@ ruler, i.e. the structure of the Golomb ruler has to be respected.

    3.2.2.2. Model

    For each positive difference, we have a decision variable. We collect them in an array Y\hspace{-0.1cm}. Let’s order the differences so that we know which difference is represented by Y[i].

    -

    Figure An ordered sequence of differences for the Golomb ruler of order 4. +

    Figure An ordered sequence of differences for the Golomb ruler of order 4. illustrates an ordered sequence of differences for a Golomb ruler of order 4.

    An ordered sequence of differences for the Golomb ruler of order 4. @@ -189,7 +189,7 @@ illustrates an ordered sequence of differences for a Golomb ruler of order 4.

    We want to minimize the last difference in Y i.e. Y[\frac{n (n-1)}{2}-1] since the first index of an array is 0. When the order is n = 4, we want to optimize Y[\frac{4 (4-1)}{2}-1] = Y[5] which represents the 6^\textrm{th} difference. Instead of writing Y[i], we will also use the more convenient notation Y_i.

    -

    Figure Inner structure of a Golomb ruler of order 5. +

    Figure Inner structure of a Golomb ruler of order 5. illustrates the structure than must be respected for a Golomb ruler of order 5.

    An ordered sequence of differences for the Golomb ruler of order 4. @@ -253,9 +253,9 @@ A default basic strategy will do for the moment.

    Welcome

    @@ -267,8 +267,8 @@ A default basic strategy will do for the moment.

    @@ -304,7 +304,7 @@ A default basic strategy will do for the moment.

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/objective_functions.html b/documentation/user_manual/manual/objectives/objective_functions.html index d434ad437c..e72db4ef8d 100644 --- a/documentation/user_manual/manual/objectives/objective_functions.html +++ b/documentation/user_manual/manual/objectives/objective_functions.html @@ -8,7 +8,7 @@ - 3.1. Objective functions and how to compare search strategies — or-tools User's Manual' + 3.1. Objective functions and how to compare search strategies — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -123,9 +123,9 @@ problem.

    Welcome

    @@ -137,8 +137,8 @@ problem. @@ -160,7 +160,7 @@ problem.
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/optimization_how.html b/documentation/user_manual/manual/objectives/optimization_how.html index ba314431db..62431b5a7c 100644 --- a/documentation/user_manual/manual/objectives/optimization_how.html +++ b/documentation/user_manual/manual/objectives/optimization_how.html @@ -8,7 +8,7 @@ - 3.9. How does the solver optimize? — or-tools User's Manual' + 3.9. How does the solver optimize? — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -95,9 +95,9 @@

    Welcome

    @@ -109,8 +109,8 @@ @@ -132,7 +132,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/second_implementation.html b/documentation/user_manual/manual/objectives/second_implementation.html index 6607795627..5375c407ce 100644 --- a/documentation/user_manual/manual/objectives/second_implementation.html +++ b/documentation/user_manual/manual/objectives/second_implementation.html @@ -8,7 +8,7 @@ - 3.6. A second model and its implementation — or-tools User's Manual' + 3.6. A second model and its implementation — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -315,9 +315,9 @@ Can we do better? You bet!

    Welcome

    @@ -329,8 +329,8 @@ Can we do better? You bet!

    @@ -362,7 +362,7 @@ Can we do better? You bet!

  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/summary.html b/documentation/user_manual/manual/objectives/summary.html index feb7dbc588..a0c7bde83c 100644 --- a/documentation/user_manual/manual/objectives/summary.html +++ b/documentation/user_manual/manual/objectives/summary.html @@ -8,7 +8,7 @@ - 3.10. Summary — or-tools User's Manual' + 3.10. Summary — or-tools User's Manual @@ -26,9 +26,9 @@ - + - + @@ -39,12 +39,12 @@ index
  • - next |
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -103,9 +103,9 @@ School of computer studies, University of Leeds, 1999.

    Welcome

    @@ -117,8 +117,8 @@ School of computer studies, University of Leeds, 1999. @@ -135,12 +135,12 @@ School of computer studies, University of Leeds, 1999. index
  • - next |
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/third_implementation.html b/documentation/user_manual/manual/objectives/third_implementation.html index e4ca46f0c0..ec6940fc33 100644 --- a/documentation/user_manual/manual/objectives/third_implementation.html +++ b/documentation/user_manual/manual/objectives/third_implementation.html @@ -8,7 +8,7 @@ - 3.7. A third model and its implementation — or-tools User's Manual' + 3.7. A third model and its implementation — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -154,9 +154,9 @@ propagations of the “quaternary constraints”. But these constraints

    Welcome

    @@ -168,8 +168,8 @@ propagations of the “quaternary constraints”. But these constraints @@ -191,7 +191,7 @@ propagations of the “quaternary constraints”. But these constraints
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/objectives/tighten_model.html b/documentation/user_manual/manual/objectives/tighten_model.html index 82b89f4c85..2f0098470d 100644 --- a/documentation/user_manual/manual/objectives/tighten_model.html +++ b/documentation/user_manual/manual/objectives/tighten_model.html @@ -8,7 +8,7 @@ - 3.8. How to tighten the model? — or-tools User's Manual' + 3.8. How to tighten the model? — or-tools User's Manual @@ -26,7 +26,7 @@ - + @@ -44,7 +44,7 @@
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • @@ -286,9 +286,9 @@ Golomb Ruler Problem
    , XXX, 2007.

    Welcome

    @@ -300,8 +300,8 @@ Golomb Ruler Problem, XXX, 2007. @@ -332,7 +332,7 @@ Golomb Ruler Problem, XXX, 2007.
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • 3. Using objectives in constraint programming: Golomb rulers »
  • diff --git a/documentation/user_manual/manual/search_primitives.html b/documentation/user_manual/manual/search_primitives.html index 0f2b1f07bf..30baf3e966 100644 --- a/documentation/user_manual/manual/search_primitives.html +++ b/documentation/user_manual/manual/search_primitives.html @@ -8,7 +8,7 @@ - 4. Defining search primitives: NQueens problems — or-tools User's Manual' + 4. Defining search primitives: n-queens problems — or-tools User's Manual @@ -26,8 +26,8 @@ - - + + @@ -38,12 +38,12 @@ index
  • - next |
  • previous |
  • -
  • User's Manual »
  • +
  • or-tools User's Manual »
  • @@ -52,9 +52,36 @@