Skip to content

Commit

Permalink
VRP porting (#156)
Browse files Browse the repository at this point in the history
* add use case quarkus vehicle routing

* add vehicle routing to  README

* update quarkus e optaplanner version

* add distance to Vehicle List

* Image alignment on index.html

Co-authored-by: Marco Taiuti <[email protected]>
  • Loading branch information
taiuti and Marco Taiuti authored Sep 6, 2021
1 parent 220fc54 commit 4ac14ff
Show file tree
Hide file tree
Showing 49 changed files with 3,310 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ a|* <<school-timetabling, School timetabling>>
* <<maintenance-scheduling, Maintenance scheduling>>
* <<call-center, Call center>>
* <<vaccination-scheduling, Vaccination scheduling>>
* <<quarkus-vehicle-routing, Vehicle Routing>>

a|* link:use-cases/school-timetabling/README.adoc[Quarkus] (Java, Maven or Gradle, Quarkus, H2)
* link:technology/java-spring-boot/README.adoc[Spring Boot] (Java, Maven or Gradle, Spring Boot, H2)
Expand Down Expand Up @@ -49,6 +50,7 @@ image::build/quickstarts-showcase/src/main/resources/META-INF/resources/screensh
* link:technology/java-spring-boot/README.adoc[Run spring-boot-school-timetabling] (Java, Maven or Gradle, Spring Boot, H2)
* link:technology/java-activemq-quarkus/README.adoc[Run activemq-quarkus-school-timetabling] (Java, ActiveMQ, Maven, Quarkus)
* link:technology/kotlin-quarkus/README.adoc[Run kotlin-quarkus-school-timetabling] (Kotlin, Maven, Quarkus, H2)
* link:use-cases/vehicle-routing/README.adoc[Run quarkus-vehicle-routing] (Java, Maven or Gradle, Quarkus)

Without a UI:

Expand Down Expand Up @@ -92,6 +94,15 @@ image::build/quickstarts-showcase/src/main/resources/META-INF/resources/screensh

* link:use-cases/vaccination-scheduling/README.adoc[Run quarkus-vaccination-scheduling] (Java, Maven, Quarkus)

[[quarkus-vehicle-routing]]
=== Quarkus Vehicle Routing

Find the most efficient routes for a fleet of vehicles.

image::build/quickstarts-showcase/src/main/resources/META-INF/resources/screenshot/quarkus-vehicle-routing-screenshot.png[]

* link:use-cases/vehicle-routing/README.adoc[Run quarkus-vehicle-routing] (Java, Maven, Quarkus)

[[optaweb-vehicle-routing]]
=== OptaWeb Vehicle Routing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@
<include>quarkus-app/**</include>
</includes>
</fileSet>
<fileSet>
<directory>../../use-cases/vehicle-routing/target</directory>
<outputDirectory>binaries/use-cases/vehicle-routing</outputDirectory>
<includes>
<include>quarkus-app/**</include>
</includes>
</fileSet>
<fileSet>
<directory>../../use-cases/call-center/target</directory>
<outputDirectory>quickstarts/binaries/use-cases/call-center</outputDirectory>
Expand Down
9 changes: 9 additions & 0 deletions build/optaplanner-distribution/src/main/assembly/sources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
<exclude>.gitignore</exclude>
</excludes>
</fileSet>
<fileSet>
<useDefaultExcludes>false</useDefaultExcludes>
<directory>../../use-cases/vehicle-routing</directory>
<outputDirectory>sources/use-cases/vehicle-routing</outputDirectory>
<excludes>
<exclude>target/**</exclude>
<exclude>.gitignore</exclude>
</excludes>
</fileSet>
<fileSet>
<useDefaultExcludes>false</useDefaultExcludes>
<directory>../../technology/java-quarkus</directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public void setup(@Observes StartupEvent startupEvent) {
new QuickstartMeta("facility-location"),
new QuickstartMeta("maintenance-scheduling"),
new QuickstartMeta("vaccination-scheduling"),
new QuickstartMeta("call-center"));
new QuickstartMeta("call-center"),
new QuickstartMeta("vehicle-routing"));
File workingDirectory;
try {
workingDirectory = new File(".").getCanonicalFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ $(document).ready(function () {
$("#vaccination-scheduling-launch").click(function () {
launchQuickstart("vaccination-scheduling");
});
$("#vehicle-routing-launch").click(function () {
launchQuickstart("vehicle-routing");
});
$("#exit").click(function () {
exit();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ <h5>
</div>
</div>
</div>
<div class="col mb-4">
<div class="card">
<div class="card-header">
<h5>
Quarkus Vehicle Routing
</h5>
</div>
<img src="screenshot/quarkus-vehicle-routing-screenshot.png" class="card-img-top mt-3" alt="Screenshot"/>
<div class="card-body">
<p class="card-text">
Find the most efficient routes <br> for a fleet of vehicles.
</p>
<button id="vehicle-routing-launch" type="button" class="btn btn-primary w-100">
<span class="fas fa-play"></span> Launch
</button>
<div id="vehicle-routing-ports" class="row row-cols-1 row-cols-md-3 mt-3"></div>
</div>
</div>
</div>
<div class="col mb-4">
<div class="card">
<div class="card-header">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module>use-cases/maintenance-scheduling</module>
<module>use-cases/call-center</module>
<module>use-cases/vaccination-scheduling</module>
<module>use-cases/vehicle-routing</module>
<module>build/quickstarts-showcase</module>
</modules>

Expand Down
3 changes: 3 additions & 0 deletions use-cases/vehicle-routing/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!target/*-runner
!target/quarkus-app/*
13 changes: 13 additions & 0 deletions use-cases/vehicle-routing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/target
/build
/local

# Eclipse, Netbeans and IntelliJ files
/.*
!.gitignore
!.dockerignore
!.mvn
/nbproject
/*.ipr
/*.iws
/*.iml
70 changes: 70 additions & 0 deletions use-cases/vehicle-routing/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
= Vehicle Routing Problem (Java, Quarkus, Maven)

== Run the application with live coding

. Start the application:
+
[source, shell]
----
$ mvn quarkus:dev
----

. Visit http://localhost:8080 in your browser.

. Click on the *Solve* button.

Then try _live coding_:

. Make some changes in the source code.
. Refresh your browser (F5).

Notice that those changes are immediately in effect.

== Package and run the application

When you're done iterating in `quarkus:dev` mode, run the application as a conventional jar file.

. Compile it:
+
[source, shell]
----
$ mvn package
----

. Run it:
+
[source, shell]
----
$ java -jar ./target/quarkus-app/quarkus-run.jar
----
+
[NOTE]
====
To run it on port 8081 instead, add `-Dquarkus.http.port=8081`.
====

. Visit http://localhost:8080 in your browser.

== Run a native executable

. https://quarkus.io/guides/building-native-image#configuring-graalvm[Install GraalVM and gu install the native-image tool]

. Compile it natively:
+
[source, shell]
----
$ mvn package -Dnative -DskipTests
----

. Run the native executable:
+
[source, shell]
----
$ ./target/*-runner
----

. Visit http://localhost:8080 in your browser.

== More information

Visit https://www.optaplanner.org/[www.optaplanner.org].
184 changes: 184 additions & 0 deletions use-cases/vehicle-routing/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.acme</groupId>
<artifactId>optaplanner-quarkus-vehicle-routing-quickstart</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<version.io.quarkus>2.2.0.Final</version.io.quarkus>
<version.org.optaplanner>8.12.0-SNAPSHOT</version.org.optaplanner>

<version.compiler.plugin>3.8.1</version.compiler.plugin>
<version.surefire.plugin>3.0.0-M5</version.surefire.plugin>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<!-- Alternatively, use <artifactId>quarkus-universe-bom</artifactId>
which includes both quarkus-bom and optaplanner-bom. -->
<artifactId>quarkus-bom</artifactId>
<version>${version.io.quarkus}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-bom</artifactId>
<version>${version.org.optaplanner}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-quarkus-jackson</artifactId>
</dependency>

<!-- Testing -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-test</artifactId>
<scope>test</scope>
</dependency>

<!-- UI -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.5.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.15.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>leaflet</artifactId>
<version>1.6.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${version.io.quarkus}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>

<repositories>
<repository>
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<!-- Get releases only from Maven Central which is faster. -->
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
Loading

0 comments on commit 4ac14ff

Please sign in to comment.