Skip to content

chen0040/java-datasets-discrete-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-datasets-discrete-optimization

Package provides datasets in the domain of discrete optimization

Features

  • TSP

Install

Add the following dependency to your POM file:

<dependency>
  <groupId>com.github.chen0040</groupId>
  <artifactId>java-datasets-discrete-optimization</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

TSP

The sample code below shows how to list all the TSP benchmarks:

Tsp.Instance[] instances = Tsp.Instance.values();
      for(Tsp.Instance instance : instances){
         TspBenchmark benchmark = Tsp.get(instance);
      }
}

The sample code belows show how to obtain use the api of a TSP benchmark:

TspBenchmark benchmark = Tsp.get(Tsp.Instance.a280);
System.out.println(benchmark.size());

for(int v = 0; v < benchmark.size(); ++v){
   System.out.println(benchmark.position(v)); // print the (x, y) coordinate of vertex v 
   for(int w = v+1; w < benchmark.size(); ++w) {
      System.out.println(benchmark.distance(v, w)); // symmetric distance between vertices v and w
   }
}

// optTour is the known optimal tour for which the last vertex is connected to the first vertex
for(Integer v : benchmark.optTour()){
   System.out.println(v);
}

System.out.println(benchmark.optCost()); // print the total distance of the known optimal tour

About

Package provides datasets in the domain of discrete optimization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages