Solver
Solver list is shown in Solvers.
- flopt.Solver(algo='auto')[source]
Obtain Solver object.
- Parameters:
algo (str) – algorithm name
- Returns:
return Solver
- Return type:
Solver object
- flopt.Solver_list()[source]
Obtain useable solver list
- Returns:
return list of algorithm names
- Return type:
list
- flopt.allAvailableSolvers(prob)[source]
Obtain all available solvers to solve the problem
- Parameters:
prob (Problem) – problem
- Returns:
algorithm names that can solve the problem
- Return type:
list of str
Examples
import flopt from flopt import Variable, Problem, CustomExpression # Linear problem without constraint a = Variable("a", 0, 1, "Integer") b = Variable("b", 1, 2, "Continuous") c = Variable("c", 1, 3, "Continuous") prob_linear = Problem(name="Only objective") prob_linear += a + b + c # Problem with constraint prob_with_const = Problem(name="With constraint") prob_with_const += a + b + c prob_with_const += a + b >= 2 # Non-Linear problem prob_nonlinear = Problem("Non Linear") prob_nonlinear += a*b*c prob_nonlinear += a + b >= 2 # Permutation Problem p = Variable("p", 0, 4, "Permutation") prob_perm = Problem("TestP") def obj(p): return p[-1] - p[0] prob_perm += CustomExpression(obj, [p]) # display solvers can solve prob_linear print(flopt.allAvailableSolvers(prob_linear) # display solvers can solve prob_with_const print(flopt.allAvailableSolvers(prob_with_const)) # display solvers can solve prob_nonlinear print(flopt.allAvailableSolvers(prob_nonlinear)) # display solvers can solve prob_perm print(flopt.allAvailableSolvers(prob_perm))