All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rinde.rinsim.scenario.gendreau06.Gendreau06Scenario Maven / Gradle / Ivy

There is a newer version: 4.4.6
Show newest version
/*
 * Copyright (C) 2011-2016 Rinde van Lon, iMinds-DistriNet, KU Leuven
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.rinde.rinsim.scenario.gendreau06;

import java.util.List;

import javax.measure.Measure;
import javax.measure.quantity.Velocity;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;

import com.github.rinde.rinsim.core.model.ModelBuilder;
import com.github.rinde.rinsim.core.model.pdp.DefaultPDPModel;
import com.github.rinde.rinsim.core.model.pdp.TimeWindowPolicy.TimeWindowPolicies;
import com.github.rinde.rinsim.core.model.road.RoadModelBuilders;
import com.github.rinde.rinsim.core.model.time.TimeModel;
import com.github.rinde.rinsim.geom.Point;
import com.github.rinde.rinsim.pdptw.common.PDPRoadModel;
import com.github.rinde.rinsim.pdptw.common.StatsStopConditions;
import com.github.rinde.rinsim.pdptw.common.StatsTracker;
import com.github.rinde.rinsim.scenario.Scenario;
import com.github.rinde.rinsim.scenario.StopCondition;
import com.github.rinde.rinsim.scenario.StopConditions;
import com.github.rinde.rinsim.scenario.TimedEvent;
import com.github.rinde.rinsim.util.TimeWindow;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

/**
 *
 * The length of the scenario is a soft constraint. There is a pre defined
 * length of the day (either 4 hours or 7.5 hours), vehicles are allowed to
 * continue driving after the end of the day.
 * 

* Once a vehicle is moving towards a Parcel it is obliged to service it. This * means that diversion is not allowed. *

* Distance is expressed in km, time is expressed in ms (the original format is * in seconds, however it allows fractions as such it was translated to ms), * speed is expressed as km/h. * @author Rinde van Lon */ @AutoValue public abstract class Gendreau06Scenario extends Scenario { static final Point MIN = new Point(0, 0); static final Point MAX = new Point(5, 5); static final Measure MAX_SPEED = Measure.valueOf( 30d, NonSI.KILOMETERS_PER_HOUR); static Gendreau06Scenario create(List pEvents, long ts, GendreauProblemClass problemClass, int instanceNumber, boolean diversion, boolean realtime) { final TimeModel.Builder timeModelBuilder = TimeModel.builder() .withTickLength(ts) .withTimeUnit(SI.MILLI(SI.SECOND)); final ImmutableSet> modelBuilders = ImmutableSet.>builder() .add(realtime ? timeModelBuilder.withRealTime() : timeModelBuilder) .add( PDPRoadModel.builder( RoadModelBuilders.plane() .withMinPoint(MIN) .withMaxPoint(MAX) .withDistanceUnit(SI.KILOMETER) .withSpeedUnit(MAX_SPEED.getUnit()) .withMaxSpeed(MAX_SPEED.getValue())) .withAllowVehicleDiversion(diversion)) .add( DefaultPDPModel.builder() .withTimeWindowPolicy(TimeWindowPolicies.TARDY_ALLOWED)) .add( StatsTracker.builder()) .build(); return new AutoValue_Gendreau06Scenario( ImmutableList.copyOf(pEvents), modelBuilders, Integer.toString(instanceNumber), ts, diversion, problemClass); } abstract long getTickSize(); abstract boolean getAllowDiversion(); @Override public abstract GendreauProblemClass getProblemClass(); @Override public TimeWindow getTimeWindow() { return TimeWindow.always(); } @Override public StopCondition getStopCondition() { return StopConditions.and( StatsStopConditions.vehiclesDoneAndBackAtDepot(), StatsStopConditions.timeOutEvent()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy