Permalink
Browse files

cleanups

  • Loading branch information...
akegermany committed Sep 25, 2018
1 parent 39865fc commit 9d7935346f02db113c1045a809f8fa7e4fa1770e
@@ -24,7 +24,7 @@
* Container for some shared information. Singleton pattern. <br>
* created: Mar 9, 2013<br>
*/
// TODO this class deperately needs a throughout refactoring !!!
// TODO this class needs a throughout refactoring !!!
public final class ProjectMetaData {
private static final String MOVSIM_COMMON_LOG_PATH = "config";
@@ -43,8 +43,6 @@
private String xodrNetworkFilename;
private String xodrPath;
private String consumptionFilename;
private String consumptionPath;
@@ -26,24 +26,10 @@ private CsvReaderUtil() {
List<String[]> myEntries = Lists.newArrayList();
// see http://opencsv.sourceforge.net/#how-to-read
CSVReader reader = null;
try {
reader = new CSVReader(new FileReader(file), separator);
try (CSVReader reader = new CSVReader(new FileReader(file), separator)) {
myEntries = reader.readAll();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
}
return myEntries;
}
@@ -5,5 +5,5 @@
/**
* Callback to allow the application to close all open resources in an ordered way before the program exits.
*/
public void onShutDown();
void onShutDown();
}
@@ -28,33 +28,33 @@
public interface Units {
/** converts 1/s to 1/h, factor is 3600 */
final double INVS_TO_INVH = 3600.;
double INVS_TO_INVH = 3600.;
/** converts 1/h to 1/s, factor is 1/3600 */
final double INVH_TO_INVS = 1 / INVS_TO_INVH;
double INVH_TO_INVS = 1 / INVS_TO_INVH;
/** converts m/s to km/h, factor is 3.6 */
final double MS_TO_KMH = 3.6;
double MS_TO_KMH = 3.6;
/** converts km/h to m/s, factor is 1/3.6 */
final double KMH_TO_MS = 1. / MS_TO_KMH;
double KMH_TO_MS = 1. / MS_TO_KMH;
/** converts from 1/m to 1/km, factor is 1000 */
final double INVM_TO_INVKM = 1000.;
double INVM_TO_INVKM = 1000.;
/** converts from 1/km to 1/m, factor is 1/1000 */
final double INVKM_TO_INVM = 1. / INVM_TO_INVKM;
double INVKM_TO_INVM = 1. / INVM_TO_INVKM;
/** converts meter to kilometer. Factor is 1000. */
final double KM_TO_M = 1000;
double KM_TO_M = 1000;
/** converts kilometer to meter. Factor is 1/1000. */
final double M_TO_KM = 1. / KM_TO_M;
double M_TO_KM = 1. / KM_TO_M;
/** converts hours to seconds. Factor is 3600. */
final double H_TO_S = 3600;
double H_TO_S = 3600;
/** converts seconds to hours. Factor is 1/3600. */
final double S_TO_H = 1 / H_TO_S;
double S_TO_H = 1 / H_TO_S;
}
@@ -14,7 +14,7 @@
// private static final Logger LOG = LoggerFactory.getLogger(RoadGeometry.class);
public enum GeometryType {
LINE, ARC, SPIRAL, POLY3;
LINE, ARC, SPIRAL, POLY3
}
protected final Geometry geometry;
@@ -2,25 +2,25 @@
* Copyright (C) 2010, 2011, 2012 by Arne Kesting, Martin Treiber, Ralph Germ, Martin Budden
* <movsim.org@gmail.com>
* -----------------------------------------------------------------------------------------
*
*
* This file is part of
*
*
* MovSim - the multi-model open-source vehicular-traffic simulator.
*
*
* MovSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* MovSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with MovSim. If not, see <http://www.gnu.org/licenses/>
* or <http://www.movsim.org>.
*
*
* -----------------------------------------------------------------------------------------
*/
package org.movsim.simulator;
@@ -35,33 +35,32 @@
public class SimulationRun {
public interface CompletionCallback {
/**
* Callback to inform the application that the simulation has run to
* completion.
*
* @param simulationTime
*/
void simulationComplete(double simulationTime);
/**
* Callback to inform the application that the simulation has run to
* completion.
*
* @param simulationTime
*/
void simulationComplete(double simulationTime);
}
public interface UpdateStatusCallback {
/**
* Callback to allow the application to make updates to its state after
* the vehicle positions etc have been updated, but before the repaint
* is called.
*
* @param simulationTime
* the current logical time in the simulation
*/
public void updateStatus(double simulationTime);
/**
* Callback to allow the application to make updates to its state after
* the vehicle positions etc have been updated, but before the repaint
* is called.
*
* @param simulationTime the current logical time in the simulation
*/
void updateStatus(double simulationTime);
}
protected double dt; // timestep, seconds
protected double duration; // duration, seconds
protected double simulationTime; // Simulation time, seconds (reset to 0.0
// in each run)
// in each run)
protected long iterationCount;
@@ -76,125 +75,122 @@
/**
* Constructor, sets the simulation object.
*
* @param simulation
* a simulation object that implements the SimulationTimeStep
* interface
*
* @param simulation a simulation object that implements the SimulationTimeStep
* interface
*/
public SimulationRun(SimulationTimeStep simulation) {
this.simulation = Preconditions.checkNotNull(simulation);
initShutdownHook();
this.simulation = Preconditions.checkNotNull(simulation);
initShutdownHook();
}
/**
* Returns the simulation timestep object.
*
*
* @return the simulation timestep object
*/
public final SimulationTimeStep simulation() {
return simulation;
return simulation;
}
/**
* Sets the simulation timestep.
*
* @param dt
* simulation timestep in seconds
*
* @param dt simulation timestep in seconds
*/
public final void setTimeStep(double dt) {
this.dt = dt;
this.dt = dt;
}
/**
* Returns the simulation timestep
*
*
* @return simulation timestep in seconds
*/
public final double timeStep() {
return dt;
return dt;
}
/**
* Sets the simulation duration.
*
* @param duration
* simulation duration in seconds
*
* @param duration simulation duration in seconds
*/
public final void setDuration(double duration) {
this.duration = duration;
this.duration = duration;
}
/**
* Returns the simulation duration.
*
*
* @return simulation duration in seconds
*/
public final double duration() {
return duration;
return duration;
}
/**
* Returns the number of iterations executed.
*
*
* @return number of iterations
*/
public final long iterationCount() {
return iterationCount;
return iterationCount;
}
/**
* <p>
* Returns the time for which the simulation has been running.
* </p>
*
*
* <p>
* This is the logical time in the simulation (that is the sum of the
* deltaTs), not the amount of real time that has been required to do the
* simulation calculations.
* </p>
*
*
* @return the simulation time
*/
public final double simulationTime() {
return simulationTime;
return simulationTime;
}
/**
* Returns the total execution time of the simulation. Useful for order of
* magnitude benchmarking.
*
*
* @return total execution time of the simulation
*/
public final long totalSimulationTime() {
return totalSimulationTime;
return totalSimulationTime;
}
/**
* Resets the simulation instrumentation data.
*/
public void reset() {
simulationTime = 0.0;
iterationCount = 0;
totalSimulationTime = 0;
simulationTime = 0.0;
iterationCount = 0;
totalSimulationTime = 0;
}
/**
* Adds a update status callback.
*
*
* @param updateStatusCallback
*/
public void addUpdateStatusCallback(UpdateStatusCallback updateStatusCallback) {
updateStatusCallbacks.add(Preconditions.checkNotNull(updateStatusCallback));
updateStatusCallbacks.add(Preconditions.checkNotNull(updateStatusCallback));
}
/**
* Sets the completion callback.
*
*
* @param completionCallback
*/
public final void setCompletionCallback(CompletionCallback completionCallback) {
Preconditions.checkState(this.completionCallback == null, "it's a mistake if this is set twice");
this.completionCallback = completionCallback;
Preconditions.checkState(this.completionCallback == null, "it's a mistake if this is set twice");
this.completionCallback = completionCallback;
}
/**
@@ -10,7 +10,7 @@ private RoadNetworkUtils() {
public enum TravelTimeType {
GRID,
MEAN;
MEAN
}
public static double instantaneousTravelTime(Route route, TravelTimeType type) {
@@ -6,6 +6,6 @@
public enum RoadSegmentDirection {
FORWARD,
BACKWARD;
BACKWARD
}
@@ -36,7 +36,7 @@
LOOPDETECTOR,
VMS_DIVERSION,
FLOW_CONSERVING_BOTTLENECK,
GRADIENT_PROFILE;
GRADIENT_PROFILE
}
RoadObjectType getType();
Oops, something went wrong.

0 comments on commit 9d79353

Please sign in to comment.