or-tools

Adding OR-Tools Library to Visual Studio

假如想象 提交于 2021-02-09 09:20:06
问题 I am trying to write a code using Google's OR-Tools library on Microsoft Visual Studio 2019. I followed the following steps: Installed OR-Tools from Binary on Windows on their website. Extracted the .zip file in C:\Libraries Wrote my code on VS (I wrote #include <ortools/linear_solver/linear_solver.h> and using namespace operations_research; rest is usual C++ Code) In Visual Studio, went to Project > Properties > C/C++ > Additional Include Directories Added "C:\Libraries\or-tools\include"

Adding OR-Tools Library to Visual Studio

∥☆過路亽.° 提交于 2021-02-09 09:18:49
问题 I am trying to write a code using Google's OR-Tools library on Microsoft Visual Studio 2019. I followed the following steps: Installed OR-Tools from Binary on Windows on their website. Extracted the .zip file in C:\Libraries Wrote my code on VS (I wrote #include <ortools/linear_solver/linear_solver.h> and using namespace operations_research; rest is usual C++ Code) In Visual Studio, went to Project > Properties > C/C++ > Additional Include Directories Added "C:\Libraries\or-tools\include"

Understanding how to set soft constraints using Google OR -tools

大城市里の小女人 提交于 2021-02-07 08:55:23
问题 I have been using Google OR-tools and trying to follow along with their examples for scheduling problems. However, the python documentation is sometimes hard to follow, and the more complex example ( https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py) is not described well. I want to be able to set hard and soft constraints on the amount of shifts employees work. In the above example I believe the function add_soft_sum_constraint() (I've put its exact code

Setting Binary Constraints with Google OR-tools

久未见 提交于 2021-02-05 08:36:59
问题 I have been using OR-tools, in particular looking at its uses for scheduling. I feel I have grasp on the library now, though there is one aspect of Google's main example ( https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py ) that I am having trouble understanding. The function I am having a problem with is: add_soft_sequence_constraint() and the related: negated_bounded_span (relevant code is below). These are meant to constrain the number of shifts a

Setting Binary Constraints with Google OR-tools

不问归期 提交于 2021-02-05 08:35:43
问题 I have been using OR-tools, in particular looking at its uses for scheduling. I feel I have grasp on the library now, though there is one aspect of Google's main example ( https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py ) that I am having trouble understanding. The function I am having a problem with is: add_soft_sequence_constraint() and the related: negated_bounded_span (relevant code is below). These are meant to constrain the number of shifts a

Setting Binary Constraints with Google OR-tools

孤街浪徒 提交于 2021-02-05 08:35:14
问题 I have been using OR-tools, in particular looking at its uses for scheduling. I feel I have grasp on the library now, though there is one aspect of Google's main example ( https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py ) that I am having trouble understanding. The function I am having a problem with is: add_soft_sequence_constraint() and the related: negated_bounded_span (relevant code is below). These are meant to constrain the number of shifts a

Google OR-Tools (using SCIP solver) - How to access the intermediate solutions found by the solver?

只谈情不闲聊 提交于 2021-01-29 17:20:39
问题 I'm new to Google OR-Tools. Using Python, I implemented a MIP model with SCIP as a solver. The objective function is for minimization ( solver.Minimize(C) ) and I am accessing the final solution through solver.Objective().Value() . However, I also need to access the intermediate solutions that the solver finds, before reaching the final one, and their timestamp . (The final goal is to plot a graph with the solutions evolution through time). I tried to use a while loop: solutions_evolution = {

Fair Shift Distribution

北城余情 提交于 2021-01-29 06:20:55
问题 I have a slightly modified version of nurse_sat https://github.com/google/or-tools/blob/master/examples/python/nurses_sat.py where I have a dictionary of key - value pares of (day, nurse, shift) = BoolVar I want to make it so all nurses have same amount of each shift. E.G: Let's assume that we have 30 days, and there are 3 shifts per day {0, 1, 2} and we have 3 nurses {a, b, c} I would like to have all nurses do 10 of shift 0, 10 of shift 2 and 10 of shift 3. The way I am trying to achieve

Google ORTools - Nodes that can't share the same route

落花浮王杯 提交于 2021-01-29 04:01:13
问题 I need to solve this routing problem: two nodes cannot share the same route. I.e.: if vehicle stop at node A, it shouldn't be allowed to stop also at node B, that means that node A and node B cannot be on the same route. Any ideas? Thanks in advance for your help. Fabio 回答1: Did you try: routing.solver().Add(routing.VehicleVar(index_a) != routing.VehicleVar(index_b)) 来源: https://stackoverflow.com/questions/61405089/google-ortools-nodes-that-cant-share-the-same-route

Make K different (cardinality) google OR-TOOLS

旧时模样 提交于 2021-01-28 11:06:15
问题 I'm wondering if there is a generalisation of solver.AllDifferent(x) in google or-tools that allows for the specification of how many different elements I allow. So if len(x) = 4, then AllDifferent(x) means that len(set(x)) = 4. But what if I just want to enforce "at least 2 different", so: len(set(x)) >=2 ? Is there a constraint that generalises AllDifferent to be able to set the cardinality of the solution variable ? 来源: https://stackoverflow.com/questions/48021694/make-k-different