|
| __init__ (self, number=None, domain=None, name='X') |
| Init model.
|
|
| add_variables (self, number, domain, name='X') |
| Add variable domains.
|
|
| restrict_domains (self, vars, domain) |
| Restrict the domain of a variable.
|
|
| add_constraints (self, constraints) |
| Add constraints to the model.
|
|
| add_functions (self, functions, group='base') |
| Add functions to the model.
|
|
| num_named_variables (self, name) |
| Number of variables.
|
|
| has_empty_domains (self) |
| Check inconsistency due to empty domains.
|
|
| add_feature (self, name, group, eval_fun) |
| Add a (custom) feature.
|
|
| eval_feature (self, assignment, name) |
| Evaluate named feature at assignment.
|
|
| set_feature_weight (self, weight, name) |
| Set the weight of a feature and its function group.
|
|
| idx (self, variables) |
| Raw indices of named variables.
|
|
| dependencies (self, non_redundant=True) |
| Dependencies due to constraints and functions.
|
|
| bindependencies (self, non_redundant=True) |
|
| write_graph (self, out, non_redundant=True) |
| Write dependency graph.
|
|
| connected_components (self) |
| Connected components of the model's dependency graph.
|
|
◆ __init__()
infrared.infrared.Model.__init__ |
( |
|
self, |
|
|
|
number = None , |
|
|
|
domain = None , |
|
|
|
name = 'X' |
|
) |
| |
Init model.
If number is not None, calls add_variables with the
given parameters after initialization.
- Parameters
-
number | if not None, number of variables |
domain | domains of variables |
name | name of variable series. Defaults to X |
◆ _automatic_feature()
infrared.infrared.Model._automatic_feature |
( |
|
self, |
|
|
|
group |
|
) |
| |
|
protected |
Automatic feature for function group.
Feature with value that is derived as sum of the feature functions
- Returns
- the feature
◆ _expand_to_cliques()
infrared.infrared.Model._expand_to_cliques |
( |
|
dependencies | ) |
|
|
staticprotected |
Expand non-binary dependencies to cliques of binary deps.
- Parameters
-
dependencies | list of dependencies |
- Returns
- list of binary dependencies
◆ _remove_subsumed_dependencies()
infrared.infrared.Model._remove_subsumed_dependencies |
( |
|
deps | ) |
|
|
staticprotected |
Removes redundant dependencies that are subsumed by others Removes all dependencies that are subsumed by other dependencies in deps.
- Parameters
-
deps | list of dependencies (where a dependency is a list of indices) |
- Returns
- pruned list of dependencies
◆ add_constraints()
infrared.infrared.Model.add_constraints |
( |
|
self, |
|
|
|
constraints |
|
) |
| |
Add constraints to the model.
- Parameters
-
constraints | an iterable of constraints or a single constraint |
- Note
- supports optimizations via on_add and entailed methods of added constraints; see ValueIn
◆ add_feature()
infrared.infrared.Model.add_feature |
( |
|
self, |
|
|
|
name, |
|
|
|
group, |
|
|
|
eval_fun |
|
) |
| |
Add a (custom) feature.
- Parameters
-
name | name of the feature |
group | one or several groups of feature controlled functions |
eval_fun | function to evaluate the feature at an assignment |
◆ add_functions()
infrared.infrared.Model.add_functions |
( |
|
self, |
|
|
|
functions, |
|
|
|
group = 'base' |
|
) |
| |
Add functions to the model.
- Parameters
-
functions | [const] an iterable of functions or a single function |
group | indentifier of function group. Defaults to base |
- Note
- deep copies the input functions
◆ add_variables()
infrared.infrared.Model.add_variables |
( |
|
self, |
|
|
|
number, |
|
|
|
domain, |
|
|
|
name = 'X' |
|
) |
| |
Add variable domains.
- Parameters
-
number | number of variables |
domain | domain size; defines the domain values as 0..domain-1 |
name | assign a name to the variable(s) |
◆ bindependencies()
infrared.infrared.Model.bindependencies |
( |
|
self, |
|
|
|
non_redundant = True |
|
) |
| |
◆ connected_components()
infrared.infrared.Model.connected_components |
( |
|
self | ) |
|
Connected components of the model's dependency graph.
- Returns
- a list of sets of the connected components
◆ dependencies()
infrared.infrared.Model.dependencies |
( |
|
self, |
|
|
|
non_redundant = True |
|
) |
| |
Dependencies due to constraints and functions.
- Parameters
-
non_redundant | whether the dependency list is made non-redundant. Defaults to True |
- Returns
- list of lists of indices of variables that depend on each other either through functions or constraints
◆ eval_feature()
infrared.infrared.Model.eval_feature |
( |
|
self, |
|
|
|
assignment, |
|
|
|
name |
|
) |
| |
Evaluate named feature at assignment.
- Parameters
-
assignment | the assignment |
name | name of the feature |
- Returns
- value of the feature
◆ has_empty_domains()
infrared.infrared.Model.has_empty_domains |
( |
|
self | ) |
|
Check inconsistency due to empty domains.
- Returns
- whether model has empty domains
◆ idx()
infrared.infrared.Model.idx |
( |
|
self, |
|
|
|
variables |
|
) |
| |
Raw indices of named variables.
- Parameters
-
variables | single variable or list of variables; variables can be named; default name 'X' |
- Returns
- list of (internal) variable indices
◆ num_named_variables()
infrared.infrared.Model.num_named_variables |
( |
|
self, |
|
|
|
name |
|
) |
| |
Number of variables.
- Parameters
-
name | name of the variables series |
- Returns
- number of variables of the given series
◆ restrict_domains()
infrared.infrared.Model.restrict_domains |
( |
|
self, |
|
|
|
vars, |
|
|
|
domain |
|
) |
| |
Restrict the domain of a variable.
- Parameters
-
vars | variable or list of variables, each specified by (name,index); or simply index, then addressing ('X',index) |
domain | the domain |
- Note
- the domain bounds are intersected with the original domain
◆ set_feature_weight()
infrared.infrared.Model.set_feature_weight |
( |
|
self, |
|
|
|
weight, |
|
|
|
name |
|
) |
| |
Set the weight of a feature and its function group.
This method sets the weight for the Feature itself and in
all the functions (currently!) in its group.
The method should be called after all functions of its group are
defined. Otherwise, weights of the feature and its functions get out
of sync (but can be re-synced by another call to this method.)
- Parameters
-
weight | the weight |
name | the feature name |
◆ write_graph()
infrared.infrared.Model.write_graph |
( |
|
self, |
|
|
|
out, |
|
|
|
non_redundant = True |
|
) |
| |
Write dependency graph.
Writes the dependency graph to file in dot format; hyper-edges are expanded to cliques.
- Parameters
-
out | a filehandle of name of the target file |
◆ _constraints
infrared.infrared.Model._constraints |
|
protected |
◆ _domains
infrared.infrared.Model._domains |
|
protected |
◆ _features
infrared.infrared.Model._features |
|
protected |
◆ _functions
infrared.infrared.Model._functions |
|
protected |
◆ constraints
infrared.infrared.Model.constraints = property |
|
static |
Constraints of the model.
- Returns
- specification of the model's functions
◆ domains
infrared.infrared.Model.domains = property |
|
static |
Domains of the model.
- Returns
- list of all domain descriptions
◆ features
infrared.infrared.Model.features = property |
|
static |
Features of the model.
- Returns
- dictionary of features
◆ functions
infrared.infrared.Model.functions = property |
|
static |
All functions of the model.
- Returns
- list of all functions
◆ num_variables
infrared.infrared.Model.num_variables = property |
|
static |
Number of all variables.
- Returns
- number of all variables
The documentation for this class was generated from the following file: