Eclipse plug-in for ILP solvers.
Go to file
Maximilian Kratz fe9191286b
Merge pull request #69 from eMoflon/feature/update-github-release-action-nodejs20
Updates GitHub release action to NodeJS v20
2024-03-29 07:24:15 +01:00
.github/workflows Updates GitHub release action to NodeJS v20 2024-03-29 07:21:05 +01:00
org.emoflon.ilp Prepares release v0.0.2 2024-03-22 13:38:54 +01:00
org.emoflon.ilp.dependencies Prepares release v0.0.2 2024-03-22 13:38:54 +01:00
org.emoflon.ilp.feature Prepares release v0.0.2 2024-03-22 13:38:54 +01:00
org.emoflon.ilp.tests Prepares release v0.0.2 2024-03-22 13:38:54 +01:00
org.emoflon.ilp.updatesite Prepares release v0.0.2 2024-03-22 13:38:54 +01:00
scripts Updates Gurobi dependency to v11.0.1 2024-03-13 09:53:57 +01:00
.gitignore Fixes wrong maven-osgi-packaging-plugin version + adds gitignore for target folders 2023-04-21 15:00:43 +02:00
.project Adds dependencies and tests 2023-08-14 11:05:39 +02:00
LICENSE Initial commit 2022-10-31 09:14:08 +01:00
README.md Updates Gurobi dependency to v11.0.1 2024-03-13 09:53:57 +01:00
pom.xml Updates Tycho to v4.0.7 2024-03-29 07:19:14 +01:00

README.md

eMoflon-ILP

The goal of this plug-in is to simplify the use of different ILP solvers in Eclipse projects. Therefore, the plug-in provides an interface to specify the ILP problem only once instead of having to do different implementations for each solver individually. Switching between solvers is done by changing one parameter in the solver configuration.

How to install the plug-in

  • Install at least one of the supported ILP solvers:
    • Install Gurobi in version 11.0.1 and activate a license for your computer.
    • Install GLPK (free and open-source) in the newest version (4.65) and add it to your path.
    • Install CPLEX in version 22.1.1 and activate a license for your computer (if necessary).
  • Build + install the project to the local .m2/ folder:
    $ mvn clean install

How to build the plugin

  • Install at least one of the supported ILP solvers:
    • Install Gurobi in version 11.0.1 and activate a license for your computer.
    • Install GLPK (free and open-source) in the newest version (4.65) and add it to your path.
    • Install CPLEX in version 22.1.1 and activate a license for your computer (if necessary).
  • Build the project + feature + update site:
    $ mvn clean package

How to run tests

Remember: Depending on the solver a license is necessary (e.g., for Gurobi).

  • Run all tests:
    $ mvn clean verify
  • Run a specific test class (e.g., GlpkTest.java):
    $ mvn -Dtest=GlpkTest -DfailIfNoTests=false verify

Before running tests with the CPLEX solver, it might be necessary to add the following Run Configuration to the VM Arguments (Eclipse: right click on the project -> Run as -> Run Configurations -> Arguments tab), replace with the appropriate path, for example:
-Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio2211/cplex/bin/x86-64_linux

Example Problem

Knapsack Problem

This example can be found in the test class SolverTest.java.

There is a set of items, which all have a weight and a value. The goal is to determine a collection of items, for which the profit is maximized but the capacity constraint is satisfied.

// Amount of items
int I = 6;
// Profit
int[] p = { 10, 13, 18, 32, 7, 15 };
// Weight
int[] w = { 11, 15, 20, 35, 10, 33 };
// Capacity
int c = 47;

// Create variables:
// 0 -> item i not put in knapsack
// 1 -> item i put in knapsack
List<BinaryVariable> x_i = new ArrayList<>();
for (int i = 0; i < I; i++) {
	x_i.add(new BinaryVariable("x_" + i));
}

// Objective: maximize the total price of selected items
// maximize SUM(p_i * x_i)
Problem problem = new Problem();
problem.setType(ObjectiveType.MAX);

LinearFunction lin = new LinearFunction();
for (int i = 0; i < I; i++) {
	lin.addTerm(x_i.get(i), p[i]);
}

// Constraint: Total weight must be equal or less than the capacity
// SUM(w_i * x_i) <= c
LinearConstraint c1 = new LinearConstraint(Operator.LESS_OR_EQUAL, c);
for (int i = 0; i < I; i++) {
	c1.addTerm(x_i.get(i), w[i]);
}

// Model
problem.setObjective(lin);
problem.add(c1);

// Optimize
SolverConfig config = new SolverConfig(SolverType.GLPK, false, 0.0, true, 42, false, 0.0, false, 0, 0, true, false, false, null);
Solver solver = (new SolverHelper(config)).getSolver();
solver.buildILPProblem(problem);
SolverOutput out = solver.solve();
// Prints the result of the objective
System.out.println(out.toString());
// Sets the values for the Variables
solver.updateValuesFromSolution();

// Do something, e.g. print

solver.terminate();

Repository/Project structure

Name Description
org.emoflon.ilp Contains the implementation of the plug-in.
org.emoflon.ilp.feature Contains the information for the feature to export.
org.emoflon.ilp.updatesite Contains the update site configuration (to include the feature above).
org.emoflon.ilp.dependencies Contains all necessary dependencies (JARs of each solver).
org.emoflon.ilp.tests Contains all tests and test-related content.
ci.yml GitHub Actions configuration to build and test the plug-in.
pom.xml Maven configuration file that contains the parent group/project.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for more details.