1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

read/write unassignedJobs

This commit is contained in:
oblonski 2014-08-26 15:01:02 +02:00
parent c832364557
commit 568d16d699
3 changed files with 28 additions and 6 deletions

View file

@ -20,10 +20,7 @@ import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize; import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.driver.Driver; import jsprit.core.problem.driver.Driver;
import jsprit.core.problem.driver.DriverImpl; import jsprit.core.problem.driver.DriverImpl;
import jsprit.core.problem.job.Delivery; import jsprit.core.problem.job.*;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute; import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.problem.solution.route.activity.TimeWindow;
@ -304,7 +301,16 @@ public class VrpXMLReader{
} }
routes.add(routeBuilder.build()); routes.add(routeBuilder.build());
} }
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost); VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost);
List<HierarchicalConfiguration> unassignedJobConfigs = solutionConfig.configurationsAt("unassignedJobs.job");
for(HierarchicalConfiguration unassignedJobConfig : unassignedJobConfigs){
String jobId = unassignedJobConfig.getString("[@id]");
Job job = getShipment(jobId);
if(job == null) job = getService(jobId);
if(job == null) throw new IllegalStateException("cannot find unassignedJob with id " + jobId);
solution.getUnassignedJobs().add(job);
}
solutions.add(solution); solutions.add(solution);
} }
} }

View file

@ -203,6 +203,11 @@ public class VrpXMLWriter {
xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").end", route.getEnd().getArrTime()); xmlConfig.setProperty(solutionPath + "(" + counter + ").routes.route(" + routeCounter + ").end", route.getEnd().getArrTime());
routeCounter++; routeCounter++;
} }
int unassignedJobCounter = 0;
for(Job unassignedJob : solution.getUnassignedJobs()){
xmlConfig.setProperty(solutionPath + "(" + counter + ").unassignedJobs.job(" + unassignedJobCounter + ")[@id]", unassignedJob.getId());
unassignedJobCounter++;
}
counter++; counter++;
} }
} }

View file

@ -281,7 +281,18 @@
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> <xs:element name="unassignedJobs" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="job" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType> </xs:complexType>