本文整理了Java中org.matsim.api.core.v01.population.Activity.getMaximumDuration()
方法的一些代码示例,展示了Activity.getMaximumDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getMaximumDuration()
方法的具体详情如下:
包路径:org.matsim.api.core.v01.population.Activity
类名称:Activity
方法名:getMaximumDuration
暂无
代码示例来源:origin: matsim-org/matsim
@Override
public double getMaximumDuration() {
return this.delegate.getMaximumDuration() ;
}
代码示例来源:origin: matsim-org/matsim
@Override
public double getMaximumDuration() {
return act.getMaximumDuration();
}
代码示例来源:origin: matsim-org/matsim
private static double updateTime(
final double currTime,
final Activity act) {
double e = act.getEndTime();
double d = act.getMaximumDuration();
return e != Time.UNDEFINED_TIME ? e :
currTime + ( d != Time.UNDEFINED_TIME ? d : 0 );
}
代码示例来源:origin: matsim-org/matsim
@Override
public double getMaximumDuration() {
return this.delegate.getMaximumDuration();
}
@Override
代码示例来源:origin: matsim-org/matsim
/**
* Computes the (expected or planned) activity end time, depending on the configured time interpretation.
*/
public static double getActivityEndTime( Activity act, double now, Config config ) {
switch ( config.plans().getActivityDurationInterpretation() ) {
case endTimeOnly:
return act.getEndTime() ;
case tryEndTimeThenDuration:
if ( act.getEndTime() != Time.UNDEFINED_TIME ) {
return act.getEndTime() ;
} else if ( act.getMaximumDuration() != Time.UNDEFINED_TIME ) {
return now + act.getMaximumDuration() ;
} else {
return Time.UNDEFINED_TIME ;
}
case minOfDurationAndEndTime:
return Math.min( now + act.getMaximumDuration() , act.getEndTime() ) ;
default:
break ;
}
return Time.UNDEFINED_TIME ;
}
代码示例来源:origin: matsim-org/matsim
out.write("\"");
if (act.getMaximumDuration() != Time.UNDEFINED_TIME) {
out.write(" dur=\"");
out.write(Time.writeTime(act.getMaximumDuration()));
out.write("\"");
代码示例来源:origin: matsim-org/matsim
private static double updateNow(
final double now,
final PlanElement pe) {
if (pe instanceof Activity) {
Activity act = (Activity) pe;
double endTime = act.getEndTime();
double startTime = act.getStartTime();
double dur = (act instanceof Activity ? ((Activity) act).getMaximumDuration() : Time.UNDEFINED_TIME);
if (endTime != Time.UNDEFINED_TIME) {
// use fromAct.endTime as time for routing
return endTime;
}
else if ((startTime != Time.UNDEFINED_TIME) && (dur != Time.UNDEFINED_TIME)) {
// use fromAct.startTime + fromAct.duration as time for routing
return startTime + dur;
}
else if (dur != Time.UNDEFINED_TIME) {
// use last used time + fromAct.duration as time for routing
return now + dur;
}
else {
throw new RuntimeException("activity has neither end-time nor duration." + act);
}
}
double tt = ((Leg) pe).getTravelTime();
return now + (tt != Time.UNDEFINED_TIME ? tt : 0);
}
代码示例来源:origin: matsim-org/matsim
private static double updateNow(
final double now,
final PlanElement pe) {
if (pe instanceof Activity) {
Activity act = (Activity) pe;
double endTime = act.getEndTime();
double startTime = act.getStartTime();
double dur = (act instanceof Activity ? act.getMaximumDuration() : Time.UNDEFINED_TIME);
if (endTime != Time.UNDEFINED_TIME) {
// use fromAct.endTime as time for routing
return endTime;
}
else if ((startTime != Time.UNDEFINED_TIME) && (dur != Time.UNDEFINED_TIME)) {
// use fromAct.startTime + fromAct.duration as time for routing
return startTime + dur;
}
else if (dur != Time.UNDEFINED_TIME) {
// use last used time + fromAct.duration as time for routing
return now + dur;
}
else {
throw new RuntimeException("activity has neither end-time nor duration." + act);
}
}
double tt = ((Leg) pe).getTravelTime();
return now + (tt != Time.UNDEFINED_TIME ? tt : 0);
}
}
代码示例来源:origin: matsim-org/matsim
out.write("\"");
if (!Time.isUndefinedTime(act.getMaximumDuration())) {
out.write(" max_dur=\"");
out.write(Time.writeTime(act.getMaximumDuration()));
out.write("\"");
代码示例来源:origin: matsim-org/matsim
out.write("\"");
if (!Time.isUndefinedTime(act.getMaximumDuration())) {
out.write(" max_dur=\"");
out.write(Time.writeTime(act.getMaximumDuration()));
out.write("\"");
代码示例来源: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 run(final Plan plan) {
for ( Activity act : TripStructureUtils.getActivities( plan , blackList ) ) {
// this is deliberately simplistic. Cleanup up of the time information should be done somewhere else.
if ( !Time.isUndefinedTime( act.getEndTime() ) ) {
act.setEndTime(mutateTime(act.getEndTime()));
}
if ( affectingDuration ) {
if ( !Time.isUndefinedTime( act.getMaximumDuration() ) ) {
act.setMaximumDuration(mutateTime(act.getMaximumDuration()));
}
}
}
// the legs are not doing anything. kai, jun'12
}
代码示例来源:origin: matsim-org/matsim
private void fillEvents(
final Plan plan,
final Queue<LocationEvent> events) {
final Id personId = plan.getPerson().getId();
double lastEnd = 0;
int ind = 0;
for ( Activity act : TripStructureUtils.getActivities( plan , stages ) ) {
final Id loc = act.getFacilityId();
final LocationEvent event =
new LocationEvent(
ind++,
personId,
act.getType(),
loc,
lastEnd );
// correct times if inconsistent
lastEnd = Math.max(
lastEnd,
act.getEndTime() != Time.UNDEFINED_TIME ?
act.getEndTime() :
lastEnd + act.getMaximumDuration() );
if ( log.isTraceEnabled() ) {
log.trace( "add event "+event+" to queue" );
}
events.add( event );
}
}
代码示例来源:origin: matsim-org/matsim
private static double calcArrivalTime(final Trip trip) {
double now = trip.getOriginActivity().getEndTime();
for ( final PlanElement pe : trip.getTripElements() ) {
if ( pe instanceof Activity ) {
final double end = ((Activity) pe).getEndTime();
now = end != Time.UNDEFINED_TIME ? end : now + ((Activity) pe).getMaximumDuration();
// TODO: do not fail *that* badly, but just revert to random alloc
if ( now == Time.UNDEFINED_TIME ) throw new RuntimeException( "could not get time from "+pe );
}
else if ( pe instanceof Leg ) {
final Route r = ((Leg) pe).getRoute();
if ( r != null && r.getTravelTime() != Time.UNDEFINED_TIME ) {
now += r.getTravelTime();
}
else {
now += ((Leg) pe).getTravelTime() != Time.UNDEFINED_TIME ?
((Leg) pe).getTravelTime() :
0; // no info: just assume instantaneous. This will give poor results!
}
}
}
return now;
}
}
代码示例来源:origin: matsim-org/matsim
switch ( setting ) {
case MUTATE_DUR:
((Activity) a).setMaximumDuration( mutateTime( a.getMaximumDuration() ) );
break;
case MUTATE_END:
代码示例来源: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
act.setEndTime(act.getStartTime()+act.getMaximumDuration());
代码示例来源: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
mutator.run(plan);
Assert.assertEquals(0.0, ptAct1.getMaximumDuration(), 1e-8);
Assert.assertEquals(0.0, ptAct2.getMaximumDuration(), 1e-8);
Assert.assertEquals(0.0, ptAct3.getMaximumDuration(), 1e-8);
Assert.assertEquals(0.0, ptAct4.getMaximumDuration(), 1e-8);
内容来源于网络,如有侵权,请联系作者删除!