├── .gitignore ├── README.md ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── vrprep │ │ └── model │ │ └── util │ │ └── Instances.java ├── resources │ └── README.md └── xsd │ └── instance.xsd └── test ├── java └── org │ └── vrprep │ └── model │ └── test │ └── util │ └── InstancesTest.java └── resources └── instance-example.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .classpath 3 | .project 4 | /.settings/ 5 | /bin/ 6 | /target/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | VRP-REP model files 2 | ====================== 3 | 4 | VRP-REP model files is a maven project. It simply contains XML schema files, used to describe Vehicle Routing Problem instances files on the web application [VRP-REP](http://www.vrp-rep.org). 5 | 6 | How do I use the model in my own project ? 7 | ------------------------------------------ 8 | 9 | If you intend to use the format in a java project, you can use JAXB generated classes to read and write XML files. 10 | 11 | ### Maven 12 | The best way to go is to add the following to your pom.xml : 13 | 14 | ```xml 15 | 16 | org.vrp-rep 17 | vrprep-model 18 | LATEST 19 | 20 | ``` 21 | 22 | ### Manually include the JAR 23 | Versioned JAR files are directly available from [Maven central](http://search.maven.org/#search%7Cga%7C1%7Cvrp-rep). 24 | 25 | Reader and Writer 26 | ----------------- 27 | As of 0.1.4, the project also include a basic instance reader and writer, that you may use this way : 28 | 29 | ```java 30 | import java.io.File; 31 | import org.vrprep.model.instance.Instance; 32 | import org.vrprep.model.util.Instances; 33 | ... 34 | Instance instance = Instances.read(inputPath); 35 | File file = Instances.write(instance, outputPath); 36 | ``` 37 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | UTF-8 4 | UTF-8 5 | 6 | 4.0.0 7 | org.vrp-rep 8 | vrprep-model 9 | 0.5.1-SNAPSHOT 10 | VRP-REP model files 11 | VRP-REP is a web sharing platform that put together data dedicated to Vehicle Routing Problem, that mainly uses a recommended data format described in an xsd file. This repository includes the model files used to marshall/unmarshall XML data instances using JAXB. 12 | https://github.com/VRP-REP/model 13 | 14 | scm:git:git@github.com:VRP-REP/model.git 15 | scm:git:git@github.com:VRP-REP/model.git 16 | scm:git:git@github.com:VRP-REP/model.git 17 | HEAD 18 | 19 | 20 | VRP-REP 21 | http://www.vrp-rep.org 22 | 23 | 24 | 25 | Jorge Mendoza 26 | 27 | 28 | Maxim Hoskins 29 | 30 | 31 | 32 | 33 | MIT License 34 | http://www.opensource.org/licenses/mit-license.php 35 | 36 | 37 | 38 | 39 | ossrh 40 | https://oss.sonatype.org/content/repositories/snapshots 41 | 42 | 43 | ossrh 44 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 45 | 46 | 47 | 48 | 49 | 50 | src/main/xsd 51 | xsd 52 | 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-surefire-plugin 58 | 2.17 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-compiler-plugin 63 | 3.1 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-resources-plugin 72 | 2.7 73 | 74 | UTF-8 75 | 76 | 77 | 78 | readme 79 | process-resources 80 | 81 | copy-resources 82 | 83 | 84 | true 85 | ${basedir} 86 | 87 | 88 | ${basedir}/src/main/resources 89 | true 90 | 91 | README.md 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.codehaus.mojo 101 | jaxb2-maven-plugin 102 | 1.5 103 | 104 | 105 | xjc-instance 106 | 107 | xjc 108 | 109 | 110 | instance.xsd 111 | org.vrprep.model.instance 112 | ${project.build.directory}/jaxb2/.xjcStaleFlag-instance 113 | 114 | 115 | 116 | 117 | 118 | org.apache.maven.plugins 119 | maven-source-plugin 120 | 2.2.1 121 | 122 | 123 | attach-sources 124 | 125 | jar-no-fork 126 | 127 | 128 | 129 | 130 | 131 | org.apache.maven.plugins 132 | maven-javadoc-plugin 133 | 2.9.1 134 | 135 | 136 | attach-javadocs 137 | 138 | jar 139 | 140 | 141 | -Xdoclint:none 142 | 143 | 144 | 145 | 146 | 147 | org.apache.maven.plugins 148 | maven-gpg-plugin 149 | 1.5 150 | 151 | 152 | sign-artifacts 153 | verify 154 | 155 | sign 156 | 157 | 158 | 159 | 160 | 161 | org.sonatype.plugins 162 | nexus-staging-maven-plugin 163 | 1.6.3 164 | true 165 | 166 | ossrh 167 | https://oss.sonatype.org/ 168 | true 169 | 170 | 171 | 172 | org.apache.maven.plugins 173 | maven-release-plugin 174 | 2.5.1 175 | 176 | 177 | 178 | 179 | 180 | junit 181 | junit 182 | 4.11 183 | test 184 | 185 | 186 | javax.xml.bind 187 | jaxb-api 188 | 2.2.7 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /src/main/java/org/vrprep/model/util/Instances.java: -------------------------------------------------------------------------------- 1 | package org.vrprep.model.util; 2 | 3 | import java.io.File; 4 | import java.io.InputStream; 5 | import java.nio.file.Path; 6 | 7 | import javax.xml.XMLConstants; 8 | import javax.xml.bind.JAXBContext; 9 | import javax.xml.bind.JAXBException; 10 | import javax.xml.bind.Marshaller; 11 | import javax.xml.bind.Unmarshaller; 12 | import javax.xml.bind.ValidationEvent; 13 | import javax.xml.bind.ValidationEventHandler; 14 | import javax.xml.transform.Source; 15 | import javax.xml.transform.stream.StreamSource; 16 | import javax.xml.validation.Schema; 17 | import javax.xml.validation.SchemaFactory; 18 | 19 | import org.xml.sax.SAXException; 20 | import org.vrprep.model.instance.Instance; 21 | 22 | public class Instances { 23 | 24 | /** 25 | * Example method that returns an Instance object from an XML file. 26 | * 27 | * @param inputPath 28 | * @throws JAXBException 29 | */ 30 | public static Instance read(Path inputPath) throws JAXBException { 31 | JAXBContext jc = JAXBContext.newInstance(Instance.class); 32 | Unmarshaller unmarshaller = jc.createUnmarshaller(); 33 | return (Instance) unmarshaller.unmarshal(inputPath.toFile()); 34 | } 35 | 36 | /** 37 | * Example method that writes XML from an Instance object. 38 | * This method also process a basic validation when marshalling. 39 | * 40 | * @param instance 41 | * @param outputPath 42 | * @throws SAXException 43 | * @throws JAXBException 44 | */ 45 | public static File write(Instance instance, Path outputPath) throws SAXException, JAXBException { 46 | outputPath.getParent().toFile().mkdirs(); 47 | 48 | InputStream stream = Instance.class.getResourceAsStream("/xsd/instance.xsd"); 49 | Source schemaSource = new StreamSource(stream); 50 | SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 51 | Schema schema = sf.newSchema(schemaSource); 52 | 53 | JAXBContext jc = JAXBContext.newInstance(Instance.class); 54 | Marshaller marshaller = jc.createMarshaller(); 55 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); 56 | marshaller.setSchema(schema); 57 | marshaller.setEventHandler(new ValidationEventHandler(){ 58 | public boolean handleEvent(ValidationEvent event) { 59 | System.err.println("MESSAGE: " + event.getMessage()); 60 | return true; 61 | }}); 62 | marshaller.marshal(instance, outputPath.toFile()); 63 | 64 | return outputPath.toFile(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/README.md: -------------------------------------------------------------------------------- 1 | ${project.name} 2 | ====================== 3 | 4 | ${project.name} is a maven project. It simply contains XML schema files, used to describe Vehicle Routing Problem instances files on the web application [VRP-REP](http://www.vrp-rep.org). 5 | 6 | How do I use the model in my own project ? 7 | ------------------------------------------ 8 | 9 | If you intend to use the format in a java project, you can use JAXB generated classes to read and write XML files. 10 | 11 | ### Maven 12 | The best way to go is to add the following to your pom.xml : 13 | 14 | ```xml 15 | 16 | ${project.groupId} 17 | ${project.artifactId} 18 | LATEST 19 | 20 | ``` 21 | 22 | ### Manually include the JAR 23 | Versioned JAR files are directly available from [Maven central](http://search.maven.org/#search%7Cga%7C1%7Cvrp-rep). 24 | 25 | Reader and Writer 26 | ----------------- 27 | As of 0.1.4, the project also include a basic instance reader and writer, that you may use this way : 28 | 29 | ```java 30 | import java.io.File; 31 | import org.vrprep.model.instance.Instance; 32 | import org.vrprep.model.util.Instances; 33 | ... 34 | Instance instance = Instances.read(inputPath); 35 | File file = Instances.write(instance, outputPath); 36 | ``` 37 | -------------------------------------------------------------------------------- /src/main/xsd/instance.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Defines a vehicle compartment 8 | 9 | 10 | 11 | Variable capacity (e.g. MC-VRP) 12 | 13 | 14 | 15 | 16 | Defines the capacity of the compartment. The capacity of a compartment can be defined by either a flexible capacity range (i.e., the exact capacity is left a a decision variable) or by a fixed capacity value 17 | 18 | 19 | 20 | Flexible compartment capacity 21 | 22 | 23 | 24 | Minimum compartment capacity 25 | 26 | 27 | 28 | 29 | Maximum compartment capacity 30 | 31 | 32 | 33 | 34 | 35 | Fixed compartment capacity 36 | 37 | 38 | 39 | 40 | 41 | Defines the types of requests that are compatible with this compartment 42 | 43 | 44 | 45 | 46 | Compartment dimensions 47 | 48 | 49 | 50 | Variable compartment dimensions 51 | 52 | 53 | 54 | Minimum dimensions 55 | 56 | 57 | 58 | 59 | Maximum dimensions 60 | 61 | 62 | 63 | 64 | 65 | Fix compartment dimensions 66 | 67 | 68 | 69 | 70 | 71 | 72 | The compartment number 73 | 74 | 75 | 76 | 77 | 78 | A type of compatible request can appear only once on each compartment type 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Defines the dimensions of an object 87 | 88 | 89 | 90 | 91 | Customizable element 92 | 93 | 94 | 95 | 96 | 97 | Possibility to add other carateristics 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Defines a VRP instance 106 | 107 | 108 | 109 | 110 | 111 | Provides information about the instance file 112 | 113 | 114 | 115 | 116 | 117 | Identifier of the dataset to wich the instance belongs as it appears on www.vrp-rep.org. For instance: Christofides, Mingozzi, and Toth (1979) 118 | 119 | 120 | 121 | 122 | Identifier of the instance as it appears on www.vrp-rep.org. For instance: E-n22-k4 in the Christofides, Mingozzi, and Toth (1979) dataset 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | Defines the transportation network 131 | 132 | 133 | 134 | 135 | 136 | The set of nodes in the network 137 | 138 | 139 | 140 | 141 | 142 | Defines a node in the network 143 | 144 | 145 | 146 | 147 | Node characteristics 148 | 149 | 150 | 151 | Defines the location of the node. The location may be deffined by a set of Euclidean coordinates or set of GPS coordinates 152 | 153 | 154 | 155 | Euclidean coordinates 156 | 157 | 158 | 159 | Coordinate value on the x axis 160 | 161 | 162 | 163 | 164 | Coordinate value on the y axis 165 | 166 | 167 | 168 | 169 | Coordinate value on the z axis 170 | 171 | 172 | 173 | 174 | 175 | GPS Coordinates 176 | 177 | 178 | 179 | Latitude 180 | 181 | 182 | 183 | 184 | Longitude 185 | 186 | 187 | 188 | 189 | 190 | 191 | List of vehicle profiles that are compatible with this node. Use this element to model site-dependent VRPs 192 | 193 | 194 | 195 | 196 | Custom element. Use this element to define VRP features that are not pre-defined in the specification 197 | 198 | 199 | 200 | 201 | 202 | Unique identifier of the node 203 | 204 | 205 | 206 | 207 | Type of node. Use this attribute to model different node types. For instance, set type=0 to denote a depot, and type=1 to denote customer nodes 208 | 209 | 210 | 211 | 212 | True if the node is accessible by a vehicle pulling a trailer and false otherwise 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | The links of the network can be explicitly defined using a list of links or implicitly defined assuming that the network is complete 223 | 224 | 225 | 226 | The set of links in the network 227 | 228 | 229 | 230 | 231 | Links 232 | 233 | 234 | 235 | Defines a link on the network 236 | 237 | 238 | 239 | 240 | Link parameters 241 | 242 | 243 | 244 | Length of the link 245 | 246 | 247 | 248 | 249 | Travel time 250 | 251 | 252 | 253 | Deterministic travel time on the link 254 | 255 | 256 | 257 | 258 | Time-dependent travel times 259 | 260 | 261 | 262 | 263 | Uncertain travel time 264 | 265 | 266 | 267 | 268 | 269 | Travel cost 270 | 271 | 272 | 273 | Deterministic travel time on the link 274 | 275 | 276 | 277 | 278 | Time-dependent travel costs 279 | 280 | 281 | 282 | 283 | Uncertain travel cost 284 | 285 | 286 | 287 | 288 | 289 | Time windows. Use these elements to model the link's availability 290 | 291 | 292 | 293 | 294 | Custom element. Use this element to define link attributes that are not pre-defined in the specification 295 | 296 | 297 | 298 | 299 | 300 | Identifier of the "tail" node of the link. The value must exist in the list of nodes. For example to model a link connecting nodes 1 and 2, the value for tail must be set to 1 301 | 302 | 303 | 304 | 305 | Identifier of the "head" node of the link. The value must exist in the list of nodes. For example to model a link connecting nodes 1 and 2, the value for head must be set to 2 306 | 307 | 308 | 309 | 310 | Unique identifier of the link 311 | 312 | 313 | 314 | 315 | Defines if the link is directed. Set is_directed=true if the link is directed and is_directed=false otherwise. The default value is false. Use this attribute to model, for instance, asymetric VRPs 316 | 317 | 318 | 319 | 320 | Defines a type for the link. Use this attribute to model different types of links. For instance service arcs and regular arcs in arc routing problems 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | Are the links symmetric? set "symmetric=true" if that is the case and "symmetric=false" otherwise. 329 | 330 | 331 | 332 | 333 | 334 | 335 | Asume the network is complete 336 | 337 | 338 | 339 | Distance type 340 | 341 | 342 | 343 | Euclidean distances 344 | 345 | 346 | 347 | 348 | 349 | Manhattan or cap driver distances 350 | 351 | 352 | 353 | 354 | 355 | User-defined distance calculation strategy 356 | 357 | 358 | 359 | 360 | 361 | Rounding rule 362 | 363 | 364 | 365 | Round distances to the higher integer 366 | 367 | 368 | 369 | 370 | 371 | Round distances to the lower integer 372 | 373 | 374 | 375 | 376 | 377 | Specify the number of decimals 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | Defines the fleet of vehicles 390 | 391 | 392 | 393 | 394 | 395 | Defines the profile of one type of vehicle. Use several profiles to model VRPs with heterogeneous fleet 396 | 397 | 398 | 399 | 400 | Vehicle characteristics 401 | 402 | 403 | 404 | Defines the departure node(s) of vehicles of the type 405 | 406 | 407 | 408 | Add this element if vehicles can start their routes at any node 409 | 410 | 411 | 412 | 413 | 414 | Defines the node(s) from where vehicles with this profile can start their routes. The value of this element must be the id of one of the nodes of the network 415 | 416 | 417 | 418 | 419 | 420 | Defines the arrival node(s) of vehicles of the type 421 | 422 | 423 | 424 | Add this element if vehicles can end their routes at any node 425 | 426 | 427 | 428 | 429 | 430 | Defines the node(s) where vehicles with this profile can finish their routes. The value of this element must be the id of one of the nodes of the network 431 | 432 | 433 | 434 | 435 | 436 | Defines the storage space of the vehicle 437 | 438 | 439 | 440 | 441 | Defines the vehicle's maximum travel time 442 | 443 | 444 | 445 | 446 | Defines the vehicle's maximum travel distance 447 | 448 | 449 | 450 | 451 | Defines the vehicle's speed profile 452 | 453 | 454 | 455 | 456 | Costs 457 | 458 | 459 | 460 | The cost 461 | 462 | 463 | 464 | 465 | Variable cost per unit of distance 466 | 467 | 468 | 469 | 470 | Varaible cost per unit of time 471 | 472 | 473 | 474 | 475 | 476 | Defines the resources available to the vehicle (e.g. a tool). 477 | 478 | 479 | 480 | 481 | Amount 482 | 483 | 484 | 485 | At the beninng of the planning horizon (e.g., when the route departs from the depot) 486 | 487 | 488 | 489 | 490 | At the end of the planning horizon (e.g., the vehicle must end its route with X units of the resource) 491 | 492 | 493 | 494 | 495 | Maximum amounth of resource that the vehicle can carry 496 | 497 | 498 | 499 | 500 | 501 | The type of resource. Values for this attribute must correspond to existing resources 502 | 503 | 504 | 505 | 506 | 507 | 508 | Defines the number of trilers that can be attached to the vehicle 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | Custom element. Use this element to define vehicle attributes that are not pre-defined in the specification 521 | 522 | 523 | 524 | 525 | 526 | Type of vehicle profile. Use this attribute to model VRPs with heterogeneous fleet 527 | 528 | 529 | 530 | 531 | Defines the number of vehicles sharing this profile. Use this attribute to model fix-fleet VRPs 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | A resource can appear only once on each vehicle profile 542 | 543 | 544 | 545 | 546 | 547 | 548 | A type of trailer can appear only once on each vehicle profile 549 | 550 | 551 | 552 | 553 | 554 | 555 | A departurel can appear only once on each vehicle profile 556 | 557 | 558 | 559 | 560 | 561 | 562 | An arrival node can appear only once on each vehicle profile 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | Trailer attributes 573 | 574 | 575 | 576 | Defines the lstorage space of the trailer 577 | 578 | 579 | 580 | 581 | Costs 582 | 583 | 584 | 585 | The cost of using the trailer 586 | 587 | 588 | 589 | 590 | The cost of pulling the trailler for one unit of distance 591 | 592 | 593 | 594 | 595 | The cost of using the trailer for one time unit 596 | 597 | 598 | 599 | 600 | 601 | Custom element. Use this element to define trailer attributes that are not pre-defined in the specification 602 | 603 | 604 | 605 | 606 | 607 | Type of trailer 608 | 609 | 610 | 611 | 612 | Number of available trailers of the type 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | Custom element. Use this element to define trailer attributes that are not pre-defined in the specification 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | The set of requests in the instance 632 | 633 | 634 | 635 | 636 | 637 | Defines a request on the network 638 | 639 | 640 | 641 | 642 | Request attributes 643 | 644 | 645 | 646 | Release date of the request (e.g. dynamic VRPs) 647 | 648 | 649 | 650 | 651 | The weight of the request. Use this element to model priorities between requests. 652 | 653 | 654 | 655 | 656 | Prize collected for servicing the request (e.g. prize-collecting TSP) 657 | 658 | 659 | 660 | 661 | Model request time windows (e.g., VRPTW) 662 | 663 | 664 | 665 | 666 | Demand 667 | 668 | 669 | 670 | Fix (deterministic) quantity 671 | 672 | 673 | 674 | 675 | Time-dependent quantity 676 | 677 | 678 | 679 | 680 | Uncertain quantity 681 | 682 | 683 | 684 | 685 | 686 | Service time 687 | 688 | 689 | 690 | Fix (deterministic) service time 691 | 692 | 693 | 694 | 695 | Time-dependent service time 696 | 697 | 698 | 699 | 700 | Uncertain service time 701 | 702 | 703 | 704 | 705 | 706 | 707 | Set of preceeding requests. Use this element to model, for instnace, pick-ups preceding deliveries in PDPs 708 | 709 | 710 | 711 | 712 | 713 | Identifiers of the preceding requests. The value for this element must correspond to the identifier of a request 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | Set of succeding requests. Use this element to model, for instnace, deliveries succeding pick-ups in PDPs 722 | 723 | 724 | 725 | 726 | 727 | Identifiers of the succeding requests. The value for this element must correspond to the identifier of a request 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | The set of skills needed to complete the request (e.g., a skill on the technician routing problem). The value for this element must correspont to the identifier of one of the skills defined in the "skills" section 736 | 737 | 738 | 739 | 740 | The set of resources needed to complete the request (e.g., a tool on the technician routing problem). The value for this element is the "amount" of the resource needed 741 | 742 | 743 | 744 | 745 | 746 | 747 | The resource's identifier. The value for this attribute must correspond to the id of one of the existing resouces 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | Custom element. Use this element to define request attributes that are not pre-defined in the specification 757 | 758 | 759 | 760 | 761 | 762 | The unique identifier of the request 763 | 764 | 765 | 766 | 767 | The type of request. Use this attribute to model requests of different nature. For instnace, set type=0 for pick-ups and type=1 for deliveries in PDPs 768 | 769 | 770 | 771 | 772 | Identifier of the node to which the request is attached (e.g., node routing problems). The value for this attribute must correspond to the identifier of one of the nodes of the network 773 | 774 | 775 | 776 | 777 | Identifier of the arc to which the request is attached (e.g. arc routing problems). The value for this attribute must correspond to the identifier of one of the links of the network 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | This element models incompatibilities between requests 801 | 802 | 803 | 804 | 805 | 806 | Incompatibility between two types of requests (e.g., product 1 and product 2) 807 | 808 | 809 | 810 | The first incompatible type of request 811 | 812 | 813 | 814 | 815 | The second incompatible type of request 816 | 817 | 818 | 819 | 820 | 821 | Incompatibility between two specific requests (e.g., request number 1 and request number 10) 822 | 823 | 824 | 825 | ID of the first incompatible request 826 | 827 | 828 | 829 | 830 | ID of the second incompatible request 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | Defines the set of resources 843 | 844 | 845 | 846 | 847 | 848 | Models a resource (e.g., a tool or a spare partl). The value of this element represents the "amount" of avaliable resources of the type. 849 | 850 | 851 | 852 | 853 | 854 | 855 | Defines the unique identifier of the resource 856 | 857 | 858 | 859 | 860 | True if the resource is renewable (e.g., a tool) and false otherwise (e.g., a spare part) 861 | 862 | 863 | 864 | 865 | Name of the resource 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | Driver profile attributes 883 | 884 | 885 | 886 | Compatible vehicles 887 | 888 | 889 | 890 | Add this element if the driver is compatible with all types of vehicles 891 | 892 | 893 | 894 | 895 | 896 | Add one of these elements for each compatible vehicle type 897 | 898 | 899 | 900 | 901 | 902 | The list of skills of the driver 903 | 904 | 905 | 906 | 907 | Unique identifier of the skill 908 | 909 | 910 | 911 | 912 | 913 | 914 | Represents the amount of work assigned or expected from the driver 915 | 916 | 917 | 918 | 919 | 920 | Maximum working time of the driver 921 | 922 | 923 | 924 | 925 | Maximum driving time 926 | 927 | 928 | 929 | 930 | Driver's availability time windows. May model either breaks or availability times 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | Custom element. Use this element to define driver profile attributes that are not pre-defined in the specification 939 | 940 | 941 | 942 | 943 | 944 | Unique identifier of the driver profile 945 | 946 | 947 | 948 | 949 | 950 | A skill can appear only once on each profile 951 | 952 | 953 | 954 | 955 | 956 | 957 | A compatible vehicle can appear only once on each profile 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | Defines a geographical location 1056 | 1057 | 1058 | 1059 | 1060 | A location may be deffined by one, and only one, of the following features: a set of Euclidean coordinates, a set of GPS coordinates, or a user custom feature 1061 | 1062 | 1063 | 1064 | Euclidean coordinates 1065 | 1066 | 1067 | 1068 | Coordinate value on the x axis 1069 | 1070 | 1071 | 1072 | 1073 | Coordinate value on the y axis 1074 | 1075 | 1076 | 1077 | 1078 | Coordinate value on the z axis 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | GPS Coordinates 1085 | 1086 | 1087 | 1088 | Latitude 1089 | 1090 | 1091 | 1092 | 1093 | Longitude 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | Defines a probability distribution 1103 | 1104 | 1105 | 1106 | 1107 | Defines a time window (TW). Time windows may be used to model periods of availability/unavailability for customers, drivers, resources, vehicles, etc. 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | Defines the dimensions of an object 1118 | 1119 | 1120 | 1121 | 1122 | The width 1123 | 1124 | 1125 | 1126 | 1127 | The height 1128 | 1129 | 1130 | 1131 | 1132 | The depth 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | Defines a random variable 1140 | 1141 | 1142 | 1143 | 1144 | A parameter of the distribution (e.g., mean or variance) 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | Name of the moment (e.g., mean, variance) 1152 | 1153 | 1154 | 1155 | 1156 | Moment number. For instance set moment_number=1 to define the mean, moment_number=2 to define the variance, moment_number=3 to define the skewness, etc. 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | A parameter of the distribution 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | Name of the parameter (e.g., lambda in Poisson distributions) 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | Distibution type (e.g., normal or Poisson) 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | Defines a parameter which value is time-dependent (e.g., travel time or service time) 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | Start point (in time) of the time interval (e.g., rush-hour or off-peak hours) 1195 | 1196 | 1197 | 1198 | 1199 | End point (in time) of the time interval (e.g., rush-hour or off-peak hours) 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | Defines a parameter which value is uncertain (e.g., stochastic travel time or stochastic demand) 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | Describes a scenario 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | Scenario id 1221 | 1222 | 1223 | 1224 | 1225 | Probability of occurence of the scenario 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | Defines a time window type 1237 | 1238 | 1239 | 1240 | There are two ways to represent a time window either with a pair (start,end) representing the start and end time of the TW or by a parameter (period) representing a single-period TW 1241 | 1242 | 1243 | 1244 | 1245 | Point in the time horizon at which the time window begins 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | Use this attribute to model the flexibility of the start of the time window (set it to true if the start of the window is a hard constraint, false otherwise) 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | Point in the time horizon at which the time window ends 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | Use this attribute to model the flexibility of the end of the time window (set it to true if the start of the window is a hard constraint, false otherwise) 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | Point in the time horizon representing the time window 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | Defines a storage unit 1294 | 1295 | 1296 | 1297 | Defines the storage capacity. Two options are avaliable to define the capacity: a single element representing a "global" capacity (e.g., CVRP) or a pair of elements defining the maximum weight and volume. 1298 | 1299 | 1300 | 1301 | The global storage capacity (e.g., CVRP) 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | The maximum weight that can be stored 1308 | 1309 | 1310 | 1311 | 1312 | The maximum weight that can be stored 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | Defines the dimensions of the storage unit 1320 | 1321 | 1322 | 1323 | 1324 | Defines the storage unit of the compartments 1325 | 1326 | 1327 | 1328 | Defines a compartment. Use this element to model multicompartment VRPs 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | Double restricted to be greater than or equal to 0 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | Double restricted to be greater than or equal to 0 and lower than or equal to 1 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | -------------------------------------------------------------------------------- /src/test/java/org/vrprep/model/test/util/InstancesTest.java: -------------------------------------------------------------------------------- 1 | package org.vrprep.model.test.util; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | import java.net.URISyntaxException; 7 | import java.net.URL; 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import java.util.Arrays; 11 | import java.util.Collection; 12 | 13 | import javax.xml.bind.JAXBException; 14 | 15 | import org.junit.Test; 16 | import org.junit.runner.RunWith; 17 | import org.junit.runners.Parameterized; 18 | import org.vrprep.model.instance.Instance; 19 | import org.vrprep.model.util.Instances; 20 | import org.xml.sax.SAXException; 21 | 22 | @RunWith(Parameterized.class) 23 | public class InstancesTest { 24 | 25 | private Path inputPath; 26 | private Path outputPath; 27 | 28 | public InstancesTest(Path inputPath, Path outputPath) { 29 | this.inputPath = inputPath; 30 | this.outputPath = outputPath; 31 | } 32 | 33 | @Parameterized.Parameters 34 | public static Collection data() { 35 | URL resourceUrl = Instances.class.getResource("/instance-example.xml"); 36 | Path resourcePath = null; 37 | try { 38 | resourcePath = Paths.get(resourceUrl.toURI()); 39 | } catch (URISyntaxException e) { 40 | e.printStackTrace(); 41 | } 42 | Path outputPath = Paths.get(resourcePath.getParent().toString(), "output.xml"); 43 | 44 | return Arrays.asList(new Object[][] { 45 | {resourcePath, outputPath} 46 | }); 47 | } 48 | 49 | @Test 50 | public void readAndWriteTest() { 51 | Instance instance = null; 52 | try { 53 | instance = Instances.read(inputPath); 54 | } catch (JAXBException e) { 55 | e.printStackTrace(); 56 | } 57 | assertNotNull(instance); 58 | 59 | File file = null; 60 | try { 61 | file = Instances.write(instance, outputPath); 62 | } catch (SAXException e) { 63 | e.printStackTrace(); 64 | } catch (JAXBException e) { 65 | e.printStackTrace(); 66 | } 67 | assertTrue(file.exists()); 68 | file.delete(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/test/resources/instance-example.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Solomon 1987 — 25 5 | C101 6 | 7 | 8 | 9 | 10 | 40.0 11 | 50.0 12 | 13 | 14 | 45.0 15 | 68.0 16 | 17 | 18 | 45.0 19 | 70.0 20 | 21 | 22 | 42.0 23 | 66.0 24 | 25 | 26 | 42.0 27 | 68.0 28 | 29 | 30 | 42.0 31 | 65.0 32 | 33 | 34 | 40.0 35 | 69.0 36 | 37 | 38 | 40.0 39 | 66.0 40 | 41 | 42 | 38.0 43 | 68.0 44 | 45 | 46 | 38.0 47 | 70.0 48 | 49 | 50 | 35.0 51 | 66.0 52 | 53 | 54 | 35.0 55 | 69.0 56 | 57 | 58 | 25.0 59 | 85.0 60 | 61 | 62 | 22.0 63 | 75.0 64 | 65 | 66 | 22.0 67 | 85.0 68 | 69 | 70 | 20.0 71 | 80.0 72 | 73 | 74 | 20.0 75 | 85.0 76 | 77 | 78 | 18.0 79 | 75.0 80 | 81 | 82 | 15.0 83 | 75.0 84 | 85 | 86 | 15.0 87 | 80.0 88 | 89 | 90 | 30.0 91 | 50.0 92 | 93 | 94 | 30.0 95 | 52.0 96 | 97 | 98 | 28.0 99 | 52.0 100 | 101 | 102 | 28.0 103 | 55.0 104 | 105 | 106 | 25.0 107 | 50.0 108 | 109 | 110 | 25.0 111 | 52.0 112 | 113 | 114 | 115 | 2 116 | 117 | 118 | 119 | 0 120 | 0 121 | 200.0 122 | 1236.0 123 | 124 | 125 | 126 | 127 | 128 | 912 129 | 967 130 | 131 | 10.0 132 | 90.0 133 | 134 | 135 | 136 | 825 137 | 870 138 | 139 | 30.0 140 | 90.0 141 | 142 | 143 | 144 | 65 145 | 146 146 | 147 | 10.0 148 | 90.0 149 | 150 | 151 | 152 | 727 153 | 782 154 | 155 | 10.0 156 | 90.0 157 | 158 | 159 | 160 | 15 161 | 67 162 | 163 | 10.0 164 | 90.0 165 | 166 | 167 | 168 | 621 169 | 702 170 | 171 | 20.0 172 | 90.0 173 | 174 | 175 | 176 | 170 177 | 225 178 | 179 | 20.0 180 | 90.0 181 | 182 | 183 | 184 | 255 185 | 324 186 | 187 | 20.0 188 | 90.0 189 | 190 | 191 | 192 | 534 193 | 605 194 | 195 | 10.0 196 | 90.0 197 | 198 | 199 | 200 | 357 201 | 410 202 | 203 | 10.0 204 | 90.0 205 | 206 | 207 | 208 | 448 209 | 505 210 | 211 | 10.0 212 | 90.0 213 | 214 | 215 | 216 | 652 217 | 721 218 | 219 | 20.0 220 | 90.0 221 | 222 | 223 | 224 | 30 225 | 92 226 | 227 | 30.0 228 | 90.0 229 | 230 | 231 | 232 | 567 233 | 620 234 | 235 | 10.0 236 | 90.0 237 | 238 | 239 | 240 | 384 241 | 429 242 | 243 | 40.0 244 | 90.0 245 | 246 | 247 | 248 | 475 249 | 528 250 | 251 | 40.0 252 | 90.0 253 | 254 | 255 | 256 | 99 257 | 148 258 | 259 | 20.0 260 | 90.0 261 | 262 | 263 | 264 | 179 265 | 254 266 | 267 | 20.0 268 | 90.0 269 | 270 | 271 | 272 | 278 273 | 345 274 | 275 | 10.0 276 | 90.0 277 | 278 | 279 | 280 | 10 281 | 73 282 | 283 | 10.0 284 | 90.0 285 | 286 | 287 | 288 | 914 289 | 965 290 | 291 | 20.0 292 | 90.0 293 | 294 | 295 | 296 | 812 297 | 883 298 | 299 | 20.0 300 | 90.0 301 | 302 | 303 | 304 | 732 305 | 777 306 | 307 | 10.0 308 | 90.0 309 | 310 | 311 | 312 | 65 313 | 144 314 | 315 | 10.0 316 | 90.0 317 | 318 | 319 | 320 | 169 321 | 224 322 | 323 | 40.0 324 | 90.0 325 | 326 | 327 | 328 | --------------------------------------------------------------------------------