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

sentry fixes + tests + output corrections #35

Merged
merged 9 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ services:

before_install:
- export REGISTRY=${REGISTRY:-registry.mapotempo.com/}
- docker build --build-arg VROOM_VERSION=${VROOM_VERSION:-v1.2.0} --build-arg OPTIMIZER_ORTOOLS_VERSION=${OPTIMIZER_ORTOOLS_VERSION:-v1.3.0} -f docker/Dockerfile -t registry.test.com/mapotempo/optimizer-api:latest .
- source ci-utils/version.sh
- docker build --build-arg VROOM_VERSION=${VROOM_VERSION:-v1.2.0} --build-arg OPTIMIZER_ORTOOLS_VERSION=$OPTIMIZER_ORTOOLS_VERSION -f docker/Dockerfile -t registry.test.com/mapotempo/optimizer-api:latest .
- docker swarm init
- mkdir -p ./redis
- docker stack deploy -c ./docker/docker-compose.yml optimizer
Expand All @@ -13,25 +14,25 @@ jobs:
- stage: "Tests"
install: skip
env: TEST_SUITE='basis'
script: bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='dicho'
install: skip
script: travis_wait 60 bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='scheduling'
install: skip
script: bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='real_scheduling'
install: skip
script: travis_wait 60 bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='real_scheduling_solver'
install: skip
script: travis_wait 60 bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='split_clustering'
install: skip
script: bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- env: TEST_SUITE='real'
install: skip
script: bash ci-utils/tests.sh ${TEST_SUITE}
script: travis_wait 50 bash ci-utils/tests.sh ${TEST_SUITE}
- stage: deploy
name: "Deploy"
install: skip
Expand Down
2 changes: 2 additions & 0 deletions api/v01/vrp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ def self.vrp_request_schedule(this)
optional(:configuration, type: Hash, documentation: { hidden: true, desc: 'Describe the limitations of the solve in term of computation' }, coerce_with: ->(c) { c.has_key?('filename') ? JSON.parse(c.tempfile.read) : c }) do
Vrp.vrp_request_configuration(self)
end

exactly_one_of :vrp, :vehicles # either it is a json (and :vrp is required) or it is a csv (and :vehicles is required)
}
post do
begin
Expand Down
7 changes: 7 additions & 0 deletions ci-utils/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

if [[ $TRAVIS_BRANCH == "master" ]] || [[ $TRAVIS_TAG != "" ]]; then
export OPTIMIZER_ORTOOLS_VERSION="v1.3.0";
else
export OPTIMIZER_ORTOOLS_VERSION=${OPTIMIZER_ORTOOLS_VERSION:-Mapotempo};
fi
5 changes: 3 additions & 2 deletions lib/interpreters/compute_several_solutions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def self.find_best_heuristic(service_vrp)
if custom_heuristics.size > 1
log '---> find_best_heuristic'
tic = Time.now
total_time_allocated_for_heuristic_selection = service_vrp[:vrp].resolution_duration.to_f * 0.30 # spend at most 30% of the total time for heuristic selection
percent_allocated_to_heur_selection = 0.3 # spend at most 30% of the total time for heuristic selection
total_time_allocated_for_heuristic_selection = service_vrp[:vrp].resolution_duration.to_f * percent_allocated_to_heur_selection
batched_service_vrps = batch_heuristic([service_vrp], custom_heuristics).flatten(1)
times = []
first_results = batched_service_vrps.collect{ |s_vrp|
Expand Down Expand Up @@ -202,7 +203,7 @@ def self.find_best_heuristic(service_vrp)
vrp.resolution_batch_heuristic = nil
vrp.preprocessing_first_solution_strategy = [best_heuristic]
vrp.preprocessing_heuristic_synthesis = synthesis
vrp.resolution_duration = vrp.resolution_duration ? (vrp.resolution_duration - times.sum).floor : nil
vrp.resolution_duration = vrp.resolution_duration ? [(vrp.resolution_duration.to_f * (1 - percent_allocated_to_heur_selection)).round, 1000].max : nil
senhalil marked this conversation as resolved.
Show resolved Hide resolved
log "<--- find_best_heuristic elapsed: #{Time.now - tic}sec selected heuristic: #{best_heuristic}"
else
vrp.preprocessing_first_solution_strategy = custom_heuristics
Expand Down
Binary file modified test/fixtures/minimum_duration_lapse_shipments.dump
Binary file not shown.
2 changes: 1 addition & 1 deletion test/fixtures/minimum_duration_lapse_shipments.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@
"resolution": {
"vehicle_limit": 6,
"minimum_duration": null,
"duration": 6000
"duration": 15000
}
},
"name": null
Expand Down
24 changes: 24 additions & 0 deletions test/wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3046,4 +3046,28 @@ def test_detecting_unfeasible_services_can_not_take_too_long

assert_operator total_time, :<=, 14.0
end

def test_initial_route_with_infeasible_service
# service_1 is eliminated due to
# "Incompatibility between service skills and sticky vehicles"
# but it is referenced inside an initial route which should not cause an issue
problem = VRP.basic

problem[:vehicles] += [{
id: 'vehicle_1',
matrix_id: 'matrix_0',
start_point_id: 'point_0',
skills: [['vehicle_1']]
}]

problem[:services][0][:skills] = ['vehicle_1']
problem[:services][0][:sticky_vehicle_ids] = ['vehicle_0']

problem[:routes] = [{
vehicle_id: 'vehicle_0',
mission_ids: ['service_1', 'service_2', 'service_3']
}]

assert OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(problem), nil)
end
end
6 changes: 5 additions & 1 deletion util/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OptimizerLogger
@@logger.formatter = proc do |severity, datetime, progname, msg|
datetime = OptimizerLogger.with_datetime ? "[#{datetime}]" : nil
job_id = OptimizerWrapper::Job.current_job_id ? "#{OptimizerWrapper::Job.current_job_id} -" : nil
progname = progname.empty? ? nil : "- #{progname}"
progname = progname&.empty? ? nil : "- #{progname}"

[datetime, job_id, severity, progname].compact.join(' ') + ": #{msg}\n"
end
Expand Down Expand Up @@ -104,6 +104,10 @@ def self.log_device=(logdev)
@@logger.reopen logdev
end

def self.logger
@@logger
end

def self.formatter=(formatter)
@@logger.formatter = formatter
end
Expand Down
2 changes: 1 addition & 1 deletion wrappers/ortools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def run_ortools(problem, vrp, services, points, matrix_indices, thread_proc = ni
s && (cost = Float(s[1]))
t = /Time : ([0-9.eE+]+)/.match(line)
t && (time = t[1].to_f)
log line.strip, level: (/Final Iteration :/.match(line) || /First solution strategy :/.match(line) || /Using initial solution provided./.match(line) || /OR-Tools v[0-9]+\.[0-9]+\.[0-9]+\n/.match(line)) ? :info : (r || s || t) ? :debug : :error
log line.strip, level: (/Final Iteration :/.match(line) || /First solution strategy :/.match(line) || /Using initial solution provided./.match(line) || /OR-Tools v[0-9]+\.[0-9]+\n/.match(line)) ? :info : (r || s || t) ? :debug : :error
out += line

next unless r && t # if there is no iteration and time then there is nothing to do
Expand Down
2 changes: 2 additions & 0 deletions wrappers/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ def check_distances(vrp, unfeasible)

log "Following services marked as infeasible:\n#{unfeasible.group_by{ |u| u[:reason] }.collect{ |g, set| "#{(set.size < 20) ? set.collect{ |s| s[:service_id] }.join(', ') : "#{set.size} services"}\n with reason '#{g}'" }.join("\n")}", level: :debug unless unfeasible.empty?

log "#{unfeasible.size} services marked as infeasible with the following reasons: #{unfeasible.collect{ |u| u[:reason] }.uniq.join(', ')}", level: :info unless unfeasible.empty?

unfeasible
end

Expand Down