A comprehensive collection of Java libraries for logical aspects of artificial intelligence and knowledge representation
Home Libraries Downloads Documentation Newsletter Web Interfaces Contact

Brought to you by

Supported by


Integration of optimization problem solvers

Optimization problems occur frequently in more sophisticated reasoning problems. TweetyProject provides bridges to several third-party optimization solvers and distinguishes between several categories of optimization solvers such as solvers for linear optimization problems, solvers for non-linear optimization problems, and solvers for combinatorial optimization problems.

Solvers for linear problems

For linear optimization problems, TweetyProject has built-in support for the Apache Commons Simplex solver which is also set as the default solver for linear problems (if there is also no solver for general problems configured). However, whenever you perform a reasoning task that involves a linear optimization solver, a warning message is printed out that no linear solver is configured and ApacheCommonsSimplex is used as a default. If you do not care about performance issues and only want to get rid of the warning message, you should configure ApacheCommonsSimplex as your default solver for linear problems explicitly. To do that, simply add the following lines somewhere before you invoke your reasoning task for the first time:

import org.tweetyproject.math.opt.*;
import org.tweetyproject.math.opt.solver.*;
Solver.setDefaultLinearSolver(new ApacheCommonsSimplex());

However, depending on your reasoning tasks it is recommend that you either configure ApacheCommonsSimplex further or set another linear solver as your default solver. TweetyProject also supports the integration of e.g. LpSolve. If you have LpSolve installed in your system and the binary lp_solve is accessible in your PATH, you can set it as your default solver for linear problems via:

Solver.setDefaultLinearSolver(new LpSolve());
Solvers for general problems

Unfortunately, to the best of our knowledge there is no free, stable, and versatile Java-based solver for general optimization problems available (if you have one please let us know, we tried out a lot of different approaches). Consequently, there is no default solver for general optimization problems available in TweetyProject. We recommend using the OctaveSqpSolver which provides a bridge to the Octave optimization solver "sqp" which itself implements a successive quadratic programming solver for general non-linear optimization problems. For that to work you must have Octave installed on your system. You can then set OctaveSqpSolver as your default solver for general problems via:

Solver.setDefaultGeneralSolver(new OctaveSqpSolver());
Solvers for combinatorial problems and general comments

The above given code lines set the corresponding solvers as default solvers with default settings. Please be aware that, depending on your actual problem that is to be solved, the configuration of your solver is a crucial issue and influences the quality of the results significantly.

If your favorite solver is not supported, please have a look at the interface in the org.tweetyproject.math.opt package and think about implementing a bridge yourself and contribute it to TweetyProject.


Last updated 28.01.2021, Anna Gessler | Terms