Skip to content

Commit

Permalink
Fix find_best_heuristic selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
senhalil committed Jan 31, 2022
1 parent 62e427c commit 5d9cef9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

### Added


### Changed


### Removed


### Fixed

- Fix find_best_heuristic selection logic [#337](https://github.com/Mapotempo/optimizer-api/pull/337)

## [v1.8.2] - 2022-01-19

### Added
Expand Down
3 changes: 2 additions & 1 deletion lib/interpreters/compute_several_solutions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def self.find_best_heuristic(service_vrp)
first_results.each_with_index{ |result, i|
synthesis << {
heuristic: custom_heuristics[i],
quality: result.nil? ? Float::MAX : result[:cost].to_i + (times[i] / 1000).to_i,
# If the cost is 0 we might want to set it to Float::MAX because 0 cost is not possible.
quality: result.nil? ? [Float::MAX] : [result[:unassigned]&.size.to_i, result[:cost].to_i, times[i]],
used: false,
cost: result ? result[:cost] : nil,
time_spent: times[i],
Expand Down

0 comments on commit 5d9cef9

Please sign in to comment.