Created
September 10, 2015 03:03
-
-
Save kreas/bece522dc38754fea78d to your computer and use it in GitHub Desktop.
optimize_route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Route | |
API_KEY = 'XXXXXXXXXXXXXXXX' | |
ADDRESSES = [· | |
{:index=>0, :lat=>36.08290100097656, :lng=>-87.09459686279297, :site_id=>1532, :address=>"162 Luyben Hills Rd, Kingston Springs, TN, 37082"}, | |
{:index=>1, :lat=>35.911598205566406, :lng=>-84.14720153808594, :site_id=>1517, :address=>"608 Lovell Rd., Knoxville, TN, 37932"}, | |
{:index=>2, :lat=>41.52130126953125, :lng=>-83.46160125732422, :site_id=>1967, :address=>"3483 Libbey Rd., Perrysburg, OH, 43551"} | |
] | |
def self.addresses | |
File.open('./addresses.json', "r") do |f| | |
JSON.load(f) | |
end | |
end | |
def self.route | |
Route4me.api_key = API_KEY | |
Route4me::OptimizationProblem.optimize( | |
:addresses => ADDRESSES, | |
:parameters => { | |
:algorithm_type => Route4me::AlgorithmType::TSP, | |
:distance_unit => Route4me::DistanceUnit::MILES, | |
:device_type => Route4me::DeviceType::WEB, | |
:optimize => Route4me::OptimizationType::DISTANCE, | |
:travel_mode => Route4me::TravelMode::DRIVING, | |
:vehicle_capacity => 1, | |
:vehicle_max_distance_mi => 10000 | |
} | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment