Developer Interface

Main Module

suspect.detect_special_structure(problem, max_iter=10)

Detect special structure in the problem.

Parameters
modelsuspect.dag.ProblemDag or ConcreteModel

the problem DAG or a Pyomo ConcreteModel.

max_iterint

number of maximum bound propagation/tightening iterations.

Returns
ModelInformation

an object containing the detected infomation about the problem.

class suspect.summary.ModelInformation(name, variables, objectives, constraints)

Hold structure information about a problem.

Attributes
variablesdict

map variables names to their information

objectivesdict

map objectives names to their information

constraintsdict

map constraints names to their information

conscurvature()

Returns the convexity of each constraint.

num_binaries()

Returns the number of binary variables in the problem.

num_constraints()

Returns the number of constraints in the problem.

num_integers()

Returns the number of integer variables in the problem.

num_variables()

Returns the number of variables in the problem.

objcurvature()

Returns the convexity of each objective.

objtype()

Returns the type of each objective.

Expression Types

Generic expression support.

class suspect.expression.ExpressionType(value)

Expression types supported by SUSPECT.

Constant = 2
Constraint = 3
Division = 5
Linear = 7
Negation = 10
Objective = 4
Power = 9
Product = 6
Quadratic = 12
Reciprocal = 13
Sum = 8
UnaryFunction = 11
Variable = 1
class suspect.expression.UnaryFunctionType(value)

Unary function type supported by SUSPECT.

Abs = 1
Acos = 9
Asin = 8
Atan = 10
Cos = 6
Exp = 3
Log = 4
Sin = 5
Sqrt = 2
Tan = 7

Interfaces

Interfaces used in SUSPECT.

You don’t need them, but they are nice for documentation purpose.

class suspect.interfaces.BackwardIterator

An iterator for iterating over nodes in descending depth order.

class suspect.interfaces.CombineUnaryFunctionRules(rules, needs_matching_rules=True)

Rule to combine a collection of UnaryFunctionRule.

Parameters
rules: UnaryFunctionRule dict

dict of unary functions rules

needs_matching_rulesbool

if True, will raise an exception if no rule matched

apply(expr, ctx, *args)

Apply rule to expr and ctx.

class suspect.interfaces.ForwardIterator

An iterator for iterating over nodes in ascending depth order.

class suspect.interfaces.Iterator

Iterator over vertices of Problem.

abstract iterate(problem, visitor, ctx, *args, **kwargs)

Iterate over vertices of problem, calling visitor on each one of them.

Returns the list of vertices for which the visitor returned a True value.

class suspect.interfaces.Problem

Generic problem with vertices of type V.

class suspect.interfaces.Rule

Represent a series of contraints on an expression yielding a value.

apply(expr, ctx)

Apply rule to expr and ctx.

class suspect.interfaces.UnaryFunctionRule

Represent a series of contraints on an unary function expression yielding a value.

class suspect.interfaces.Visitor

Visitor for vertices of Problem.

abstract visit(vertex, ctx)

Visit vertex. Return True if the vertex should be considered “dirty”.

Interval

Numerical interval object.

class suspect.interval.EmptyInterval

An empty interval.

exception suspect.interval.EmptyIntervalError
class suspect.interval.Interval(lower, upper)

Numerical interval.

property acos

Return the bound of acos(self)

property asin

Return the bound of asin(self)

property atan

Return the bound of atan(self)

property cos

Return the bound of cos(self)

property exp

Return the bound of exp(self)

intersect(other, rel_eps=None, abs_eps=None)

Intersect this interval with another.

inverse()

Return the inverse of self, or 1/self.

is_negative()

Check if the interval [a, b] has b < 0.

is_nonnegative()

Check if the interval [a, b] has a >= 0.

is_nonpositive()

Check if the interval [a, b] has b <= 0.

is_positive()

Check if the interval [a, b] has a > 0.

is_zero()

Check if the interval is [0, 0].

property log

Return the bound of log(self)

property log10

Return the bound of log10(self)

property lower_bound

Return interval lower bound as float.

property negation

Return the negation of self, or 0-self

property sin

Return the bound of sin(self)

size()

Return interval size.

property sqrt

Return the bound of sqrt(self)

property tan

Return the bound of tan(self)

property upper_bound

Return interval upper bound as float.

static zero()

Return Interval = [0, 0].

suspect.interval.monotonic_decreasing(func)

Correctly round monotonic decreasing function.

suspect.interval.monotonic_increasing(func)

Correctly round monotonic increasing function.

Pyomo Compatibility

suspect.pyomo.create_connected_model(model, active=True, connect_max_linear_children=50, connect_max_quadratic_children=100)
suspect.pyomo.read_osil(filename, objective_prefix=None, constraint_prefix=None)

Read OSiL-formatted problem into a Pyomo model.

It’s possible to optionally specify a prefix for objectives/constraints to avoid name clashes.

Parameters
filenamestr

the OSiL file path.

objective_prefixstr

a prefix to give all objectives.

constraint_prefixstr

a prefix to give all constraints.

Returns
ConcreteModel

a Pyomo concrete model.