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

Brought to you by

Supported by


Integration of optimization problem solvers

Optimization problems occur frequently in more sophisticated reasoning problems. Tweety provides bridges to several third-party optimization solvers and distinguishes currently between two important categories of optimization solvers: solvers for linear optimization problems and solver for general optimization problems. It is required that at least one solver for linear problems and one solver for general problems are explicitly configured as default solvers.

Solvers for linear problems

For linear optimization problems, Tweety 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 net.sf.tweety.math.opt.*;
import net.sf.tweety.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. Tweety 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 Tweety. We recommend installing the OpenOpt solver suite (which is freely available and written in Python). If OpenOpt is installed on your system and the binary python is accessible in your PATH, you can set OpenOpt as your default solver for general problems via:

Solver.setDefaultGeneralSolver(new OpenOptSolver());
General note on solvers for optimization problems

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 net.sf.tweety.math.opt package and think about implementing a bridge yourself and contribute it to Tweety.


Last updated 11.01.2016, Matthias Thimm