cosapp.drivers.utils

Classes

Constraint(lhs, rhs, is_inequality)

Named tuple representing a non-negative constraint of the kind lhs <op> rhs, where <op> is either == (equality) or >= (inequality constraint), depending on Boolean attribute is_inequality.

ConstraintParser()

ConstraintType(value)

Enum covering constraint types

DesignProblemHandler(system)

Class managing tied design and off-design problems, including unknown aliasing.

SystemAnalyzer(system)

Class containing data collected on a system, to be shared between different drivers.

UnknownAnalyzer(system)

Class used to resolve unknown aliasing

class cosapp.drivers.utils.Constraint(lhs: str, rhs: str, is_inequality: bool = True)[source]

Bases: NamedTuple

Named tuple representing a non-negative constraint of the kind lhs <op> rhs, where <op> is either == (equality) or >= (inequality constraint), depending on Boolean attribute is_inequality.

  • lhs [str]: left-hand side.

  • rhs [str]: right-hand side.

  • is_inequality [bool].

  • expression [str]: non-negative constraint lhs - rhs.

property expression
is_inequality: bool

Alias for field number 2

lhs: str

Alias for field number 0

rhs: str

Alias for field number 1

class cosapp.drivers.utils.ConstraintParser[source]

Bases: object

classmethod parse(expression: Union[str, List[str]])Set[cosapp.drivers.utils.Constraint][source]

Parse a string expression or a list thereof as a set of non-negative constraints to be used in solvers.

  • expression [str or List[str]]:

    Human-readable equality or inequality constraints, such as ‘x >= y’, ‘0 < alpha < 1’, or a list thereof.

  • constraints [Set[Constraint]]:

    Set of Constraint named tuple objects.

classmethod types()Dict[str, cosapp.drivers.utils.ConstraintType][source]
class cosapp.drivers.utils.ConstraintType(value)[source]

Bases: enum.Enum

Enum covering constraint types

EQ = {'operator': '==', 'sort': <function ConstraintType.<lambda>>}
GE = {'operator': '>=', 'sort': <function ConstraintType.<lambda>>}
LE = {'operator': '<=', 'sort': <function ConstraintType.<lambda>>}
property description
expression(lhs: str, rhs: str)str[source]
property is_inequality
property operator
sort(lhs: str, rhs: str)Tuple[str, str][source]
class cosapp.drivers.utils.DesignProblemHandler(system: cosapp.systems.System)[source]

Bases: object

Class managing tied design and off-design problems, including unknown aliasing.

export_problems(prune=True)Tuple[cosapp.core.numerics.basics.MathematicalProblem, cosapp.core.numerics.basics.MathematicalProblem][source]

Export design and off-design problems.

  • prune, Optional[bool]:

    If True (default), resolve unknown aliasing first. If False, returned problems are copies of object attributes.

  • (design, offdesign): Filtered design and off-design problems,

    as a tuple of MathematicalProblem objects.

extend(other: cosapp.drivers.utils.DesignProblemHandler, prune=True, copy=True, overwrite=False)cosapp.drivers.utils.DesignProblemHandler[source]
classmethod make(design: cosapp.core.numerics.basics.MathematicalProblem, offdesign: cosapp.core.numerics.basics.MathematicalProblem)cosapp.drivers.utils.DesignProblemHandler[source]
merged_problem(name='merged', offdesign_prefix='offdesign')cosapp.core.numerics.basics.MathematicalProblem[source]

Merge design and off-design problems into a single MathematicalProblem instance.

new_problem(name: str)cosapp.core.numerics.basics.MathematicalProblem[source]

Create new MathematicalProblem instance

property problems

design and off-design problems as a tuple

Type

Tuple[MathematicalProblem, MathematicalProblem]

reset()None[source]

Reset handler

property system
class cosapp.drivers.utils.SystemAnalyzer(system: Optional[cosapp.systems.System] = None)[source]

Bases: object

Class containing data collected on a system, to be shared between different drivers.

check_system()None[source]
clear_data()None[source]
property data
property system

system of interest

Type

System

class cosapp.drivers.utils.UnknownAnalyzer(system: cosapp.systems.System)[source]

Bases: cosapp.drivers.utils.SystemAnalyzer

Class used to resolve unknown aliasing

filter_problem(problem: cosapp.core.numerics.basics.MathematicalProblem, name=None)cosapp.core.numerics.basics.MathematicalProblem[source]
property input_mapping