diff --git a/build.gradle b/build.gradle index 79c99d5cd0d..2cddc054761 100755 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,3 @@ -import com.amazonaws.services.lambda.model.InvocationType -import jp.classmethod.aws.gradle.lambda.AWSLambdaInvokeTask -import com.bmuschko.gradle.docker.tasks.image.* - import java.time.Instant import java.time.ZoneOffset import java.time.format.DateTimeFormatter @@ -150,6 +146,10 @@ dependencies { compile "org.jgrapht:jgrapht-core:1.3.0" + compile ('com.github.LBNL-UCB-STI:or-tools-wrapper:7.5-0'){ + exclude group: 'com.google.protobuf', module: 'protobuf-java' + } + // GPLv3 compile group: 'org.matsim.contrib', name: 'multimodal', version: '0.10.0' compile group: 'org.matsim.contrib', name: 'bicycle', version: '0.10.0' @@ -225,10 +225,6 @@ dependencies { compile "com.github.vagmcs:optimus_${scalaBinaryVersion}:3.1.0" compile "com.github.vagmcs:optimus-solver-oj_${scalaBinaryVersion}:3.1.0" - compile("io.github.oliviercailloux:google-or-tools:6.7.2") { - exclude group: 'com.google.protobuf', module: 'protobuf-java' - } - //////////////////////////////////// ///Performance Monitoring (Kamon)/// //////////////////////////////////// diff --git a/src/main/scala/beam/agentsim/agents/ridehail/AlonsoMoraPoolingAlgForRideHail.scala b/src/main/scala/beam/agentsim/agents/ridehail/AlonsoMoraPoolingAlgForRideHail.scala index 6caa487c4bd..837e55b737f 100644 --- a/src/main/scala/beam/agentsim/agents/ridehail/AlonsoMoraPoolingAlgForRideHail.scala +++ b/src/main/scala/beam/agentsim/agents/ridehail/AlonsoMoraPoolingAlgForRideHail.scala @@ -13,6 +13,7 @@ import beam.router.Modes.BeamMode import beam.router.skim.SkimsUtils import beam.sim.BeamServices import beam.sim.config.BeamConfig.Beam.Agentsim.Agents.RideHail.AllocationManager +import com.github.beam.OrToolsLoader import com.google.ortools.linearsolver.{MPSolver, MPVariable} import org.jgrapht.graph.DefaultEdge import org.matsim.core.utils.collections.QuadTree @@ -23,12 +24,20 @@ import scala.collection.mutable import scala.collection.mutable.ListBuffer import scala.concurrent.Future +object AlonsoMoraPoolingAlgForRideHail { + private lazy val initialize: Unit = { + OrToolsLoader.load() + } +} + class AlonsoMoraPoolingAlgForRideHail( spatialDemand: QuadTree[CustomerRequest], supply: List[VehicleAndSchedule], beamServices: BeamServices ) extends RHMatchingAlgorithm { + AlonsoMoraPoolingAlgForRideHail.initialize + // Methods below should be kept as def (instead of val) to allow automatic value updating private def alonsoMora: AllocationManager.AlonsoMora = beamServices.beamConfig.beam.agentsim.agents.rideHail.allocationManager.alonsoMora @@ -234,6 +243,7 @@ class AlonsoMoraPoolingAlgForRideHail( epsilonCostMap.flatMap(_._2.values).foreach { case (epsilon, c) => objective.setCoefficient(epsilon, c) } + objective.setMinimization() val resultStatus = solver.solve if (resultStatus ne MPSolver.ResultStatus.OPTIMAL) {