21 package org.matsim.run;
23 import java.io.BufferedWriter;
24 import java.io.IOException;
66 private final static String
outfileTable=
"./output/analyseSelectedPlansTable.txt";
67 private final static String
outfileAverages=
"./output/analyseSelectedPlansTableAverages.txt";
88 public static void main(
final String[] args) {
90 if (args.length < 2 || args.length > 3 ) {
91 System.out.println(
"Too few arguments.");
100 if (args.length==3) {
102 table.
run(args[0], args[1], args[2]);
108 table.
run(args[0], args[1],
"");
115 private void init(
final String networkPath) {
121 System.out.println(
" reading the network...");
126 System.out.println(
" reading file "+plansfilePath);
128 plansReader.
readFile(plansfilePath);
135 final String header=
"plansfile_nr\tplantraveltime\tplantraveldistance\t" +
136 "legtraveltime\tlegtraveldistance\tnumberoflegs";
142 final int nr_selectedplans=this.plans0.
getPersons().size();
149 for (
int i=0; i<i_max; i++) {
151 out.write(this.sumPlanTraveltime[i]/nr_selectedplans+
"\t");
152 out.write(this.sumPlanTraveldistance[i]/nr_selectedplans+
"\t");
153 out.write(this.sumLegTraveltime[i]/nr_selectedplans+
"\t");
154 out.write(this.sumLegTraveldistance[i]/nr_selectedplans+
"\t");
155 out.write(this.sumNrLegs[i]/nr_selectedplans+
"\t");
161 catch (
final IOException e) {
170 String header=
"personid\tsex\tage\tlicense\tcaravail\temployed\thomex\thomey\thomelink\t" +
171 "score0\tplantraveltime0\tplantraveldistance0\tnumberoftrips0\t";
174 header=header.concat(
"score1\tplantraveltime1\tplantraveldistance1\tnumberoftrips1");
185 out.write(person_id.toString()+
"\t");
196 Plan selectedPlanImpl = (
Plan) selectedPlan;
199 String link_id =
"-";
201 if (firstActivity.
getType().substring(0,1).equals(
"h")) {
204 link_id = firstActivity.
getLinkId().toString();
208 out.write(c.
getX()+
"\t");
209 out.write(c.
getY()+
"\t");
214 out.write(link_id+
"\t");
217 out.write(selectedPlan.
getScore()+
"\t");
238 this.sumPlanTraveldistance[1]+=this.
getTravelDist(person_comp);
250 catch (
final IOException e) {
259 double travelTime=0.0;
261 if (pe instanceof
Leg) {
262 travelTime+= ((Leg)pe).getTravelTime().seconds();
269 double travelDist=0.0;
271 if (pe instanceof
Leg) {
272 travelDist+=((Leg) pe).getRoute().getDistance();
281 if (pe instanceof
Leg) {
290 private void run(
final String networkPath,
final String plansfilePath0,
final String plansfilePath1) {
291 this.
init(networkPath);
294 System.out.println(this.twoPlans);
302 System.out.println(
"finished");
306 System.out.println();
307 System.out.println(
"CreateSelectedPlansTables:");
308 System.out.println();
309 System.out.println(
"Creates an agent-based table including all agent \n" +
310 "attributes, the selected plan score and the plan and \n" +
311 "leg travel times and distances and \n" +
312 "another table containing the aggregated values.");
313 System.out.println();
314 System.out.println(
"usage: CompareSelectedPlansTable args");
315 System.out.println(
" arg 0: path to network file (required)");
316 System.out.println(
" arg 1: path to plans file 0 (required)");
317 System.out.println(
" arg 2: path to plans file 1 (optional)");
319 System.out.println(
"----------------");
320 System.out.println(
"2008, matsim.org");
321 System.out.println();
341 this.myPopulation = population;
350 return new Coord(x, y);
void init(final String networkPath)
void addScenarioElement(String name, Object o)
static final void startMeasurement()
void readPlansFile(final String plansfilePath, final Population plans)
final double [] sumLegTraveltime
static final String outfileAverages
Vehicles getTransitVehicles()
static void main(final String[] args)
static String getCarAvail(Person person)
void setTwoPlans(final boolean twoPlans)
double getTravelDist(final Person person)
void addScenarioElement(String name, Object o)
final double [] sumPlanTraveldistance
TransitSchedule getTransitSchedule()
Coord createCoord(double x, double y)
final Population myPopulation
Map< Id< Person >,? extends Person > getPersons()
void run(final String networkPath, final String plansfilePath0, final String plansfilePath1)
Object getScenarioElement(String name)
double getTravelTime(final Person person)
static BufferedWriter getBufferedWriter(URL url, Charset charset, boolean append)
static Boolean isEmployed(Person person)
Vehicles getTransitVehicles()
final double [] sumPlanTraveltime
static String getSex(Person person)
static final String outfileTable
Population getPopulation()
Households getHouseholds()
final double [] sumLegTraveldistance
static final void printElapsedTime()
int getNumberOfTrips(final Person person)
final Network getNetwork()
ActivityFacilities getActivityFacilities()
Object getScenarioElement(String name)
TransitSchedule getTransitSchedule()
ActivityFacilities getActivityFacilities()
static Integer getAge(Person person)
static Scenario createScenario(final Config config)
void readFile(String filename)
static Activity getFirstActivity(Plan plan)
PseudoScenario(final Scenario scenario, final Population population)
Households getHouseholds()
static String getLicense(Person person)
static Config createConfig(final String context)
abstract T getSelectedPlan()