Skip to content

Commit

Permalink
clean intermediate solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Graber committed Jul 5, 2022
1 parent a4d76c0 commit 3a447a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
29 changes: 29 additions & 0 deletions test/api/v01/with_solver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,33 @@ def test_returned_graph
end
delete_completed_job @job_id, api_key: 'ortools' if @job_id
end

def test_filter_intermediate_solution
# Verify that intermediate solution are correctly filtered
asynchronously start_worker: true do
vrp = VRP.lat_lon
vrp[:configuration][:resolution][:duration] = 2000
vrp[:units] = [{id: 'unit_1'}]
vrp[:services].each{ |s|
s[:quantities] = [{unit_id: 'unit_1', value: 1}]
}
vrp[:services] << {
id: 'vidage_1',
activity: {
point_id: 'point_0'
},
quantities: [{
unit_id: 'unit_1',
empty: true
}]
}
vrp[:vehicles].first[:capacities] = [{unit_id: 'unit_1', limit: 10}]
vrp[:services] << vrp[:services].last.dup.tap{ |s| s[:id] = 'vidage_2'}
vrp[:configuration][:restitution][:intermediate_solutions] = true
@job_id = submit_vrp api_key: 'ortools', vrp: vrp
result = wait_avancement_match(@job_id, /run optimization, iterations/, api_key: 'ortools')
assert_equal "Duplicate empty service.", result['solutions'].first["unassigned"].first["reason"]
end
delete_job(@job_id, api_key: 'ortools') if @job_id
end
end
5 changes: 4 additions & 1 deletion util/job_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def perform
geometry: ask_restitution_geojson
}
p[:graph] << { iteration: avancement, cost: cost, time: time }
p[:result] = [solution.vrp_result].flatten if solution
if solution
Cleanse.cleanse(services_vrps.first[:vrp], solution)
p[:result] = [solution.vrp_result].flatten
end
begin
Result.set(self.uuid, p)
rescue Redis::BaseError => e
Expand Down

0 comments on commit 3a447a4

Please sign in to comment.