Coder Social home page Coder Social logo

google / or-tools Goto Github PK

View Code? Open in Web Editor NEW
10.4K 298.0 2.1K 1.22 GB

Google's Operations Research tools:

Home Page: https://developers.google.com/optimization/

License: Apache License 2.0

Makefile 0.93% Python 7.57% C++ 76.04% Java 2.67% C# 2.82% C 0.10% Lex 0.01% Yacc 0.11% CMake 1.19% Shell 0.47% Batchfile 0.09% Dockerfile 0.61% Starlark 1.81% SWIG 1.76% sed 0.01% CSS 0.01% Jupyter Notebook 0.10% Julia 3.01% Go 0.70%

or-tools's Introduction

OR-Tools - Google Optimization Tools

PyPI version PyPI download Binder
NuGet version NuGet download
Maven Central
Discord

Google's software suite for combinatorial optimization.

Table of Contents

About OR-Tools

Google Optimization Tools (a.k.a., OR-Tools) is an open-source, fast and portable software suite for solving combinatorial optimization problems.

The suite contains:

  • Two constraint programming solver (CP* and CP-SAT);
  • Two linear programming solvers (Glop and PDLP);
  • Wrappers around commercial and other open source solvers, including mixed integer solvers;
  • Bin packing and knapsack algorithms;
  • Algorithms for the Traveling Salesman Problem and Vehicle Routing Problem;
  • Graph algorithms (shortest paths, min cost flow, max flow, linear sum assignment).

We wrote OR-Tools in C++, but provide wrappers in Python, C# and Java.

Codemap

This software suite is composed of the following components:

  • Makefile Top-level for GNU Make based build.
  • makefiles Subsidiary Make files, CI and build system documentation.
  • CMakeLists.txt Top-level for CMake based build.
  • cmake Subsidiary CMake files, CI and build system documentation.
  • WORKSPACE Top-level for Bazel based build.
  • bazel Subsidiary Bazel files, CI and build system documentation.
  • ortools Root directory for source code.
    • base Basic utilities.
    • algorithms Basic algorithms.
      • samples Carefully crafted samples.
    • graph Graph algorithms.
      • samples Carefully crafted samples.
    • linear_solver Linear solver wrapper.
      • samples Carefully crafted samples.
    • glop Simplex-based linear programming solver.
      • samples Carefully crafted samples.
    • pdlp First-order linear programming solver.
      • samples Carefully crafted samples.
    • lp_data Data structures for linear models.
    • constraint_solver Constraint and Routing solver.
      • docs Documentation of the component.
      • samples Carefully crafted samples.
    • sat SAT solver.
      • docs Documentation of the component.
      • samples Carefully crafted samples.
    • bop Boolean solver based on SAT.
    • util Utilities needed by the constraint solver
  • examples Root directory for all examples.
  • tools Delivery Tools (e.g. Windows GNU binaries, scripts, release dockers)

Installation

This software suite has been tested under:

  • Ubuntu 18.04 LTS and up (64-bit);
  • Apple macOS Mojave with Xcode 9.x (64-bit);
  • Microsoft Windows with Visual Studio 2022 (64-bit).

OR-Tools currently builds with a Makefile, but also provides Bazel and CMake support.

For installation instructions (both source and binary), please visit https://developers.google.com/optimization/introduction/installing.

Build from source using Make (legacy)

We provide a Make based build.
Please check the Make build instructions.

Build from source using CMake

We provide a CMake based build.
Please check the CMake build instructions.

Build from source using Bazel

We provide a Bazel based build.
Please check the Bazel build instructions.

Quick Start

The best way to learn how to use OR-Tools is to follow the tutorials in our developer guide:

https://developers.google.com/optimization/introduction/get_started

If you want to learn from code examples, take a look at the examples in the examples directory.

Documentation

The complete documentation for OR-Tools is available at: https://developers.google.com/optimization/

Contributing

The CONTRIBUTING.md file contains instructions on how to submit the Contributor License Agreement before sending any pull requests (PRs). Of course, if you're new to the project, it's usually best to discuss any proposals and reach consensus before sending your first PR.

License

The OR-Tools software suite is licensed under the terms of the Apache License 2.0.
See LICENSE for more information.

or-tools's People

Contributors

acco32 avatar ambasta avatar bollhals avatar cjdrake avatar dependabot[bot] avatar djunglas avatar furnon avatar jjacobsohn avatar jmarca avatar kapeck avatar kmader avatar legrosbuffle avatar lperron avatar mizux avatar mjfwest avatar mlubin avatar nazavode avatar oratier1a avatar orwant avatar paultrow avatar pet-mit avatar regista6 avatar sgatto avatar simonlynen avatar stefanbruens avatar stradivari96 avatar stuarthillary avatar supermihi avatar thecoolrob avatar two4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

or-tools's Issues

Non Linear programming with CLP

Originally reported on Google Code with ID 8

I'm using Google.OrTools.java.Win32.1304 to solve the Linear , Non-Linear & mixed Imteger
optimization problems using CLP, CBC.

I'm looking for non-linear example programming using CLP/CBC.

Please provide the steps/example for non-Linear program.

-Anu

Reported by kaminenia on 2012-04-10 14:23:35

Many routing options are unavailable via swig wrapper

Originally reported on Google Code with ID 39

After SetCommandLineOption has been removed, only routing search parameters are accessible
from Python. This leaves inaccessible filtering control, first solution heuristics,
propagation control (routing_use_light_propagation) and misc options.

Reported by ntoshev on 2014-02-25 14:46:47

SCIP not available in jnilinearsolver.jar

Originally reported on Google Code with ID 9

I downloaded Google.OrTools.java.x64.1304.zip and tested my installation with IntegerProgramming.java
using the compiled jars.

When I run the program GLPK and CBC worked fine, but not SCIP. I got the following
output:

---- Integer programming example with GLPK ----
Problem solved in 70 milliseconds
Optimal objective value = 6.0
x1 = 6.0
x2 = 0.0
Advanced usage:
Problem solved in 3 branch-and-bound nodes
---- Integer programming example with CBC ----
Problem solved in 346 milliseconds
Optimal objective value = 6.0
x1 = 6.0
x2 = 0.0
Advanced usage:
Problem solved in 0 branch-and-bound nodes
---- Integer programming example with SCIP ----
Could not create solver SCIP_MIXED_INTEGER_PROGRAMMING

=====

I was expecting to have access to the SCIP wrapper, but apparently it is not available
in jnilinearsolver.jar. How can I have access to SCIP from your wrappers?

By the way, I run my program on Eclipse Indigo with Java JRE 7 on Windows 7 Enterprise
64 bit.

Last, but not least, thanks for putting this together. It is amazing!

Reported by andres.medaglia on 2012-04-29 03:25:15

CBC Solver.EnableOutput() does not work in .NET

Originally reported on Google Code with ID 16

Here's a simple code example to reproduce the problem :

    static void Main(string[] args)
    {
        var solver = Solver.CreateSolver("IntegerProgramming", "CBC_MIXED_INTEGER_PROGRAMMING");
        var a = solver.MakeBoolVar("A");
        var b = solver.MakeBoolVar("B");
        var c = solver.MakeBoolVar("C");
        solver.Add(a + b + c == 1);
        solver.Minimize(30 * a + 10 * b + 100 * c);
        solver.EnableOutput(); // <-- useless
        solver.Solve();
        Console.WriteLine("A={0},B={1},C={2}", a.SolutionValue(), b.SolutionValue(),
c.SolutionValue());
        Console.ReadLine();
    }

This simple MIP problem is correctly solved, but no solver log is printed on the console
even if solver.EnableOutput() has been called. 

or-tools version: 2322 
Both 32 and 64 bit binaries are affected; 
Binaries downloaded from http://code.google.com/p/or-tools/downloads/list

Reported by giunto.cardanico on 2012-11-05 18:12:00

GettingStarted should be updated with glpk-4.49

Originally reported on Google Code with ID 23

Since the make file in trunk is looking for glpk-4.49, the documentation should be updated
accordingly. Any reference to glpk-4.47 should be replaced by glpk-4.49.

Reported by ikus060 on 2013-04-21 02:20:27

Un-decided IntervalVar causing Crash

Originally reported on Google Code with ID 33

What steps will reproduce the problem?
1. Compile the unpacked .cs-files 
2. Run the executable

The model:
I have ported your c++-model: http://or-tools.googlecode.com/svn/trunk/examples/cpp/jobshop.cc
to C#.

On top I have added transition times (the function "PostTransitionTimeConstraints"
i Program.cs).

I expect the model to run and solve a small instance of a flexible jobshop problem
with transition times.

The solver often finds a couple of solutions before it crashes.
(For the choice of randomisation seed I get 1 solution before it crashes, as the problem
instance is so small. However, it can also be 0 or any number of aquired solutions
before the crash, depending on the seed in the search phase where I assign the tools,
and the size and composition of the problem instance)

The error message from the c++ library is:
"src/constraint_solver/interval.cc:809: Check failed: performed_.MayBeTrue()".
For my version of the code this piece of code reads:

int64 FixedDurationIntervalVar::StartMax() const {
  CHECK(performed_.MayBeTrue());
  return start_.Max();
}

I have found that I can enforce correct transition times, but I cannot constrain the
next start time without the application eventually crashing.
(this key piece of code can be found on line 216 in my "program.cs" file)

My revision of Google Or-tools is: 2907
My operating system is Windows 7, and I compile on Visual Studio 2012 64bit.

I just saw that you added setup dependent transition times in revision 2909. I will
look at it, but I think this error is relevant even if the new features would solve
my problem.

Reported by johan.ludde.wessen on 2013-10-24 11:42:25


- _Attachment: [DataModel.cs](https://storage.googleapis.com/google-code-attachments/or-tools/issue-33/comment-0/DataModel.cs)_ - _Attachment: [DataReader.cs](https://storage.googleapis.com/google-code-attachments/or-tools/issue-33/comment-0/DataReader.cs)_ - _Attachment: [Program.cs](https://storage.googleapis.com/google-code-attachments/or-tools/issue-33/comment-0/Program.cs)_ - _Attachment: [Heuristics.cs](https://storage.googleapis.com/google-code-attachments/or-tools/issue-33/comment-0/Heuristics.cs)_

Cannot export MPSolver model as MPS in Java

Originally reported on Google Code with ID 37

MPSolver.ExportModelAsMpsFormat should return the created model as String instead of
taking model_str as argument which does not work in Java. Alternatively use a mutable
argument.

Reported by [email protected] on 2013-11-15 08:49:54

Build Issue VS2013 -- src/constraint_solver/diffn.cc

Originally reported on Google Code with ID 27

Hi.
I'm trying to build the code using VS2013 and came across the following code errors.



C:\src\or-tool>tools\make all
cl /EHsc /MD /nologo -nologo  /O2 -DNDEBUG /Isrc /Iexamples /Isrc\\gen /IC:\\src\\or-tool\\dependencies\\install\\src\\windows
/IC:\\src\\or-tool\\dependencies\\install\\src /DGFLAGS_DLL_DECL=
 /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /IC:\\src\\or-tool\\dependencies\\install\\include
/Idependencies\\sources\\TinyThread++-1.0\\source /Idependencies\\sources\\Minisat
/IC:
\\src\\or-tool\\dependencies\\install\\include /IC:\\src\\or-tool\\dependencies\\install\\include
/DUSE_CBC /IC:\\src\\or-tool\\dependencies\\install\\include /DUSE_CLP    /D__WIN32__
/IC:\\sr
c\\or-tool\\dependencies\\install\\include -c src/constraint_solver/diffn.cc /Foobjs\\diffn.obj
diffn.cc
src/constraint_solver/diffn.cc(85) : error C2065: 'vector' : undeclared identifier
src/constraint_solver/diffn.cc(85) : error C2275: 'int64' : illegal use of this type
as an expression
        src\base/integral_types.h(26) : see declaration of 'int64'
src/constraint_solver/diffn.cc(85) : error C2065: 'size_x' : undeclared identifier
src/constraint_solver/diffn.cc(86) : error C2065: 'size_x' : undeclared identifier
src/constraint_solver/diffn.cc(87) : error C2065: 'vector' : undeclared identifier
src/constraint_solver/diffn.cc(87) : error C2275: 'int64' : illegal use of this type
as an expression
        src\base/integral_types.h(26) : see declaration of 'int64'
src/constraint_solver/diffn.cc(87) : error C2065: 'size_y' : undeclared identifier
src/constraint_solver/diffn.cc(88) : error C2065: 'size_y' : undeclared identifier
src/constraint_solver/diffn.cc(90) : error C2065: 'size_x' : undeclared identifier
src/constraint_solver/diffn.cc(90) : error C2065: 'size_y' : undeclared identifier
src/constraint_solver/diffn.cc(91) : error C2065: 'size_y' : undeclared identifier
src/constraint_solver/diffn.cc(91) : error C2065: 'size_x' : undeclared identifier
src/constraint_solver/diffn.cc(241) : error C2065: 'vector' : undeclared identifier
src/constraint_solver/diffn.cc(241) : error C2059: syntax error : '>'
src/constraint_solver/diffn.cc(243) : error C2065: 'intervals' : undeclared identifier
src/constraint_solver/diffn.cc(245) : error C2065: 'intervals' : undeclared identifier
tools\make: *** [objs/diffn.obj] Error 2

Reported by [email protected] on 2013-07-07 18:36:36

Can't use on OS X (binary or source)

Originally reported on Google Code with ID 48

I'm using the latest OS X Mavericks 10.9.4 with the latest Xcode and latest command
line tools.

When I try running using the binary:

/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java -Djava.library.path=intellij-lib
com.intellij.rt.execution.application.AppMain com.whamcitylights.signalDataAnalyzer.SetCovering3
java(50037,0x1057da000) malloc: *** error for object 0x1057d9000: pointer being freed
was not allocated
*** set a breakpoint in malloc_error_break to debug




When I try building from source:

Checked out revision 512.
cd dependencies/sources/protobuf-512 && PATH=/Users/keith/Code/lib/or-tools-read-only/dependencies/install/bin:/usr/local/git/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/Users/keith/Code/sloccount-2.26:/Users/keith/Code/android-ndk-r8b:/Users/keith/Code/android-sdk-macosx/tools:/Users/keith/Code/android-sdk-macosx/platform-tools:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:/opt/local/bin:/opt/local/sbin:/opt/local/lib:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
./autogen.sh
+ sed -i -e 's/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
           s/RuntimeLibrary="4"/RuntimeLibrary="2"/g;' gtest/msvc/gtest-md.vcproj gtest/msvc/gtest.vcproj
gtest/msvc/gtest_main-md.vcproj gtest/msvc/gtest_main.vcproj gtest/msvc/gtest_prod_test-md.vcproj
gtest/msvc/gtest_prod_test.vcproj gtest/msvc/gtest_unittest-md.vcproj gtest/msvc/gtest_unittest.vcproj
+ autoreconf -f -i -Wall,no-obsolete
configure.ac:27: installing 'build-aux/compile'
configure.ac:30: installing 'build-aux/config.guess'
configure.ac:30: installing 'build-aux/config.sub'
configure.ac:24: installing 'build-aux/install-sh'
configure.ac:30: error: required file 'build-aux/ltmain.sh' not found
configure.ac:24: installing 'build-aux/missing'
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
autoreconf: automake failed with exit status: 1
make: *** [dependencies/sources/protobuf-512/configure] Error 1

Reported by [email protected] on 2014-09-09 14:11:54

Can't instantiate MPSolverParameters

Originally reported on Google Code with ID 50

Since rev3750 (Java binaries,  OS X),   class com.google.ortools.linearsolver.MPSolverParameters
 doesn't have any public constructors.  As a result, it can't be used to set parameters
(such as RELATIVE_MIP_GAP) when starting the MPSolver.

Arguably we can extend MPSolverParameters and instantiate the subclass instead, but
it's unclear whether it's the intended usage of this class.  In the past MPSolverParameters
did provide a public constructor.


Reported by yunjun.mu on 2014-09-24 15:43:38

Trouble Running Solver Under IIS

Originally reported on Google Code with ID 19

I have built a .net project under Visual Studio 12, and with the 32-bit version (the
development web server with Visual Studio is 32 bit), I am able to run my web application
in debug mode. However, when I publish it to a web server running IIS on Windows Server
2008 (IIS 7.5), on running the web site I get the following error:

Could not load file or assembly 'Google.OrTools.LinearSolver.DLL' or one of its dependencies.
The specified module could not be found

I have tried all permutations of the following:

* 32/64 bit versions of the tool
* project compile to platform target CPU (any, 86, 64 - in both debug and release (used
for publishing a web application) configurations)
* IIS application pool allow 32-bit applications, and app-pool (and application) restarted

Has anyone else managed to get it working in IIS, please?

To reproduce the issue:

* add the DLL as a reference to a .NET project
* in a C# file in the project, add: using Google.OrTools.LinearSolver
* in the same file, add: Solver solver = Solver.CreateSolver("IntegerProgramming",
"CBC_MIXED_INTEGER_PROGRAMMING");
* publish the application to an IIS web server
* try to open the application in a browser

Reported by GLaight on 2013-01-23 14:31:28

TinyThread not updated with a clean make third_party

Originally reported on Google Code with ID 11

What steps will reproduce the problem?
1. Checkout trunk
2. Build (success because TinyThread source is in the original check out)
3. make clean_third_party
4. Build (fails because no TinyThread source present)

What is the expected output? What do you see instead?

I would not have expected a make clean to break my build. If possible I suggest to
either refetch the source or don't wipe it.

What version of the product are you using? On what operating system?

Linux trunk


Please provide any additional information below.


Reported by jensen.bo on 2012-06-11 11:21:36

using a vector of NodeIndex from Python

Originally reported on Google Code with ID 17

m = pywraprouting.RoutingModel(100, 2, [1,10],[11,21])

But I get:

Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    m = pywraprouting.RoutingModel(100, 2, [1,10],[11,21])
  File "/home/nik/or-tools-read-only/src/constraint_solver/../gen/constraint_solver/pywraprouting.py",
line 2224, in __init__
    this = _pywraprouting.new_RoutingModel(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_RoutingModel'.
  Possible C/C++ prototypes are:
    operations_research::RoutingModel::RoutingModel(int,int)
    operations_research::RoutingModel::RoutingModel(int,int,std::vector< std::pair<
operations_research::RoutingModel::NodeIndex,operations_research::RoutingModel::NodeIndex
>,std::allocator< std::pair< operations_research::RoutingModel::NodeIndex,operations_research::RoutingModel::NodeIndex
> > > const &)
    operations_research::RoutingModel::RoutingModel(int,int,std::vector< operations_research::RoutingModel::NodeIndex,std::allocator<
operations_research::RoutingModel::NodeIndex > > const &,std::vector< operations_research::RoutingModel::NodeIndex,std::allocator<
operations_research::RoutingModel::NodeIndex > > const &)

Reported by laurent.perron on 2013-01-09 11:38:56

.NET Release 172 Examples are not working

Originally reported on Google Code with ID 12

Hi,

I cannot run your examples.

I get 'The type initializer for 'SWIGExceptionHelper' threw an exception.'. One of
the inner exceptions contains following message:

c:\\Users\\Laurent\\Documents\\or-tools\\bin\\Google.OrTools.Graph.dll': The specified
module could not be found.

Reported by mstijak on 2012-08-02 10:29:49

mixed_integer_programming's result isn't global optimum(for .NET)

Originally reported on Google Code with ID 25

mixed_integer_programming's solution isn't global optimum(for .NET)

Thanks for your attention!

I'm trying to solve a mixed-integer problem with orTools like the example csintegerprogramming.cs.
The objective function and the constraints are all linear.
When I solved it with CBC_MIXED_INTEGER_PROGRAMMING or other methods,then I got one
result(this is the first result).
But when I change the first result into a new constraint and add it into the problem
above.Then I get a second result,I found that the sencond result is better then the
first one. 
So, I think I got a locally optimal solution.
How can I solve this problem?


Reported by mwzh2520 on 2013-05-16 08:23:31

Enhancement - Flatzinc Functionality from C#

Originally reported on Google Code with ID 49

Add ability to work with flatzinc models from C# code as per this thread:
https://groups.google.com/forum/#!topic/or-tools-discuss/J95C2NxXz4A

- Add swig declaration.
- Add a real solution query API on the solver. Currently flatzinc output is a text
 console output.

Reported by slashing75 on 2014-09-15 19:48:14

C# DLLs are not strong-named (aka signed), so cannot be referenced from other strong named assemblies.

Originally reported on Google Code with ID 13

There are various reasons for strong-naming an assembly. These include:

* Only strong-named assemblies can be put into the GAC.

* Strong-named assemblies can only reference other strong-named assmeblies.

* Strong-named assemblies are uniquely identifiable by key, name and version and can
be verified as not having been tampered with.

In our scenario, we needed to make our core application signed, which requires that
all third party DLLs are also signed. The ildasm/ilasm workaround for retro-signing
does not work for or-tools DLLs likely due to the unusual linking process.

I've modified Makefile.csharp.mk to consider the variables CLR_KEYFILE and CLR_DELAYSIGN
which can be passed as arguments to make. Specifying CLR_KEYFILE (and optionally CLR_DELAYSIGN)
will produce signed DLLs and test executables. A diff against r2200 is attached.

Reported by [email protected] on 2012-09-05 11:17:09


- _Attachment: [diff.txt](https://storage.googleapis.com/google-code-attachments/or-tools/issue-13/comment-0/diff.txt)_

Cannot set (Linear)-SolverParameters or solver-specific parameters for CBC in .Net

Originally reported on Google Code with ID 41

I would like to solve a LP by using different parameters (especially different from
the default parameters). I tried to set some solver specific parameters for CBC by
two different ways:

1. I  tried to change the default values of the parameters LP_ALGORITHM, BARRIER and
DUAL by using the SetIntegerParam/SetDoubleParam-methods, but the values are unchanged
afterwards. The other default-parameters are changeable by using this methods.

2. Additionally, I tried to use SetSolverSpecificParametersAsString() with a string
of CBC-specific parameters. Currently, SetSolverSpecificParametersAsString() always
returns false, unless the input is empty. Could you give me an example to use this
method?

What version of the product are you using? On what operating system?
.Net OrTools.dll Version 3236 





Reported by luisachristine on 2014-04-10 09:10:26

catch of Ctrl+C to stop the search

Originally reported on Google Code with ID 2

That would be great to have that to stop the search otherwise you have to put the process
in bg and kill it manually.

Pierre



Reported by pschaus on 2010-10-09 08:40:02

DomainIntVar::RemoveValue

Originally reported on Google Code with ID 7

I was going through the code of the DomainIntVar::RemoveValue method and there are two
things I find suspicious. The function goes like this (taken from trunk) :

---------------------------

void DomainIntVar::RemoveValue(int64 v)  {
  if (v < min_ || v > max_)
    return;
  if (v == min_) {
    SetMin(v + 1);
  } else if (v == max_) {
    SetMax(v - 1);
  } else {
    if (bits_ == NULL) {
      CreateBits();
    }
    if (in_process_ && v >= new_min_ && v <= new_max_ && bits_->Contains(v)) {
      bits_->DelayRemoveValue(v);
    } else {
      if (bits_->RemoveValue(v)) {
        Push();
      }
    }
  }
}

---------------------------

1) If the variable is "in process", shouldn't you test v with new_min_ and new_max_
instead of min_ and max_?

2) In the last if statement, shouldn't it be more like this?

if (in_process_) {
  if (v >= new_min_ && v <= new_max_ && bits_->Contains(v)) {
      bits_->DelayRemoveValue(v);
  }
} else {
  if (bits_->RemoveValue(v)) {
    Push();
  }
}


So to summarize I think the patch would be :

void DomainIntVar::RemoveValue(int64 v)  {

  if (in_process_) {

    if (v < new_min_ || v > new_max_) {
      return;
    } else if (v == new_min_ && v == new_max_) {
      solver()->Fail();
    } else if (v == new_min_ ) {
      new_min_++; 
    } else if (v == new_max_) {
      new_max_--;
    } else {
      if (!bits_) CreateBits();
      bits_->DelayRemoveValue(v);
    }

  } else {

    if (v < min_ || v > max_) {
      return;
    } else if (v == min_) {
      SetMin(v + 1);
    } else if (v == max_) {
      SetMax(v - 1);
    } else {
      if (bits_ == NULL) CreateBits();
      if (bits_->RemoveValue(v)) Push();
    }

  }
}


Maybe I'm wrong but I just wanted to let you know in case it's really a problem!


Philippe Van Kessel

Reported by phil.vank on 2011-11-28 20:52:23

Time limit do not work

Originally reported on Google Code with ID 4

Following program does not stop.

from constraint_solver import pywrapcp

def main():
   solver = pywrapcp.Solver('time limit test')
   n = 10
   x = [solver.IntVar(1, n, 'x[%i]'%i) for i in range(n)]
   solver.Add(solver.AllDifferent(x, True))

   solution = solver.Assignment()
   solution.Add(x)

   db = solver.Phase(x,
                     solver.CHOOSE_FIRST_UNBOUND,
                     solver.ASSIGN_MIN_VALUE)

   time_limit = 10
   branch_limit = 100000000
   failures_limit = 100000000
   solutions_limit = 10000000
   limits = solver.Limit(time_limit, branch_limit, failures_limit, solutions_limit,
True)

   search_log = solver.SearchLog(1000)

   solver.NewSearch(db, [limits, search_log])
   num_solutions = 0
   while solver.NextSolution():
       print "x:", [x[i].Value() for i in range(n)]
       num_solutions += 1
   solver.EndSearch()

   print
   print "num_solutions:", num_solutions
   print "failures:", solver.failures()
   print "branches:", solver.branches()
   print "wall_time:", solver.wall_time()


if __name__ == '__main__':
   main()

Reported by [email protected] on 2010-10-10 00:15:36

src\constraint_solver\expressions.cc doesn't build on VS2013

Originally reported on Google Code with ID 44

What steps will reproduce the problem?
1. Build on Windows with Visual Studio 2013

Error to build file src\constraint_solver\expressions.cc, method Solver::MakeIntVar

To fix it, add the namespace "std" to the vector instances used inside the method:

IntVar* Solver::MakeIntVar(const std::vector<int64>& values, const std::string& name)
{
  const std::vector<int64> cleaned = SortedNoDuplicates(values);
  int64 gcd = 0;
  for (int64 v : cleaned) {
    if (v == 0) {
      continue;
    }
    if (gcd == 0) {
      gcd = std::abs(v);
    } else {
      gcd = MathUtil::GCD64(gcd, std::abs(v));
    }
    if (gcd == 1) {
      break;
    }
  }
  if (gcd == 1) {
    return RegisterIntVar(RevAlloc(new DomainIntVar(this, cleaned, name)));
  } else {
    std::vector<int64> new_values;
    new_values.reserve(values.size());
    for (int64 v : cleaned) {
      DCHECK_EQ(0, v % gcd);
      new_values.push_back(v / gcd);
    }
    const std::string new_name = name.empty() ? "" : "inner_" + name;
    IntVar* const inner =
        RegisterIntVar(RevAlloc(new DomainIntVar(this, new_values, new_name)));
    return MakeProd(inner, gcd)->Var();
  }
}


Reported by izanette on 2014-05-19 18:10:50

setup.py broken for Windows 64-bit.

Originally reported on Google Code with ID 21

I just downloaded the file Google.OrTools.python.Windows64.2322.zip from the homepage
and tried the command

    setup.py install

setup.py has a syntax error on line 16. The line reads
    pjoin('constraint_solver', '_pywraprouting.dll']),
and should presumably be
    pjoin('constraint_solver', '_pywraprouting.dll')]),

Furthermore, setup.py refers to ".dll" files, but the files in the packages have ".pyd"
extensions.

Reported by petter.strandmark on 2013-03-06 13:04:24

compilation problem: std::vector no data member

Originally reported on Google Code with ID 1

What steps will reproduce the problem?
1. make
2.
3.

What is the expected output? What do you see instead?

./constraint_solver/constraint_solver.h: In member function โ€˜void operations_research::IntVar::RemoveValues(const
std::vector<int64, std::allocator<int64> >&)โ€™:
./constraint_solver/constraint_solver.h:2095: error: โ€˜const class std::vector<int64,
std::allocator<int64> >โ€™ has no member named โ€˜dataโ€™
./constraint_solver/constraint_solver.h: In member function โ€˜void operations_research::IntVar::SetValues(const
std::vector<int64, std::allocator<int64> >&)โ€™:
./constraint_solver/constraint_solver.h:2103: error: โ€˜const class std::vector<int64,
std::allocator<int64> >โ€™ has no member named โ€˜dataโ€™
constraint_solver/alldiff_cst.cc: In member function โ€˜operations_research::Constraint*
operations_research::Solver::MakeAllDifferent(const std::vector<operations_research::IntVar*,
std::allocator<operations_research::IntVar*> >&, bool)โ€™:
constraint_solver/alldiff_cst.cc:139: error: โ€˜const class std::vector<operations_research::IntVar*,
std::allocator<operations_research::IntVar*> >โ€™ has no member named โ€˜dataโ€™


What version of the product are you using? On what operating system?




Please provide any additional information below.

Macos 10.5.8
i686-apple-darwin9-g++-4.0.1

To make some progress with the compilation on Macos 10.5.8
I had to remove  -DARCH_K8 from the CFLAGS definition in the makefile.

Then I'm having troubles with the vector class. The data() method is not recognized.
Is data() a standard method from the stl vector?

Reported by pschaus on 2010-09-16 07:44:24

CVRPTW example is not available in EXAMPLE folder for .NET

Originally reported on Google Code with ID 20

I am looking for CVRPTW (Capacitated Vehicle Routing Problem with Time Windows) example/source
code in .NET

I have download 'Google.OrTools.NET.Windows64.2322.zip' vesrion. TSP example is availble
but CVRPTW example is not available in example folder.


Reported by [email protected] on 2013-03-05 06:27:30

Compilation error

Originally reported on Google Code with ID 31

What steps will reproduce the problem?
1. make csharp
2.
3.

What is the expected output? What do you see instead?
compiler error in src/constraint_solver/hybrid.cc:

src\linear_solver/linear_solver.h(680) : error C2512: 'operations_research::CoeffMap?'
: no appropriate default constructor available src\linear_solver/linear_solver.h(851)
: error C2512: 'operations_research::CoeffMap?' : no appropriate default constructor
available

What version of the product are you using? On what operating system?
current svn checkout
win7, vs2010

Please provide any additional information below.
Just checked out the source from svn and hit the compilation error straight on.




Reported by saxorut on 2013-10-20 19:08:35

Loss of methods in SequenceVarLocalSearchMethods [C#]

Originally reported on Google Code with ID 36

It seems like some of the methods didn't pass through in fix of issue35, actually all
the protected ones:
Activate(.. )
Activated(.. )
AddVars(.. )
ApplyChanges(.. )
Deactivate(.. )
OldSequence(.. )
RevertChanges(.. )
SetForwardSequence(.. )
SetBackwardSequence(.. )

Also, Sequence(.. ) is now conditional on the value of SWIG, but needed in any case:
#if !defined(SWIG)
  const std::vector<int>& Sequence(int64 index) const {
    DCHECK_LT(index, vars_.size());
    return values_[index];
  }
#endif

Reported by johan.ludde.wessen on 2013-11-05 15:30:19

Windows build failing if sh.exe is on path

Originally reported on Google Code with ID 43

What steps will reproduce the problem?
1. Have a sh.exe file on path.
2. make third_party
3. If your PATH variable contains any spaces, autoconf build will fail.

What is the expected output? What do you see instead?
Complete building the third_party target successfully.

What version of the product are you using? On what operating system?
trunk, win8.1

Please provide any additional information below.
Removing sh.exe from PATH solves the problem.

It seems that win vs unix detection depends on existence of sh.exe in PATH.

Reported by keremkat on 2014-05-13 14:21:52

Problem with Element in C#

Originally reported on Google Code with ID 22

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Google.OrTools.ConstraintSolver;

public class OrTools
{
  private static long Solve(long num_buses_check = 0)
  {
    SolverParameters sPrm = new SolverParameters();
    sPrm.compress_trail = 0;
    sPrm.trace_level = 0;
    sPrm.profile_level = 0;
    Solver solver = new Solver("OrTools",sPrm);

    //this works
    IntVar[,] x = solver.MakeIntVarMatrix(2,2, new int[] {-2,0,1,2}, "x");

    //this doesn't work
    //IntVar[,] x = solver.MakeIntVarMatrix(2, 2, new int[] { 0, 1, 2 }, "x");

    for (int w = 0; w < 2; w++)
    {
      IntVar[] b = new IntVar[2];
      for (int i = 0; i < 2; i++)
      {
        b[i] = solver.MakeIsEqualCstVar(x[w, i], 0);
      }
      solver.Add(solver.MakeSumGreaterOrEqual(b, 2));
    }

    IntVar[] x_flat = x.Flatten();
    DecisionBuilder db = solver.MakePhase(x_flat,
                                          Solver.CHOOSE_FIRST_UNBOUND,
                                          Solver.ASSIGN_MIN_VALUE);
    solver.NewSearch(db);
    while (solver.NextSolution())
    {
      Console.WriteLine("x: ");
      for (int j = 0; j < 2; j++)
      {
        Console.Write("worker" + (j + 1).ToString() + ":");
        for (int i = 0; i < 2; i++)
        {
          Console.Write(" {0,2} ", x[j, i].Value());
        }
        Console.Write("\n");
      }
      Console.WriteLine("End   at---->" + DateTime.Now);
    }

    Console.WriteLine("\nSolutions: {0}", solver.Solutions());
    Console.WriteLine("WallTime: {0}ms", solver.WallTime());
    Console.WriteLine("Failures: {0}", solver.Failures());
    Console.WriteLine("Branches: {0} ", solver.Branches());

    solver.EndSearch();
    return 1;
  }

  /// <summary>
  ///
  /// </summary>
  /// <param name="args"></param>
  public static void Main(String[] args)
  {
    Console.WriteLine("Check for minimum number of buses: ");
    long num_buses = Solve();
    Console.WriteLine("\n... got {0} as minimal value.", num_buses);
    Console.WriteLine("\nAll solutions: ", num_buses);
    Console.ReadKey();
    //num_buses = Solve(num_buses);
  }
}

Reported by laurent.perron on 2013-03-11 10:59:04

No pcre repository can be cloned. timeout errors.

Originally reported on Google Code with ID 29

What steps will reproduce the problem?
1. make all
2. wait 
3.

What is the expected output? What do you see instead?
svn co svn://vcs.exim.org/pcre/code/trunk

What version of the product are you using? On what operating system?
from source code

Please provide any additional information below.
I tried to install or-tools, but I was unable due to the lack of this repository,

Reported by Beniamin.Kalinowski on 2013-07-22 15:32:38

cplusplus exampe of chap9 does not exist in the trunk

Originally reported on Google Code with ID 30

What steps will reproduce the problem?
1. I can not find the tsptw code of chap9 in tutorials.

What is the expected output? What do you see instead?

I want to see the code example and if possible in C#, thanks.

What version of the product are you using? On what operating system?


Please provide any additional information below.


Reported by HotWingDelft on 2013-08-06 13:08:12

Would you please tell which state or-tools on?

Originally reported on Google Code with ID 10

I have tried to use 
Google.OrTools.ConstraintSolver.dll
Google.OrTools.LinearSolver.dll
to solve some real world schedule problem,
found there are no float expression in ConstraintSolver.
When I head to LinearSolver, I found no Element function for arrays in it.

Is or-tools still in state for fun?
Can it solve real world schedule problem?

Looking forward to your reply! Thank you ahead.

Reported by JinGuiSiYuan on 2012-04-29 15:21:26

Crash if custom search monitor is created in NewSearch

Originally reported on Google Code with ID 18

Solver solver = new Google.OrTools.ConstraintSolver.Solver("p");

// creating dummy variables
List<IntVar> vars = new List<IntVar>();
for (int i = 0; i < 200000; i++)
{
       vars.Add(solver.MakeIntVar(0, 1));
}

IntExpr globalSum = solver.MakeSum(vars.ToArray());

DecisionBuilder db = solver.MakePhase(vars.ToArray(),
                                            Google.OrTools.ConstraintSolver.Solver.INT_VAR_SIMPLE,
                                            Google.OrTools.ConstraintSolver.Solver.INT_VALUE_SIMPLE);


// works
         //   OptimizeVar obj = new OptimizeVar(solver, true, globalSum.Var(), 100);
         //   solver.NewSearch(db, obj);

// crashes
solver.NewSearch(db, new OptimizeVar(solver, true, globalSum.Var(), 100));

while (solver.NextSolution())
{
     Console.WriteLine("solution " + globalSum.Var().Value());
}
Console.WriteLine("fini");
Console.ReadLine();

Reported by laurent.perron on 2013-01-15 10:32:06

Unable to use SWIG on nested classes

Originally reported on Google Code with ID 26

What steps will reproduce the problem?
1. Modify the C++ header files so classes can be used with python/java/c#/etc. wrappers.


What is the expected output? What do you see instead?
When running SWIG on ebert_graph.h, I get the warning: "Warning 325: Nested class not
currently supported (NodeIterator ignored)." 

What version of the product are you using? On what operating system?
Ubuntu 12.04

Please provide any additional information below.


Reported by danajferranti on 2013-06-28 14:56:47

StackOverflow while adding a dimension in a RoutingModel in .Net

Originally reported on Google Code with ID 14

Here's the piece of code that gives me trouble:

    Public Class ContainerDimensiuneTimp
        Inherits NodeEvaluator2

        Dim Timpi()() As Double

        Public Sub New(_timpi()() As Double)
            Timpi = _timpi
        End Sub

        Public Overloads Function Run(nod1 As Integer, nod2 As Integer) As Long
            Return CLng(Timpi(nod1)(nod2) * 60)
        End Function
    End Class

  After Initialising the RouterModel as "rutare" and setting the cost,


        Dim TimesContainer As New ContainerDimensiuneTimp(_timpi)
        rutare.AddDimension(TimesContainer, 100, 24 * 3600, "T")

When calling "rutare.AddDimension(TimesContainer, 100, 24 * 3600, "T")" it throws a
StackOverflow.

Reported by stefy1995 on 2012-09-10 15:05:33

make third_party fail because some source moved to git from svn

Originally reported on Google Code with ID 45

What steps will reproduce the problem?
1.make third_party

What is the expected output? What do you see instead?
svn: E000060: Unable to connect to a repository at URL 'svn://vcs.exim.org/pcre/code/trunk'
svn: E000060: Can't connect to host 'vcs.exim.org': Operation timed out
make: *** [dependencies/sources/pcre-1336/autogen.sh] Error 1

What version of the product are you using? On what operating system?
latest, checkout from svn

Please provide any additional information below.
they moved to git 

Reported by boaz.menuhin on 2014-06-16 14:45:18

No constructor for SequenceVarLocalSearchOperator [C#]

Originally reported on Google Code with ID 35

During creation of a customized LocalSearch in C#, and I am following chapter 6.7 in
the user manual.

As I am trying to create the "SwapIntervals" @ 6.7.3 that inherits the "SequenceVarLocalSearchOperator"-class,
I get the error message:
"The Type Google.ConstraintSolver.SequenceVarLocalSearchOperator has no constructors
defined" (see attached picture of object browser)

The trial to resolve by forcing SWIG to create constructors, even if the class is abstract
did not solve the issue.
(see: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn6)

Reported by johan.ludde.wessen on 2013-11-05 10:18:15


- _Attachment: [NoSVLSO.jpg](https://storage.googleapis.com/google-code-attachments/or-tools/issue-35/comment-0/NoSVLSO.jpg)_

Java Application stop if creating two constraints with the same name.

Originally reported on Google Code with ID 24

What steps will reproduce the problem?

int solvertype = MPSolver.getSolverEnum("CBC_MIXED_INTEGER_PROGRAMMING");
MPSolver solver = new MPSolver("My_solver_name", this.solvertype);
solver.makeConstraint("my_const_name");
try {
solver.makeConstraint("my_const_name");
} catch(Throwable e) {
System.out.println(e);
}

What is the expected output? What do you see instead?
I'm expecting the second called to makeConstraint() with the same name to return either
null or generate an exception. Currently it print the following line to the console
and exit the application:
 > [17:10:33] src/base/map-util.h:126: Check failed: collection->insert(value_type(key,
data)).secondduplicate key: test2

What version of the product are you using? On what operating system?
2200

I'm getting the same behavior while creating two variables with the same name.

Reported by ikus060 on 2013-04-26 21:34:29

Python 3 support

Originally reported on Google Code with ID 47

I see on PyPI that your Python wrapper only works on Python 2. Any chance of adding
support for Python 3?

Reported by kermit666 on 2014-08-21 08:35:40

Unable to compile with Visual Studio Express 2012

Originally reported on Google Code with ID 32

What steps will reproduce the problem?
1. Running tools\make all


What is the expected output? What do you see instead?

I was expecting to make all to produce the appropriate binaries. Instead I am seeing
the error

"src\linear_solver/linear_solver.h(680) : error C2512: 'operations_research::Coef
fMap' : no appropriate default constructor available
src\linear_solver/linear_solver.h(851) : error C2512: 'operations_research::Coef
fMap' : no appropriate default constructor available
tools\make: *** [objs/hybrid.obj] Error 2"


What version of the product are you using? On what operating system?
I am using Visual Studio Express 2012 to compile and I am on Windows 7.


Please provide any additional information below.
Is this possibly a compatibility issue with VS2012? The readme does not say the source
has been tested with VS2012.

Reported by gtshteve on 2013-10-21 13:38:45

Bug in PositiveTableConstraint::InitialPropagate

Originally reported on Google Code with ID 6

On some instances, there is an assertion failure when PositiveTableConstraint::InitialPropagate
calls IntervalUp64.

You pass position+1 as argument, but position can have any value between 0 and 63.
If it is 63, then you call IntervalUp64(64) which leads to the assertion failure.

If you run the program with NDEBUG, this leads to an infinite loop.

The trivial solution would be to add a check, but maybe there's something smarter that
can be done.

Reported by phil.vank on 2011-09-16 05:55:00

Patch for /trunk/src/constraint_solver/routing.cc

Originally reported on Google Code with ID 40

time_limit from RoutingSearchParameter was not getting applied for solving.

Reported by [email protected] on 2014-04-01 15:16:49


- _Attachment: [routing.cc.patch](https://storage.googleapis.com/google-code-attachments/or-tools/issue-40/comment-0/routing.cc.patch)_

c# compilation error

Originally reported on Google Code with ID 38


What steps will reproduce the problem?
1. run make csharp (make csharplp not working any longer?)
2.
3.

What is the expected output? What do you see instead?

I get the compilation error:

cl /EHsc /MD /nologo -nologo  /O2 -DNDEBUG /Isrc /Iexamples /Isrc\\gen /IC:\\pro
jects\\or-tools\\dependencies\\install\\include /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_
DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /IC:\\projects\\or-tools\\dependencies\\
install\\include /Idependencies\\sources\\TinyThread++-1.1\\source  /IC:\\projec
ts\\or-tools\\dependencies\\install\\include /IC:\\projects\\or-tools\\dependenc
ies\\install\\include /DUSE_CBC /IC:\\projects\\or-tools\\dependencies\\install\
\include /DUSE_CLP     /D__WIN32__ /IC:\\projects\\or-tools\\dependencies\\insta
ll\\include -c src\\gen\\constraint_solver\\constraint_solver_csharp_wrap.cc /Fo
objs\\constraint_solver_csharp_wrap.obj
constraint_solver_csharp_wrap.cc
src\util/tuple_set.h(375) : error C2039: 'sort' : is not a member of 'std'
src\util/tuple_set.h(375) : error C3861: 'sort': identifier not found
src\util/tuple_set.h(408) : error C2039: 'sort' : is not a member of 'std'
src\util/tuple_set.h(408) : error C3861: 'sort': identifier not found
Tools\make: *** [objs/constraint_solver_csharp_wrap.obj] Error 2


What version of the product are you using? On what operating system?
Win 7, VS 2012 SP4, running under "Open VS2012 x64 Cross Tools Command Prompt"


Please provide any additional information below.
Having real trouble using or-tools dlls under "Win 8/IIS app pool" env made me resort
to compiling everything myself hoping it would link to "the right" c++/c libraries...
blind man shooting :)

Reported by saxorut on 2014-01-17 09:51:30

/bin/fzn "proves" best solution if less ":: output_var" is used

Originally reported on Google Code with ID 42

See the two attached tgz-ed fzn-files: test_nooutput.fzn and test_output.fzn are the
same fzn-problems, both very hard. The only difference is, that in test_nooutput.fzn
only the variable "end_cost" (which must be minimised) is annotated with ":: output_var",
whereas in test_output.fzn there are eight more variables annotated like that (you
can run a diff to see what I mean).

> What steps will reproduce the problem?
1. Run ./bin/fz -all test_nooutput.fzn, you will get "**proven**" in around 980ms with
a value of end_cost = 2116 (which is just the lower bound of this var).
2. Run ./bin/fz -all test_output.fzn, or-tools just takes forever searching without
finding any solution.

> What is the expected output? What do you see instead?
I expect "2." to be the correct behaviour, I tested a lot of solvers with this problem
and never got any solutions better than around 2300.

> What version of the product are you using? On what operating system?
trunk from yesterday, compiled on Ubuntu 12.04, 64-bit

> Please provide any additional information below.
The fz-files were generated from a minizinc-file with G12's mzn2fzn.

Reported by a.schuppisser on 2014-04-11 07:45:53


- _Attachment: [issue_ortools.tgz](https://storage.googleapis.com/google-code-attachments/or-tools/issue-42/comment-0/issue_ortools.tgz)_

error in make csharpexe - dirty fix

Originally reported on Google Code with ID 34

During run of "make csharpexe" the compiler complained on line 93 in "adjustable_priority_queue.h":

const vector<T*>* Raw() const { return &elems_; }

Changing to 
std::vector<T*>* Raw() const { return &elems_; }
resolved the build errors (even if I'm not sure this reflects your full intent)

My revision of Google Or-tools is: 2932
My operating system is Windows 7, and I compile on Visual Studio 2012 64bit.

Reported by johan.ludde.wessen on 2013-11-04 18:50:30

Problem with Sequence Var in Python

Originally reported on Google Code with ID 46

I have some problem that I don't understand with the SequenceVar created by the DisjunctivConstraint.
One example : 
def main():
    solver = pywrapcp.Solver('Ordo')
    tasks = []
    [tasks.append(solver.FixedDurationIntervalVar(0, 25, 5, False, 'Tasks%i' %i)) for
i in range(3)]
    print tasks
    disj = solver.DisjunctiveConstraint(tasks, 'Disjunctive')
    solver.Add(disj)
    collector = solver.AllSolutionCollector()
    collector.Add(tasks)
    intervalPhase = solver.Phase(tasks, solver.INTERVAL_DEFAULT)
    solver.Solve(intervalPhase, [ collector])
    print collector.SolutionCount()
    for i in range(collector.SolutionCount()):
        print "Solution " , i
        print collector.ObjectiveValue(i)
        print [collector.StartValue(i, tasks[j]) for j in range(3)]
        print [collector.EndValue(i, tasks[j]) for j in range(3)]
With this code all is good, I have 6 solutions and it's what I expected.
But when I want call SequenceVar (for example make first the first task) that doesn't
work :
def main():
    solver = pywrapcp.Solver('Ordo')
    tasks = []
    [tasks.append(solver.FixedDurationIntervalVar(0, 25, 5, False, 'Tasks%i' %i)) for
i in range(3)]
    print tasks
    disj = solver.DisjunctiveConstraint(tasks, 'Disjunctive')
    sequence = []
    sequence.append(disj.SequenceVar())
    sequence[0].RankFirst(0)
    solver.Add(disj)
    collector = solver.AllSolutionCollector()
    collector.Add(sequence)
    collector.Add(tasks)
    sequencePhase = solver.Phase(sequence, solver.SEQUENCE_DEFAULT)
    intervalPhase = solver.Phase(tasks, solver.INTERVAL_DEFAULT)
    mainPhase = solver.Compose([sequencePhase, intervalPhase])
    solver.Solve(mainPhase, [ collector])
    print collector.SolutionCount()
    for i in range(collector.SolutionCount()):
        print "Solution " , i
        print collector.ObjectiveValue(i)
        print [collector.StartValue(i, tasks[j]) for j in range(3)]
        print [collector.EndValue(i, tasks[j]) for j in range(3)]

So how can I use SequenceVar from the disjunctivConstraint and what is the use of the
SequenceVar ?

Reported by [email protected] on 2014-07-21 17:25:50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.