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 8, 2022
1 parent 7db0527 commit 5696ca0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Exclusive position for activities that needs to be both first and last position [#438](https://github.com/Mapotempo/optimizer-api/pull/438)
- The intermediate solutions are now cleaned similarly to the final solution [#435](https://github.com/Mapotempo/optimizer-api/pull/435)

### Changed

Expand Down
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 @@ -105,7 +105,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 5696ca0

Please sign in to comment.