friendlysam.opt.Problem¶
-
class
friendlysam.opt.
Problem
¶ An optimization problem.
The problem class is essentially a container for an objective function and a set of constraints.
Examples
>>> x = VariableCollection('x') >>> prob = Problem() >>> prob.objective = Maximize(x(1) + x(2)) >>> prob.add(8 * x(1) + 4 * x(2) <= 11) >>> prob.add(2 * x(1) + 4 * x(2) <= 5) >>> >>> # Get a solver and solve the problem >>> solver = fs.get_solver() >>> solution = solver.solve(prob) >>> type(solution) <class 'dict'> >>> solution[x(1)] 1.0 >>> solution[x(2)] 0.75
Problem.add (*constraints) |
Add zero or more constraints to the problem. |
Problem.variables_without_value () |
Get all Variable instances without value. |
Problem.constraints |
A set of constraints. |
Problem.objective |