Merge branch 'master' of github.com:google/or-tools

This commit is contained in:
Laurent Perron
2021-09-21 13:58:45 +02:00
34 changed files with 169 additions and 70 deletions

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
cmake:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- name: Check cmake
@@ -18,10 +14,6 @@ jobs:
run: sudo apt install -y swig
- name: Check swig
run: swig -version
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Configure

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
cmake_make:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- name: Check cmake
@@ -18,10 +14,6 @@ jobs:
run: brew install swig
- name: Check swig
run: swig -version
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Configure

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
cmake:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- name: Check cmake
@@ -21,10 +17,6 @@ jobs:
echo "$((Get-Item .).FullName)/swigwin-4.0.2" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Check swig
run: swig -version
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Configure

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
make:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- name: Check make
@@ -18,10 +14,6 @@ jobs:
run: sudo apt install -y swig
- name: Check swig
run: swig -version
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: ./
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Build third party

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
make:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- name: Check make
@@ -18,10 +14,6 @@ jobs:
run: brew install swig
- name: Check swig
run: swig -version
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Build third party

View File

@@ -6,10 +6,6 @@ jobs:
# Building using the github runner environement directly.
make:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
dotnet-version: ['3.1.x', '5.0.x']
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
@@ -19,10 +15,6 @@ jobs:
rm 'C:\Program Files\Git\usr\bin\sh.exe'
rm 'C:\Program Files\Git\bin\sh.exe'
shell: bash
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Check dotnet
run: dotnet --info
- name: Check make

View File

@@ -12,6 +12,17 @@ RUN dotnet_sdk_version=3.1.404 \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# see: https://dotnet.microsoft.com/download/dotnet-core/5.0
RUN dotnet_sdk_version=5.0.401 \
&& wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a80a3834-c8a1-4012-b7d9-a3a5a1e4ba30/29e11d1acb7595d79ce48a5f1fb33c82/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='a2077f4d1c9da9c69453b771cd239bad27f62379402cc5e1c74a1f2a960fd55efc85cc15eafbac11f17ea975895ce107fab4bbfc49880a0a14791e8ac13ca2de' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
FROM env AS devel
WORKDIR /home/project

View File

@@ -1,7 +1,7 @@
FROM ortools/cmake:archlinux_swig AS env
# Currently dotnet-sdk (.Net 5) is broken
# see: https://github.com/google/or-tools/issues/2465
RUN pacman -Syu --noconfirm dotnet-sdk-3.1
RUN pacman -Syu --noconfirm dotnet-sdk-3.1 dotnet-sdk-5.0
FROM env AS devel
WORKDIR /home/project

View File

@@ -1,7 +1,7 @@
FROM ortools/cmake:centos_swig AS env
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos8
RUN dnf -y update \
&& dnf -y install dotnet-sdk-3.1 \
&& dnf -y install dotnet-sdk-3.1 dotnet-sdk-5.0 \
&& dnf clean all \
&& rm -rf /var/cache/dnf
# Trigger first run experience by running arbitrary cmd

View File

@@ -7,7 +7,7 @@ RUN apt-get update -qq \
&& wget -q https://packages.microsoft.com/config/debian/10/prod.list \
&& mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \
&& apt-get update -qq \
&& apt-get install -yq dotnet-sdk-3.1 \
&& apt-get install -yq dotnet-sdk-3.1 dotnet-sdk-5.0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Trigger first run experience by running arbitrary cmd

View File

@@ -1,7 +1,7 @@
FROM ortools/cmake:fedora_swig AS env
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-fedora
RUN dnf -y update \
&& dnf -y install dotnet-sdk-3.1 \
&& dnf -y install dotnet-sdk-3.1 dotnet-sdk-5.0 \
&& dnf clean all
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info

View File

@@ -13,6 +13,17 @@ RUN dotnet_sdk_version=3.1.404 \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# see: https://dotnet.microsoft.com/download/dotnet-core/5.0
RUN dotnet_sdk_version=5.0.401 \
&& wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/5972698f-ba44-4664-9c50-bdc69ca70fb7/1cf7d94425d8dd4d5789dfa978d61475/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz \
&& dotnet_sha512='a444d44007709ceb68d8f72dec0531e17f85f800efc0007ace4fa66ba27f095066930e6c6defcd2f85cdedea2fec25e163f5da461c1c2b8563e5cd7cb47091e0' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
FROM env AS devel
WORKDIR /home/project

View File

@@ -5,7 +5,7 @@ RUN apt-get update -qq \
&& wget -q https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq dotnet-sdk-3.1 \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq dotnet-sdk-3.1 dotnet-sdk-5.0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Trigger first run experience by running arbitrary cmd

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- see https://github.com/dotnet/docs/issues/12237 -->
<RollForward>LatestMajor</RollForward>

View File

@@ -605,6 +605,7 @@ test_python_constraint_solver_samples: \
rpy_vrp_drop_nodes \
rpy_vrp_global_span \
rpy_vrp_initial_routes \
rpy_vrp_nodes_indices \
rpy_vrp_pickup_delivery \
rpy_vrp_pickup_delivery_fifo \
rpy_vrp_pickup_delivery_lifo \

View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python3
# Copyright 2010-2021 Google LLC
# 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.
# [START program]
"""Sample to better understand Node/Index relation.
This script generate few markdown tables to better understand
the relation between nodes and indices.
Things to notice:
* Since we have two duplicates (node 5 and node 4) solver need 2 extra indices to have an unique index for each vehicle start/stop and locations.
* Solver needs to "create" an index for a vehicle 1 start since solver need an unique start index per vehicle.
* All end nodes are moved to the end of the index list aka [15, 16, 17, 18].
* routing.Size() return the number of node which are not end nodes (here 15 aka [0-14])
note: using the two properties above, we know that any index in range(routing.Size()) is not a vehicle end node.
* Since end nodes are moved to the end, their respective "empty" node index are
reused so all locations indices are "shifted"
e.g. node 9 is mapped to index 6
* Same for start nodes which are moved to "empty" space
e.g. start node 7 mapped to index 4
Takeaway:
* Allways use routing.Start(), routing.End(), manager.IndexToNode() or manager.NodeToIndex().
* Location node is not necessarily equal to its index.
* To loop through ALL indices use manager.GetNumberOfIndices() (Python) or manager::num_indices() (C++)
"""
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
def main():
"""Entry point of the program."""
locations = 17
starts = [5, 5, 7, 8]
ends = [1, 2, 4, 4]
vehicles = len(starts)
assert len(starts) == len(ends)
manager = pywrapcp.RoutingIndexManager(locations, vehicles, starts, ends)
routing = pywrapcp.RoutingModel(manager)
print('Starts/Ends:')
header = '| |'
separator = '|---|'
v_starts = '| start |'
v_ends = '| end |'
for v in range(manager.GetNumberOfVehicles()):
header += f' vehicle {v} |'
separator += '---|'
v_starts += f' {starts[v]} |'
v_ends += f' {ends[v]} |'
print(header)
print(separator)
print(v_starts)
print(v_ends)
print('\nNodes:')
print('| locations | manager.GetNumberOfNodes | manager.GetNumberOfIndices | routing.nodes | routing.Size |')
print('|---|---|---|---|---|')
print(f'| {locations} | {manager.GetNumberOfNodes()} | {manager.GetNumberOfIndices()} | {routing.nodes()} | {routing.Size()} |')
print('\nLocations:')
print('| node | index | routing.IsStart | routing.IsEnd |')
print('|---|---|---|---|')
for node in range(manager.GetNumberOfNodes()):
if node in starts or node in ends:
continue
index = manager.NodeToIndex(node)
print(
f'| {node} | {index} | {routing.IsStart(index)} | {routing.IsEnd(index)} |'
)
print('\nStart/End:')
print('| vehicle | Start/end | node | index | routing.IsStart | routing.IsEnd |')
print('|---|---|---|---|---|---|')
for v in range(manager.GetNumberOfVehicles()):
start_index = routing.Start(v)
start_node = manager.IndexToNode(start_index)
print(f'| {v} | start | {start_node} | {start_index} | {routing.IsStart(start_index)} | {routing.IsEnd(start_index)} |')
for v in range(manager.GetNumberOfVehicles()):
end_index = routing.End(v)
end_node = manager.IndexToNode(end_index)
print(f'| {v} | end | {end_node} | {end_index} | {routing.IsStart(end_index)} | {routing.IsEnd(end_index)} |')
if __name__ == '__main__':
main()
# [END program]

View File

@@ -33,6 +33,19 @@ RUN dotnet_sdk_version=3.1.404 \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-5.0.401-linux-x64-alpine-binaries
# see: https://dotnet.microsoft.com/download/dotnet-core/5.0
RUN dotnet_sdk_version=5.0.401 \
&& wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a80a3834-c8a1-4012-b7d9-a3a5a1e4ba30/29e11d1acb7595d79ce48a5f1fb33c82/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='a2077f4d1c9da9c69453b771cd239bad27f62379402cc5e1c74a1f2a960fd55efc85cc15eafbac11f17ea975895ce107fab4bbfc49880a0a14791e8ac13ca2de' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/ \
&& chmod a+x /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
################
## OR-TOOLS ##

View File

@@ -18,6 +18,17 @@ RUN dotnet_sdk_version=3.1.404 \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# see: https://dotnet.microsoft.com/download/dotnet-core/5.0
RUN dotnet_sdk_version=5.0.401 \
&& wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a80a3834-c8a1-4012-b7d9-a3a5a1e4ba30/29e11d1acb7595d79ce48a5f1fb33c82/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='a2077f4d1c9da9c69453b771cd239bad27f62379402cc5e1c74a1f2a960fd55efc85cc15eafbac11f17ea975895ce107fab4bbfc49880a0a14791e8ac13ca2de' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
WORKDIR /root
ADD or-tools_alpine-edge_v*.tar.gz .

View File

@@ -43,7 +43,7 @@ setup(
packages=find_packages(),
install_requires=[
'protobuf >= 3.18.0',
'absl-py >= 0.11',
'absl-py >= 0.13',
],
package_data={
'ortools.init' : ['_pywrapinit.dll', '*.pyi'],