本文整理了Java中org.matsim.api.core.v01.population.Activity.getStartTime()
方法的一些代码示例,展示了Activity.getStartTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getStartTime()
方法的具体详情如下:
包路径:org.matsim.api.core.v01.population.Activity
类名称:Activity
方法名:getStartTime
暂无
代码示例来源:origin: matsim-org/matsim
@Override
public double getStartTime() {
return act.getStartTime();
}
代码示例来源:origin: matsim-org/matsim
@Override
public double getStartTime() {
return this.delegate.getStartTime() ;
}
代码示例来源:origin: matsim-org/matsim
@Override
public void handleLastActivity(Activity act) {
this.currentActivityStartTime = act.getStartTime();
this.handleOvernightActivity(act);
this.firstActivity = null;
}
代码示例来源:origin: matsim-org/matsim
@Override
public double getStartTime() {
return this.delegate.getStartTime();
}
@Override
代码示例来源:origin: matsim-org/matsim
@Override
public void handleLastActivity(Activity act) {
this.currentActivityStartTime = act.getStartTime();
this.handleOvernightActivity(act);
this.firstActivity = null;
}
代码示例来源:origin: matsim-org/matsim
public final void handleActivity(Activity activity) {
if (activity.getStartTime() != Time.UNDEFINED_TIME) {
startActivity(activity.getStartTime(), activity);
}
if (activity.getEndTime() != Time.UNDEFINED_TIME) {
endActivity(activity.getEndTime(), activity);
}
}
代码示例来源:origin: matsim-org/matsim
@Override
public final void handleActivity(Activity activity) {
if (activity.getStartTime() != Time.UNDEFINED_TIME) {
startActivity(activity.getStartTime(), activity);
}
if (activity.getEndTime() != Time.UNDEFINED_TIME) {
endActivity(activity.getEndTime(), activity);
}
}
代码示例来源:origin: matsim-org/matsim
@Override
public void handleActivity(Activity act) {
this.score += calcActScore(act.getStartTime(), act.getEndTime(), act);
}
代码示例来源:origin: matsim-org/matsim
@Override
public void handleActivity(Activity act) {
this.score += calcActScore(act.getStartTime(), act.getEndTime(), act);
}
代码示例来源:origin: matsim-org/matsim
@Override
public void startAct(final Activity act, final BufferedWriter out) throws IOException {
out.write("\t\t\t<act");
out.write(" type=\"" + act.getType() + "\"");
if (act.getCoord() != null) {
final Coord coord = coordinateTransformation.transform( act.getCoord() );
out.write(" x100=\"" + coord.getX() + "\"");
out.write(" y100=\"" + coord.getY() + "\"");
}
if (act.getLinkId() != null)
out.write(" link=\"" + act.getLinkId() + "\"");
if (act.getStartTime() != Integer.MIN_VALUE)
out.write(" start_time=\"" + Time.writeTime(act.getStartTime()) + "\"");
if (!Time.isUndefinedTime(act.getMaximumDuration()))
out.write(" dur=\"" + Time.writeTime(act.getMaximumDuration()) + "\"");
if (act.getEndTime() != Integer.MIN_VALUE)
out.write(" end_time=\"" + Time.writeTime(act.getEndTime()) + "\"");
out.write(" />\n");
}
代码示例来源:origin: matsim-org/matsim
public ActivitySerializable(Activity act) {
coord = new CoordSerializable(act.getCoord());
endTime = act.getEndTime();
facIdString = act.getFacilityId() == null ? null : act.getFacilityId().toString();
linkIdString = act.getLinkId() == null ? null : act.getLinkId().toString();
maximumDuration = act.getMaximumDuration();
startTime = act.getStartTime();
type = act.getType();
}
代码示例来源:origin: matsim-org/matsim
@Override
public void handleActivity(Activity act) {
if(act instanceof FreightActivity) {
double actStartTime = act.getStartTime();
// log.info(act + " start: " + Time.writeTime(actStartTime));
TimeWindow tw = ((FreightActivity) act).getTimeWindow();
if(actStartTime > tw.getEnd()){
double penalty_score = (-1)*(actStartTime - tw.getEnd())*missedTimeWindowPenalty;
assert penalty_score <= 0.0 : "penalty score must be negative";
// log.info("penalty " + penalty_score);
score += penalty_score;
}
double actTimeCosts = (act.getEndTime()-actStartTime)*timeParameter;
// log.info("actCosts " + actTimeCosts);
assert actTimeCosts >= 0.0 : "actTimeCosts must be positive";
score += actTimeCosts*(-1);
}
}
代码示例来源:origin: matsim-org/matsim
private SimpleFeature getActFeature(final String id, final Activity act) {
String type = act.getType();
String linkId = act.getLinkId().toString();
Double startTime = act.getStartTime();
Double endTime = act.getEndTime();
double rx = MatsimRandom.getRandom().nextDouble() * this.actBlurFactor;
double ry = MatsimRandom.getRandom().nextDouble() * this.actBlurFactor;
Coord cc = this.network.getLinks().get(act.getLinkId()).getCoord();
Coord c = new Coord(cc.getX() + rx, cc.getY() + ry);
try {
return this.actBuilder.buildFeature(null, new Object [] {MGC.coord2Point(c), id, type, linkId, startTime, endTime});
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: matsim-org/matsim
private static double calcTripDuration(List<PlanElement> planElements) {
double duration = 0.0;
for (PlanElement pe : planElements) {
if (pe instanceof Activity) {
Activity act = (Activity) pe;
double endTime = act.getEndTime();
double startTime = act.getStartTime();
if (startTime != Time.UNDEFINED_TIME && endTime != Time.UNDEFINED_TIME) {
duration += (endTime - startTime);
}
} else if (pe instanceof Leg) {
Leg leg = (Leg) pe;
duration += leg.getTravelTime();
}
}
return duration;
}
代码示例来源:origin: matsim-org/matsim
@Override
public final void handleActivity(Activity activity) {
double startTime = activity.getStartTime();
double endTime = activity.getEndTime();
if (Time.isUndefinedTime(startTime) && !Time.isUndefinedTime(endTime)) {
for (ActivityScoring activityScoringFunction : this.activityScoringFunctions) {
activityScoringFunction.handleFirstActivity(activity);
}
} else if (!Time.isUndefinedTime(startTime) && !Time.isUndefinedTime(endTime)) {
for (ActivityScoring activityScoringFunction : this.activityScoringFunctions) {
activityScoringFunction.handleActivity(activity);
}
} else if (!Time.isUndefinedTime(startTime) && Time.isUndefinedTime(endTime)) {
for (ActivityScoring activityScoringFunction : this.activityScoringFunctions) {
activityScoringFunction.handleLastActivity(activity);
}
} else {
throw new RuntimeException("Trying to score an activity without start or end time. Should not happen.");
}
}
代码示例来源:origin: matsim-org/matsim
private static void copyPlanFieldsToFrom1(Plan planTarget, Plan planTemplate) {
planTarget.setScore(planTemplate.getScore());
int actLegIndex = 0;
for (PlanElement pe : planTarget.getPlanElements()) {
if (pe instanceof Activity) {
Activity actTemplate = ((Activity) planTemplate.getPlanElements().get(actLegIndex));
((Activity) pe).setEndTime(actTemplate.getEndTime());
((Activity) pe).setCoord(actTemplate.getCoord());
((Activity) pe).setFacilityId(actTemplate.getFacilityId());
((Activity) pe).setLinkId(actTemplate.getLinkId());
((Activity) pe).setMaximumDuration(actTemplate.getMaximumDuration());
((Activity) pe).setStartTime(actTemplate.getStartTime());
((Activity) pe).setType(actTemplate.getType());
} else if (pe instanceof Leg) {
Leg legTemplate = ((Leg)planTemplate.getPlanElements().get(actLegIndex));
Leg r = ((Leg) pe);
r.setTravelTime( legTemplate.getDepartureTime() + legTemplate.getTravelTime() - r.getDepartureTime() );
((Leg) pe).setDepartureTime(legTemplate.getDepartureTime());
((Leg) pe).setMode(legTemplate.getMode());
((Leg) pe).setRoute(legTemplate.getRoute());
((Leg) pe).setTravelTime(legTemplate.getTravelTime());
} else throw new RuntimeException("Unexpected PlanElement type was found: " + pe.getClass().toString() + ". Aborting!");
actLegIndex++;
}
}
代码示例来源:origin: matsim-org/matsim
public static void copyFromTo(Activity act, Activity newAct) {
Coord coord = act.getCoord() == null ? null : new Coord(act.getCoord().getX(), act.getCoord().getY());
// (we don't want to copy the coord ref, but rather the contents!)
newAct.setCoord(coord);
newAct.setType( act.getType() );
newAct.setLinkId(act.getLinkId());
newAct.setStartTime(act.getStartTime());
newAct.setEndTime(act.getEndTime());
newAct.setMaximumDuration(act.getMaximumDuration());
newAct.setFacilityId(act.getFacilityId());
AttributesUtils.copyAttributesFromTo( act , newAct );
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testCreateNightActivity() {
EventsToActivities testee = new EventsToActivities();
MockActivityHandler ah = new MockActivityHandler();
testee.addActivityHandler(ah);
testee.reset(0);
testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home"));
Assert.assertNotNull(ah.handledActivity);
Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getStartTime(), 1e-8);
Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime(), 1e-8);
ah.reset();
testee.handleEvent(new ActivityStartEvent(90.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home"));
testee.finish();
Assert.assertNotNull(ah.handledActivity);
Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getEndTime(), 1e-8);
Assert.assertEquals(90.0, ah.handledActivity.getActivity().getStartTime(), 1e-8);
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testDontCreateNightActivityIfNoneIsBeingPerformedWhenSimulationEnds() {
EventsToActivities testee = new EventsToActivities();
MockActivityHandler ah = new MockActivityHandler();
testee.addActivityHandler(ah);
testee.reset(0);
testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("f1", ActivityFacility.class), "home"));
Assert.assertNotNull(ah.handledActivity);
Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getStartTime(), 1e-8);
Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime(), 1e-8);
ah.reset();
testee.finish();
Assert.assertNull(ah.handledActivity);
}
代码示例来源:origin: matsim-org/matsim
@Test
public void testCreatesActivty() {
EventsToActivities testee = new EventsToActivities();
MockActivityHandler ah = new MockActivityHandler();
testee.addActivityHandler(ah);
testee.reset(0);
testee.handleEvent(new ActivityStartEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "work"));
testee.handleEvent(new ActivityEndEvent(30.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "work"));
Assert.assertNotNull(ah.handledActivity);
Assert.assertEquals(10.0, ah.handledActivity.getActivity().getStartTime(), 1e-8);
Assert.assertEquals(30.0, ah.handledActivity.getActivity().getEndTime(), 1e-8);
}
内容来源于网络,如有侵权,请联系作者删除!