Questions tagged [or-tools]
Google's Operations Research Tools (OR-Tools)
1,025
questions
0
votes
0
answers
24
views
How to use OR-Tools Routing Library to model a CVRP where vehicles have multipurpose capacities for different products that cannot be mixed? [closed]
I'm traying to model a CVRP where each vehicle has multiple tanks (capacities). These tanks can carry different types of products, but just one at a time. Example: There are three types of products (A,...
-1
votes
0
answers
22
views
VRPTW, how to prioritize certain stops and make them in the beginning of route?
given all time window and distance constraints, how do we incorporate additional constraint and make sure certain stops should happen in the beginning of routes? I know some might suggest editing time ...
0
votes
0
answers
41
views
Multi-trip, multi-depot VRP in OR-tools
I'm struggling to model a variation of a VRP in OR-tools in python:
multiple vehicles
each vehicle has a capacity
each vehicle can make multiple routes
there are multiple depots
The first two are ...
-1
votes
1
answer
39
views
OR-tools returns sub-optimal TSP solution
I'm trying to replicate a TSP code to calculate an optimal route from a user-supplied array of distances, but the code returns never giving me the optimized option. The return is always fixed at 90.
...
-1
votes
1
answer
48
views
Is there a tool to visualize a tree search in ORtools?
I am conceiving a global constraint with the ORtools solver, and to have a better understanding of my algorithm's behavior, i want to visualize the tree search generated by the solver.
So Is there any ...
0
votes
2
answers
45
views
Minimizing the sum of an array as exponent to the base 2
I have a problem that roughly does the following
set of int: SIZE = 1..3;
array[SIZE] of int: bound;
array[SIZE] of var int: cost;
constraint forall(i in SIZE) (cost[i] > bound[i]);
solve ...
1
vote
0
answers
47
views
LP model INFEASIBLE when expected Feasible
I am using the default linear solver in GLOP with a problem that I know has an optimal solution, but it is terminating with INFEASIBLE when I use == in the constraints. I have looked at (https://www....
1
vote
0
answers
75
views
Google OR-Tools, accessing value of the variables that the solver tries. Dynamic coefficients for variables
I am using google or tools, to find the spend allocation for maximum revenue. In below example, (say) mon, tues are variables for spend allocation for monday tuesday out of total alloaction.
To be ...
0
votes
1
answer
65
views
Getting variable constraint value
How would I find the constraint value of a variable using SAT_INTEGER_PROGRAMMING given a feasible solution. Essentially solution_value() but for constraint.
Looked through documentation and nothing ...
-3
votes
0
answers
40
views
ortools OVRP same result when change matrix of distance
i using this example OVRP:
https://github.com/google/or-tools/blob/stable/ortools/constraint_solver/samples/vrp_starts_ends.py
with the differenct in the function create_data_model() becouse my case ...
0
votes
0
answers
50
views
Maven deployment onto heroku issue for ORtools + Import for local maven dependency not appearing
I am trying to use the jar file for google OR tools as a dependency in order for it to run on heroku, because on heroku I get this error
$ ./mvnw -DskipTests clean dependency:list install
[INFO] ...
0
votes
1
answer
51
views
How to run the solving process step by step
When we have defined a relatively complicated model, the solving process could be long.
One way is to cut the long solving process into phases. We can find a quick and feasible solution first with an ...
0
votes
0
answers
45
views
Solving a flexible multi-depot multi-vehicle VRP with OR-tools
I'm trying to solve a seemingly unique VRP using OR-tools where I have a number of depots, each with a capacity constraint and a number of vehicles, also with a capacity constraint.
I then have a ...
-1
votes
0
answers
63
views
Capacity vehicle routing problem assign wrong vehicle for route, google or tools
I'am using google or-tools to find the best matching vehicle to capacity constrains problem. Trying to run the python example given in the official documentation in the below link with a simple ...
0
votes
1
answer
104
views
maximize internal L1 distance between multiple points
I am trying to maximize the internal distance between multiple 2D points while simultaneously minimizing their distance to a center point. I am using L1 distance for calculation and based on one of my ...
0
votes
1
answer
37
views
AddNoOverlap2D takes no arguments?
i have a python plugin i'm trying to write some parts of in C#
but adding no overlap 2D seems to confuse me.
in python it takes
model.AddNoOverlap2D(x_intervals,y_intervals)
in C# i tried but the ...
0
votes
0
answers
24
views
Do Anylogic models with external dependencies that need "write" permission runnable on the (Anylogic) public cloud?
I am using Google OR-Tools as an external dependency in an Anylogic model. The model runs on the Anylogic desktop version. However, after I upload my code on the (Anylogic) public cloud, I get this ...
0
votes
1
answer
44
views
Is AddMaxEquality not compatible with OnlyEnforceIf in CP-SAT solver
When we would like to combine AddMaxEquality and OnlyEnforceIf in the model formulation, we consistently get cp_model.MODEL_INVALID.
Are these two not compatible with each other yet? If not, is there ...
-2
votes
0
answers
39
views
I am using Colab to run some python code but I keep facing attribute errors
The code I have is for a vehicle routing problem with variable time windows (VRPTW). I am using Colab to run it and I am currently facing attribute errors. I am somewhat new to coding so if possible ...
0
votes
0
answers
24
views
Google OR-Tools OP-TW implementation not respecting time window constraint
Trying to implement an OP-TW problem using Google OR-Tools,however the results are not correct. Not sure where the issue is, hoping someone can guide me.
This is the Network of nodes/cost/time windows:...
0
votes
1
answer
33
views
OR-Tools CVRP with delivery and collection of goods at same location
I want to model a CVRP with reloads where goods are shipped from the depot to a location, and other goods are collected at that same location and brought back to the depot. Vehicles have a maximum ...
0
votes
0
answers
28
views
Detailed logging of OR-Tools VRP solver behaviour
To better understand how the OR-Tools VRP solver arrives at a solution, I want to log each step in the search algorithm. The log must use terminology from the problem domain, not implementation ...
0
votes
1
answer
38
views
Is there any smarter way to constrain the max size of continuous tasks with ortools cp-sat
In pharceutical industry, the changeover/cleaning events are typically very long and may even need different level of operator resource. As a result, they need to modelled carefully when we schedule ...
0
votes
1
answer
48
views
How to write alternative constraint with interval variable in or-tools?
How to write alternative constraint with interval variable in or-tools? I thought something like this would work but the method AddAlternative doesn´t exist. Another question is how to know if ...
0
votes
0
answers
51
views
In or-tools, VRPTW, how can I build a constraint that uses the fewest vehicles?
python 3.6, or-tools 9.3.10497
Because my business scenario is more complicated, I will simplify it to describe.
There are two kinds of nodes, normal nodes and special nodes. If the vehicle only ...
1
vote
1
answer
80
views
OR-Tools MIP Python wrapper: is there a way to introduce products (e.g. coef * x * y < threshold) into objective and constraints
My MIP problem requires semi-continuous variables :
Problem formulation states that all goods could be either produced at Minimum Order Quantity (MOQ) or as 0, which could be summarized as:
Xi >= ...
0
votes
1
answer
53
views
How to create a bool variable to indicate if another integer variable is between two specific values
In ortools cp-sat, how could we link an boolean decision variable to whether an integer variable value is between two given values.
from ortools.sat.python import cp_model
def get(x):
return ...
0
votes
0
answers
29
views
In or-tools, VRPTW, how can we incorporate the constraint that vehicles should wait at each location for different length of time
I am using or tools to solve vehicle routing problem with time windows, capacity constraints. Wait-time matrix (in minutes) is as below.
In the vrptw code, there is an input parameter as allowed wait ...
0
votes
0
answers
38
views
OR-Tools: Is there any way to get raw combinations and permutations?
For example, you call something like permutations([1,2,3,4],2) or combinations([1,2,3,4],2) and get list of permutations/combinations like [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), ...]. Is it possible ...
0
votes
1
answer
102
views
L1 distance constraint or distance objective
I am very new to Linear Programming and Optimization problems in general and I am trying to set up a simple LP problem.
I want to minimize the L1 distance between two 2D points. One of them will be ...
0
votes
0
answers
34
views
in or tools' VRPTW, how do we have customized objective function?
As title indicates, the or tools uses overall route driving time(or distance) as objective function and searches for a solution combination that minimizes the sum of driving times (or distances) for ...
-1
votes
1
answer
86
views
Find the best combination of n element from a list that satisfies specific conditions
I'm developing a function that solves any combination from an arbitrary list that needs to meet some of condition. A specific case is depicted below:
Given a list of 9 elements
[3,2,5,8,9,11,45,12,44],...
1
vote
1
answer
85
views
Minimize AbsEquality rather than enforce in OrTools
I'm trying to solve the following using OR tools:
Given the following bags containing different colors of balls:
bag
red
blue
green
black
A
10
5
85
0
B
25
50
25
0
C
0
100
0
0
D
90
5
5
0
E
2
0
98
...
0
votes
0
answers
86
views
Can I add variables to a 2D knapsack problem that can take multiple values?
this is my first question on stack overflow and I am quite new to OR, so bear with me.
I am trying to solve what could be considered a rectangular 2D knapsack problem with a twist. In order to solve ...
1
vote
1
answer
58
views
in VRPTW, how to make the constraints soft instead of being strictly hard when doing the routing?
as the title indicates, when incorporating time window, vehicle constraints for nodes, in some scenarios the constraints are too strict and I am unable to produce an output.
How can I make the ...
1
vote
1
answer
44
views
VRP example in the docs gives different output when I run it
On https://developers.google.com/optimization/routing/vrp, it says:
The complete programs are shown in the next section. When you run the programs, they display the following output:
Route for ...
1
vote
1
answer
30
views
How give a possible value range and a possible value out of that range to a variable
I'm using CP-SAT model of google OR Tools with python. and I need to add a constraint as below,
x must be in the range of 10 and 100. Otherwise, it must be zero.
How can I add such a constraint to the ...
0
votes
0
answers
98
views
How to solve constraint problem where variables must be one of a discrete set of values in OR-Tools?
My problem looks like this: A movie theatre is showing a set of n films over a 5 day period. Each movie has a corresponding IMBD score. I want to watch one movie per day over the 5 day period, ...
0
votes
1
answer
51
views
In OR tools, more specifically in VRPTW, why start and end times for a time window should only be integers?
I am wondering why the start and end of time windows have to be integers, for example for a node who has 7am-10am window, it is (7, 10)? There could be case where a time window is between 7:30am-10:...
1
vote
2
answers
181
views
In or-tools, VRPTW, how can I incorporate the constraint that some stops should be visited by only one subset of vehicles?
vehicle 1
vehicle 2
vehicle 3
vehicle 4
node 1
1
1
0
0
node 2
0
1
1
0
node 3
0
0
1
1
As could be seen from the matrix, a node could only be served by a specified list of vehicles. Node 1 should be ...
0
votes
1
answer
93
views
Using Google OR-Tools to solve a Vehicle Routing Problem (VRP) for UAVs
I have tried to use OR-Tools to solve a VRP. The problem is that I don't want to find the shortest routes for every vehicle, but the ones that uses the least energy.
Explanation on that: If a vehicle ...
-1
votes
1
answer
94
views
Solve Stable Marriages Problem using constraint programming - BoundedLinearExpression object is not iterable
I'm taking a course on Discrete Optimization, and we're working through constraint programming. In a topic about reification, we're working through the Stable Marriages Problem (SPM).
The model ...
0
votes
1
answer
95
views
OR-Tools in python how to set power of a variable
here is a google OR-tool example to optimize a function:
from ortools.linear_solver import pywraplp
def LinearProgrammingExample():
"""Linear programming sample."""
...
0
votes
1
answer
73
views
Constraint Programming, how to add x[i] <= (max(x[:i]) + 1)
I'm building a model using or-tools CP tools. The values I want to find are placed in a vector X, and I want to add a constraint that says up to each position of X, the next position cannot have as a ...
0
votes
1
answer
82
views
python OR-tools, how to make certain numbers in a 2D-array be specific numbers
I have a 2D list called list_of_numbers where each list in the list has 1 or-tools model int variable inside of it where the numbers can be from 0 to 10. I have another 2D list called ...
0
votes
0
answers
69
views
python OR-tools printing a solution when the solution is a list of numbers
I want to print the solution in OR-tools when the solution is a 2D array of pairs with a different number of pairs each time.
For example i have this code
from ortools.sat.python import cp_model
...
2
votes
2
answers
280
views
How to use CP-SAT solver or other tools to find 3D arrays with constraints on rows, columns and tubes (representing school classes, terms and days)?
I will be grateful to anyone who can help me write some Python code to enumerate the 21×2×3 arrays, indexed with i, j and k, which are two-thirds filled with 0's and one-third filled with the values '...
0
votes
0
answers
60
views
How can I satisfy the At-Most constraint in a workflow satisfiability problem with Google OR-Tools?
For a given set of steps T, I have to ensure that at most k users are assigned to steps T. For example, at most 2 users can be assigned to steps 1, 2, and 3. Each task is only assigned to one user ...
0
votes
2
answers
80
views
Google OR Tools does not return solution if First solution strategy = SAVINGS
I'm currently learning on how to use Google OR-Tools, specifically on the routing problem. I want to try to use Clarke and Wright Savings Algorithm by setting the first solution strategy equals ...
1
vote
2
answers
63
views
Can we only print the first solution strategy and not the local search solution in Google OR Tools?
I am currently learning how to use Google OR-Tools, specifically on the CVRP Problem. The code is divided into two stages. The first one is finding the initial/first solution using path-cheapest-arc, ...