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

clean intermediate solutions #435

Merged
merged 1 commit into from
Jul 8, 2022
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
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