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

Add or-tools #2377

Merged
merged 7 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -150,6 +146,10 @@ dependencies {

compile "org.jgrapht:jgrapht-core:1.3.0"

compile(group: 'com.github.LBNL-UCB-STI', name: 'or-tools-wrapper', version: '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'
Expand Down Expand Up @@ -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)///
////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down