mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added multiple caps
This commit is contained in:
parent
cec4e4235e
commit
8da2d1e1c5
13 changed files with 147 additions and 40 deletions
|
|
@ -174,7 +174,10 @@ public class VrpXMLWriter {
|
|||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@x]", service.getCoord().getX());
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@y]", service.getCoord().getY());
|
||||
}
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-demand", service.getCapacityDemand());
|
||||
for(int i=0;i<service.getCapacity().getNuOfDimensions();i++){
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", service.getCapacity().get(i));
|
||||
}
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").duration", service.getServiceDuration());
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").timeWindows.timeWindow(0).start", service.getTimeWindow().getStart());
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").timeWindows.timeWindow(0).end", service.getTimeWindow().getEnd());
|
||||
|
|
@ -212,8 +215,10 @@ public class VrpXMLWriter {
|
|||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).end", shipment.getDeliveryTimeWindow().getEnd());
|
||||
|
||||
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-demand", shipment.getCapacityDemand());
|
||||
for(int i=0;i<shipment.getCapacity().getNuOfDimensions();i++){
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", shipment.getCapacity().get(i));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
|
@ -262,7 +267,12 @@ public class VrpXMLWriter {
|
|||
xmlConfig.setProperty(typePathString + "("+typeCounter+")[@penaltyFactor]", ((PenaltyVehicleType)type).getPenaltyFactor());
|
||||
}
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").id", type.getTypeId());
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").capacity", type.getCapacity());
|
||||
|
||||
for(int i=0;i<type.getCapacityDimensions().getNuOfDimensions();i++){
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").capacity-dimensions.dimension("+i+")", type.getCapacityDimensions().get(i));
|
||||
}
|
||||
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.fixed", type.getVehicleCostParams().fix);
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.distance", type.getVehicleCostParams().perDistanceUnit);
|
||||
xmlConfig.setProperty(typePathString + "("+typeCounter+").costs.time", type.getVehicleCostParams().perTimeUnit);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public interface Job {
|
|||
*
|
||||
* <p>It determines how much capacity this job consumes of vehicle/transport unit.
|
||||
*
|
||||
* @deprecated use getCapacity() instead
|
||||
* @deprecated use <code>.getCapacity()</code> instead
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
|||
|
|
@ -44,11 +44,16 @@ public class Service implements Job {
|
|||
/**
|
||||
* Returns a new instance of service-builder.
|
||||
*
|
||||
* <p>Note that if you use this builder, size is assigned to capacity-dimension with index=0.
|
||||
*
|
||||
* @param id of service
|
||||
* @param size of capacity-demand
|
||||
* @return builder
|
||||
* @throws IllegalArgumentException if size < 0 or id is null
|
||||
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
|
||||
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
|
||||
*/
|
||||
@Deprecated
|
||||
public static Builder newInstance(String id, int size){
|
||||
Builder builder = new Builder(id,size);
|
||||
builder.addCapacityDimension(0, size);
|
||||
|
|
@ -71,7 +76,6 @@ public class Service implements Job {
|
|||
|
||||
protected TimeWindow timeWindow = TimeWindow.newInstance(0.0, Double.MAX_VALUE);
|
||||
|
||||
protected int demand;
|
||||
protected Capacity.Builder capacityBuilder = Capacity.Builder.newInstance();
|
||||
protected Capacity capacity;
|
||||
|
||||
|
|
@ -86,7 +90,6 @@ public class Service implements Job {
|
|||
if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero");
|
||||
if(id == null) throw new IllegalArgumentException("id must not be null");
|
||||
this.id = id;
|
||||
this.demand = size;
|
||||
}
|
||||
|
||||
Builder(String id){
|
||||
|
|
@ -144,7 +147,13 @@ public class Service implements Job {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds capacity dimension.
|
||||
*
|
||||
* @param dimensionIndex
|
||||
* @param dimensionValue
|
||||
* @return the builder
|
||||
*/
|
||||
public Builder addCapacityDimension(int dimensionIndex, int dimensionValue){
|
||||
capacityBuilder.addDimension(dimensionIndex, dimensionValue);
|
||||
return this;
|
||||
|
|
@ -196,7 +205,7 @@ public class Service implements Job {
|
|||
|
||||
private final TimeWindow timeWindow;
|
||||
|
||||
private final int demand;
|
||||
// private final int demand;
|
||||
|
||||
private final Capacity capacity;
|
||||
|
||||
|
|
@ -206,7 +215,6 @@ public class Service implements Job {
|
|||
coord = builder.coord;
|
||||
serviceTime = builder.serviceTime;
|
||||
timeWindow = builder.timeWindow;
|
||||
demand = builder.demand;
|
||||
type = builder.type;
|
||||
capacity = builder.capacity;
|
||||
}
|
||||
|
|
@ -252,9 +260,15 @@ public class Service implements Job {
|
|||
return timeWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated use <code>.getCapacity()</code> instead. if you still use this method, it returns the
|
||||
* capacity dimension with index=0.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getCapacityDemand() {
|
||||
return demand;
|
||||
return capacity.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,7 +285,7 @@ public class Service implements Job {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][size=" + demand + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]";
|
||||
return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][capacity=" + capacity + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ public class Shipment implements Job{
|
|||
*/
|
||||
public static class Builder {
|
||||
|
||||
private int demand;
|
||||
|
||||
private String id;
|
||||
|
||||
private String pickupLocation;
|
||||
|
|
@ -58,11 +56,16 @@ public class Shipment implements Job{
|
|||
/**
|
||||
* Returns a new instance of this builder.
|
||||
*
|
||||
* <p>Note that if you use this builder, size is assigned to capacity-dimension with index=0.
|
||||
*
|
||||
* @param id
|
||||
* @param size
|
||||
* @return builder
|
||||
* @throws IllegalArgumentException if size < 0 or id is null
|
||||
* @deprecated use <code>.newInstance(String id)</code> instead, and add a capacity dimension
|
||||
* with dimensionIndex='your index' and and dimsionValue=size to the returned builder
|
||||
*/
|
||||
@Deprecated
|
||||
public static Builder newInstance(String id, int size){
|
||||
Builder builder = new Builder(id,size);
|
||||
builder.addCapacityDimension(0, size);
|
||||
|
|
@ -84,7 +87,6 @@ public class Shipment implements Job{
|
|||
if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero");
|
||||
if(id == null) throw new IllegalArgumentException("id must not be null");
|
||||
this.id = id;
|
||||
this.demand = size;
|
||||
}
|
||||
|
||||
Builder(String id){
|
||||
|
|
@ -241,8 +243,6 @@ public class Shipment implements Job{
|
|||
|
||||
}
|
||||
|
||||
private final int demand;
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String pickupLocation;
|
||||
|
|
@ -271,7 +271,6 @@ public class Shipment implements Job{
|
|||
*/
|
||||
Shipment(Builder builder){
|
||||
this.id = builder.id;
|
||||
this.demand = builder.demand;
|
||||
this.pickupLocation = builder.pickupLocation;
|
||||
this.pickupCoord = builder.pickupCoord;
|
||||
this.pickupServiceTime = builder.pickupServiceTime;
|
||||
|
|
@ -288,9 +287,14 @@ public class Shipment implements Job{
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated use <code>.getCapacity()</code> instead. if you still use this method, it returns the
|
||||
* capacity dimension with index=0.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getCapacityDemand() {
|
||||
return demand;
|
||||
return capacity.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -81,7 +81,11 @@ public interface Vehicle {
|
|||
* Returns the capacity of this vehicle.
|
||||
*
|
||||
* @return capacity
|
||||
* @deprecated use .getType().getCapacityDimensions() - if you still use this method,
|
||||
* but set capacity-dimensions via <code>VehicleTypeImpl.Builder.newInstance(...).addCapacityDimension(...)</code> then this method returns the
|
||||
* dimension with index=0.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract int getCapacity();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ public class VehicleImpl implements Vehicle {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getCapacity() {
|
||||
return type.getCapacity();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,12 @@ public interface VehicleType {
|
|||
*
|
||||
* <p>In future versions there will be a capacity-object with an arbitrary number of capacity dimensions. (stefan,11.01.14)
|
||||
*
|
||||
*
|
||||
* @deprecated use <code>.getCapacityDimensions()</code> - if you still use it, but set CapacityDimensions rather
|
||||
* than setCapacity(...) it will return the capacity.dimension with index=0
|
||||
* @return cap
|
||||
*/
|
||||
@Deprecated
|
||||
public int getCapacity();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -187,6 +187,13 @@ public class VehicleTypeImpl implements VehicleType {
|
|||
return new VehicleTypeImpl(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a capacity dimension.
|
||||
*
|
||||
* @param dimIndex
|
||||
* @param dimVal
|
||||
* @return the builder
|
||||
*/
|
||||
public Builder addCapacityDimension(int dimIndex, int dimVal) {
|
||||
capacityBuilder.addDimension(dimIndex,dimVal);
|
||||
return this;
|
||||
|
|
@ -285,8 +292,9 @@ public class VehicleTypeImpl implements VehicleType {
|
|||
* @see basics.route.VehicleType#getCapacity()
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
return capacityDimensions.get(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@
|
|||
<xs:element name="capacity" type="xs:integer" minOccurs="0" maxOccurs="1" default="0"/>
|
||||
<xs:element name="capacity-dimensions" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="dimension" minOccurs="1">
|
||||
<xs:sequence>
|
||||
<xs:element name="dimension" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:integer">
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="costs">
|
||||
|
|
@ -126,8 +126,8 @@
|
|||
<xs:element name="capacity-demand" type="xs:integer" minOccurs="0" maxOccurs="1" default="0"/>
|
||||
<xs:element name="capacity-dimensions" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="dimension" minOccurs="1">
|
||||
<xs:sequence>
|
||||
<xs:element name="dimension" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:integer">
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="duration" type="xs:decimal" minOccurs="0" maxOccurs="1" default="0.0"/>
|
||||
|
|
@ -195,11 +195,11 @@
|
|||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="capacity-demand" type="xs:integer" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="capacity-demand" type="xs:integer" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="capacity-dimensions" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="dimension" minOccurs="1">
|
||||
<xs:sequence>
|
||||
<xs:element name="dimension" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:integer">
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue