A Java library for solving the Assignment Problem using cost minimization or productivity maximization.
The Assignment Solver is a Java library that solves the Assignment Problem efficiently using the Hungarian Algorithm. It supports both:
✔ Cost minimization (e.g., minimizing task assignment costs).
✔ Productivity maximization (e.g., maximizing worker efficiency).
To include this library in your project, add the following dependency to your build file:
Add the JitPack repository to your pom.xml
:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Then, add the dependency:
<dependency>
<groupId>io.github.rivon0507</groupId>
<artifactId>or-assignment-problem</artifactId>
<version>0.1.0</version>
</dependency>
Add the JitPack repository to your build.gradle
:
repositories {
maven { url 'https://jitpack.io' }
}
Then, add the dependency:
dependencies {
implementation 'io.github.rivon0507:or-assignment-problem:0.1.0'
}
- Download the latest JAR from Releases.
- Add it to your classpath.
import io.github.rivon0507.or.assignmentproblem.AssignmentSolver;
public class Main {
public static void main(String[] args) {
AssignmentSolver solver = new AssignmentSolver();
int[][] costMatrix = {{9, 2, 7}, {6, 4, 3}, {5, 8, 1}};
solver.configure(costMatrix, AssignmentSolver.OptimizationType.MINIMIZE);
solver.solve();
if (solver.isSolved()) {
int[] optimalAssignment = solver.getSolution();
for (int i = 0; i < optimalAssignment.length; i++) {
System.out.printf("Employee %d is assigned to task %d%n", i, optimalAssignment[i]);
}
System.out.println("Optimal value: " + solver.getOptimalValue());
}
}
}
✔ Supports both cost minimization & productivity maximization
✔ Works with square cost matrices
✔ Simple, intuitive API
This project is licensed under the MIT License. See LICENSE for details.
- Fork the repository
- Create a new branch (
git checkout -b feat/feature-name
) - Commit changes (
git commit -m "Add new feature"
) - Push to your branch (
git push origin feat/feature-name
) - Open a pull request
Developed by rivon0507.