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

dh001 #203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

dh001 #203

Show file tree
Hide file tree
Changes from all 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
17 changes: 11 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<artifactId>amodtaxi</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>ch.ethz.idsc</groupId>
<artifactId>java</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -34,24 +39,24 @@

<repositories>
<repository>
<id>tensor-mvn-repo</id>
<url>https://raw.github.com/amodeus-science/tensor/mvn-repo/</url>
<id>amodeus-mvn-repo</id>
<url>https://raw.github.com/amodeus-science/amodeus/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>amodeus-mvn-repo</id>
<url>https://raw.github.com/amodeus-science/amodeus/mvn-repo/</url>
<id>amodtaxi-mvn-repo</id>
<url>https://raw.github.com/amodeus-science/amodtaxi/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>amodtaxi-mvn-repo</id>
<url>https://raw.github.com/amodeus-science/amodtaxi/mvn-repo/</url>
<id>java-mvn-repo</id>
<url>https://raw.github.com/datahaki/java/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/amodeus/amod/ScenarioPreparer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
import java.io.File;
import java.net.MalformedURLException;

import amodeus.amodeus.options.ScenarioOptions;
import amodeus.amodeus.options.ScenarioOptionsBase;
import amodeus.amodeus.prep.ConfigCreator;
import amodeus.amodeus.prep.NetworkPreparer;
import amodeus.amodeus.prep.PopulationPreparer;
import amodeus.amodeus.prep.TheApocalypse;
import amodeus.amodeus.prep.VirtualNetworkPreparer;
import amodeus.amodeus.util.io.MultiFileTools;
import org.matsim.amodeus.config.AmodeusConfigGroup;
import org.matsim.amodeus.config.modal.GeneratorConfig;
import org.matsim.api.core.v01.Scenario;
Expand All @@ -22,6 +14,14 @@
import org.matsim.core.scenario.ScenarioUtils;

import amodeus.amod.ext.Static;
import amodeus.amodeus.options.ScenarioOptions;
import amodeus.amodeus.options.ScenarioOptionsBase;
import amodeus.amodeus.prep.ConfigCreator;
import amodeus.amodeus.prep.NetworkPreparer;
import amodeus.amodeus.prep.PopulationPreparer;
import amodeus.amodeus.prep.TheApocalypse;
import amodeus.amodeus.prep.VirtualNetworkPreparer;
import amodeus.amodeus.util.io.MultiFileTools;

/** Class to prepare a given scenario for MATSim, includes preparation of
* network, population, creation of virtualNetwork and travelData objects. As an
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/amodeus/amod/ScenarioServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
import java.net.MalformedURLException;
import java.util.Objects;

import amodeus.amodeus.analysis.Analysis;
import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.ReferenceFrame;
import amodeus.amodeus.linkspeed.TaxiTravelTimeRouter;
import amodeus.amodeus.net.MatsimAmodeusDatabase;
import amodeus.amodeus.net.SimulationServer;
import amodeus.amodeus.options.ScenarioOptions;
import amodeus.amodeus.options.ScenarioOptionsBase;
import amodeus.amodeus.util.io.MultiFileTools;
import amodeus.amodeus.util.math.GlobalAssert;
import amodeus.amodeus.util.matsim.AddCoordinatesToActivities;
import org.matsim.amodeus.AmodeusConfigurator;
import org.matsim.amodeus.config.AmodeusConfigGroup;
import org.matsim.amodeus.framework.AmodeusUtils;
Expand All @@ -35,6 +24,17 @@
import amodeus.amod.dispatcher.DemoDispatcher;
import amodeus.amod.ext.Static;
import amodeus.amod.generator.DemoGenerator;
import amodeus.amodeus.analysis.Analysis;
import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.ReferenceFrame;
import amodeus.amodeus.linkspeed.TaxiTravelTimeRouter;
import amodeus.amodeus.net.MatsimAmodeusDatabase;
import amodeus.amodeus.net.SimulationServer;
import amodeus.amodeus.options.ScenarioOptions;
import amodeus.amodeus.options.ScenarioOptionsBase;
import amodeus.amodeus.util.io.MultiFileTools;
import amodeus.amodeus.util.math.GlobalAssert;
import amodeus.amodeus.util.matsim.AddCoordinatesToActivities;

/** This class runs an AMoDeus simulation based on MATSim. The results can be
* viewed if the {@link ScenarioViewer} is executed in the same working
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/amodeus/amod/ScenarioViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import java.io.FileNotFoundException;
import java.io.IOException;

import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;

import amodeus.amod.ext.Static;
import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.ReferenceFrame;
import amodeus.amodeus.gfx.AmodeusComponent;
Expand All @@ -16,11 +21,6 @@
import amodeus.amodeus.util.io.MultiFileTools;
import amodeus.amodeus.util.matsim.NetworkLoader;
import amodeus.amodeus.virtualnetwork.core.VirtualNetworkGet;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;

import amodeus.amod.ext.Static;

/** the viewer allows to connect to the scenario server or to view saved simulation results. */
/* package */ enum ScenarioViewer {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/amodeus/amod/analysis/CustomAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

import java.io.File;

import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;

import amodeus.amod.ext.Static;
import amodeus.amodeus.analysis.Analysis;
import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.ReferenceFrame;
Expand All @@ -13,11 +18,6 @@
import amodeus.amodeus.options.ScenarioOptionsBase;
import amodeus.amodeus.util.io.MultiFileTools;
import amodeus.amodeus.util.matsim.NetworkLoader;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;

import amodeus.amod.ext.Static;

/** This is a demonstration of the functionality of AMoDeus that customized analysis and reporting
* elements can be easily added. In this example, we present the case in which for every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@

import java.io.File;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAnchor;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.plot.CategoryPlot;
import org.matsim.amodeus.dvrp.request.AmodeusRequest;

import amodeus.amodeus.analysis.AnalysisSummary;
import amodeus.amodeus.analysis.element.AnalysisExport;
import amodeus.amodeus.analysis.plot.AmodeusChartUtils;
import amodeus.amodeus.dispatcher.core.RoboTaxi;
import amodeus.amodeus.util.math.GlobalAssert;
import amodeus.tensor.fig.Histogram;
import amodeus.tensor.fig.VisualSet;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAnchor;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.plot.CategoryPlot;
import org.matsim.amodeus.dvrp.request.AmodeusRequest;

import ch.ethz.idsc.tensor.RationalScalar;
import ch.ethz.idsc.tensor.RealScalar;
import ch.ethz.idsc.tensor.Scalar;
import ch.ethz.idsc.tensor.Scalars;
import ch.ethz.idsc.tensor.Tensor;
import ch.ethz.idsc.tensor.Unprotect;
import ch.ethz.idsc.tensor.alg.Range;
import ch.ethz.idsc.tensor.img.ColorDataIndexed;
import ch.ethz.idsc.tensor.pdf.BinCounts;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void summaryTarget(AnalysisSummary analysisSummary, File relativeDirector
visualSet.setAxesLabelY("% of RoboTaxis");
visualSet.setAxesLabelX("Requests");

JFreeChart jFreeChart = Histogram.of(visualSet, s -> "[" + s.number() + " , " + s.add(histoGrambinSize).number() + ")");
JFreeChart jFreeChart = Histogram.of(visualSet, s -> "[" + Unprotect.withoutUnit(s).number() + " , " + Unprotect.withoutUnit(s.add(histoGrambinSize)).number() + ")");
CategoryPlot categoryPlot = jFreeChart.getCategoryPlot();
categoryPlot.getDomainAxis().setLowerMargin(0.0);
categoryPlot.getDomainAxis().setUpperMargin(0.0);
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/amodeus/amod/dispatcher/DemoDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
import java.util.Map;
import java.util.Random;

import amodeus.amodeus.dispatcher.core.DispatcherUtils;
import amodeus.amodeus.dispatcher.core.RebalancingDispatcher;
import amodeus.amodeus.dispatcher.core.RoboTaxi;
import amodeus.amodeus.dispatcher.core.RoboTaxiUsageType;
import amodeus.amodeus.dispatcher.util.DrivebyRequestStopper;
import amodeus.amodeus.net.MatsimAmodeusDatabase;
import amodeus.amodeus.util.matsim.SafeConfig;
import org.matsim.amodeus.components.AmodeusDispatcher;
import org.matsim.amodeus.components.AmodeusRouter;
import org.matsim.amodeus.config.AmodeusModeConfig;
Expand All @@ -25,6 +18,14 @@
import org.matsim.core.config.Config;
import org.matsim.core.router.util.TravelTime;

import amodeus.amodeus.dispatcher.core.DispatcherUtils;
import amodeus.amodeus.dispatcher.core.RebalancingDispatcher;
import amodeus.amodeus.dispatcher.core.RoboTaxi;
import amodeus.amodeus.dispatcher.core.RoboTaxiUsageType;
import amodeus.amodeus.dispatcher.util.DrivebyRequestStopper;
import amodeus.amodeus.net.MatsimAmodeusDatabase;
import amodeus.amodeus.util.matsim.SafeConfig;

/** Dispatcher sends vehicles to all links in the network and lets them pickup
* any customers which are waiting along the road. */
public class DemoDispatcher extends RebalancingDispatcher {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/amodeus/amod/ext/Static.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import java.io.OutputStream;
import java.util.Properties;

import org.gnu.glpk.GLPK;

import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.LocationSpecDatabase;
import amodeus.amodeus.options.LPOptionsBase;
import org.gnu.glpk.GLPK;

public enum Static {
;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/amodeus/amod/ext/UserLocationSpecs.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* amod - Copyright (c) 2018, ETH Zurich, Institute for Dynamic Systems and Control */
package amodeus.amod.ext;

import org.matsim.api.core.v01.Coord;

import amodeus.amodeus.data.LocationSpec;
import amodeus.amodeus.data.ReferenceFrame;
import org.matsim.api.core.v01.Coord;

/* package */ enum UserLocationSpecs implements LocationSpec {
SANFRANCISCO( //
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/amodeus/amod/ext/UserReferenceFrames.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* amod - Copyright (c) 2018, ETH Zurich, Institute for Dynamic Systems and Control */
package amodeus.amod.ext;

import amodeus.amodeus.data.ReferenceFrame;
import amodeus.amodeus.util.math.SI;
import org.matsim.core.utils.geometry.CoordinateTransformation;
import org.matsim.core.utils.geometry.transformations.GeotoolsTransformation;
import org.matsim.core.utils.geometry.transformations.IdentityTransformation;

import amodeus.amodeus.data.ReferenceFrame;
import amodeus.amodeus.util.math.SI;
import ch.ethz.idsc.tensor.qty.Unit;

/* package */ enum UserReferenceFrames implements ReferenceFrame {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/amodeus/amod/generator/DemoGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.util.LinkedList;
import java.util.List;

import amodeus.amodeus.dispatcher.core.RoboTaxi;
import amodeus.amodeus.generator.RandomDensityGenerator;
import org.apache.log4j.Logger;
import org.matsim.amodeus.components.AmodeusGenerator;
import org.matsim.amodeus.components.generator.AmodeusIdentifiers;
Expand All @@ -21,6 +19,9 @@
import org.matsim.contrib.dvrp.run.ModalProviders.InstanceGetter;
import org.matsim.core.gbl.MatsimRandom;

import amodeus.amodeus.dispatcher.core.RoboTaxi;
import amodeus.amodeus.generator.RandomDensityGenerator;


/** the initial placement of {@link RoboTaxi} in the {@link Network} is determined
* with an {@link AmodeusGenerator}. In most cases it is sufficient to use the
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/amodeus/amod/router/CustomRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.IOException;
import java.util.concurrent.Future;

import amodeus.amodeus.dispatcher.core.RoboTaxi;
import org.matsim.amodeus.components.AmodeusRouter;
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.network.Node;
Expand All @@ -13,6 +12,8 @@
import org.matsim.core.router.util.LeastCostPathCalculator.Path;
import org.matsim.vehicles.Vehicle;

import amodeus.amodeus.dispatcher.core.RoboTaxi;

/** This is a nonfunctional sample demonstrating of how to include a custom router
* to AMoDeus which is not the standard choice of the Paralllel Djikstra router used
* normally to calculate the path for {@link RoboTaxi} */
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/amodeus/socket/SocketExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

import java.io.File;

import org.jfree.chart.JFreeChart;

import amodeus.amodeus.analysis.AnalysisSummary;
import amodeus.amodeus.analysis.UnitSaveUtils;
import amodeus.amodeus.analysis.element.AnalysisExport;
import amodeus.amodeus.analysis.element.AnalysisMeanFilter;
import amodeus.amodeus.analysis.plot.AmodeusChartUtils;
import amodeus.amodeus.util.math.GlobalAssert;
import amodeus.socket.core.SocketScoreElement;
import amodeus.tensor.fig.TimedChart;
import amodeus.tensor.fig.VisualRow;
import amodeus.tensor.fig.VisualSet;
import org.jfree.chart.JFreeChart;

import amodeus.socket.core.SocketScoreElement;
import ch.ethz.idsc.tensor.Tensor;
import ch.ethz.idsc.tensor.Unprotect;
import ch.ethz.idsc.tensor.img.ColorDataIndexed;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void summaryTarget(AnalysisSummary analysisSummary, File relativeDirector
new String[] { "fleet size score integrated" }, //
"time of day", "scores integrated", time, fleetSizeScoreIntg, colorScheme);
File fileChart = new File(relativeDirectory, FILENAME_SCORE_INTG);
chart.getXYPlot().getRangeAxis().setRange(fleetSizeScoreIntg.get(0).Get(0).number().intValue() * 2.0, 0.0);
chart.getXYPlot().getRangeAxis().setRange(Unprotect.withoutUnit(fleetSizeScoreIntg.Get(0,0)).number().intValue() * 2.0, 0.0);
AmodeusChartUtils.saveAsPNG(chart, fileChart.toString(), WIDTH, HEIGHT);
GlobalAssert.that(fileChart.isFile());
} catch (Exception e1) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/amodeus/socket/SocketHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.File;
import java.util.Objects;

import org.matsim.amodeus.config.AmodeusModeConfig;

import amodeus.amodeus.analysis.Analysis;
import amodeus.amodeus.options.ScenarioOptions;
import amodeus.amodeus.options.ScenarioOptionsBase;
Expand All @@ -14,15 +16,14 @@
import amodeus.amodeus.util.net.StringServerSocket;
import amodeus.amodeus.util.net.StringSocket;
import amodeus.amodeus.video.VideoGenerator;
import org.matsim.amodeus.config.AmodeusModeConfig;

import amodeus.socket.core.ScoreParameters;
import amodeus.socket.core.SocketDispatcherHost;
import amodeus.socket.core.SocketScoreElement;
import ch.ethz.idsc.tensor.RealScalar;
import ch.ethz.idsc.tensor.Scalar;
import ch.ethz.idsc.tensor.Tensor;
import ch.ethz.idsc.tensor.Tensors;
import ch.ethz.idsc.tensor.Unprotect;
import ch.ethz.idsc.tensor.red.Total;
import ch.ethz.idsc.tensor.sca.Round;

Expand Down Expand Up @@ -86,8 +87,8 @@ public static void run(File workingDirectory) throws Exception {
/** get additional information */
String readLine2 = stringSocket.readLine();
Tensor config2 = Tensors.fromString(readLine2);
int numReqDes = config2.Get(0).number().intValue();
int fleetSize = config2.Get(1).number().intValue();
int numReqDes = Unprotect.withoutUnit(config2.Get(0)).number().intValue();
int fleetSize = Unprotect.withoutUnit(config2.Get(1)).number().intValue();

{
String env = System.getenv(ENV_REQUESTS_SIZE);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/amodeus/socket/SocketModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

import java.util.Objects;

import amodeus.amodeus.util.net.StringSocket;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.controler.AbstractModule;

import com.google.inject.Provides;
import com.google.inject.Singleton;

import amodeus.amodeus.util.net.StringSocket;

public class SocketModule extends AbstractModule {
private final StringSocket stringSocket;
private final int numReqTot;
Expand Down
Loading