1

我正在尝试执行此链接提供的 Jsprit CostMatrixExample 。我正在使用 Jsprit 1.6.2 发行版来测试这个功能。我在我的程序中修改了以下两件事。

  1. 使用 setLocation 函数而不是 setLocationID 向 VRP 注册服务,如下所示。我猜 setLocationID 在最新版本中不存在,因此无法使用此功能。

    服务 s1 = Service.Builder.newInstance("1").addSizeDimension(0,1).setLocation(Location.newInstance(1, 1)).build();

    1. 如本链接所述,将 fastalgo.xml 中的radialRuinAndRecreate 修改为 randomRuinAndRecreate

实际上,在测试程序时,这个调用堆栈会中断。

java.lang.IllegalStateException: time value for relation from [x=1.0][y=1.0] to [x=3.0][y=3.0] does not exist
    at jsprit.core.util.VehicleRoutingTransportCostsMatrix.getTime(VehicleRoutingTransportCostsMatrix.java:225)
    at jsprit.core.util.VehicleRoutingTransportCostsMatrix.getTransportTime(VehicleRoutingTransportCostsMatrix.java:206)
    at jsprit.core.problem.constraint.VehicleDependentTimeWindowConstraints.fulfilled(VehicleDependentTimeWindowConstraints.java:109)
    at jsprit.core.problem.constraint.HardActivityLevelConstraintManager.fulfilled(HardActivityLevelConstraintManager.java:83)
    at jsprit.core.problem.constraint.ConstraintManager.fulfilled(ConstraintManager.java:148)
    at jsprit.core.algorithm.recreate.ServiceInsertionCalculator.getInsertionData(ServiceInsertionCalculator.java:141)
    at jsprit.core.algorithm.recreate.JobCalculatorSwitcher.getInsertionData(JobCalculatorSwitcher.java:41)
    at jsprit.core.algorithm.recreate.VehicleTypeDependentJobInsertionCalculator.getInsertionData(VehicleTypeDependentJobInsertionCalculator.java:116)
    at jsprit.core.algorithm.recreate.BestInsertion.insertUnassignedJobs(BestInsertion.java:83)
    at jsprit.core.algorithm.recreate.AbstractInsertionStrategy.insertJobs(AbstractInsertionStrategy.java:89)
    at jsprit.core.algorithm.InsertionInitialSolutionFactory.createSolution(InsertionInitialSolutionFactory.java:56)
    at jsprit.core.algorithm.PrettyAlgorithmBuilder$2.informAlgorithmStarts(PrettyAlgorithmBuilder.java:144)
    at jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.algorithmStarts(VehicleRoutingAlgorithmListeners.java:127)
    at jsprit.core.algorithm.VehicleRoutingAlgorithm.algorithmStarts(VehicleRoutingAlgorithm.java:296)
    at jsprit.core.algorithm.VehicleRoutingAlgorithm.searchSolutions(VehicleRoutingAlgorithm.java:196)
    at com.learning.testvrp.JSpiritVRP.buildPickers(JSpiritVRP.java:202)
    at com.learning.testvrp.JSpiritVRP.buildSoultion(JSpiritVRP.java:58)
    at com.learning.testvrp.TestVRPWS.generateSweep(TestVRPWS.java:101)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

我可以知道这次失败的原因吗?你能帮我解决这个问题吗?

4

1 回答 1

1

我能够解决这个问题。我可以观察到两个因素的联系

  1. 在当前版本中无法使用 setLocationId(1),因此使用了 setLocation(1,1)。

  2. addTransportTime 和 addTransportDistance 需要特定格式的 from 和 to 字符串。这些不是位置的 id,而不仅仅是像 (1,1) 这样的位置坐标。位置坐标需要像下面的字符串一样转换并将这些字符串传递给这些函数。假设您的起点和终点坐标是 (1,1) 和 (2,2),那么这些坐标需要转换为 [x=1.0][y=1.0] 和 [x=2.0][y=2.0]。

如果您传递这些值,则在使用此程序时不会出现此错误,并且能够查看 VRP 结果。

于 2016-03-17T04:30:41.217 回答