forked from onclave/NSGA-II
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Commit * Adapted the readme.md and moved the main class to be executable with exec-maven plugin * Adapted project information * Update README.md * Title correction * Deleted previous versions * Added reference to the data sets
- Loading branch information
Showing
66 changed files
with
1,254 additions
and
3,800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,32 @@ | ||
# NSGA-II | ||
**an NSGA-II implementation using Java** | ||
|
||
**_Original Authors of the Paper_: [Kalyanmoy Deb](http://www.egr.msu.edu/~kdeb/), [Amrit Pratap](https://scholar.google.com/citations?user=E8wJ7G8AAAAJ&hl=en), [Sameer Agarwal](http://ieeexplore.ieee.org/search/searchresult.jsp?searchWithin=%22Authors%22:.QT.S.%20Agarwal.QT.&newsearch=true), [T. Meyarivan](http://ieeexplore.ieee.org/search/searchresult.jsp?searchWithin=%22Authors%22:.QT.T.%20Meyarivan.QT.&newsearch=true)** | ||
|
||
_links to original contents:_ | ||
|
||
* [NSGA-II paper: PDF](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.542.385&rep=rep1&type=pdf) | ||
* [NSGA-II code implementation by original authors at **KanGAL**](https://www.iitk.ac.in/kangal/codes.shtml) | ||
|
||
_**note**: this implementation of NSGA-II algorithm is in pure reference to the original published paper. This is not an effort to convert the originally implemented C code in Java. The original C code by the authors has not be referred to while writing this implementation._ | ||
|
||
_**Dependency: Java( >= 13), JFreeChart(1.5.0), JCommon(1.0.24)**_ | ||
|
||
### Please Note: | ||
|
||
This is **v3** of the algorithm implementation. This reference implementation has been updated to be: | ||
|
||
* Used as package. | ||
* Much more generic, customizable and hence more powerful. | ||
* More efficient than the previous version. | ||
|
||
The reference **v2** implementation can be found [here](https://github.com/onclave/NSGA-II/tree/master/v2). The _README_ of that implementation can be found [here](https://github.com/onclave/NSGA-II/blob/master/v2/README.md). | ||
|
||
The reference **v1** implementation can be found [here](https://github.com/onclave/NSGA-II/tree/master/v1). The _README_ of that implementation can be found [here](https://github.com/onclave/NSGA-II/blob/master/v1/README.md). | ||
|
||
**note:** Code commenting of **v3** is under progress and not all code is commented properly. This shall be done shortly. In the mean time, if you are unable to understand any part of the code, feel free to open an _issue_ about it and I shall try to | ||
resolve it. | ||
|
||
### Documentation | ||
|
||
This is a fully customizable implementation of the NSGA-II algorithm, made as generic as possible. This documentation assumes you have basic understanding of the NSGA-II algorithm. Apart from the core concepts of the algorithm, everything else in this | ||
package can be implemented as per the user's choice and plugged into the algorithm dynamically. | ||
|
||
By default, the package provides a default implementation of every plugin and hence the package can be run with just one line of code as a PoC. | ||
|
||
```java | ||
(new NSGA2()).run(); | ||
``` | ||
|
||
For more information, visit the [Wiki](https://github.com/onclave/NSGA-II/wiki) | ||
|
||
For full documentation, visit the [Documentation Wiki](https://github.com/onclave/NSGA-II/wiki/Documentation). | ||
|
||
### Using it in your project | ||
|
||
This package shall be published to maven shortly. Till then you can use the source package directly in your project. | ||
|
||
### [Getting Started](https://github.com/onclave/NSGA-II/wiki/Getting-Started) | ||
|
||
### Contributing | ||
|
||
This project is open to pull requests and encourages new features through contribution. The contribution guidelines shall be updated shortly. | ||
# Train rostering using NSGA-II | ||
**an NSGA-II implementation for assigning randomly Train Services to train crews** | ||
|
||
**Original implementation of the algorithm: [here](https://github.com/onclave/NSGA-II) v3.0.1** | ||
**Original readme.md [here](https://github.com/sgirardin/NSGA-II/wiki/Original-readme.md)** | ||
|
||
## Installation | ||
You will need: | ||
1. Have Java >= 13 | ||
1. Maven 3+ | ||
1. Then clone the repository locally | ||
|
||
## How to run | ||
### With your favorite IDE (prefered way) | ||
1. Run the main class ```NSGA2Test.java``` | ||
|
||
### Command line | ||
1. Go in project root folder with a terminal | ||
2. Run ```mvn install -Dgpg.skip exec:java``` | ||
3. Do modification in the configuration and do the command at point above. | ||
|
||
## Configuration | ||
In the ```NSGA2Test:main``` method you can change the following parameters: | ||
1. Population size | ||
2. Number of generations | ||
3. Mutation probability | ||
4. Which crossover operator (for the moment we have UniformCrossover or OnePointMutation) | ||
5. Size of Train Crew against which 63 Services will be distributed | ||
|
||
## Data sets | ||
* ```ch.fhnw.mbis.aci.nsgaii.sets.models.TrainService.java``` for the train services | ||
* ```ch.fhnw.mbis.aci.nsgaii.sets.models.TrainCrew.java ```for the train drivers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import ch.fhnw.mbis.aci.nsgaii.plugin.OnePointCrossover; | ||
import ch.fhnw.mbis.aci.nsgaii.plugin.SchedulingPluginProvider; | ||
import ch.fhnw.mbis.aci.nsgaii.population.TrainCrewSet; | ||
import ch.fhnw.mbis.aci.nsgaii.population.TrainServiceSet; | ||
import ch.fhnw.mbis.aci.nsgaii.sets.models.enums.TrainCrewPopulationSize; | ||
import com.debacharya.nsgaii.Configuration; | ||
import com.debacharya.nsgaii.NSGA2; | ||
import com.debacharya.nsgaii.datastructure.Population; | ||
import com.debacharya.nsgaii.plugin.CrossoverParticipantCreatorProvider; | ||
import com.debacharya.nsgaii.plugin.PopulationProducer; | ||
import com.debacharya.nsgaii.plugin.SinglePointMutation; | ||
import com.debacharya.nsgaii.plugin.UniformCrossover; | ||
|
||
public class NSGA2Test { | ||
|
||
public static void main(String[] args) { | ||
// Set parameters | ||
int populationSize = 3; | ||
int nbGenerations = 1; | ||
float mutationProbability = 0.4f; | ||
TrainCrewPopulationSize crewPopulationSize = TrainCrewPopulationSize.TWENTY; | ||
|
||
//Implemented Mutations and crossovers | ||
UniformCrossover uniformCrossover = new UniformCrossover(CrossoverParticipantCreatorProvider.selectByBinaryTournamentSelection()); | ||
OnePointCrossover onePointCrossover = new OnePointCrossover(CrossoverParticipantCreatorProvider.selectByBinaryTournamentSelection()); | ||
SinglePointMutation singlePointMutation = new SinglePointMutation(mutationProbability); | ||
|
||
|
||
//Initialize Population sets | ||
TrainServiceSet.setupServiceSet(); | ||
TrainCrewSet.setupPopulation(crewPopulationSize); | ||
|
||
PopulationProducer populationProducer = SchedulingPluginProvider.defaultPopulationProducer(); | ||
|
||
Configuration configuration = new Configuration(populationSize,nbGenerations, populationProducer, uniformCrossover, singlePointMutation); | ||
|
||
NSGA2 nsga2 = new NSGA2(configuration); | ||
Population paretoFront = nsga2.run(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/ch/fhnw/mbis/aci/nsgaii/datastructure/IntegerAllele.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ch.fhnw.mbis.aci.nsgaii.datastructure; | ||
|
||
import com.debacharya.nsgaii.datastructure.AbstractAllele; | ||
|
||
public class IntegerAllele extends AbstractAllele { | ||
|
||
public IntegerAllele(Integer gene) { | ||
super(gene); | ||
} | ||
|
||
@Override | ||
public Integer getAllele() { | ||
return (int) this.allele; | ||
} | ||
|
||
@Override | ||
public IntegerAllele getCopy() { | ||
return new IntegerAllele((Integer)this.allele); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IntegerAllele{" + | ||
"gene=" + allele + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.