getStep(int i);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/cadyts/src/main/java/floetteroed/cadyts/demand/PlanChoiceModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Cadyts - Calibration of dynamic traffic simulations
3 | *
4 | * Copyright 2009-2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Cadyts.
8 | *
9 | * Cadyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Cadyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Cadyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.cadyts.demand;
26 |
27 | import java.util.List;
28 |
29 | import floetteroed.utilities.math.Vector;
30 |
31 |
32 |
33 | /**
34 | *
35 | * @author Gunnar Flötteröd
36 | *
37 | * @param
38 | * the plan type
39 | */
40 | public interface PlanChoiceModel
> {
41 |
42 | public Vector getChoiceProbabilities(final List extends P> plans);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/cadyts/src/main/java/floetteroed/cadyts/interfaces/defaults/BasicMeasurementLoaderStringLinks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Cadyts - Calibration of dynamic traffic simulations
3 | *
4 | * Copyright 2009-2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Cadyts.
8 | *
9 | * Cadyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Cadyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Cadyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.cadyts.interfaces.defaults;
26 |
27 | import floetteroed.cadyts.calibrators.Calibrator;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | public class BasicMeasurementLoaderStringLinks extends
35 | BasicMeasurementLoader {
36 |
37 | // -------------------- CONSTRUCTION --------------------
38 |
39 | public BasicMeasurementLoaderStringLinks(final Calibrator calibrator) {
40 | super(calibrator);
41 | }
42 |
43 | // --------------- IMPLEMENTATION OF BasicMeasurementLoader ---------------
44 |
45 | @Override
46 | protected String label2link(String label) {
47 | return label;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/cadyts/src/main/java/floetteroed/cadyts/interfaces/dracula/DraculaMeasurementLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Cadyts - Calibration of dynamic traffic simulations
3 | *
4 | * Copyright 2009-2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Cadyts.
8 | *
9 | * Cadyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Cadyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Cadyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.cadyts.interfaces.dracula;
26 |
27 | import floetteroed.cadyts.interfaces.defaults.BasicMeasurementLoader;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | class DraculaMeasurementLoader extends BasicMeasurementLoader {
35 |
36 | // -------------------- CONSTRUCTION --------------------
37 |
38 | DraculaMeasurementLoader(final DraculaCalibrator calibrator) {
39 | super(calibrator);
40 | }
41 |
42 | // --------------- IMPLEMENTATION OF BasicMeasurementLoader ---------------
43 |
44 | @Override
45 | protected DraculaLink label2link(final String label) {
46 | return new DraculaLink(Integer.parseInt(label));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/cadyts/src/main/java/floetteroed/cadyts/interfaces/dracula/DynamicXMLFileIOStringKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Cadyts - Calibration of dynamic traffic simulations
3 | *
4 | * Copyright 2009-2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Cadyts.
8 | *
9 | * Cadyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Cadyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Cadyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.cadyts.interfaces.dracula;
26 |
27 | import floetteroed.utilities.DynamicDataXMLFileIO;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | class DynamicXMLFileIOStringKey extends DynamicDataXMLFileIO {
35 |
36 | // -------------------- CONSTANTS --------------------
37 |
38 | private static final long serialVersionUID = 1L;
39 |
40 | // --------------- IMPLEMENTATION OF DynamicDataFileIO ---------------
41 |
42 | @Override
43 | protected String attrValue2key(String string) {
44 | return string;
45 | }
46 |
47 | @Override
48 | protected String key2attrValue(String key) {
49 | return key;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/emulation/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 |
9 | gunnarfloetteroed
10 | java
11 | MASTER-SNAPSHOT
12 |
13 |
14 | cadyts
15 | cadyts
16 |
17 |
18 |
19 | gunnarfloetteroed
20 | utilities
21 | MASTER-SNAPSHOT
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/experimental/src/main/java/modalsharecalibrator/CalibrationModeExtractor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package modalsharecalibrator;
21 |
22 | import java.util.Map;
23 |
24 | import org.matsim.api.core.v01.population.Plan;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public interface CalibrationModeExtractor {
32 |
33 | public Map extractTripModes(final Plan plan);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/experimental/src/main/java/modalsharecalibrator/ModeASCContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package modalsharecalibrator;
21 |
22 | import java.util.LinkedHashMap;
23 | import java.util.Map;
24 |
25 | import org.apache.log4j.Logger;
26 |
27 | import com.google.inject.Singleton;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | @Singleton
35 | public class ModeASCContainer {
36 |
37 | private final Map mode2asc = new LinkedHashMap<>();
38 |
39 | public ModeASCContainer() {
40 | }
41 |
42 | public synchronized double getASC(final String mode) {
43 | return this.mode2asc.getOrDefault(mode, 0.0);
44 | }
45 |
46 | public synchronized void setASC(final String mode, final double asc) {
47 | this.mode2asc.put(mode, asc);
48 | Logger.getLogger(this.getClass()).info("Set ASC for mode " + mode + " to " + this.getASC(mode));
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/experimental/src/main/java/nonpropassignment/Plans.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package nonpropassignment;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | class Plans {
30 |
31 | final List allXn;
32 |
33 | final List realizedCosts;
34 |
35 | final List freeFlowCosts;
36 |
37 | // Array index: links. Values in allXn are indices of deltaX.
38 | final double[] x;
39 |
40 | Plans(final List allXn, final List allRealizedCosts, final List allFreeFlowCosts,
41 | final int linkCnt) {
42 | this.allXn = allXn;
43 | this.realizedCosts = allRealizedCosts;
44 | this.freeFlowCosts = allFreeFlowCosts;
45 |
46 | this.x = new double[linkCnt];
47 | for (int[] xn : allXn) {
48 | for (int index : xn) {
49 | x[index]++;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/experimental/src/main/java/nonpropassignment/Runner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package nonpropassignment;
21 |
22 | import org.matsim.api.core.v01.Scenario;
23 | import org.matsim.core.config.Config;
24 | import org.matsim.core.config.ConfigUtils;
25 | import org.matsim.core.controler.Controler;
26 | import org.matsim.core.scenario.ScenarioUtils;
27 |
28 | /**
29 | *
30 | * @author Gunnar Flötteröd
31 | *
32 | */
33 | public class Runner {
34 |
35 | static void runSimulation(final String path) {
36 | final Config config = ConfigUtils.loadConfig(path);
37 | final Scenario scenario = ScenarioUtils.loadScenario(config);
38 | final Controler controler = new Controler(scenario);
39 | controler.run();
40 | }
41 |
42 | public static void main(String[] args) {
43 | runSimulation(args[0]);
44 | }
45 |
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/carsharing/manager/supply/CompanyAgentImpl.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.carsharing.manager.supply;
2 |
3 | import org.matsim.api.core.v01.Id;
4 | import org.matsim.api.core.v01.network.Link;
5 | import org.matsim.api.core.v01.population.Person;
6 | import org.matsim.contrib.carsharing.vehicles.CSVehicle;
7 |
8 | public class CompanyAgentImpl implements CompanyAgent {
9 |
10 | private CompanyContainer companyContainer;
11 |
12 | public CompanyAgentImpl(CompanyContainer companyContainer, String strategyType) {
13 | this.companyContainer = companyContainer;
14 | // System.out.println("Here I am: " + this.getClass().getSimpleName());
15 | // System.exit(-1);
16 | }
17 |
18 | @Override
19 | public CSVehicle vehicleRequest(Id personId, Link locationLink, Link destinationLink,
20 | String carsharingType, String vehicleType) {
21 |
22 | VehiclesContainer vehiclesContainer = companyContainer.getVehicleContainer(carsharingType);
23 | System.out.println(" -> vehicles container reference: " + vehiclesContainer);
24 |
25 | if (vehiclesContainer != null) {
26 |
27 | //Depending on the company strategy
28 | //here the company just provides the closest vehicle in the search radius
29 | // CSVehicle vehicle = vehiclesContainer.findClosestAvailableVehicle(locationLink, vehicleType, 500.0);
30 | CSVehicle vehicle = vehiclesContainer.findClosestAvailableVehicle(locationLink, vehicleType, 1e6);
31 |
32 | return vehicle;
33 | }
34 |
35 | else
36 | return null;
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/datastructures/MatsimLinkDataIO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.datastructures;
21 |
22 | import org.matsim.api.core.v01.Id;
23 | import org.matsim.api.core.v01.network.Link;
24 |
25 | import floetteroed.utilities.DynamicDataXMLFileIO;
26 |
27 | /**
28 | *
29 | * @author Gunnar Flötteröd
30 | *
31 | */
32 | @SuppressWarnings("serial")
33 | public class MatsimLinkDataIO extends DynamicDataXMLFileIO> {
34 |
35 | @Override
36 | protected String key2attrValue(Id key) {
37 | return key.toString();
38 | }
39 |
40 | @Override
41 | protected Id attrValue2key(String string) {
42 | return Id.createLinkId(string);
43 | }
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/greedoreplanning/TestARStats.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.greedoreplanning;
21 |
22 | import static java.lang.Math.abs;
23 | import static java.lang.Math.pow;
24 |
25 | /**
26 | *
27 | * @author Gunnar Flötteröd
28 | *
29 | */
30 | public class TestARStats {
31 |
32 | static double meanVar(double varEps, double a, double _K) {
33 | return varEps / pow(_K, 2) * (_K + 2 * a * (_K * (1 - a) - (1 - pow(a, _K))) / pow(1 - a, 2));
34 | }
35 |
36 | public static void main(String[] args) {
37 | for (int _K : new int[] { 10, 100, 1000 }) {
38 | for (double a : new double[] { 0.0, 0.5, 0.9, 1 - 1e-6 }) {
39 | double meanVar = 0;
40 | for (int r = 0; r < _K; r++) {
41 | for (int s = 0; s < _K; s++) {
42 | meanVar += pow(a, abs(r - s));
43 | }
44 | }
45 | meanVar /= (_K * _K);
46 | System.out.println("a=" + a + "\t_K=" + _K + "\tnum=" + meanVar + "\tanalyt=" + meanVar(1.0, a, _K));
47 | }
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgAnticipatedDeltaUtility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgAnticipatedDeltaUtility extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getReplanningSummaryStatistics().getSumOfAnticipatedUtilityChanges(),
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgAnticipatedReplannerDeltaUtility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgAnticipatedReplannerDeltaUtility extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getReplanningSummaryStatistics().sumOfReplannerUtilityChanges,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgNonReplannerSize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgNonReplannerSize extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getReplanningSummaryStatistics().nonReplannerSizeSum, arg0.getReplanningSummaryStatistics().numberOfNonReplanners);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgRealizedDeltaUtility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgRealizedDeltaUtility extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getRealizedUtilityChangeSum(),
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgRealizedUtility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgRealizedUtility extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getRealizedUtilitySum(),
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/AvgReplannerSize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class AvgReplannerSize extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getReplanningSummaryStatistics().replannerSizeSum, arg0.getReplanningSummaryStatistics().numberOfReplanners);
34 | }
35 |
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/CnMean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | import floetteroed.utilities.statisticslogging.Statistic;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public class CnMean implements Statistic {
32 |
33 | @Override
34 | public String label() {
35 | return this.getClass().getSimpleName();
36 | }
37 |
38 | @Override
39 | public String value(final LogDataWrapper arg0) {
40 | return Statistic.toString(arg0.getCnMean());
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/CnStddev.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | import floetteroed.utilities.statisticslogging.Statistic;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public class CnStddev implements Statistic {
32 |
33 | @Override
34 | public String label() {
35 | return this.getClass().getSimpleName();
36 | }
37 |
38 | @Override
39 | public String value(final LogDataWrapper arg0) {
40 | return Statistic.toString(arg0.getCnStddev());
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/DoesNothingShare.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class DoesNothingShare extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getReplanningSummaryStatistics().doesNothingCnt,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/EEstim2Mean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class EEstim2Mean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfEstimE2,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/EEstimMean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class EEstimMean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfEstimE,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/ENaive2Mean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ENaive2Mean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfNaiveE2,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/ENaiveMean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ENaiveMean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfNaiveE,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/ENull2Mean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ENull2Mean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfNullE2,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/ENullMean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ENullMean extends PopulationAverageStatistic {
30 |
31 | @Override
32 | public String value(final LogDataWrapper arg0) {
33 | return this.averageOrEmpty(arg0.getDisappoinmentSummaryStatistics().sumOfNullE,
34 | arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/LambdaRealized.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.greedo.logging;
2 |
3 | import org.matsim.contrib.greedo.LogDataWrapper;
4 |
5 | public class LambdaRealized extends PopulationAverageStatistic {
6 |
7 | @Override
8 | public String value(LogDataWrapper arg0) {
9 | return this.averageOrEmpty(new Double(arg0.getReplanningSummaryStatistics().numberOfReplanners), arg0.getReplanningSummaryStatistics().getNumberOfReplanningCandidates());
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/MATSimIteration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | import floetteroed.utilities.statisticslogging.Statistic;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public class MATSimIteration implements Statistic {
32 |
33 | @Override
34 | public String label() {
35 | return this.getClass().getSimpleName();
36 | }
37 |
38 | @Override
39 | public String value(LogDataWrapper arg0) {
40 | return Statistic.toString(arg0.getIteration());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/PopulationAverageStatistic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | import floetteroed.utilities.statisticslogging.Statistic;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | abstract class PopulationAverageStatistic implements Statistic {
32 |
33 | String averageOrEmpty(final Double sum, final Integer count) {
34 | if ((sum != null) && (count != null)) {
35 | return Double.toString(sum / count);
36 | } else {
37 | return "";
38 | }
39 | }
40 |
41 | @Override
42 | public String label() {
43 | return this.getClass().getSimpleName();
44 | }
45 |
46 | @Override
47 | public abstract String value(LogDataWrapper arg0);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/logging/ReplanningRecipe.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.logging;
21 |
22 | import org.matsim.contrib.greedo.LogDataWrapper;
23 |
24 | import floetteroed.utilities.statisticslogging.Statistic;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public class ReplanningRecipe implements Statistic {
32 |
33 | @Override
34 | public String label() {
35 | return this.getClass().getSimpleName();
36 | }
37 |
38 | @Override
39 | public String value(LogDataWrapper arg0) {
40 | return Statistic.toString(arg0.getReplanningSummaryStatistics().replannerIdentifierRecipeName);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/recipes/AccelerationRecipe.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.recipes;
21 |
22 | import org.matsim.api.core.v01.Id;
23 | import org.matsim.api.core.v01.population.Person;
24 | import org.matsim.contrib.greedo.LogDataWrapper;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public class AccelerationRecipe implements ReplannerIdentifierRecipe {
32 |
33 | public AccelerationRecipe() {
34 | }
35 |
36 | @Override
37 | public void update(final LogDataWrapper logDataWrapper) {
38 | }
39 |
40 | @Override
41 | public boolean isReplanner(final Id personId, final double anticipatedUtilityChange) {
42 | throw new UnsupportedOperationException();
43 | }
44 |
45 | @Override
46 | public String getDeployedRecipeName() {
47 | return this.getClass().getSimpleName();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/recipes/ReplannerIdentifierRecipe.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.recipes;
21 |
22 | import org.matsim.api.core.v01.Id;
23 | import org.matsim.api.core.v01.population.Person;
24 | import org.matsim.contrib.greedo.LogDataWrapper;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public interface ReplannerIdentifierRecipe {
32 |
33 | public void update(LogDataWrapper logDataWrapper);
34 |
35 | // public default void update(LogDataWrapper logDataWrapper, Map, Double> personId2avgExpDeltaUn0) {
36 | // this.update(logDataWrapper);
37 | // }
38 |
39 | public boolean isReplanner(Id personId, double anticipatedUtilityChange);
40 |
41 | public String getDeployedRecipeName();
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/trustregion/Slot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.trustregion;
21 |
22 | import org.matsim.api.core.v01.Id;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class Slot {
30 |
31 | public final Id> loc;
32 | public final int timeBin;
33 |
34 | public Slot(final Id> loc, final int timeBin) {
35 | this.loc = loc;
36 | this.timeBin = timeBin;
37 | }
38 |
39 | @Override
40 | public boolean equals(final Object other) {
41 | if (other instanceof Slot) {
42 | final Slot otherSlot = (Slot) other;
43 | return (this.loc.equals(otherSlot.loc) && (this.timeBin == otherSlot.timeBin));
44 | } else {
45 | return false;
46 | }
47 | }
48 |
49 | @Override
50 | public int hashCode() {
51 | return 31 * (31 * this.loc.hashCode() + Integer.hashCode(this.timeBin));
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | return this.loc + "(" + this.timeBin + ")";
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/trustregion/TestRW.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.trustregion;
21 |
22 | import java.util.Random;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class TestRW {
30 |
31 | public static void main(String[] args) {
32 |
33 | Random rnd = new Random();
34 |
35 | double x = 1.0;
36 | double y = 0.0;
37 |
38 | Double prev = null;
39 | for (int k = 0; k < 1000; k++) {
40 | final double e = rnd.nextGaussian() + 10;
41 | if (prev != null) {
42 | final double delta = e - prev;
43 | x *= Math.exp(-delta);
44 | y += delta;
45 | System.out.println((x + "\t" + y).replace('.', ','));
46 | }
47 | prev = e;
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/greedo/variabilityanalysis/Slot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.greedo.variabilityanalysis;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | public class Slot {
28 |
29 | public final L loc;
30 |
31 | public final int timeBin;
32 |
33 | public Slot(final L loc, final int timeBin) {
34 | this.loc = loc;
35 | this.timeBin = timeBin;
36 | }
37 |
38 | @Override
39 | public boolean equals(final Object other) {
40 | if (other instanceof Slot) {
41 | final Slot> otherSlot = (Slot>) other;
42 | return (this.loc.equals(otherSlot.loc) && (this.timeBin == otherSlot.timeBin));
43 | } else {
44 | return false;
45 | }
46 | }
47 |
48 | @Override
49 | public int hashCode() {
50 | return 31 * (31 * this.loc.hashCode() + Integer.hashCode(this.timeBin));
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return this.loc + "(" + this.timeBin + ")";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/ier/IERModule.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.ier;
2 |
3 | import org.matsim.contrib.ier.emulator.AgentEmulator;
4 | import org.matsim.contrib.ier.emulator.SimulationEmulatorImpl;
5 | import org.matsim.contrib.ier.emulator.SimulationEmulator;
6 | import org.matsim.contrib.ier.replannerselection.AllReplannersSelector;
7 | import org.matsim.contrib.ier.replannerselection.ReplannerSelector;
8 | import org.matsim.core.controler.AbstractModule;
9 | import org.matsim.core.controler.corelisteners.PlansReplanning;
10 |
11 | /**
12 | * This module overrides the default replanning.
13 | *
14 | * @author shoerl
15 | */
16 | public final class IERModule extends AbstractModule {
17 |
18 | private final Class extends ReplannerSelector> replannerSelectorClass;
19 |
20 | public IERModule(Class extends ReplannerSelector> replannerSelector) {
21 | this.replannerSelectorClass = replannerSelector;
22 | }
23 |
24 | public IERModule() {
25 | this(AllReplannersSelector.class);
26 | }
27 |
28 | @Override
29 | public void install() {
30 | bind(PlansReplanning.class).to(IERReplanning.class);
31 | bind(AgentEmulator.class);
32 |
33 | // We choose the simple emulator for now.
34 | bind(SimulationEmulator.class).to(SimulationEmulatorImpl.class);
35 |
36 | bind(ReplannerSelector.class).to(this.replannerSelectorClass);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/ier/emulator/ActivityEmulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.ier.emulator;
21 |
22 | import org.matsim.api.core.v01.population.Activity;
23 | import org.matsim.api.core.v01.population.Person;
24 |
25 | /**
26 | *
27 | * @author Gunnar Flötteröd
28 | *
29 | */
30 | public interface ActivityEmulator {
31 |
32 | public double emulateActivityAndReturnEndTime_s(final Activity activity, final Person person, double time_s,
33 | final boolean isFirstElement, final boolean isLastElement);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/ier/emulator/LegEmulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.ier.emulator;
21 |
22 | import org.matsim.api.core.v01.population.Activity;
23 | import org.matsim.api.core.v01.population.Leg;
24 | import org.matsim.api.core.v01.population.Person;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public interface LegEmulator {
32 |
33 | public double emulateLegAndReturnEndTime_s(Leg leg, Person person, Activity previousActivity,
34 | Activity followingActivity, double time_s);
35 | }
36 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/ier/emulator/SimulationEmulator.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.ier.emulator;
2 |
3 | import org.matsim.api.core.v01.population.Person;
4 | import org.matsim.api.core.v01.population.Plan;
5 | import org.matsim.core.api.experimental.events.EventsManager;
6 | import org.matsim.core.router.util.TravelTime;
7 |
8 | /**
9 | * The SimulationEmulator has the purpose to create events for an agent's plan.
10 | * While the standard network simulation in MATSim performs a detailed
11 | * queue-based simulation with interacting agents the idea is here to create
12 | * events as quickly as possible, potentially loosing some of the dynamics.
13 | * However, this is meant to be a fast approximation of the actual network
14 | * simulation in MATSim.
15 | *
16 | * @author shoerl
17 | */
18 | public interface SimulationEmulator {
19 | void emulate(Person person, Plan plan, EventsManager eventsManager, TravelTime overridingCarTravelTimes);
20 | }
21 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/ier/replannerselection/ReplannerSelector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.ier.replannerselection;
21 |
22 | import java.util.Set;
23 |
24 | import org.matsim.api.core.v01.Id;
25 | import org.matsim.api.core.v01.population.Person;
26 | import org.matsim.api.core.v01.population.Population;
27 | import org.matsim.core.events.handler.EventHandler;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | public interface ReplannerSelector {
35 |
36 | public IEREventHandlerProvider beforeReplanningAndGetEventHandlerProvider();
37 |
38 | public IEREventHandlerProvider getOverrideExperiencedScoresEventHandlerProvider();
39 |
40 | public void afterReplanning();
41 |
42 | public interface IEREventHandlerProvider {
43 |
44 | public EventHandler get(Set> persons);
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/calibration/counting/Filter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.calibration.counting;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | public interface Filter {
28 |
29 | public static Filter newAcceptAllFilter(final Class clazz) {
30 | return new Filter() {
31 | @Override
32 | public boolean test(T object) {
33 | return true;
34 | }
35 | };
36 | }
37 |
38 | public static Filter newSingleObjectFilter(final T acceptedObject) {
39 | if (acceptedObject == null) {
40 | throw new RuntimeException("Accepted object must not be null.");
41 | }
42 | return new Filter() {
43 | @Override
44 | public boolean test(T object) {
45 | return acceptedObject.equals(object);
46 | }
47 | };
48 | }
49 |
50 | public boolean test(T object);
51 | }
52 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/calibration/plotting/TrajectoryDataSummarizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.calibration.plotting;
21 |
22 | import java.util.function.Predicate;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public interface TrajectoryDataSummarizer extends TrajectoryPlotDataSource {
30 |
31 | public void clear();
32 |
33 | public void offerCandidate(TrajectoryPlotDataSource dataSource);
34 |
35 | public void build();
36 |
37 | public void setDataSourcePredicate(Predicate predicate);
38 |
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/calibration/plotting/TrajectoryPlotDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.calibration.plotting;
21 |
22 | import floetteroed.utilities.TimeDiscretization;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public interface TrajectoryPlotDataSource {
30 |
31 | public String getIdentifier();
32 |
33 | public TimeDiscretization getTimeDiscretization();
34 |
35 | public double[] getSimulatedData();
36 |
37 | public double[] getRealData();
38 |
39 | public String getDataType();
40 |
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/decisionvariables/activitytimes/ClosingTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.decisionvariables.activitytimes;
21 |
22 | import org.matsim.core.config.Config;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ClosingTime extends ActivityTime {
30 |
31 | // -------------------- CONSTRUCTION --------------------
32 |
33 | public ClosingTime(final Config config, final String activityType, final double value_s) {
34 | super(config, activityType, value_s);
35 | }
36 |
37 | // --------------- IMPLEMENTATION OF ActivityTime ---------------
38 |
39 | @Override
40 | public void implementInSimulation() {
41 | this.getActivityParams().setClosingTime(this.getValue());
42 | }
43 |
44 | @Override
45 | public ClosingTime newDeepCopy() {
46 | return new ClosingTime(this.getConfig(), this.getActivityType(), this.getValue());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/decisionvariables/activitytimes/OpeningTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.decisionvariables.activitytimes;
21 |
22 | import org.matsim.core.config.Config;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class OpeningTime extends ActivityTime {
30 |
31 | // -------------------- CONSTRUCTION --------------------
32 |
33 | public OpeningTime(final Config config, final String activityType, final double value_s) {
34 | super(config, activityType, value_s);
35 | }
36 |
37 | // --------------- IMPLEMENTATION OF ActivityTime ---------------
38 |
39 | @Override
40 | public void implementInSimulation() {
41 | this.getActivityParams().setOpeningTime(this.getValue());
42 | }
43 |
44 | @Override
45 | public OpeningTime newDeepCopy() {
46 | return new OpeningTime(this.getConfig(), this.getActivityType(), this.getValue());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/decisionvariables/activitytimes/TypicalDuration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.decisionvariables.activitytimes;
21 |
22 | import org.matsim.core.config.Config;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class TypicalDuration extends ActivityTime {
30 |
31 | // -------------------- CONSTRUCTION --------------------
32 |
33 | public TypicalDuration(Config config, String activityType, double value_s) {
34 | super(config, activityType, value_s);
35 | }
36 |
37 | // --------------- IMPLEMENTATION OF ActivityTime ---------------
38 |
39 | @Override
40 | public void implementInSimulation() {
41 | this.getActivityParams().setTypicalDuration(this.getValue());
42 | }
43 |
44 | @Override
45 | public TypicalDuration newDeepCopy() {
46 | return new TypicalDuration(this.getConfig(), this.getActivityType(), this.getValue());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/buildingblocks/decisionvariables/scalar/ScalarDecisionVariable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.decisionvariables.scalar;
21 |
22 | import floetteroed.opdyts.DecisionVariable;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public interface ScalarDecisionVariable> extends DecisionVariable {
30 |
31 | /**
32 | * If the decision variable is limited to a particular value range, the
33 | * implementing class is responsible for adjusting the set value accordingly.
34 | */
35 | public void setValue(double val);
36 |
37 | public double getValue();
38 |
39 | public U newDeepCopy();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/experimental/DecisionVariableRandomizationUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.experimental;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Collections;
24 | import java.util.LinkedHashSet;
25 | import java.util.List;
26 | import java.util.Set;
27 |
28 | /**
29 | *
30 | * @author Gunnar Flötteröd
31 | *
32 | */
33 | public class DecisionVariableRandomizationUtils {
34 |
35 | public static Set drawDistinctElements(final Set universe, final int draws) {
36 | final List list = new ArrayList<>(universe);
37 | Collections.shuffle(list); // inefficient if draws << universe.size()
38 | return new LinkedHashSet<>(list.subList(0, draws));
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/macrostate/SimulationMacroStateAnalyzer.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.opdyts.macrostate;
2 |
3 | import org.matsim.core.events.handler.EventHandler;
4 |
5 | import floetteroed.utilities.math.Vector;
6 |
7 | /**
8 | * An event handler that composes (part of) the macro-state of a simulation.
9 | *
10 | * @author Gunnar Flötteröd
11 | *
12 | */
13 | public interface SimulationMacroStateAnalyzer extends EventHandler {
14 |
15 | /**
16 | * Clears the internal state, i.e. all (event) book-keeping from which the
17 | * macro-state of interest is composed.
18 | *
19 | * This reset-functionality must not be implemented in
20 | * EventHandler.reset(int) because that function appears to be called before
21 | * BeforeMobsimListener.notifyBeforeMobsim(BeforeMobsimEvent), where the
22 | * macro-state is needed.
23 | *
24 | * The logic is now such that
25 | * BeforeMobsimListener.notifyBeforeMobsim(BeforeMobsimEvent) is called within
26 | * the framework, extracts all needed information, and then calls
27 | * SimulatorMacroStateAnalyzer.clear().
28 | */
29 | public void clear();
30 |
31 | /**
32 | * Returns a new instance of a fixed-dimension vector-valued macro-state
33 | * representation based on the most recently handled event stream.
34 | */
35 | public Vector newStateVectorRepresentation();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/microstate/MATSimStateFactory.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.opdyts.microstate;
2 |
3 | import org.matsim.api.core.v01.population.Population;
4 |
5 | import floetteroed.opdyts.DecisionVariable;
6 | import floetteroed.opdyts.SimulatorState;
7 | import floetteroed.utilities.math.Vector;
8 |
9 | /**
10 | * A factory for MATSim simulation states.
11 | *
12 | * @author Gunnar Flötteröd
13 | *
14 | * @see MATSimState
15 | * @see DecisionVariable
16 | */
17 | public interface MATSimStateFactory {
18 |
19 | /**
20 | * Creates a new object representation of the current MATSim simulation state.
21 | *
22 | * IMPORTANT: Do not take over a controler reference into the state object and
23 | * attempt to compute state properties (such as objective function values) on
24 | * the fly. Instead, compute all relevant state attributes explicitly when
25 | * creating the state object.
26 | *
27 | * @see MATSimState
28 | *
29 | * @param population
30 | * the current MATSim population
31 | * @param stateVector
32 | * a vector representation of the state to be created
33 | * @param decisionVariable
34 | * the decision variable that has led to the state to be created
35 | * @return the current MATSim simulation state
36 | */
37 | public X newState(Population population, Vector stateVector, U decisionVariable);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/contrib/opdyts/microstate/MATSimStateFactoryImpl.java:
--------------------------------------------------------------------------------
1 | package org.matsim.contrib.opdyts.microstate;
2 |
3 | import org.matsim.api.core.v01.population.Population;
4 |
5 | import floetteroed.opdyts.DecisionVariable;
6 | import floetteroed.opdyts.SimulatorState;
7 | import floetteroed.utilities.math.Vector;
8 |
9 | /**
10 | *
11 | * @author Gunnar Flötteröd
12 | *
13 | * @param
14 | * decision variable type
15 | */
16 | public class MATSimStateFactoryImpl
17 | implements MATSimStateFactory {
18 |
19 | public MATSimStateFactoryImpl() {
20 | }
21 |
22 | @Override
23 | public final MATSimState newState(final Population population, final Vector stateVector, final U decisionVariable) {
24 | final MATSimState result = new MATSimState(population, stateVector);
25 | // this.addComponents(result);
26 | return result;
27 | }
28 |
29 | // /**
30 | // * An inheritance-based attempt to support a modular objective function.
31 | // * Reasoning behind this:
32 | // *
33 | // * The MATSimOpdytsRunner ensures dependency injections into MATSimStateFactory
34 | // * and hence into subclasses of this. Subclasses are hence able to access the
35 | // * entire MATSim simulation machinery and to extract and insert (in a type-safe
36 | // * manner) components (e.g. their injected members) into the MATSimState.
37 | // *
38 | // * Composition may be better, but type-safety may be more complicated to ensure.
39 | // */
40 | // protected void addComponents(final MATSimState state) {
41 | // }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/roadpricing/MyRoadPricingUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.roadpricing;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | @Deprecated
28 | public class MyRoadPricingUtils {
29 |
30 | /*
31 | * Don't know how to get my own instance of CalcPaidToll otherwise, with its
32 | * constructor being package private and the class being final. Will eventually
33 | * switch to a more recent version of the roadpricing contrib, hence living with
34 | * this hack for the time being.
35 | */
36 | // public static CalcPaidToll newInstance(final Network network, final RoadPricingScheme scheme,
37 | // EventsManager events) {
38 | // final Level level = Logger.getLogger("org.matsim").getLevel();
39 | // Logger.getLogger("org.matsim").setLevel(Level.OFF);
40 | // final CalcPaidToll result = new CalcPaidToll(network, scheme, events);
41 | // Logger.getLogger("org.matsim").setLevel(level);
42 | // return result;
43 | // }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/experimental/src/main/java/org/matsim/utils/objectattributes/ObjectAttributeUtils2.java:
--------------------------------------------------------------------------------
1 | package org.matsim.utils.objectattributes;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedHashSet;
5 | import java.util.List;
6 | import java.util.Map;
7 | import java.util.Set;
8 |
9 | import floetteroed.utilities.FractionalIterable;
10 |
11 | /**
12 | *
13 | * @author Gunnar Flötteröd
14 | *
15 | */
16 | public class ObjectAttributeUtils2 {
17 |
18 | private ObjectAttributeUtils2() {
19 | }
20 |
21 | public static List allObjectKeys(
22 | final ObjectAttributes objectAttributes) {
23 | return new ArrayList(objectAttributes.attributes.keySet());
24 | }
25 |
26 | public static List allAttributeKeys(
27 | final ObjectAttributes objectAttributes) {
28 | final Set result = new LinkedHashSet();
29 | for (String objectKey : allObjectKeys(objectAttributes)) {
30 | result.addAll(ObjectAttributesUtils.getAllAttributeNames(
31 | objectAttributes, objectKey));
32 | }
33 | return new ArrayList(result);
34 | }
35 |
36 | public static ObjectAttributes newFractionalSubset(
37 | final ObjectAttributes parent, final double fraction) {
38 | final ObjectAttributes subset = new ObjectAttributes();
39 | for (Map.Entry> objKey2attrs : new FractionalIterable<>(
40 | parent.attributes.entrySet(), fraction)) {
41 | subset.attributes.put(objKey2attrs.getKey(),
42 | objKey2attrs.getValue());
43 | }
44 | return subset;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/experimental/src/main/java/playground/LinearProgramMATLABWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package playground;
21 |
22 | // import com.mathworks.engine.MatlabEngine;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class LinearProgramMATLABWrapper {
30 |
31 | // private final MatlabEngine eng = MatlabEngine.startMatlab();
32 |
33 | public LinearProgramMATLABWrapper() {
34 |
35 | }
36 |
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/regent/costwriting/LinkTravelDistanceInKilometers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.regent.costwriting;
21 |
22 | import org.matsim.api.core.v01.network.Link;
23 | import org.matsim.api.core.v01.population.Person;
24 | import org.matsim.core.router.util.TravelDisutility;
25 | import org.matsim.vehicles.Vehicle;
26 |
27 | import floetteroed.utilities.Units;
28 |
29 | /**
30 | *
31 | * @author Gunnar Flötteröd
32 | *
33 | */
34 | public class LinkTravelDistanceInKilometers implements TravelDisutility {
35 |
36 | public LinkTravelDistanceInKilometers() {
37 | }
38 |
39 | @Override
40 | public double getLinkTravelDisutility(Link link, double time,
41 | Person person, Vehicle vehicle) {
42 | return Units.KM_PER_M * link.getLength();
43 | }
44 |
45 | @Override
46 | public double getLinkMinimumTravelDisutility(Link link) {
47 | return Units.KM_PER_M * link.getLength();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/regent/unused/MyObjectAttributes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.regent.unused;
21 |
22 | import java.util.LinkedHashSet;
23 | import java.util.Set;
24 |
25 | import org.matsim.utils.objectattributes.ObjectAttributes;
26 |
27 | @Deprecated
28 | public class MyObjectAttributes extends ObjectAttributes {
29 |
30 | final Set allObjectIds = new LinkedHashSet();
31 |
32 | final Set allAttributes = new LinkedHashSet();
33 |
34 | @Override
35 | public Object putAttribute(final String objectId, final String attribute, final Object value) {
36 |
37 | this.allObjectIds.add(objectId);
38 | this.allAttributes.add(attribute);
39 |
40 | return super.putAttribute(objectId, attribute, value);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/transmodeler/networktransformation/TransmodelerElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.transmodeler.networktransformation;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | abstract class TransmodelerElement {
28 |
29 | private final String id;
30 |
31 | TransmodelerElement(final String id) {
32 | this.id = id;
33 | }
34 |
35 | String getId() {
36 | return this.id;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/transmodeler/networktransformation/TransmodelerNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.transmodeler.networktransformation;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | class TransmodelerNode extends TransmodelerElement {
28 |
29 | private final double longitude;
30 |
31 | private final double latitude;
32 |
33 | TransmodelerNode(final String id, final double longitude,
34 | final double latitude) {
35 | super(id);
36 | this.longitude = longitude;
37 | this.latitude = latitude;
38 | }
39 |
40 | double getLongitude() {
41 | return this.longitude;
42 | }
43 |
44 | double getLatitude() {
45 | return this.latitude;
46 | }
47 |
48 | @Override
49 | public String toString() {
50 | return this.getClass().getSimpleName() + "(id=" + this.getId()
51 | + ", lon=" + this.longitude + ", lat=" + this.latitude + ")";
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/utils/MovePics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.utils;
21 | import java.io.File;
22 | import java.io.IOException;
23 |
24 | import org.apache.commons.io.FileUtils;
25 |
26 | public class MovePics {
27 |
28 | public MovePics() {
29 | }
30 |
31 | public static void main(String[] args) throws IOException {
32 |
33 | for (int i = 0; i <= 200; i++) {
34 | System.out.println(i);
35 | final File from = new File(
36 | "./test/regentmatsim/matsim-output/ITERS/it." + i + "/" + i
37 | + ".legHistogram_car.png");
38 | final File to = new File("./test/regentmatsim/hist" + i + ".png");
39 |
40 | FileUtils.copyFile(from, to);
41 |
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop2/utils/StringAsIntegerComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop2.utils;
21 |
22 | import java.util.Comparator;
23 |
24 | public class StringAsIntegerComparator implements Comparator {
25 |
26 | public StringAsIntegerComparator() {
27 | }
28 |
29 | @Override
30 | public int compare(final String arg0, final String arg1) {
31 | return (new Integer(arg0)).compareTo(new Integer(arg1));
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop4/resampling/Alternative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop4.resampling;
21 |
22 | import org.matsim.api.core.v01.population.Plan;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public interface Alternative {
30 |
31 | public double getSampersOnlyScore();
32 |
33 | public double getSampersTimeScore();
34 |
35 | public double getMATSimTimeScore();
36 |
37 | // TODO NEW
38 | // public void setMATSimTimeScore(double score);
39 | public void updateMATSimTimeScore(double score, double innovationWeight);
40 |
41 | public double getSampersChoiceProbability();
42 |
43 | public EpsilonDistribution getEpsilonDistribution();
44 |
45 | public double getSampersEpsilonRealization();
46 |
47 | public void setSampersEpsilonRealization(double eps);
48 |
49 | public Plan getMATSimPlan();
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop4/resampling/ChoiceSetFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop4.resampling;
21 |
22 | import java.util.Set;
23 |
24 | import org.matsim.api.core.v01.population.Person;
25 |
26 | /**
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public interface ChoiceSetFactory {
32 |
33 | public Set newChoiceSet(Person person);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop4/resampling/EpsilonDistribution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop4.resampling;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | public interface EpsilonDistribution {
28 |
29 | public double nextEpsilon();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop4/sampersutilities/SampersDifferentiatedPTScoringFunctionModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop4.sampersutilities;
21 |
22 | import org.matsim.core.controler.AbstractModule;
23 | import org.matsim.core.scoring.ScoringFunctionFactory;
24 | import org.matsim.core.scoring.functions.ScoringParametersForPerson;
25 | import org.matsim.core.scoring.functions.SubpopulationScoringParameters;
26 |
27 | /**
28 | *
29 | * @author Gunnar Flötteröd
30 | *
31 | */
32 | public class SampersDifferentiatedPTScoringFunctionModule extends AbstractModule {
33 | @Override
34 | public void install() {
35 | bind(ScoringFunctionFactory.class).to(SampersDifferentiatedPTScoringFunctionFactory.class);
36 | bind(ScoringParametersForPerson.class).to(SubpopulationScoringParameters.class);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/ihop4/sampersutilities/SampersScoringFunctionModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.ihop4.sampersutilities;
21 |
22 | import org.matsim.core.controler.AbstractModule;
23 | import org.matsim.core.scoring.ScoringFunctionFactory;
24 | import org.matsim.core.scoring.functions.ScoringParametersForPerson;
25 | import org.matsim.core.scoring.functions.SubpopulationScoringParameters;
26 |
27 | /**
28 | *
29 | * @author Gunnar Flötteröd
30 | *
31 | */
32 | public class SampersScoringFunctionModule extends AbstractModule {
33 | @Override
34 | public void install() {
35 | bind(ScoringFunctionFactory.class).to(SampersScoringFunctionFactory.class);
36 | bind(ScoringParametersForPerson.class).to(SubpopulationScoringParameters.class);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/saleem/CollectionUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Mohammad Saleem
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: salee@kth.se
18 | *
19 | */
20 | package stockholm.saleem;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Iterator;
24 | import java.util.List;
25 | /**
26 | * A class to convert a list to array.
27 | *
28 | * @author Mohammad Saleem
29 | *
30 | */
31 | public class CollectionUtil {
32 | public ArrayList toArrayList(Iterator iter){
33 | ArrayList arraylist = new ArrayList();
34 | while(iter.hasNext()){
35 | arraylist.add(iter.next());
36 | }
37 | return arraylist;
38 | }
39 | public double[] toArray(List alist){//Converting a list to array
40 | double[] array = new double[alist.size()];
41 | Iterator iter = alist.iterator();
42 | int i=0;
43 | while(iter.hasNext()){
44 | array[i]=iter.next();
45 | i++;
46 | }
47 | return array;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/wum/WUMASCInstaller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.wum;
21 |
22 | import org.matsim.core.config.Config;
23 | import org.matsim.core.config.ConfigUtils;
24 | import org.matsim.core.controler.listener.ControlerListener;
25 |
26 | import com.google.inject.Inject;
27 |
28 | import modalsharecalibrator.ModeASCContainer;
29 | import stockholm.StockholmConfigGroup;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class WUMASCInstaller implements ControlerListener {
37 |
38 | @Inject
39 | WUMASCInstaller(final Config config, final ModeASCContainer ascs) {
40 | final StockholmConfigGroup sthlmConf = ConfigUtils.addOrGetModule(config, StockholmConfigGroup.class);
41 | ascs.setASC("car", sthlmConf.getCarASC());
42 | ascs.setASC("pt", sthlmConf.getPtASC());
43 | ascs.setASC("bike", sthlmConf.getBikeASC());
44 | ascs.setASC("walk", sthlmConf.getWalkASC());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/wum/malin/Test.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.wum.malin;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | public class Test {
28 |
29 | public static void main(String[] args) {
30 | String x = "blah" + null;
31 | System.out.println(x);
32 | }
33 |
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/experimental/src/main/java/stockholm/wum/utils/EventsTypeIdentifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package stockholm.wum.utils;
21 |
22 | import java.util.LinkedHashSet;
23 |
24 | import org.matsim.core.api.experimental.events.EventsManager;
25 | import org.matsim.core.events.EventsUtils;
26 | import org.matsim.core.events.handler.EventHandler;
27 |
28 | /**
29 | *
30 | * @author Gunnar Flötteröd
31 | *
32 | */
33 | public class EventsTypeIdentifier implements EventHandler {
34 |
35 | private final LinkedHashSet> eventClasses = new LinkedHashSet<>();
36 |
37 |
38 |
39 | public static void main(String[] args) {
40 |
41 |
42 | EventsManager manager = EventsUtils.createEventsManager();
43 | EventsUtils.readEvents(manager, "output_events.xml.gz");
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/experimental/src/main/java/utils/linesearch/LineSearchUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package utils.linesearch;
21 |
22 | /**
23 | * Some translations of functions used in "Numerical Recipes in C".
24 | *
25 | * @author Gunnar Flötteröd
26 | *
27 | */
28 | class LineSearchUtils {
29 |
30 | private LineSearchUtils() {
31 | }
32 |
33 | static double sign(final double a, final double b) {
34 | return (b >= 0) ? Math.abs(a) : -Math.abs(a);
35 | }
36 |
37 | static double fabs(final double a) {
38 | return Math.abs(a);
39 | }
40 |
41 | static double fmax(final double a, final double b) {
42 | return Math.max(a, b);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/experimental/src/main/java/utils/linesearch/OneDimensionalFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package utils.linesearch;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | */
27 | public interface OneDimensionalFunction {
28 |
29 | public double evaluate(final double independentVariable);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/CSMembership.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/CarsharingStations.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
22 |
23 |
24 |
29 |
30 |
31 |
36 |
37 |
38 |
41 |
42 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/freefloating_areas_v1.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/relocation_agents_v1.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/relocation_times_v1.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/experimental/src/main/resources/dtd/relocation_zones_v1.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/experimental/src/test/java/org/matsim/contrib/opdyts/buildingblocks/decisionvariables/activitytimes/StringRepresentationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.flotterod@gmail.com
18 | *
19 | */
20 | package org.matsim.contrib.opdyts.buildingblocks.decisionvariables.activitytimes;
21 |
22 | import org.junit.Test;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class StringRepresentationTest {
30 |
31 | @Test
32 | public void test() {
33 | ActivityTime at = new OpeningTime(null, "h", 3600);
34 | System.out.println(at);
35 | }
36 |
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/greedo/src/main/java/org/matsim/contrib/emulation/emulators/ActivityEmulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Greedo -- Equilibrium approximation for general-purpose multi-agent simulations.
3 | *
4 | * Copyright 2022 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Greedo.
8 | *
9 | * Greedo is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Greedo is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Greedo. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@gmail.com
23 | *
24 | */
25 | package org.matsim.contrib.emulation.emulators;
26 |
27 | import org.matsim.api.core.v01.population.Activity;
28 | import org.matsim.api.core.v01.population.Person;
29 |
30 | /**
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | */
35 | public interface ActivityEmulator extends PlanElementEmulator {
36 |
37 | public double emulateActivityAndReturnEndTime_s(final Activity activity, final Person person, double time_s,
38 | final boolean isFirstElement, final boolean isLastElement);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/greedo/src/main/java/org/matsim/contrib/emulation/emulators/BasicLegDecomposer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Greedo -- Equilibrium approximation for general-purpose multi-agent simulations.
3 | *
4 | * Copyright 2022 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Greedo.
8 | *
9 | * Greedo is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Greedo is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Greedo. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@gmail.com
23 | *
24 | */
25 | package org.matsim.contrib.emulation.emulators;
26 |
27 | import org.matsim.api.core.v01.population.Leg;
28 | import org.matsim.api.core.v01.population.Plan;
29 |
30 | /**
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | */
35 | public class BasicLegDecomposer extends LegDecomposer {
36 |
37 | @Override
38 | public void processCompositeLeg(Plan plan, Leg leg) {
39 | // Not much to do, we decompose the (already atomic) leg in itself.
40 | super.atomicPlanElements.add(leg);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/greedo/src/main/java/org/matsim/contrib/emulation/emulators/LegEmulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Greedo -- Equilibrium approximation for general-purpose multi-agent simulations.
3 | *
4 | * Copyright 2022 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Greedo.
8 | *
9 | * Greedo is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Greedo is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Greedo. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@gmail.com
23 | *
24 | */
25 | package org.matsim.contrib.emulation.emulators;
26 |
27 | import java.util.List;
28 |
29 | import org.matsim.api.core.v01.population.Person;
30 | import org.matsim.api.core.v01.population.PlanElement;
31 | import org.matsim.core.api.experimental.events.EventsManager;
32 | import org.matsim.core.router.util.TravelTime;
33 |
34 | /**
35 | *
36 | * @author Gunnar Flötteröd
37 | *
38 | */
39 | public interface LegEmulator extends PlanElementEmulator {
40 |
41 | public void setEventsManager(EventsManager eventsManager);
42 |
43 | public void setOverridingTravelTime(TravelTime travelTime);
44 |
45 | public double emulateLegAndReturnEndTime_s(int legIndexInPlan, List planElements, Person person,
46 | double time_s);
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/greedo/src/main/java/org/matsim/contrib/emulation/emulators/PlanElementEmulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Greedo -- Equilibrium approximation for general-purpose multi-agent simulations.
3 | *
4 | * Copyright 2022 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Greedo.
8 | *
9 | * Greedo is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Greedo is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Greedo. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@gmail.com
23 | *
24 | */
25 | package org.matsim.contrib.emulation.emulators;
26 |
27 | /**
28 | *
29 | * @author Gunnar Flötteröd
30 | *
31 | */
32 | public interface PlanElementEmulator {
33 |
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/misc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 |
9 | gunnarfloetteroed
10 | java
11 | MASTER-SNAPSHOT
12 |
13 |
14 | misc
15 | misc
16 |
17 |
18 |
19 | gunnarfloetteroed
20 | utilities
21 | MASTER-SNAPSHOT
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/eventbased/AbstractEvent.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.eventbased;
2 |
3 | /**
4 | *
5 | * @author Gunnar Flötteröd
6 | *
7 | * @param
8 | * the event type
9 | *
10 | */
11 | public abstract class AbstractEvent> implements
12 | Comparable {
13 |
14 | // -------------------- CONSTANTS --------------------
15 |
16 | private final double time;
17 |
18 | // -------------------- CONSTRUCTION --------------------
19 |
20 | public AbstractEvent(final double time) {
21 | this.time = time;
22 | }
23 |
24 | // --------------------GETTERS --------------------
25 |
26 | public double getTime() {
27 | return this.time;
28 | }
29 |
30 | // --------------------IMPLEMENTATION OF Comparable --------------------
31 |
32 | @Override
33 | public int compareTo(final E other) {
34 | return (int) Math.signum(this.time - other.getTime());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/eventbased/PrintEventHandler.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.eventbased;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | * @param
10 | * the event type
11 | */
12 | public class PrintEventHandler> extends
13 | AbstractEventHandler {
14 |
15 | // --------------- OVERRIDING OF AbstractEventHandler ---------------
16 |
17 | @Override
18 | public boolean isResponsible(final E event) {
19 | return true;
20 | }
21 |
22 | @Override
23 | public List process(final E event) {
24 | System.out.println(event);
25 | return null;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/ExponentialDistribution.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | import java.util.Random;
4 |
5 | import floetteroed.misc.simulation.eventbased.DistributionRealizer;
6 |
7 | /**
8 | *
9 | * @author Gunnar Flötteröd
10 | *
11 | */
12 | public class ExponentialDistribution implements UnivariateDistribution {
13 |
14 | // -------------------- CONSTANTS --------------------
15 |
16 | private final Random rnd;
17 |
18 | private final double lambda;
19 |
20 | // -------------------- CONSTRUCTION --------------------
21 |
22 | public ExponentialDistribution(final double lambda, final Random rnd) {
23 | this.rnd = rnd;
24 | this.lambda = lambda;
25 | }
26 |
27 | public double getLambda() {
28 | return this.lambda;
29 | }
30 |
31 | // --------------- IMPLEMENTATION of UnivariateDistribution ---------------
32 |
33 | @Override
34 | public double next() {
35 | return DistributionRealizer.drawExponential(this.lambda, this.rnd);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/KWMQueueingSimEvent.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | import floetteroed.misc.simulation.eventbased.AbstractEvent;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | */
10 | public class KWMQueueingSimEvent extends AbstractEvent {
11 |
12 | // -------------------- TYPES --------------------
13 |
14 | public static enum TYPE {
15 | UQ_JOB_ARR, UQ_SPACE_ARR, DQ_JOB_ARR, DQ_JOB_SERVICE, NULL;
16 | };
17 |
18 | // -------------------- CONSTANTS --------------------
19 |
20 | private final TYPE type;
21 |
22 | private final KWMQueueingSimLink link;
23 |
24 | private final KWMQueueingSimJob job;
25 |
26 | // --------------------CONSTRUCTION --------------------
27 |
28 | public KWMQueueingSimEvent(final double time_s, final TYPE type,
29 | final KWMQueueingSimLink link, final KWMQueueingSimJob job) {
30 | super(time_s);
31 | this.type = type;
32 | this.link = link;
33 | this.job = job;
34 | }
35 |
36 | // --------------------GETTERS --------------------
37 |
38 | public double getTime_s() {
39 | return this.getTime();
40 | }
41 |
42 | public TYPE getType() {
43 | return this.type;
44 | }
45 |
46 | public KWMQueueingSimLink getLink() {
47 | return this.link;
48 | }
49 |
50 | public KWMQueueingSimJob getJob() {
51 | return this.job;
52 | }
53 |
54 | // -------------------- OVERRIDING OF OBJECT --------------------
55 |
56 | @Override
57 | public String toString() {
58 | return this.type + " of job "
59 | + (this.job == null ? "null" : this.job.getId()) + " at time "
60 | + this.getTime_s() + "s on link "
61 | + (this.link == null ? "null" : this.link.getId());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/KWMQueueingSimJob.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | /**
4 | *
5 | * @author Gunnar Flötteröd
6 | *
7 | */
8 | public interface KWMQueueingSimJob {
9 |
10 | public String getId();
11 |
12 | public double getStartTime_s();
13 |
14 | public KWMQueueingSimLink getOriginLink();
15 |
16 | public KWMQueueingSimLink getDestinationLink();
17 |
18 | public KWMQueueingSimLink getNextLink();
19 |
20 | public KWMQueueingSimLink getCurrentLink();
21 |
22 | public void advanceToNextLink();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/KWMQueueingSimNetwork.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | import floetteroed.utilities.networks.construction.AbstractNetwork;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | */
10 | public class KWMQueueingSimNetwork extends
11 | AbstractNetwork {
12 |
13 | // -------------------- CONSTRUCTION --------------------
14 |
15 | public KWMQueueingSimNetwork(final String id, final String type) {
16 | super(id, type);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/KWMQueueingSimNode.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | import floetteroed.utilities.networks.construction.AbstractNode;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | */
10 | public class KWMQueueingSimNode extends
11 | AbstractNode {
12 |
13 | // -------------------- CONSTRUCTION --------------------
14 |
15 | public KWMQueueingSimNode(final String id) {
16 | super(id);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/SingletonDistribution.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | /**
4 | *
5 | * @author Gunnar Flötteröd
6 | *
7 | */
8 | public class SingletonDistribution implements UnivariateDistribution {
9 |
10 | // -------------------- CONSTANTS --------------------
11 |
12 | public final double value;
13 |
14 | // -------------------- CONSTRUCTION --------------------
15 |
16 | public SingletonDistribution(final double value) {
17 | this.value = value;
18 | }
19 |
20 | // --------------- IMPLEMENTATION of UnivariateDistribution ---------------
21 |
22 | @Override
23 | public double next() {
24 | return value;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/UnivariateDistribution.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | /**
4 | *
5 | * @author Gunnar Flötteröd
6 | *
7 | */
8 | public interface UnivariateDistribution {
9 |
10 | public double next();
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/UpstreamJobArrivalHandler.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | import floetteroed.misc.simulation.eventbased.AbstractEventHandler;
7 |
8 | /**
9 | *
10 | * @author Gunnar Flötteröd
11 | *
12 | */
13 | public class UpstreamJobArrivalHandler extends
14 | AbstractEventHandler {
15 |
16 | // -------------------- CONSTRUCTION --------------------
17 |
18 | public UpstreamJobArrivalHandler() {
19 | super();
20 | }
21 |
22 | // --------------- IMPLEMENTATION OF AbstractEventHandler ---------------
23 |
24 | @Override
25 | public boolean isResponsible(final KWMQueueingSimEvent event) {
26 | return KWMQueueingSimEvent.TYPE.UQ_JOB_ARR.equals(event.getType());
27 | }
28 |
29 | @Override
30 | public List process(final KWMQueueingSimEvent event) {
31 |
32 | List newEvents = null;
33 | final KWMQueueingSimLink link = event.getLink();
34 | final KWMQueueingSimJob job = event.getJob();
35 |
36 | if (!link.spillsBack()) {
37 | link.incrUQ();
38 | link.addJobToRQ(job);
39 | job.advanceToNextLink();
40 | newEvents = new LinkedList();
41 | newEvents.add(new KWMQueueingSimEvent(event.getTime_s()
42 | + link.getFwdLag_s(), KWMQueueingSimEvent.TYPE.DQ_JOB_ARR,
43 | link, job));
44 | }
45 |
46 | return newEvents;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/examples/Intersection2x2DemandGenerator.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing.examples;
2 |
3 | import java.util.List;
4 | import java.util.Random;
5 |
6 | import floetteroed.misc.simulation.kwmqueueing.KWMQueueingSimLink;
7 | import floetteroed.misc.simulation.kwmqueueing.jobs.RoutedJob;
8 |
9 | class Intersection2x2DemandGenerator extends DemandGenerator {
10 |
11 | Intersection2x2DemandGenerator(final Random rnd) {
12 | this.setRandom(rnd);
13 | }
14 |
15 | @Override
16 | protected RoutedJob newJob(final String id, final KWMQueueingSimLink originLink,
17 | final KWMQueueingSimLink destinationLink, final List route,
18 | double departureTime_s) {
19 | return new RoutedJob(id, departureTime_s, route);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/misc/src/main/java/floetteroed/misc/simulation/kwmqueueing/io/QueueingNetworkFactory.java:
--------------------------------------------------------------------------------
1 | package floetteroed.misc.simulation.kwmqueueing.io;
2 |
3 | import floetteroed.misc.simulation.kwmqueueing.KWMQueueingSimLink;
4 | import floetteroed.misc.simulation.kwmqueueing.KWMQueueingSimNetwork;
5 | import floetteroed.misc.simulation.kwmqueueing.KWMQueueingSimNode;
6 | import floetteroed.utilities.networks.construction.AbstractNetworkFactory;
7 |
8 | /**
9 | *
10 | * @author Gunnar Flötteröd
11 | *
12 | */
13 | public class QueueingNetworkFactory extends
14 | AbstractNetworkFactory {
15 |
16 | // --------------- IMPLEMENTATION OF AbstractNetworkFactory ---------------
17 |
18 | @Override
19 | protected KWMQueueingSimNetwork newNetwork(final String id, final String type) {
20 | return new KWMQueueingSimNetwork(id, type);
21 | }
22 |
23 | @Override
24 | protected KWMQueueingSimNode newNode(final String id) {
25 | return new KWMQueueingSimNode(id);
26 | }
27 |
28 | @Override
29 | protected KWMQueueingSimLink newLink(final String id) {
30 | return new KWMQueueingSimLink(id);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/opdyts/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /.classpath
3 | /.project
4 |
--------------------------------------------------------------------------------
/opdyts/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 |
9 | gunnarfloetteroed
10 | java
11 | MASTER-SNAPSHOT
12 |
13 |
14 | opdyts
15 | opdyts
16 |
17 |
18 |
19 | gunnarfloetteroed
20 | utilities
21 | MASTER-SNAPSHOT
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/DecisionVariable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts;
26 |
27 | /**
28 | * A decision variable is a set of parameters that may be chosen such that an
29 | * objective function, represented by an instance of ObjectiveFunction, is
30 | * minimized.
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | */
35 | public interface DecisionVariable {
36 |
37 | /**
38 | * Implements the effect of this decision variable in the simulation,
39 | * meaning that the next simulation transition is according to this decision
40 | * variable.
41 | *
42 | * Notes:
43 | * - This needs to influence the simulation in each iteration, not just at the start iterations.
44 | *
45 | */
46 | public void implementInSimulation();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/ObjectiveFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts;
26 |
27 | /**
28 | *
29 | * Am objective function that evaluates a SimulatorState. The smaller the
30 | * objective function value, the better the state.
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | * @param X
35 | * the simulator state type
36 | *
37 | */
38 | public interface ObjectiveFunction {
39 |
40 | public double value(final X state);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/SimulatorState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts;
26 |
27 | import floetteroed.utilities.math.Vector;
28 |
29 | /**
30 | * Represents a simulator state.
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | */
35 | public interface SimulatorState {
36 |
37 | /**
38 | * Returns a reference to a real-valued, fixed-dimensional vector
39 | * representation of this state.
40 | *
41 | * @return a reference to a real-valued, fixed-dimensional vector
42 | * representation of this state
43 | */
44 | public Vector getReferenceToVectorRepresentation();
45 |
46 | /**
47 | * Sets the simulator to this SimulatorState, meaning that the next
48 | * simulation transition starts out from this state.
49 | */
50 | public void implementInSimulation();
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/convergencecriteria/ConvergenceCriterion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.convergencecriteria;
26 |
27 | import java.util.List;
28 |
29 | import floetteroed.opdyts.DecisionVariable;
30 | import floetteroed.opdyts.trajectorysampling.Transition;
31 |
32 | /**
33 | *
34 | * @author Gunnar Flötteröd
35 | *
36 | */
37 | public interface ConvergenceCriterion {
38 |
39 | /**
40 | * Evaluates the ConvergenceCriterion for the given TransitionSequence.
41 | *
42 | * @param transitionSequence
43 | * convergence is evaluated for this sequence
44 | */
45 | public ConvergenceCriterionResult evaluate(
46 | final List> mostRecentTransitionSequence,
47 | final int totalTransitionSequenceLength);
48 |
49 | // public double effectiveAveragingIterations();
50 | }
51 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/filebased/FileBasedObjectiveFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.filebased;
26 |
27 | import floetteroed.opdyts.ObjectiveFunction;
28 | import floetteroed.opdyts.SimulatorState;
29 |
30 | /**
31 | *
32 | * @author Gunnar Flötteröd
33 | *
34 | */
35 | public class FileBasedObjectiveFunction implements ObjectiveFunction {
36 |
37 | // -------------------- CONSTRUCTION --------------------
38 |
39 | public FileBasedObjectiveFunction() {
40 | }
41 |
42 | // --------------- IMPLEMENTATION OF ObjectiveFunction ---------------
43 |
44 | @Override
45 | public double value(final SimulatorState state) {
46 | return ((FileBasedSimulatorState) state).getObjectiveFunctionValue();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/ConvergedObjectiveFunctionValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class ConvergedObjectiveFunctionValue
37 | implements Statistic> {
38 |
39 | public static final String LABEL = "Converged Objective Function Value";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | final Double value = samplingStage.getConvergedObjectiveFunctionValue();
49 | if (value == null) {
50 | return "";
51 | } else {
52 | return Double.toString(value);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/EquilibriumGap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class EquilibriumGap implements
37 | Statistic> {
38 |
39 | @Override
40 | public String label() {
41 | return "Equilibrium Gap";
42 | }
43 |
44 | @Override
45 | public String value(final SamplingStage samplingStage) {
46 | return Double.toString(samplingStage.getEquilibriumGap());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/EquilibriumGapWeight.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class EquilibriumGapWeight implements
37 | Statistic> {
38 |
39 | public static final String LABEL = "Equilibrium Gap Weight";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return Double.toString(samplingStage.getEquilibriumGapWeight());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/FreeMemory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | * TODO This should become general-purpose.
33 | *
34 | * @author Gunnar Flötteröd
35 | *
36 | */
37 | public class FreeMemory implements
38 | Statistic> {
39 |
40 | @Override
41 | public String label() {
42 | return "Free Memory";
43 | }
44 |
45 | @Override
46 | public String value(final SamplingStage samplingStage) {
47 | return Long.toString(Runtime.getRuntime().freeMemory());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/LastDecisionVariable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class LastDecisionVariable implements
37 | Statistic> {
38 |
39 | public static final String LABEL = "Last Decision Variable";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return samplingStage.getLastDecisionVariable().toString();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/LastEquilibriumGap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class LastEquilibriumGap implements
37 | Statistic> {
38 |
39 | @Override
40 | public String label() {
41 | return "Last Equilibrium Gap";
42 | }
43 |
44 | @Override
45 | public String value(final SamplingStage samplingStage) {
46 | return Double.toString(samplingStage.getLastEquilibriumGap());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/LastObjectiveFunctionValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class LastObjectiveFunctionValue implements
37 | Statistic> {
38 |
39 | public static final String LABEL = "Last Objective Function Value";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return Double.toString(samplingStage.getLastObjectiveFunctionValue());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/MaxMemory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | * TODO This should become general-purpose.
33 | *
34 | * @author Gunnar Flötteröd
35 | *
36 | */
37 | public class MaxMemory implements
38 | Statistic> {
39 |
40 | @Override
41 | public String label() {
42 | return "Max. Memory";
43 | }
44 |
45 | @Override
46 | public String value(final SamplingStage samplingStage) {
47 | return Long.toString(Runtime.getRuntime().maxMemory());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/SurrogateObjectiveFunctionValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class SurrogateObjectiveFunctionValue
37 | implements Statistic> {
38 |
39 | public static final String LABEL = "Surrogate Objective Function Value";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return Double.toString(samplingStage
49 | .getSurrogateObjectiveFunctionValue());
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/TotalMemory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | * TODO This should become general-purpose.
33 | *
34 | * @author Gunnar Flötteröd
35 | *
36 | */
37 | public class TotalMemory implements
38 | Statistic> {
39 |
40 | @Override
41 | public String label() {
42 | return "Total Memory";
43 | }
44 |
45 | @Override
46 | public String value(final SamplingStage samplingStage) {
47 | return Long.toString(Runtime.getRuntime().totalMemory());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/TransientObjectiveFunctionValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class TransientObjectiveFunctionValue
37 | implements Statistic> {
38 |
39 | public static final String LABEL = "Q_interpol(alpha)";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return Double.toString(samplingStage
49 | .getOriginalObjectiveFunctionValue());
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/UniformityGap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class UniformityGap implements
37 | Statistic> {
38 |
39 | public UniformityGap() {
40 | }
41 |
42 | @Override
43 | public String label() {
44 | return "Uniformity Gap";
45 | }
46 |
47 | @Override
48 | public String value(final SamplingStage samplingStage) {
49 | return Double.toString(samplingStage.getUniformityGap());
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/logging/UniformityGapWeight.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.logging;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.trajectorysampling.SamplingStage;
29 | import floetteroed.utilities.statisticslogging.Statistic;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public class UniformityGapWeight implements
37 | Statistic> {
38 |
39 | public static final String LABEL = "Uniformity Gap Weight";
40 |
41 | @Override
42 | public String label() {
43 | return LABEL;
44 | }
45 |
46 | @Override
47 | public String value(final SamplingStage samplingStage) {
48 | return Double.toString(samplingStage.getUniformityGapWeight());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/opdyts/src/main/java/floetteroed/opdyts/searchalgorithms/Simulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Opdyts - Optimization of dynamic traffic simulations
3 | *
4 | * Copyright 2015, 2016 Gunnar Flötteröd
5 | *
6 | *
7 | * This file is part of Opdyts.
8 | *
9 | * Opdyts is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * Opdyts is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with Opdyts. If not, see .
21 | *
22 | * contact: gunnar.floetteroed@abe.kth.se
23 | *
24 | */
25 | package floetteroed.opdyts.searchalgorithms;
26 |
27 | import floetteroed.opdyts.DecisionVariable;
28 | import floetteroed.opdyts.SimulatorState;
29 | import floetteroed.opdyts.trajectorysampling.TrajectorySampler;
30 |
31 | /**
32 | *
33 | * @author Gunnar Flötteröd
34 | *
35 | */
36 | public interface Simulator {
37 |
38 | /**
39 | * Implements the same functionality as run(TrajectorySampler, null).
40 | */
41 | public SimulatorState run(TrajectorySampler evaluator);
42 |
43 | public SimulatorState run(TrajectorySampler evaluator,
44 | SimulatorState initialState);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/output/logfileWarningsErrors.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gunnarfloetteroed/java/e7790402b46361e148c67e88abe3ae4e5f98316e/output/logfileWarningsErrors.log
--------------------------------------------------------------------------------
/output/modestats.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gunnarfloetteroed/java/e7790402b46361e148c67e88abe3ae4e5f98316e/output/modestats.png
--------------------------------------------------------------------------------
/utilities/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /testdata/
3 | /.classpath
4 | /.project
5 |
--------------------------------------------------------------------------------
/utilities/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 |
9 | gunnarfloetteroed
10 | java
11 | MASTER-SNAPSHOT
12 |
13 |
14 | utilities
15 | utilities
16 |
17 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/EmptyIterable.java:
--------------------------------------------------------------------------------
1 | package floetteroed.utilities;
2 |
3 | import java.util.Iterator;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | * @param
10 | */
11 | public class EmptyIterable implements Iterable {
12 |
13 | @Override
14 | public Iterator iterator() {
15 | return new EmptyIterator<>();
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/EmptyIterator.java:
--------------------------------------------------------------------------------
1 | package floetteroed.utilities;
2 |
3 | import java.util.Iterator;
4 |
5 | /**
6 | *
7 | * @author Gunnar Flötteröd
8 | *
9 | * @param
10 | */
11 | public class EmptyIterator implements Iterator {
12 |
13 | @Override
14 | public boolean hasNext() {
15 | return false;
16 | }
17 |
18 | @Override
19 | public T next() {
20 | return null;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/ErrorMsgPrinter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities;
21 |
22 | import java.io.PrintStream;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class ErrorMsgPrinter {
30 |
31 | private ErrorMsgPrinter() {
32 | // do note instantiate
33 | }
34 |
35 | public static void toStream(final Exception e, final PrintStream stream) {
36 | stream.println();
37 | stream.println("The program terminated "
38 | + "because of an unrecoverable error:");
39 | stream.println(e.getMessage());
40 | stream.println();
41 | stream.println("------------------------------"
42 | + "------------------------------");
43 | stream.println("Stack trace:");
44 | e.printStackTrace(stream);
45 | }
46 |
47 | public static void toStdOut(final Exception e) {
48 | toStream(e, System.out);
49 | }
50 |
51 | public static void toErrOut(final Exception e) {
52 | toStream(e, System.err);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/TimeDiscretization.java:
--------------------------------------------------------------------------------
1 | package floetteroed.utilities;
2 |
3 | /**
4 | *
5 | * @author Gunnar Flötteröd
6 | *
7 | */
8 | public class TimeDiscretization {
9 |
10 | private final int startTime_s;
11 |
12 | private final int binSize_s;
13 |
14 | private final int binCnt;
15 |
16 | public TimeDiscretization(final int startTime_s, final int binSize_s, final int binCnt) {
17 | this.startTime_s = startTime_s;
18 | this.binSize_s = binSize_s;
19 | this.binCnt = binCnt;
20 | }
21 |
22 | public int getStartTime_s() {
23 | return this.startTime_s;
24 | }
25 |
26 | public int getBinSize_s() {
27 | return this.binSize_s;
28 | }
29 |
30 | public int getBinCnt() {
31 | return this.binCnt;
32 | }
33 |
34 | // TODO NEW
35 | public int getBin(final double time_s) {
36 | return (int) ((time_s - this.startTime_s) / this.binSize_s);
37 | }
38 |
39 | // TODO NEW
40 | public int getBinStartTime_s(final int bin) {
41 | return this.startTime_s + bin * this.binSize_s;
42 | }
43 |
44 | // TODO NEW
45 | public int getBinCenterTime_s(final int bin) {
46 | return this.getBinStartTime_s(bin) + this.binSize_s / 2;
47 | }
48 |
49 | // TODO NEW
50 | public int getBinEndTime_s(final int bin) {
51 | return this.getBinStartTime_s(bin + 1);
52 | }
53 |
54 | // TODO NEW
55 | public int getEndTime_s() {
56 | return this.getBinStartTime_s(this.binCnt);
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return this.getClass().getSimpleName() + " start time = " + Time.strFromSec(this.startTime_s) + ", bin size = "
62 | + Time.strFromSec(this.binSize_s) + ", number of bins = " + this.binCnt + ".";
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/config/Configurable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.config;
21 |
22 |
23 | /**
24 | * BIOROUTE interface. This is the super-interface of all other
25 | * BIOROUTE interfaces. Enables the configuration of reflectively generated
26 | * classes.
27 | *
28 | * @author Gunnar Flötteröd
29 | *
30 | */
31 | public interface Configurable {
32 |
33 | /**
34 | * Configures this instance. Should be called right after instantiation.
35 | *
36 | * @param config
37 | * object representation of the XML sub-tree defining
38 | * this object and its configuration
39 | */
40 | public void configure(final Config config);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/math/metropolishastings/MHProposal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.math.metropolishastings;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public interface MHProposal {
29 |
30 | public S newInitialState();
31 |
32 | public MHTransition newTransition(final S state);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/math/metropolishastings/MHStateProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.math.metropolishastings;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public interface MHStateProcessor {
29 |
30 | public void start();
31 |
32 | public void processState(final S state);
33 |
34 | public void end();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/math/metropolishastings/MHWeight.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.math.metropolishastings;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public interface MHWeight {
29 |
30 | public double logWeight(final S State);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/basic/BasicLink.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.basic;
21 |
22 | import floetteroed.utilities.networks.construction.AbstractLink;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class BasicLink extends AbstractLink {
30 |
31 | public BasicLink(String id) {
32 | super(id);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/basic/BasicNetwork.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.basic;
21 |
22 | import floetteroed.utilities.networks.construction.AbstractNetwork;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class BasicNetwork extends AbstractNetwork {
30 |
31 | public BasicNetwork(String id, String type) {
32 | super(id, type);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/basic/BasicNetworkFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.basic;
21 |
22 | import floetteroed.utilities.networks.construction.AbstractNetworkFactory;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class BasicNetworkFactory extends
30 | AbstractNetworkFactory {
31 |
32 | @Override
33 | protected BasicNetwork newNetwork(final String id, final String type) {
34 | return new BasicNetwork(id, type);
35 | }
36 |
37 | @Override
38 | protected BasicNode newNode(String id) {
39 | return new BasicNode(id);
40 | }
41 |
42 | @Override
43 | protected BasicLink newLink(String id) {
44 | return new BasicLink(id);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/basic/BasicNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.basic;
21 |
22 | import floetteroed.utilities.networks.construction.AbstractNode;
23 |
24 | /**
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public class BasicNode extends AbstractNode {
30 |
31 | public BasicNode(String id) {
32 | super(id);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/construction/NetworkPostprocessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.construction;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public interface NetworkPostprocessor {
29 |
30 | public void run(final NET network);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/networks/shortestpaths/LinkCost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.networks.shortestpaths;
21 |
22 | import floetteroed.utilities.networks.basic.BasicLink;
23 |
24 |
25 | /**
26 | *
27 | * @author Gunnar Flötteröd
28 | *
29 | */
30 | public interface LinkCost {
31 |
32 | public double getCost(final BasicLink link);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/simulatedannealing/ProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.simulatedannealing;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public interface ProgressListener {
29 |
30 | public void notifyCurrentState(final S state,
31 | final double currentObjectiveFunctions,
32 | final double alternativeObjectiveFunction);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/simulatedannealing/SolutionEvaluator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.simulatedannealing;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | * the solution type
28 | */
29 | public interface SolutionEvaluator {
30 |
31 | public boolean feasible(final S solution);
32 |
33 | public double evaluation(final S solution);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/simulatedannealing/SolutionGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.simulatedannealing;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param the solution type
27 | */
28 | public interface SolutionGenerator {
29 |
30 | public S randomGeneration();
31 |
32 | public S variation(final S original);
33 |
34 | public S copy(final S original);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/simulatedannealing/TextOutputProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.simulatedannealing;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param
27 | */
28 | public class TextOutputProgressListener implements ProgressListener {
29 |
30 | private int it = 0;
31 |
32 | @Override
33 | public void notifyCurrentState(final S state,
34 | final double currentObjectiveFunction,
35 | final double alternativeObjectiveFunction) {
36 | System.out.println("it. " + (this.it++) + ": f(x) = "
37 | + alternativeObjectiveFunction + ", fOpt(x) = "
38 | + currentObjectiveFunction + ", xOpt = " + state);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/statisticslogging/Statistic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.statisticslogging;
21 |
22 | /**
23 | *
24 | * @author Gunnar Flötteröd
25 | *
26 | * @param D
27 | * the data type from which the statistic is to be extracted
28 | *
29 | */
30 | public interface Statistic {
31 |
32 | public static String toString(Object arg) {
33 | if (arg == null) {
34 | return "";
35 | } else {
36 | return arg.toString();
37 | }
38 | }
39 |
40 | public String label();
41 |
42 | public String value(D data);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/statisticslogging/TimeStampStatistic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.statisticslogging;
21 |
22 | import java.text.SimpleDateFormat;
23 | import java.util.Date;
24 |
25 | /**
26 | *
27 | * @author Gunnar Flötteröd
28 | *
29 | */
30 | public class TimeStampStatistic implements Statistic {
31 |
32 | public static final String TIMESTAMP = "Timestamp";
33 |
34 | public TimeStampStatistic() {
35 | }
36 |
37 | @Override
38 | public String label() {
39 | return TIMESTAMP;
40 | }
41 |
42 | @Override
43 | public String value(final D data) {
44 | return (new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss")).format(new Date(
45 | System.currentTimeMillis()));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/tabularfileparser/TabularFileHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.tabularfileparser;
21 |
22 | /**
23 | * An implementation of this interface is expected by the
24 | * TabularFileParser
for row-by-row handling of parsed files.
25 | *
26 | * @author Gunnar Flötteröd
27 | *
28 | */
29 | public interface TabularFileHandler {
30 |
31 | public String preprocess(final String line);
32 |
33 | public void startDocument();
34 |
35 | /**
36 | * Is called by the TabularFileParser
whenever a row has been
37 | * parsed
38 | *
39 | * @param row
40 | * a String[]
representation of the parsed row's
41 | * columns
42 | */
43 | public void startRow(String[] row);
44 |
45 | public void endDocument();
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/utilities/src/main/java/floetteroed/utilities/visualization/MoviePlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, 2016 Gunnar Flötteröd
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | *
17 | * contact: gunnar.floetteroed@abe.kth.se
18 | *
19 | */
20 | package floetteroed.utilities.visualization;
21 |
22 | import java.util.TimerTask;
23 |
24 | /**
25 | * The entire utilitis.visualization package is experimental!
26 | *
27 | * @author Gunnar Flötteröd
28 | *
29 | */
30 | class MoviePlayer extends TimerTask {
31 |
32 | // -------------------- CONSTANTS --------------------
33 |
34 | private final RenderableDynamicData data;
35 |
36 | private final NetVis vis;
37 |
38 | // -------------------- CONSTRUCTION --------------------
39 |
40 | MoviePlayer(final RenderableDynamicData data, final NetVis viz) {
41 | this.data = data;
42 | this.vis = viz;
43 | }
44 |
45 | // -------------------- IMPLEMENTATION OF TimerTask --------------------
46 |
47 | public void run() {
48 | this.data.fwd();
49 | this.vis.repaintForMovie();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------