picos.modeling.objective¶
Implementation of Objective
.
Classes
- class picos.modeling.objective.Objective(direction=None, function=None)[source]¶
Bases:
Valuable
An optimization objective composed of search direction and function.
- Example
>>> from picos import Objective, RealVariable >>> x = RealVariable("x") >>> obj = Objective("min", x); obj <Objective: minimize x> >>> obj + x**2 # Add a term to the objective function. <Objective: minimize x + x²> >>> obj/2 + 2*obj # Scale and combine two objectives. <Objective: minimize x/2 + 2·x> >>> -obj # Flip the optimization direction. <Objective: maximize -x>
- __init__(direction=None, function=None)[source]¶
Construct an optimization objective.
- Parameters
direction (str) –
Case insensitive search direction string. One of
"min"
or"minimize"
,"max"
or"maximize"
,"find"
orNone
(for a feasibility problem).
function (Expression) – The objective function. Must be
None
for a feasibility problem.
- FIND = 'find'¶
Short string denoting a feasibility problem.
- MAX = 'max'¶
Short string denoting a maximization problem.
- MIN = 'min'¶
Short string denoting a minimization problem.
- property direction¶
Search direction as a short string.
- property feasibility¶
Whether the objective is “find an assignment”.
- property function¶
Objective function.
- property normalized[source]¶
The objective but with feasiblity posed as “minimize 0”.
>>> from picos import Objective >>> obj = Objective(); obj <Objective: find an assignment> >>> obj.normalized <Objective: minimize 0>
- property pair¶
Search direction and objective function as a pair.