Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max value cluster #481

Open
wants to merge 37 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
93a341f
Add test for unconstrained_initialization + change Dockerfile
Jan 4, 2023
1f8b424
blackboard structure
Jan 5, 2023
5526865
add KS : create_matrices.py
Jan 5, 2023
50c5772
add new KS
Jan 5, 2023
91009b4
add knowledge sources
Jan 5, 2023
b4889a2
add new KS + bugfix
Jan 5, 2023
2deae9b
add new KS + bugfix
Jan 5, 2023
f3764ee
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Jan 5, 2023
1abb63c
Add dictionnary index_id to parse solution with the correct ids
Jan 6, 2023
d32dae1
add tests for get arguments
Jan 6, 2023
b2446e5
Create matrices tests and add problem schema validation
Jan 6, 2023
4a8ec6c
add data attributes to BB
Jan 6, 2023
27de60c
add service_attributes creation tests + fix some bugs
Jan 6, 2023
332893b
get arguments, add checks
Jan 6, 2023
5d7306f
add some tests for create_service_attributes process() function
Jan 6, 2023
b4f37bb
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Jan 6, 2023
a11e189
fix tests
Jan 7, 2023
a543199
Add service_attributes creation tests + fix some bugs
Jan 9, 2023
8291baa
Add new unit tests
Jan 12, 2023
77a7631
Now fastvrpy can handle multiple units for capacity constraints, and …
Pierre-Graber Jan 23, 2023
e89937b
[U-I] multiple warehouses management
Pierre-Graber Feb 8, 2023
f0ed05c
add KS to check if we can solve the problem with fastvrpy + test it
Pierre-Graber Feb 9, 2023
811e81c
[U-I] Multi TW Management
Pierre-Graber Feb 16, 2023
895ebc8
fix solution parser + adapt tests for multi depot
Pierre-Graber Feb 16, 2023
8b599ce
for now process initial solution should return None for unassigned_se…
Pierre-Graber Feb 16, 2023
013586d
for now process_initial_solution should return None for unassigned_se…
Pierre-Graber Feb 16, 2023
58c48b2
Merge branch 'blackboard' of github.com:guillaumemaran/optimizer-api …
Pierre-Graber Feb 16, 2023
57ad22f
Revert "for now process_initial_solution should return None for unass…
Pierre-Graber Feb 16, 2023
8c90927
for now process_initial_solution should return None for unassigned se…
Pierre-Graber Feb 16, 2023
4b0de3e
`bumb fastvrpy to 0.3.0 : add matrix_index and force_start
Pierre-Graber Mar 20, 2023
7129c97
fastvrpy : handles free_approach and free_return
Pierre-Graber Mar 22, 2023
267944a
refacto : services attributes, vehicles attributes + matrices creation
Pierre-Graber Mar 27, 2023
fc8bba4
fastvrpy : add rest managament to the wrapper + duration constraints …
Pierre-Graber Mar 30, 2023
76861c5
UI : Fastvrpy starts from existing route if it exists + fixes
Pierre-Graber Apr 6, 2023
cd93966
Add 'strict_skills' field to 'resolution' for strict skills management
Pierre-Graber Apr 25, 2023
3099b9b
fix mapotempo-ce identification
Pierre-Graber Apr 25, 2023
6a0c3b1
set a max value from and to depot to avoid getting unbalanced cluster…
May 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ jobs:
echo $(ls -lh vendor/bundle)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: ${{ secrets.REGISTRY }}
- name: Build
uses: docker/build-push-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions api/v01/entities/vrp_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module VrpConfiguration
optional(:stable_iterations, type: Integer, allow_blank: false, documentation: { hidden: true }, desc: 'DEPRECATED : Jsprit solver and related parameters are not supported anymore')
optional(:stable_coefficient, type: Float, allow_blank: false, documentation: { hidden: true }, desc: 'DEPRECATED : Jsprit solver and related parameters are not supported anymore')
optional(:initial_time_out, type: Integer, allow_blank: false, documentation: { hidden: true }, desc: '[ DEPRECATED : use minimum_duration instead]')
optional(:strict_skills, type: Boolean, allow_blank: false, documentation: { hidden: true }, desc: 'All skills must be taken into during resolution')
optional(:minimum_duration, type: Integer, allow_blank: false, desc: 'Minimum solve duration before the solve could stop (x10 in order to find the first solution) (ORtools only)')
optional(:time_out_multiplier, type: Integer, desc: 'The solve could stop itself if the solve duration without finding a new solution is greater than the time currently elapsed multiplicate by this parameter (ORtools only)')
optional(:vehicle_limit, type: Integer, desc: 'Limit the maximum number of vehicles within a solution. Not available with periodic heuristic.')
Expand Down
12 changes: 11 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ ENV LANG C.UTF-8
# Set correct environment variables.
ENV HOME /root

RUN apt update && apt install -y python3.8 python3-pip && \
pip3 install protobuf==3.20.* && \
pip3 install schema && \
pip3 install scikit-learn

# Trick to install passenger-docker on Ruby 2.5. Othwerwise `apt-get update` fails with a
# certificate error. See following links for explanantion:
# https://issueexplorer.com/issue/phusion/passenger-docker/325
Expand All @@ -40,9 +45,14 @@ RUN apt-get update > /dev/null && \
COPY --chown=app . /srv/app/
RUN install -d --owner app /srv/app/archives

USER app
USER root
WORKDIR /srv/app

RUN pip3 install unconstrained-initialization/dependencies/fastvrpy-0.5.2.tar.gz --user



USER app
RUN gem install bundler --version 2.2.24 && \
bundle --version && \
bundle install --path vendor/bundle --full-index --without ${BUNDLE_WITHOUT} -j $(nproc)
Expand Down
6 changes: 3 additions & 3 deletions lib/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
module Filters
def self.filter(vrp)
merge_timewindows(vrp)

filter_skills(vrp)

unless vrp.configuration.resolution.strict_skills
filter_skills(vrp)
end
# calculate_unit_precision # TODO: treat only input vrp, not all models in memory from other vrps
nil
end
Expand Down
20 changes: 18 additions & 2 deletions lib/interpreters/split_clustering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,20 @@ def add_duration_from_and_to_depot(vrp, data_items)
end
log "matrix computed in #{(Time.now - tic).round(2)} seconds"

max_time_from_depot = 0
Pierre-Graber marked this conversation as resolved.
Show resolved Hide resolved
max_time_to_depot = 0

time_matrix_from_depot.map{ |matrix|
matrix.map{ |time|
((time > max_time_from_depot) && (time != 2147483647)) ? max_time_from_depot = time : nil
}
}
time_matrix_to_depot.map{ |matrix|
matrix.map{ |time|
((time > max_time_to_depot) && (time != 2147483647)) ? max_time_to_depot = time : nil
}
}

v_index = {
from: vrp.vehicles.collect{ |v|
start_loc = v.start_point&.location
Expand All @@ -1488,8 +1502,10 @@ def add_duration_from_and_to_depot(vrp, data_items)
point[4][:duration_from_and_to_depot] = []

vrp.vehicles.each_with_index{ |_vehicle, v_i|
duration_from = time_matrix_from_depot[v_index[:from][v_i]][p_index] if v_index[:from][v_i]
duration_to = time_matrix_to_depot[p_index][v_index[:to][v_i]] if v_index[:to][v_i]
duration_from = [time_matrix_from_depot[v_index[:from][v_i]][p_index], max_time_from_depot * 3].min\
if v_index[:from][v_i]
duration_to = [time_matrix_to_depot[p_index][v_index[:to][v_i]], max_time_to_depot * 3].min if\
v_index[:to][v_i]

# TODO: investigate why division by vehicle.router_options[:speed_multiplier]
# detoriarates the performance of periodic
Expand Down
1 change: 1 addition & 0 deletions models/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Resolution < Base
field :variation_ratio, default: nil
field :batch_heuristic, default: false
field :repetition, default: nil
field :strict_skills, default: false

# random_seed parameter is set by the API during the POST process before dumping the VRP
# it is to make the runs repeatable/reproducible and simplifies comparing different environments
Expand Down
65 changes: 65 additions & 0 deletions test/wrappers/ortools_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5307,4 +5307,69 @@ def test_activities_order
unassigned_stops = solution.unassigned_stops
assert_equal 2, unassigned_stops.size
end

def test_strict_skills
ortools = OptimizerWrapper.config[:services][:ortools]
problem = {
matrices: [{
id: 'matrix_0',
time: [
[0, 1, 1],
[1, 0, 1],
[1, 1, 0]
]
}],
points: [{
id: 'point_0',
matrix_index: 0
}, {
id: 'point_1',
matrix_index: 1
}, {
id: 'point_2',
matrix_index: 2
}],
vehicles: [{
id: 'vehicle_0',
start_point_id: 'point_0',
matrix_id: 'matrix_0'
}],
services: [{
id: 'service_1',
skills: ['frozen'],
activity: {
point_id: 'point_1'
}
}, {
id: 'service_2',
skills: ['frozen'],
activity: {
point_id: 'point_2'
}
}],
configuration: {
resolution: {
strict_skills: true,
duration: 20,
}
}
}

vrp_strict = TestHelper.create(problem)

Filters.filter(vrp_strict)

solution_strict = ortools.solve(vrp_strict, 'test')

assert_equal 1, solution_strict.routes.size
assert_equal problem[:services].size, solution_strict.unassigned_stops.size

problem_unstrict = Marshal.load(Marshal.dump(problem))
problem_unstrict[:configuration][:resolution][:strict_skills] = false
vrp_unstrict = TestHelper.create(problem_unstrict)
Filters.filter(vrp_unstrict)
solution_unstrict = ortools.solve(vrp_unstrict, 'test')
assert_equal 1, solution_unstrict.routes.size
assert_equal 0, solution_unstrict.unassigned_stops.size
end
end
Loading