Package jsprit.core.util

Examples of jsprit.core.util.Locations


      e.printStackTrace()
    }
  }

  private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes) throws NoLocationFoundException{
    Locations locations = retrieveLocations(vrp);
    XYSeriesCollection coll = new XYSeriesCollection();
    int counter = 1;
    for(VehicleRoute route : routes){
      if(route.isEmpty()) continue;
      XYSeries series = new XYSeries(counter, false, true);
     
      Coordinate startCoord = locations.getCoord(route.getStart().getLocationId());
      series.add(startCoord.getX()*scalingFactor, startCoord.getY()*scalingFactor);
     
      for(TourActivity act : route.getTourActivities().getActivities()){
        Coordinate coord = locations.getCoord(act.getLocationId());
        series.add(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
      }
     
      Coordinate endCoord = locations.getCoord(route.getEnd().getLocationId());
      series.add(endCoord.getX()*scalingFactor, endCoord.getY()*scalingFactor);
     
      coll.addSeries(series);
      counter++;
    }
 
View Full Code Here


    VehicleType t2 = VehicleTypeImpl.Builder.newInstance("t2").addCapacityDimension(0, 1000).setCostPerDistance(2.0).build();
    newVehicle = VehicleImpl.Builder.newInstance("newVehicle").setLatestArrival(100.0).setStartLocationId("0,0").setType(t2).build();
   
    driver = DriverImpl.noDriver();
   
    final Locations locations = new Locations(){

      @Override
      public Coordinate getCoord(String id) {
        //assume: locationId="x,y"
        String[] splitted = id.split(",");
        return Coordinate.newInstance(Double.parseDouble(splitted[0]),
            Double.parseDouble(splitted[1]));
      }
     
    };
    costs = new AbstractForwardVehicleRoutingTransportCosts() {
     
      @Override
      public double getTransportTime(String fromId, String toId,double departureTime, Driver driver, Vehicle vehicle) {
        return ManhattanDistanceCalculator.calculateDistance(locations.getCoord(fromId), locations.getCoord(toId));
      }
     
      @Override
      public double getTransportCost(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
        return vehicle.getType().getVehicleCostParams().perDistanceUnit*ManhattanDistanceCalculator.calculateDistance(locations.getCoord(fromId), locations.getCoord(toId));
      }
    };

   
    first = Service.Builder.newInstance("1").addSizeDimension(0, 0).setLocationId("0,10").setTimeWindow(TimeWindow.newInstance(0.0, 100.0)).build();
View Full Code Here

     *
     * @return locations
     *
     **/
    public Locations getLocations(){
      return new Locations() {

        @Override
        public Coordinate getCoord(String id) {
          return tentative_coordinates.get(id);
        }
View Full Code Here

    @Before
    public void doBefore(){
        final Coordinate from = Coordinate.newInstance(0,0);
        final Coordinate to = Coordinate.newInstance(100,0);

        locations = new Locations(){

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return from;
                if(id.equals("to")) return to;
View Full Code Here

        Assert.assertEquals(100.,tdCosts.getBackwardTransportTime("from","to",100.,null,null),0.01);
    }

    @Test
    public void whenTD1a_distanceShouldBe25PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(125.,0);
View Full Code Here

        Assert.assertEquals(100.,time,0.01);
    }

    @Test
    public void whenTD1b_distanceShouldBe25PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(125.,0);
View Full Code Here

        Assert.assertEquals(100.,time,0.01);
    }

    @Test
    public void whenTD1c_distanceShouldBe25PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(125.,0);
View Full Code Here

        Assert.assertEquals(100.,time,0.01);
    }

    @Test
    public void whenTD1d_distanceShouldBe25PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(125.,0);
View Full Code Here

        Assert.assertEquals(100.,time,0.01);
    }

    @Test
    public void whenTD2a_distanceShouldBe50PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(150.,0);
View Full Code Here

        Assert.assertEquals(100.,time,0.01);
    }

    @Test
    public void whenTD2b_distanceShouldBe50PercentMore(){
        Locations locations = new Locations() {

            @Override
            public Coordinate getCoord(String id) {
                if(id.equals("from")) return Coordinate.newInstance(0,0);
                if(id.equals("to")) return Coordinate.newInstance(150.,0);
View Full Code Here

TOP

Related Classes of jsprit.core.util.Locations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.