public static int run(final String[] cmdArgs, final String stdoutFileName, final int timeout, final String workingDirectory) { final ExternalExecutor myExecutor = new ExternalExecutor(cmdArgs, stdoutFileName, workingDirectory); return waitForFinish(myExecutor, timeout); }
@StringSetter(END_TIME) public void setSimulationEndTime(String simulationEndTime) { double parsedTime = Time.parseTime(simulationEndTime); if (!Time.isUndefinedTime(parsedTime)) { this.simulationEndTime = parsedTime; } }
public void testUndefined() { // test writing assertEquals("undefined", Time.writeTime(Time.UNDEFINED_TIME)); // test reading assertEquals(Time.UNDEFINED_TIME, Time.parseTime("undefined"), 0.0); assertEquals(Time.UNDEFINED_TIME, Time.parseTime(""), 0.0); assertEquals(Time.UNDEFINED_TIME, Time.parseTime(null), 0.0); }
public void testWriting() { Time.setDefaultTimeFormat(Time.TIMEFORMAT_HHMMSS); assertEquals( "12:34:56", Time.writeTime( 12*3600 + 34*60 + 56.789));// positive assertEquals( "01:02:03", Time.writeTime( 1*3600 + 2*60 + 3.4)); // positive with leading zero assertEquals("-12:34:56", Time.writeTime(-12*3600 - 34*60 - 56.789)); // negative assertEquals("-01:02:03", Time.writeTime( -1*3600 - 2*60 - 3.4)); // negative with leading zero assertEquals( "00:00:00", Time.writeTime(0.0)); // zero /* Integer.MIN_VALUE is a special value in case time values would be represented by int's, and not double's. * Math.abs(Integer.MIN_VALUE) returns Integer.MIN_VALUE again, what could lead to a infinite loop depending * how negative times are handled internally. So this test should ensure this or a future implementation * does not have problems with that. */ assertEquals("-596523:14:08", Time.writeTime(Integer.MIN_VALUE)); }
/*package*/ void checkBinSize(double tripTime) { if (tripTime > dynamicBinSize) { dynamicBinSize = tripTime * 2; enlarge.incCounter(); } else if (tripTime * 3 < dynamicBinSize) { dynamicBinSize = tripTime * 3; shrink.incCounter(); } } }
private NetworkBasedTransportCosts(Builder builder) { super(); this.travelDisutility = builder.finalDisutility; this.travelTime = builder.travelTime; this.network = builder.network; this.leastCostPathCalculatorFactory = builder.leastCostPathCalculatorFactory; this.roadPricingCalc = builder.roadPricingCalculator; this.timeSliceWidth = builder.timeSliceWidth; this.defaultTypeId = builder.defaultTypeId; this.ttMemorizedCounter = new Counter("#TransportCostValues cached "); this.ttRequestedCounter = new Counter("numTravelCosts requested "); }
public void testParsing() { assertEquals( 12*3600.0 + 34*60.0 + 56.0, Time.parseTime( "12:34:56"), 0.0); assertEquals( 12*3600.0 + 34*60.0 + 56.7, Time.parseTime( "12:34:56.7"), 0.0); assertEquals( 1*3600.0 + 2*60.0 + 3.0, Time.parseTime( "01:02:03"), 0.0); assertEquals(-12*3600.0 - 34*60.0 - 56.0, Time.parseTime("-12:34:56"), 0.0); assertEquals(-12*3600.0 - 34*60.0 - 56.7, Time.parseTime("-12:34:56.7"), 0.0); assertEquals(0.0, Time.parseTime("00:00:00"), 0.0); assertEquals(Integer.MIN_VALUE, Time.parseTime("-596523:14:08"), 0.0); /* test for parsing hours greater than 2^31-1 (i.e. hour of type long) */ assertEquals(Long.MAX_VALUE, Time.parseTime("2562047788015215:28:07"), 0.0); }
public void printRelocateCount() { this.relocateCounter.printCounter(); }
public static int run(final String[] cmdArgs, final String stdoutFileName, final int timeout) { return run(cmdArgs, stdoutFileName, timeout, null); }
public void testConvertHHMMInteger() { assertEquals( 12*3600.0 + 34*60.0, Time.convertHHMMInteger(Integer.valueOf("1234")), 0.0); assertEquals( 1*3600.0 + 2*60.0, Time.convertHHMMInteger(Integer.valueOf("0102")), 0.0); }
public void testSeparators() { // test writing double dTime = 12*3600 + 34*60 + 56.789; assertEquals("12:34:56", Time.writeTime(dTime, ':')); assertEquals("12/34/56", Time.writeTime(dTime, '/')); assertEquals("12-34-56", Time.writeTime(dTime, '-')); // test reading double iTime = 12*3600 + 34*60 + 56; assertEquals(iTime, Time.parseTime( "12:34:56", ':'), 0.0); assertEquals(iTime, Time.parseTime( "12/34/56", '/'), 0.0); assertEquals(iTime, Time.parseTime( "12-34-56", '-'), 0.0); // test reading negative times assertEquals(-iTime, Time.parseTime( "-12:34:56", ':'), 0.0); assertEquals(-iTime, Time.parseTime( "-12/34/56", '/'), 0.0); assertEquals(-iTime, Time.parseTime( "-12-34-56", '-'), 0.0); }
@Override public void handleEvent(Event event) { counter.incCounter(); }
/** * Runs an executable and waits until the executable finishes or until * a certain amount of time has passed (timeout). * * @param cmd The system command to execute. E.g. "/bin/sh some-script.sh arg1 arg2" * @param stdoutFileName specifies the file where stdout of the executable is redirected to. * @param timeout A timeout in seconds. If the executable is still running after * <code>timeout</code> seconds, the executable is stopped and this method returns. * @param workingDirectory the working directory to be used when calling the command * @return exit-code of the executable. */ public static int run(final String cmd, final String stdoutFileName, final int timeout, final String workingDirectory) { final ExternalExecutor myExecutor = new ExternalExecutor(cmd, stdoutFileName, workingDirectory); return waitForFinish(myExecutor, timeout); }
@StringGetter(END_TIME) String getEndTimeAsString() { return Time.writeTime(this.endTime ) ; } public double getEndTime() {
@StringGetter(START_TIME) String getStartTimeAsString() { return Time.writeTime(this.startTime) ; } public double getStartTime() {
public static final String writeTime(final double seconds, final String timeformat) { return writeTime(seconds, timeformat, ':'); }
private String getTime(double time) { return Time.writeTime(time); }