AV
Size: a a a
AV
AV
MK
AV
AV
ST
AI
MK
ST
(partial +)
даст менее производительный вариант, чем #(+ ^int %1 ^int %2)
T
val fleet = problem.fleet
val tours = solution.tours.orEmpty()
val tourVehicles = tours.map { t -> fleet.types.find { vt -> vt.id == t.typeId } }
val violatingTours = tours.zip(tourVehicles)
.filter { (tour, vehicleType) ->
vehicleType == null || tour.stops.any { s ->
s.load.zip(vehicleType.capacity).any { (l, c) -> l > c }
}
}
T
(defn vehicle-by-type [fleet type-name]
(m/find fleet
{:types
(m/scan {:id ~type-name :as ?vechicle})}
?vechicle))
(defn capacity-not-exceded? [vechicle stop]
(let [load (:load stop)
capacity (:capacity vechicle)]
(some true? (map < capacity load))))
(defn find-capacity-violation [tour fleet]
(let [type-name (:typeId tour)
vechicle-type (vehicle-by-type fleet type-name)
stops (:stops tour)]
(filter (partial capacity-not-exceded? vechicle-type) stops)))
(defn validate-maximal-capacity [problem solution]
(let [fleet (:fleet problem)
tours (:tours solution)]
(->> tours
(map #(find-capacity-violation % fleet))
(remove empty?)
)))
НМ
T
AI
(->> tours
(map #(find-capacity-violation % fleet))
(remove empty?))
NK
AI
T
(->> tours
(map #(find-capacity-violation % fleet))
(remove empty?))