Struct biodivine_sketchbook::sketchbook::model::ModelState
source · pub struct ModelState {
variables: HashMap<VarId, Variable>,
regulations: HashSet<Regulation>,
update_fns: HashMap<VarId, UpdateFn>,
uninterpreted_fns: HashMap<UninterpretedFnId, UninterpretedFn>,
layouts: HashMap<LayoutId, Layout>,
placeholder_variables: HashSet<VarId>,
}
Expand description
Object representing the state of the model in the Boolean network editor. The model encompasses variables, regulations, uninterpreted functions, update functions, and layout information.
ModelState
can be observed/edited using its classical Rust API, as well as through the
external events (as it implements the SessionState
event).
Fields§
§variables: HashMap<VarId, Variable>
§regulations: HashSet<Regulation>
§update_fns: HashMap<VarId, UpdateFn>
§uninterpreted_fns: HashMap<UninterpretedFnId, UninterpretedFn>
§layouts: HashMap<LayoutId, Layout>
§placeholder_variables: HashSet<VarId>
Implementations§
source§impl ModelState
impl ModelState
Methods for converting between ModelState
and BooleanNetwork
(from the lib-param-bn
).
sourcefn to_bn_with_options(
&self,
regulation_types: bool,
parameters: bool,
update_fns: bool,
extra_vars: Option<Vec<String>>,
) -> Result<BooleanNetwork, String>
fn to_bn_with_options( &self, regulation_types: bool, parameters: bool, update_fns: bool, extra_vars: Option<Vec<String>>, ) -> Result<BooleanNetwork, String>
Internal function to convert the ModelState
into a variant of BooleanNetwork
with
specified information to be included.
By default, all variables and regulations are included. You can choose the following:
regulation_types
: include types of regulationsparameters
: include all parameters for uninterpreted functionsupdate_fns
: include all update functionsextra_vars
: additional extra variables (with no update fns, no regulations)
It is up to you to make the selection reasonable (e.g., when including update functions that contain parameters, you must also include parameters, and so on…).
sourcepub fn to_empty_bn(&self) -> BooleanNetwork
pub fn to_empty_bn(&self) -> BooleanNetwork
Convert the ModelState
into the corresponding “default” BooleanNetwork
object.
The resulting BN covers the variables and regulations, but it has empty update functions,
and does not cover any parameters.
sourcepub fn to_empty_bn_with_params(&self) -> BooleanNetwork
pub fn to_empty_bn_with_params(&self) -> BooleanNetwork
Convert the ModelState
into the corresponding “default” BooleanNetwork
object with added
parameters.
The resulting BN covers the variables, parameters, and regulations, but it has empty update functions.
sourcepub fn to_fake_bn_with_params(&self, num_variables: usize) -> BooleanNetwork
pub fn to_fake_bn_with_params(&self, num_variables: usize) -> BooleanNetwork
Generate a BooleanNetwork
with a only given number of “placeholder” (fake) variables.
These variables will be named var0
, var1
, …
The resulting BN will normally contain all uninterpreted functions (parameters) of this model. There will be no regulations, and update functions will be empty.
This is useful for parsing FnUpdate
objects describing syntactic trees of uninterpreted functions.
sourcepub fn to_bn(&self) -> BooleanNetwork
pub fn to_bn(&self) -> BooleanNetwork
Convert the ModelState
into the corresponding BooleanNetwork
object (that will contain all of the
variables, regulations, update functions, and uninterpreted functions.
Note that currently the BooleanNetwork
class does not support all features of the ModelState
(such as
various regulation types or details of uninterpreted functions) – these will be lost during the conversion.
sourcepub fn to_bn_with_plain_regulations(
&self,
extra_vars: Option<Vec<String>>,
) -> BooleanNetwork
pub fn to_bn_with_plain_regulations( &self, extra_vars: Option<Vec<String>>, ) -> BooleanNetwork
Convert the ModelState
into the corresponding BooleanNetwork
object (that will contain all of the
variables, (plain) regulations, update functions, and uninterpreted functions). However,
the types of regulations (both monotonicity and essentiality) are ignored, and instead used as
unspecified.
This might be useful if we want to process regulation types later via static properties.
You can add optional extra variables (extra_vars
). These will have no update fns or
regulations.
source§impl ModelState
impl ModelState
sourcepub fn from_bn(bn: &BooleanNetwork) -> Result<Self, String>
pub fn from_bn(bn: &BooleanNetwork) -> Result<Self, String>
Convert the ModelState
into the corresponding BooleanNetwork
object (that will contain
all of the variables, regulations, update functions, and uninterpreted functions).
Annotations for both variables and functions are let empty. See ModelState::from_reg_graph for details on how regulations and variables are handled.
A name of parameters used in BooleanNetwork (which should be unique) is used as both its ID and name in the resulting ModelState.
source§impl ModelState
impl ModelState
Methods for converting between ModelState
and RegulatoryGraph
(from the lib-param-bn
).
sourcepub fn to_reg_graph(&self, extra_vars: Option<Vec<String>>) -> RegulatoryGraph
pub fn to_reg_graph(&self, extra_vars: Option<Vec<String>>) -> RegulatoryGraph
Extract the regulatory graph (RegulatoryGraph
object) from the ModelState
.
Sorted variable IDs of the ModelState
are used for variable names in RegulatoryGraph
.
The conversion might loose some information, as the RegulatoryGraph
does not support
all the variants of Monotonicity
and Essentiality
. See also bn_utils::sign_to_monotonicity.
Note that we can convert the resulting RegulatoryGraph
back, but the conversion loses
some information, like the original variable names and layout information.
Also, all of the other model components, such as update functions
or uninterpreted functions
are not part of the RegulatoryGraph
.
You can add optional extra variables (extra_vars
).
sourcepub fn to_reg_graph_with_unspecified_regs(
&self,
extra_vars: Option<Vec<String>>,
) -> RegulatoryGraph
pub fn to_reg_graph_with_unspecified_regs( &self, extra_vars: Option<Vec<String>>, ) -> RegulatoryGraph
Extract the regulatory graph (RegulatoryGraph
object) from the ModelState
.
Sorted variable IDs of the ModelState
are used for variable names in RegulatoryGraph
.
The types of regulations (their essentiality and monotonicity) are ignored, and unspecified versions are used instead.
This might be useful in inference, if we want to process regulation types later via static properties.
You can add optional extra variables (extra_vars
).
sourcefn _to_reg_graph(
&self,
include_reg_types: bool,
extra_vars: Option<Vec<String>>,
) -> RegulatoryGraph
fn _to_reg_graph( &self, include_reg_types: bool, extra_vars: Option<Vec<String>>, ) -> RegulatoryGraph
Internal utility to extract the regulatory graph (RegulatoryGraph
object) from the
ModelState
. Sorted variable IDs of the ModelState
are used for variable names in
RegulatoryGraph
.
There are two modes based on include_reg_types
argument. If it is set to true
, the
types of regulations (their essentiality and monotonicity) are preserved. If it is set to
false
, they are ignored, and unspecified versions are used instead.
You can add optional extra variables (extra_vars
).
sourcepub fn from_reg_graph(reg_graph: &RegulatoryGraph) -> Result<ModelState, String>
pub fn from_reg_graph(reg_graph: &RegulatoryGraph) -> Result<ModelState, String>
Convert the RegulatoryGraph
into the corresponding ModelState
instance. A name
of the variable used in RegulatoryGraph
(which should be unique) is used as both its ID
and name in the resulting ModelState
.
Note that only the default layout (all nodes at 0,0) is created for the ModelState
.
Variables’ annotations are left empty.
source§impl ModelState
impl ModelState
Methods for safely constructing or mutating instances of ModelState
.
These methods focus on general manipulation with variables/regulations. See below for API focusing on layout manipulation.
sourcepub fn new_empty() -> ModelState
pub fn new_empty() -> ModelState
Create a new ModelState
that does not contain any Variables
, Uninterpreted Functions
,
or Regulations
yet. It contains a single empty default Layout
.
sourcepub fn new_from_model_data(model_data: &ModelData) -> Result<ModelState, String>
pub fn new_from_model_data(model_data: &ModelData) -> Result<ModelState, String>
Create a new ModelState
given a corresponding ModelData
instance.
sourcepub fn new_from_vars(variables: Vec<(&str, &str)>) -> Result<ModelState, String>
pub fn new_from_vars(variables: Vec<(&str, &str)>) -> Result<ModelState, String>
Create new ModelState
using provided variable ID-name pairs, both strings.
All variables have default (empty) update functions.
Result will contain no UninterpretedFns
or Regulations
, and a single default Layout
.
The IDs must be unique valid identifiers. The names might be same as the IDs. It also might be empty or non-unique. The variable annotations are left empty.
Return Err
in case the IDs are not unique.
sourcepub fn add_var(
&mut self,
var_id: VarId,
name: &str,
annot: &str,
) -> Result<(), String>
pub fn add_var( &mut self, var_id: VarId, name: &str, annot: &str, ) -> Result<(), String>
Add a new variable with given var_id
and name
to this ModelState
. The variable
will receive a default “empty” update function.
The ID must be valid identifier that is not already used by some other variable. The names might be same as the ID. It also might be empty or non-unique.
Returns Err
in case the id
is already being used.
sourcepub fn add_var_by_str(
&mut self,
id: &str,
name: &str,
annot: &str,
) -> Result<(), String>
pub fn add_var_by_str( &mut self, id: &str, name: &str, annot: &str, ) -> Result<(), String>
Add a new variable with given id
and name
to this ModelState
. The variable
will receive a default “empty” update function.
The ID must be valid identifier that is not already used by some other variable. The names might be same as the ID. It also might be empty or non-unique.
Returns Err
in case the id
is not a valid identifier or if it is already being used.
sourcepub fn add_multiple_variables(
&mut self,
id_name_pairs: Vec<(&str, &str)>,
) -> Result<(), String>
pub fn add_multiple_variables( &mut self, id_name_pairs: Vec<(&str, &str)>, ) -> Result<(), String>
Shorthand to add a list of new variables with given string IDs and names to this ModelState
.
Each ID must be valid identifier that is not already used by some other variable. The names might be same as the ID. It also might be empty or non-unique. Variable annotations are left empty.
Returns Err
in case some id
is already being used.
sourcepub fn add_uninterpreted_fn(
&mut self,
fn_id: UninterpretedFnId,
name: &str,
arguments: Vec<FnArgument>,
expression: &str,
annot: &str,
) -> Result<(), String>
pub fn add_uninterpreted_fn( &mut self, fn_id: UninterpretedFnId, name: &str, arguments: Vec<FnArgument>, expression: &str, annot: &str, ) -> Result<(), String>
Add a new uninterpreted fn given by its components.
sourcepub fn add_empty_uninterpreted_fn(
&mut self,
fn_id: UninterpretedFnId,
name: &str,
arity: usize,
) -> Result<(), String>
pub fn add_empty_uninterpreted_fn( &mut self, fn_id: UninterpretedFnId, name: &str, arity: usize, ) -> Result<(), String>
Add a new uninterpreted fn with given id
, name
and arity
to this ModelState
.
Note that constraints regarding monotonicity or essentiality must be added separately.
The ID must be valid identifier that is not already used by some other uninterpreted fn.
Returns Err
in case the id
is already being used.
sourcepub fn add_empty_uninterpreted_fn_by_str(
&mut self,
id: &str,
name: &str,
arity: usize,
) -> Result<(), String>
pub fn add_empty_uninterpreted_fn_by_str( &mut self, id: &str, name: &str, arity: usize, ) -> Result<(), String>
Add a new uninterpreted fn with given string id
, name
, and arity
to this ModelState
.
The ID must be valid identifier that is not already used by some other uninterpreted fn.
Returns Err
in case the id
is already being used.
sourcepub fn add_multiple_uninterpreted_fns(
&mut self,
id_name_arity_tuples: Vec<(&str, &str, usize)>,
) -> Result<(), String>
pub fn add_multiple_uninterpreted_fns( &mut self, id_name_arity_tuples: Vec<(&str, &str, usize)>, ) -> Result<(), String>
Shorthand to add a list of new uninterpreted fns, each with a string ID, name, and arity,
to this ModelState
. Details (incl. annotations) for these functions are left empty.
Each ID must be valid identifier that is not already used by some other uninterpreted fns.
Returns Err
in case the id
is already being used.
sourcepub fn add_regulation(
&mut self,
regulator: VarId,
target: VarId,
essential: Essentiality,
regulation_sign: Monotonicity,
) -> Result<(), String>
pub fn add_regulation( &mut self, regulator: VarId, target: VarId, essential: Essentiality, regulation_sign: Monotonicity, ) -> Result<(), String>
Add a new Regulation
to this ModelState
.
Returns Err
when one of the variables is invalid, or the regulation between the two
variables already exists.
sourcepub fn add_regulation_by_str(
&mut self,
regulation_str: &str,
) -> Result<(), String>
pub fn add_regulation_by_str( &mut self, regulation_str: &str, ) -> Result<(), String>
Add a new Regulation
to this ModelState
using a string representation. The
variables in the given string must be valid ID strings for this ModelState
.
Returns Err
when the string does not encode a valid regulation, if the provided variables
are not valid variable IDs, or when the regulation between the two variables already exists.
sourcepub fn add_multiple_regulations(
&mut self,
regulations: Vec<&str>,
) -> Result<(), String>
pub fn add_multiple_regulations( &mut self, regulations: Vec<&str>, ) -> Result<(), String>
Shorthand to add a list of new Regulations
given by their string encoding to this ModelState
.
The variables in the given string must be valid ID strings for this ModelState
.
Returns Err
when the string does not encode a valid regulation, if the provided variables
are not valid variable IDs, or when the regulation between the two variables already exists.
sourcepub fn set_raw_var(
&mut self,
var_id: &VarId,
var_data: Variable,
) -> Result<(), String>
pub fn set_raw_var( &mut self, var_id: &VarId, var_data: Variable, ) -> Result<(), String>
Set the raw variable data for a variable var_id
.
sourcepub fn set_raw_function(
&mut self,
fn_id: &UninterpretedFnId,
fn_data: UninterpretedFn,
) -> Result<(), String>
pub fn set_raw_function( &mut self, fn_id: &UninterpretedFnId, fn_data: UninterpretedFn, ) -> Result<(), String>
Set the raw uninterpreted function data for a function fn_id
.
sourcepub fn set_var_name(&mut self, var_id: &VarId, name: &str) -> Result<(), String>
pub fn set_var_name(&mut self, var_id: &VarId, name: &str) -> Result<(), String>
Set the name of a network variable given by id var_id
.
The name does not have to be unique, as multiple variables might share a name.
Note that you don’t have to rename anything else in the network, since all other structures reference variables with ids.
sourcepub fn set_var_name_by_str(
&mut self,
id: &str,
name: &str,
) -> Result<(), String>
pub fn set_var_name_by_str( &mut self, id: &str, name: &str, ) -> Result<(), String>
Set the name of a network variable given by string id
.
The name does not have to be unique, as multiple variables might share a name.
sourcepub fn set_var_annot(
&mut self,
var_id: &VarId,
annot: &str,
) -> Result<(), String>
pub fn set_var_annot( &mut self, var_id: &VarId, annot: &str, ) -> Result<(), String>
Set the annotation of a network variable given by id var_id
.
sourcepub fn set_var_annot_by_str(
&mut self,
id: &str,
annot: &str,
) -> Result<(), String>
pub fn set_var_annot_by_str( &mut self, id: &str, annot: &str, ) -> Result<(), String>
Set the annotation of a network variable given by id var_id
.
sourcepub fn set_var_id(
&mut self,
original_id: &VarId,
new_id: VarId,
) -> Result<(), String>
pub fn set_var_id( &mut self, original_id: &VarId, new_id: VarId, ) -> Result<(), String>
Set the id of variable with original_id
to new_id
.
Note that this operation may be costly as it affects several components of the state.
sourcepub fn set_var_id_by_str(
&mut self,
original_id: &str,
new_id: &str,
) -> Result<(), String>
pub fn set_var_id_by_str( &mut self, original_id: &str, new_id: &str, ) -> Result<(), String>
Set the id of variable given by string original_id
to new_id
.
Note that this operation may be costly as it affects several components.
sourcepub fn remove_var(&mut self, var_id: &VarId) -> Result<(), String>
pub fn remove_var(&mut self, var_id: &VarId) -> Result<(), String>
Remove the network variable with given var_id
from this ModelState
. This also
removes the variable from all Layouts
, removes its UpdateFn
and all Regulations
where this variable figures.
Returns Err
in case the var_id
is not a valid variable’s identifier, or if some update function
depends on it.
sourcepub fn remove_var_by_str(&mut self, id: &str) -> Result<(), String>
pub fn remove_var_by_str(&mut self, id: &str) -> Result<(), String>
Remove the network variable with given var_id
from this ModelState
. This also
removes the variable from all Layouts
, removes its UpdateFn
and all Regulations
where this variable figures.
Returns Err
in case the var_id
is not a valid variable’s identifier.
sourcepub fn set_uninterpreted_fn_name(
&mut self,
fn_id: &UninterpretedFnId,
name: &str,
) -> Result<(), String>
pub fn set_uninterpreted_fn_name( &mut self, fn_id: &UninterpretedFnId, name: &str, ) -> Result<(), String>
Set the name of an uninterpreted fn given by id fn_id
.
sourcepub fn set_uninterpreted_fn_name_by_str(
&mut self,
id: &str,
name: &str,
) -> Result<(), String>
pub fn set_uninterpreted_fn_name_by_str( &mut self, id: &str, name: &str, ) -> Result<(), String>
Set the name of an uninterpreted fn given by string id
.
sourcepub fn set_fn_annot(
&mut self,
fn_id: &UninterpretedFnId,
annot: &str,
) -> Result<(), String>
pub fn set_fn_annot( &mut self, fn_id: &UninterpretedFnId, annot: &str, ) -> Result<(), String>
Set annotation of an uninterpreted fn given by id fn_id
.
sourcepub fn set_fn_annot_by_str(
&mut self,
id: &str,
annot: &str,
) -> Result<(), String>
pub fn set_fn_annot_by_str( &mut self, id: &str, annot: &str, ) -> Result<(), String>
Set annotation of an uninterpreted fn given by string id
.
sourcepub fn set_uninterpreted_fn_arity(
&mut self,
fn_id: &UninterpretedFnId,
arity: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_arity( &mut self, fn_id: &UninterpretedFnId, arity: usize, ) -> Result<(), String>
Set arity of an uninterpreted fn given by id fn_id
.
In order to change arity of a function symbol, it must not currently be used in any update/uninterpreted function’s expression (because in expressions, it is used on a fixed number of arguments).
sourcepub fn set_uninterpreted_fn_arity_by_str(
&mut self,
id: &str,
arity: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_arity_by_str( &mut self, id: &str, arity: usize, ) -> Result<(), String>
Set the arity of an uninterpreted fn given by string id
.
sourcepub fn increment_fn_arity(
&mut self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
pub fn increment_fn_arity( &mut self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
Increment the arity of an uninterpreted fn given by id fn_id
. Basically adds a defualt
argument (with unknown monotonicity/essentiality) at the end of the function’s arg list.
sourcepub fn decrement_fn_arity(
&mut self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
pub fn decrement_fn_arity( &mut self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
Decrement the arity of an uninterpreted fn given by id fn_id
. Basically drops the last
argument of the function. The last argument must not be used in function’s expression.
sourcepub fn set_uninterpreted_fn_expression(
&mut self,
fn_id: &UninterpretedFnId,
expression: &str,
) -> Result<(), String>
pub fn set_uninterpreted_fn_expression( &mut self, fn_id: &UninterpretedFnId, expression: &str, ) -> Result<(), String>
Set expression of an uninterpreted fn given by id fn_id
.
sourcepub fn set_uninterpreted_fn_expression_by_str(
&mut self,
id: &str,
expression: &str,
) -> Result<(), String>
pub fn set_uninterpreted_fn_expression_by_str( &mut self, id: &str, expression: &str, ) -> Result<(), String>
Set expression of an uninterpreted fn given by string id
.
sourcepub fn set_uninterpreted_fn_essentiality(
&mut self,
fn_id: &UninterpretedFnId,
essentiality: Essentiality,
index: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_essentiality( &mut self, fn_id: &UninterpretedFnId, essentiality: Essentiality, index: usize, ) -> Result<(), String>
Set essentiality of an argument of given uninterpreted fn (on provided index).
sourcepub fn set_uninterpreted_fn_essentiality_by_str(
&mut self,
id: &str,
essentiality: Essentiality,
index: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_essentiality_by_str( &mut self, id: &str, essentiality: Essentiality, index: usize, ) -> Result<(), String>
Set essentiality of an argument of given uninterpreted fn (on provided index).
sourcepub fn set_uninterpreted_fn_monotonicity(
&mut self,
fn_id: &UninterpretedFnId,
monotonicity: Monotonicity,
index: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_monotonicity( &mut self, fn_id: &UninterpretedFnId, monotonicity: Monotonicity, index: usize, ) -> Result<(), String>
Set monotonicity of an argument of given uninterpreted fn (on provided index).
sourcepub fn set_uninterpreted_fn_monotonicity_by_str(
&mut self,
id: &str,
monotonicity: Monotonicity,
index: usize,
) -> Result<(), String>
pub fn set_uninterpreted_fn_monotonicity_by_str( &mut self, id: &str, monotonicity: Monotonicity, index: usize, ) -> Result<(), String>
Set monotonicity of an argument of given uninterpreted fn (on provided index).
sourcepub fn set_uninterpreted_fn_all_args(
&mut self,
fn_id: &UninterpretedFnId,
fn_arguments: Vec<FnArgument>,
) -> Result<(), String>
pub fn set_uninterpreted_fn_all_args( &mut self, fn_id: &UninterpretedFnId, fn_arguments: Vec<FnArgument>, ) -> Result<(), String>
Set constraints on all arguments of given uninterpreted fn.
sourcepub fn set_uninterpreted_fn_all_args_by_str(
&mut self,
id: &str,
fn_arguments: Vec<FnArgument>,
) -> Result<(), String>
pub fn set_uninterpreted_fn_all_args_by_str( &mut self, id: &str, fn_arguments: Vec<FnArgument>, ) -> Result<(), String>
Set constraints on all arguments of given uninterpreted fn.
sourcepub fn set_uninterpreted_fn_id(
&mut self,
original_id: &UninterpretedFnId,
new_id: UninterpretedFnId,
) -> Result<(), String>
pub fn set_uninterpreted_fn_id( &mut self, original_id: &UninterpretedFnId, new_id: UninterpretedFnId, ) -> Result<(), String>
Set the id of an uninterpreted fn with original_id
to new_id
.
Note that this operation may be costly as it affects several components of the state.
sourcepub fn set_uninterpreted_fn_id_by_str(
&mut self,
original_id: &str,
new_id: &str,
) -> Result<(), String>
pub fn set_uninterpreted_fn_id_by_str( &mut self, original_id: &str, new_id: &str, ) -> Result<(), String>
Set the id of an uninterpreted fn given by string original_id
to new_id
.
sourcepub fn remove_uninterpreted_fn(
&mut self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
pub fn remove_uninterpreted_fn( &mut self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
Remove the uninterpreted fn with given fn_id
from this ModelState
. Note that this
uninterpreted fn must not be used in any update fn.
Also returns Err
in case the fn_id
is not a valid uninterpreted fn’s identifier or if some
update/uninterpreted function depends on it.
sourcepub fn remove_uninterpreted_fn_by_str(&mut self, id: &str) -> Result<(), String>
pub fn remove_uninterpreted_fn_by_str(&mut self, id: &str) -> Result<(), String>
Remove the uninterpreted_fn with given string id
from this ModelState
. Note that this
uninterpreted_fn must not be used in any update fn.
Also returns Err
in case the fn_id
is not a valid uninterpreted_fn’s identifier.
sourcepub fn remove_regulation(
&mut self,
regulator: &VarId,
target: &VarId,
) -> Result<(), String>
pub fn remove_regulation( &mut self, regulator: &VarId, target: &VarId, ) -> Result<(), String>
Remove a Regulation
pointing from regulator
to target
from this ModelState
.
Returns Err
when one of the variables is invalid, or the regulation between the two
variables does not exist.
sourcepub fn remove_regulation_by_str(
&mut self,
regulation_str: &str,
) -> Result<(), String>
pub fn remove_regulation_by_str( &mut self, regulation_str: &str, ) -> Result<(), String>
Remove a Regulation
given by regulation_str
from this ModelState
. The
variables in the regulation_str
must be valid ID strings for this ModelState
.
Returns Err
when one of the variables is invalid, or the regulation between the two
variables does not exist.
sourcepub fn change_regulation_sign(
&mut self,
regulator: &VarId,
target: &VarId,
new_sign: &Monotonicity,
) -> Result<(), String>
pub fn change_regulation_sign( &mut self, regulator: &VarId, target: &VarId, new_sign: &Monotonicity, ) -> Result<(), String>
Shorthand to change sign of a Regulation
pointing from regulator
to target
.
Currently it basically removes the regulation, and adds a new one with the new sign.
Returns Err
when one of the variables is invalid
sourcepub fn change_regulation_essentiality(
&mut self,
regulator: &VarId,
target: &VarId,
new_essentiality: &Essentiality,
) -> Result<(), String>
pub fn change_regulation_essentiality( &mut self, regulator: &VarId, target: &VarId, new_essentiality: &Essentiality, ) -> Result<(), String>
Shorthand to change essentiality of a Regulation
pointing from regulator
to target
.
Currently it basically removes the regulation, and adds a new one with the new essentiality value.
Returns Err
when one of the variables is invalid
sourcepub fn set_update_fn(
&mut self,
var_id: &VarId,
expression: &str,
) -> Result<(), String>
pub fn set_update_fn( &mut self, var_id: &VarId, expression: &str, ) -> Result<(), String>
Set update function for a given variable to a provided expression.
sourcepub fn set_multiple_update_fns(
&mut self,
update_functions: Vec<(&str, &str)>,
) -> Result<(), String>
pub fn set_multiple_update_fns( &mut self, update_functions: Vec<(&str, &str)>, ) -> Result<(), String>
Set update functions for multiple variables (given ID-function pairs). The IDs must be unique valid identifiers.
sourcefn add_placeholder_vars_if_needed(&mut self, arity: usize)
fn add_placeholder_vars_if_needed(&mut self, arity: usize)
(internal) Utility method to add as many placeholder variables as is required by an addition (or update) of an uninterpreted fn of given arity.
sourcefn remove_placeholder_vars_if_needed(&mut self)
fn remove_placeholder_vars_if_needed(&mut self)
(internal) Utility method to remove as many placeholder variables as is required after a removal (or update) of an uninterpreted fn.
source§impl ModelState
impl ModelState
Several utility methods to manipulate with layouts.
sourcepub fn add_layout_simple(
&mut self,
layout_id: LayoutId,
name: &str,
) -> Result<(), String>
pub fn add_layout_simple( &mut self, layout_id: LayoutId, name: &str, ) -> Result<(), String>
Add a new Layout
with given layout_id
and name
to this ModelState
. The layout
will contain nodes for all model’s variables, all of them located at a default position.
Returns Err
if layout_id
is already being used for some other Layout
.
sourcepub fn add_or_update_layout_raw(
&mut self,
id: LayoutId,
layout: Layout,
) -> Result<(), String>
pub fn add_or_update_layout_raw( &mut self, id: LayoutId, layout: Layout, ) -> Result<(), String>
Add a new (pre-generated) Layout
with given id
to this ModelState
, or update
existing if the id
is already used. The layout must contain nodes for exactly all model’s
variables.
sourcepub fn add_layout_copy(
&mut self,
layout_id: LayoutId,
name: &str,
template_layout_id: &LayoutId,
) -> Result<(), String>
pub fn add_layout_copy( &mut self, layout_id: LayoutId, name: &str, template_layout_id: &LayoutId, ) -> Result<(), String>
Add a new Layout
with given layout_id
and name
to this ModelState
. The layout
will be a direct copy of another existing layout given by id template_layout_id
.
Returns Err
if layout_id
is already being used for some other Layout
in
this ModelState
, or if template_layout_id
does not exist.
sourcepub fn remove_layout(&mut self, layout_id: &LayoutId) -> Result<(), String>
pub fn remove_layout(&mut self, layout_id: &LayoutId) -> Result<(), String>
Remove a Layout
with given layout_id
from this ModelState
. Default layout
can not be deleted.
Returns Err
in case the id
is not a valid identifier in this ModelState
.
sourcepub fn remove_layout_by_str(&mut self, id: &str) -> Result<(), String>
pub fn remove_layout_by_str(&mut self, id: &str) -> Result<(), String>
Remove a Layout
with given id
from this ModelState
.
Returns Err
in case the id
is not a valid identifier in this ModelState
.
sourcepub fn update_position(
&mut self,
layout_id: &LayoutId,
var_id: &VarId,
px: f32,
py: f32,
) -> Result<(), String>
pub fn update_position( &mut self, layout_id: &LayoutId, var_id: &VarId, px: f32, py: f32, ) -> Result<(), String>
Update position of a node for variable var_id
in layout layout_id
.
Returns Err
in case one of the ids is not a valid for this ModelState
.
sourcefn insert_to_layout(
&mut self,
var_id: VarId,
layout_id: &LayoutId,
) -> Result<(), String>
fn insert_to_layout( &mut self, var_id: VarId, layout_id: &LayoutId, ) -> Result<(), String>
(internal) Utility method to add a variable node to a given layout. The node is inserted to a default position x=0,y=0.
sourcefn insert_to_default_layout(&mut self, var_id: VarId) -> Result<(), String>
fn insert_to_default_layout(&mut self, var_id: VarId) -> Result<(), String>
(internal) Shorthand method for adding a variable node to a default layout. The node is inserted to a default position x=0,y=0.
source§impl ModelState
impl ModelState
Several utility methods to assert (non-)existence of variables/regulations/layouts in the current state.
sourcefn assert_no_regulation(
&self,
regulator: &VarId,
target: &VarId,
) -> Result<(), String>
fn assert_no_regulation( &self, regulator: &VarId, target: &VarId, ) -> Result<(), String>
(internal) Utility method to ensure there is no regulation between the two variables yet.
sourcefn assert_no_variable(&self, var_id: &VarId) -> Result<(), String>
fn assert_no_variable(&self, var_id: &VarId) -> Result<(), String>
(internal) Utility method to ensure there is no variable with given Id yet.
sourcefn assert_valid_variable(&self, var_id: &VarId) -> Result<(), String>
fn assert_valid_variable(&self, var_id: &VarId) -> Result<(), String>
(internal) Utility method to ensure there is a variable with given Id.
sourcefn assert_no_uninterpreted_fn(
&self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
fn assert_no_uninterpreted_fn( &self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
(internal) Utility method to ensure there is no uninterpreted_fn with given Id yet.
sourcefn assert_valid_uninterpreted_fn(
&self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
fn assert_valid_uninterpreted_fn( &self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
(internal) Utility method to ensure there is a uninterpreted fn with given Id.
sourcefn assert_no_layout(&self, layout_id: &LayoutId) -> Result<(), String>
fn assert_no_layout(&self, layout_id: &LayoutId) -> Result<(), String>
(internal) Utility method to ensure there is no layout with given Id yet.
sourcefn assert_valid_layout(&self, layout_id: &LayoutId) -> Result<(), String>
fn assert_valid_layout(&self, layout_id: &LayoutId) -> Result<(), String>
(internal) Utility method to ensure there is a layout with given Id.
sourcefn assert_fn_not_used_in_expressions(
&self,
fn_id: &UninterpretedFnId,
) -> Result<(), String>
fn assert_fn_not_used_in_expressions( &self, fn_id: &UninterpretedFnId, ) -> Result<(), String>
(internal) Utility method to ensure that an uninterpreted function is not used in any expressions (corresponding to any update function or any uninterpreted function).
source§impl ModelState
impl ModelState
Methods for safely generating valid instances of identifiers for the current ModelState
.
sourcepub fn generate_var_id(
&self,
ideal_id: &str,
start_index: Option<usize>,
) -> VarId
pub fn generate_var_id( &self, ideal_id: &str, start_index: Option<usize>, ) -> VarId
Generate valid VarId
that’s currently not used by any variable in this ModelState
.
First, the given ideal_id
or its transformation by replacing invalid characters are tried.
If they are both invalid (non-unique), a numerical identifier is added at the end.
By specifying start_index
, the index search starts directly at that number (e.g., when
ideal ID is “var” and start index is 3, search for ID starts with “var_3”, “var_4”, …)
Warning: Do not use this to pre-generate more than one id at a time, as the process is deterministic and might generate the same IDs. Always generate an Id, add that variable to the model, and then repeat for other variables.
sourcepub fn generate_layout_id(
&self,
ideal_id: &str,
start_index: Option<usize>,
) -> LayoutId
pub fn generate_layout_id( &self, ideal_id: &str, start_index: Option<usize>, ) -> LayoutId
Generate valid LayoutId
that’s currently not used by layouts in this ModelState
.
First, the given ideal_id
or its transformation by replacing invalid characters are tried.
If they are both invalid (non-unique), a numerical identifier is added at the end.
By specifying start_index
, the index search starts directly at that number (e.g., when
ideal ID is “l” and start index is 3, search for ID starts with “l_3”, “l_4”, …)
Warning: Do not use this to pre-generate more than one id at a time, as the process is deterministic and might generate the same IDs. Always generate an Id, add that layout to the model, and then repeat for other layouts.
sourcepub fn generate_uninterpreted_fn_id(
&self,
ideal_id: &str,
start_index: Option<usize>,
) -> UninterpretedFnId
pub fn generate_uninterpreted_fn_id( &self, ideal_id: &str, start_index: Option<usize>, ) -> UninterpretedFnId
Generate valid UninterpretedFnId
that’s currently not used by uninterpreted_fns in this ModelState
.
First, the given ideal_id
or its transformation by replacing invalid characters are tried.
If they are both invalid (non-unique), a numerical identifier is added at the end.
By specifying start_index
, the index search starts directly at that number (e.g., when
ideal ID is “fn” and start index is 3, search for ID starts with “fn_3”, “fn_4”, …)
Warning: Do not use this to pre-generate more than one id at a time, as the process is deterministic and might generate the same IDs. Always generate an Id, add that fn to the model, and then repeat for other fns.
source§impl ModelState
impl ModelState
Some basic utility methods for inspecting the ModelState
.
sourcepub fn num_uninterpreted_fns(&self) -> usize
pub fn num_uninterpreted_fns(&self) -> usize
The number of uninterpreted_fns in this ModelState
.
sourcepub fn num_layouts(&self) -> usize
pub fn num_layouts(&self) -> usize
The number of layouts in this ModelState
.
sourcepub fn num_regulations(&self) -> usize
pub fn num_regulations(&self) -> usize
The number of regulations in this ModelState
.
sourcepub(crate) fn num_placeholder_vars(&self) -> usize
pub(crate) fn num_placeholder_vars(&self) -> usize
The number of placeholder variables in this ModelState
.
sourcepub fn is_valid_var_id(&self, var_id: &VarId) -> bool
pub fn is_valid_var_id(&self, var_id: &VarId) -> bool
Check if there is a variable with given Id.
sourcepub(crate) fn is_valid_placeholder_var_id(&self, var_id: &VarId) -> bool
pub(crate) fn is_valid_placeholder_var_id(&self, var_id: &VarId) -> bool
Check if there is a placeholder variable with given Id.
sourcepub fn is_valid_var_id_str(&self, id: &str) -> bool
pub fn is_valid_var_id_str(&self, id: &str) -> bool
Check if the given id
corresponds to some variable’s valid Id.
sourcepub fn is_valid_uninterpreted_fn_id(&self, fn_id: &UninterpretedFnId) -> bool
pub fn is_valid_uninterpreted_fn_id(&self, fn_id: &UninterpretedFnId) -> bool
Check if there is a uninterpreted fn with given Id.
sourcepub fn is_valid_uninterpreted_fn_id_str(&self, id: &str) -> bool
pub fn is_valid_uninterpreted_fn_id_str(&self, id: &str) -> bool
Check if the given id
corresponds to some uninterpreted fn’s valid Id.
sourcepub fn is_valid_layout_id(&self, layout_id: &LayoutId) -> bool
pub fn is_valid_layout_id(&self, layout_id: &LayoutId) -> bool
Check if there is a layout with given Id.
sourcepub fn is_valid_layout_id_str(&self, id: &str) -> bool
pub fn is_valid_layout_id_str(&self, id: &str) -> bool
Check if the given id
corresponds to some layout’s valid Id.
sourcepub fn get_var_id(&self, id: &str) -> Result<VarId, String>
pub fn get_var_id(&self, id: &str) -> Result<VarId, String>
Return a valid variable’s VarId
corresponding to the given str id
.
Return Err
if such variable does not exist (and the ID is invalid).
sourcepub(crate) fn get_placeholder_var_id(&self, id: &str) -> Result<VarId, String>
pub(crate) fn get_placeholder_var_id(&self, id: &str) -> Result<VarId, String>
Return a valid placeholder variable’s VarId
corresponding to the given str id
.
Return Err
if such variable does not exist (and the ID is invalid).
sourcepub fn get_variable(&self, var_id: &VarId) -> Result<&Variable, String>
pub fn get_variable(&self, var_id: &VarId) -> Result<&Variable, String>
Return a Variable
corresponding to a given VarId
.
Return Err
if such variable does not exist (the ID is invalid in this context).
sourcepub fn get_uninterpreted_fn_id(
&self,
id: &str,
) -> Result<UninterpretedFnId, String>
pub fn get_uninterpreted_fn_id( &self, id: &str, ) -> Result<UninterpretedFnId, String>
Return a valid uninterpreted fn’s UninterpretedFnId
corresponding to the given str id
.
Return Err
if no such uninterpreted fn exists (and the ID is invalid).
sourcepub fn get_uninterpreted_fn(
&self,
fn_id: &UninterpretedFnId,
) -> Result<&UninterpretedFn, String>
pub fn get_uninterpreted_fn( &self, fn_id: &UninterpretedFnId, ) -> Result<&UninterpretedFn, String>
Return a UninterpretedFn
corresponding to a given UninterpretedFnId
.
Return Err
if no such uninterpreted fn exists (the ID is invalid in this context).
sourcepub fn get_uninterpreted_fn_arity(
&self,
fn_id: &UninterpretedFnId,
) -> Result<usize, String>
pub fn get_uninterpreted_fn_arity( &self, fn_id: &UninterpretedFnId, ) -> Result<usize, String>
Return arity of a UninterpretedFn
corresponding to a given UninterpretedFnId
.
Return Err
if no such uninterpreted fn exists (the ID is invalid in this context).
sourcepub fn get_uninterpreted_fn_annot(
&self,
fn_id: &UninterpretedFnId,
) -> Result<&str, String>
pub fn get_uninterpreted_fn_annot( &self, fn_id: &UninterpretedFnId, ) -> Result<&str, String>
Return annotation of a UninterpretedFn
corresponding to a given UninterpretedFnId
.
Return Err
if no such uninterpreted fn exists (the ID is invalid in this context).
sourcepub fn get_var_name(&self, var_id: &VarId) -> Result<&str, String>
pub fn get_var_name(&self, var_id: &VarId) -> Result<&str, String>
Shortcut to return a name of the variable corresponding to a given VarId
.
Return Err
if such variable does not exist (the ID is invalid in this context).
sourcepub fn get_var_annotation(&self, var_id: &VarId) -> Result<&str, String>
pub fn get_var_annotation(&self, var_id: &VarId) -> Result<&str, String>
Shortcut to return an annotation of the variable corresponding to a given VarId
.
Return Err
if such variable does not exist (the ID is invalid in this context).
sourcepub fn get_regulation(
&self,
regulator: &VarId,
target: &VarId,
) -> Result<&Regulation, String>
pub fn get_regulation( &self, regulator: &VarId, target: &VarId, ) -> Result<&Regulation, String>
Find a Regulation
between two variables if it exists.
Return Err
if one of variable ids is invalid or the regulation does not exist.
sourcepub fn get_regulation_by_str(
&self,
reg: &str,
target: &str,
) -> Result<&Regulation, String>
pub fn get_regulation_by_str( &self, reg: &str, target: &str, ) -> Result<&Regulation, String>
Shorthand to find a Regulation
between two variables (specified by strings) if it exists.
Return Err
if one of variable ids is invalid or the regulation does not exist.
sourcepub fn get_layout(&self, id: &LayoutId) -> Result<&Layout, String>
pub fn get_layout(&self, id: &LayoutId) -> Result<&Layout, String>
Return a Layout
corresponding to the given LayoutId
.
Return Err
if the LayoutId
is invalid.
sourcepub fn get_default_layout(&self) -> &Layout
pub fn get_default_layout(&self) -> &Layout
Return a default Layout
.
sourcepub fn get_layout_id(&self, id: &str) -> Result<LayoutId, String>
pub fn get_layout_id(&self, id: &str) -> Result<LayoutId, String>
Return a valid layout’s LayoutId
corresponding to the Id given by a String
.
Return Err
if such variable does not exist (and the ID is invalid).
sourcepub fn get_layout_name(&self, id: &LayoutId) -> Result<&String, String>
pub fn get_layout_name(&self, id: &LayoutId) -> Result<&String, String>
Shorthand for getting a string name of a layout.
sourcepub fn get_node_position(
&self,
layout_id: &LayoutId,
var_id: &VarId,
) -> Result<&NodePosition, String>
pub fn get_node_position( &self, layout_id: &LayoutId, var_id: &VarId, ) -> Result<&NodePosition, String>
Shorthand for getting a position of a node for given variable in a given layout.
sourcepub fn regulators(&self, target: &VarId) -> Result<Vec<&VarId>, String>
pub fn regulators(&self, target: &VarId) -> Result<Vec<&VarId>, String>
Return a sorted list of variables that regulate the given target
variable.
sourcepub fn targets(&self, regulator: &VarId) -> Result<Vec<&VarId>, String>
pub fn targets(&self, regulator: &VarId) -> Result<Vec<&VarId>, String>
Return a sorted list of variables that are regulated by the given regulator
variable.
sourcepub fn get_update_fn(&self, var_id: &VarId) -> Result<&UpdateFn, String>
pub fn get_update_fn(&self, var_id: &VarId) -> Result<&UpdateFn, String>
Get an update function for the given variable.
sourcepub fn get_update_fn_string(&self, var_id: &VarId) -> Result<&str, String>
pub fn get_update_fn_string(&self, var_id: &VarId) -> Result<&str, String>
Get an update function’s expression for the given variable.
sourcepub fn get_vars_with_empty_update(&self) -> Vec<&str>
pub fn get_vars_with_empty_update(&self) -> Vec<&str>
Get a list of variables with “empty” update function. Returned list contains string ID of each such variable
sourcepub fn is_var_contained_in_updates(&self, var_id: &VarId) -> bool
pub fn is_var_contained_in_updates(&self, var_id: &VarId) -> bool
Check whether variable is used in any update function’s expressions. This is important in case we want to safely delete it.
We expect valid var id here.
sourcepub fn variables(&self) -> VariableIterator<'_>
pub fn variables(&self) -> VariableIterator<'_>
Return an iterator over all variables (with IDs) of this model.
sourcepub fn update_fns(&self) -> UpdateFnIterator<'_>
pub fn update_fns(&self) -> UpdateFnIterator<'_>
Return an iterator over all update functions (with corresponding var IDs) of this model.
sourcepub fn uninterpreted_fns(&self) -> UninterpretedFnIterator<'_>
pub fn uninterpreted_fns(&self) -> UninterpretedFnIterator<'_>
Return an iterator over all uninterpreted_fns (with IDs) of this model.
sourcepub fn regulations(&self) -> RegulationIterator<'_>
pub fn regulations(&self) -> RegulationIterator<'_>
Return an iterator over all regulations of this model.
sourcepub fn layouts(&self) -> LayoutIterator<'_>
pub fn layouts(&self) -> LayoutIterator<'_>
Return an iterator over all layouts (with IDs) of this model.
sourcepub fn get_default_layout_id() -> LayoutId
pub fn get_default_layout_id() -> LayoutId
Static fn to get LayoutId
of the default layout (same for all ModelStates
).
sourcepub fn get_default_layout_name() -> &'static str
pub fn get_default_layout_name() -> &'static str
Static fn to get name of the default layout (same for all ModelStates
).
source§impl ModelState
impl ModelState
Implementation for events related to layouts
of the model.
sourcepub(super) fn perform_layout_event(
&mut self,
event: &Event,
at_path: &[&str],
) -> Result<Consumed, DynError>
pub(super) fn perform_layout_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>
Perform events related to layouts
component of this ModelState
.
source§impl ModelState
impl ModelState
Implementation for events related to regulations
of the model.
sourcepub(super) fn perform_regulation_event(
&mut self,
event: &Event,
at_path: &[&str],
) -> Result<Consumed, DynError>
pub(super) fn perform_regulation_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>
Perform events related to regulations
component of this ModelState
.
sourcepub(super) fn event_add_regulation(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_regulation( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new regulation
component to this ModelState
.
This breaks the event down into two of them, one to make corresponding property, and the other to make the regulation itself.
sourcepub(super) fn event_add_regulation_raw(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_regulation_raw( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new regulation
component to this ModelState
.
This version is only adding the raw regulation, and not the corresponding static property.
It is expected that event_add_regulation
is called first, handling the actual division
into this event + event for adding the property.
source§impl ModelState
impl ModelState
Implementation for events related to uninterpreted functions
of the model.
sourcepub(super) fn perform_uninterpreted_fn_event(
&mut self,
event: &Event,
at_path: &[&str],
) -> Result<Consumed, DynError>
pub(super) fn perform_uninterpreted_fn_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>
Perform events related to uninterpreted fns
component of this ModelState
.
sourcepub(super) fn event_add_uninterpreted_fn(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_uninterpreted_fn( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new uninterpreted fn
component to this ModelState
.
This variant assumes that ID, arity (and so on) were already given.
For now, it is assumed that new functions have no constraints (monotonicity, essentiality, or expression).
sourcepub(super) fn event_add_default_uninterpreted_fn(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_default_uninterpreted_fn( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new “default” uninterpreted fn
component to this ModelState
.
The field values will be newly generated or predefined (“default”) constants will be used. Particularly, new ID will be generated, the same string will be used for its name, and arity will be zero. Default function symbols also have no constraints (monotonicity, essentiality, or expression).
sourcepub(super) fn event_modify_uninterpreted_fn(
&mut self,
event: &Event,
at_path: &[&str],
fn_id: UninterpretedFnId,
) -> Result<Consumed, DynError>
pub(super) fn event_modify_uninterpreted_fn( &mut self, event: &Event, at_path: &[&str], fn_id: UninterpretedFnId, ) -> Result<Consumed, DynError>
Perform event of modifying or removing existing uninterpreted fn
component of this ModelState
.
source§impl ModelState
impl ModelState
Implementation for events related to variables
of the model.
sourcepub(super) fn perform_variable_event(
&mut self,
event: &Event,
at_path: &[&str],
) -> Result<Consumed, DynError>
pub(super) fn perform_variable_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>
Perform events related to variables
component of this ModelState
.
sourcepub(super) fn event_add_variable(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_variable( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new variable
component to this ModelState
.
This expects that the variable was already defined elsewhere (i.e., its ID and other
fields are already known).
This event will be broken into sub-events (raw addition of the variable, and re-positioning).
sourcepub(super) fn event_add_default_variable(
&mut self,
event: &Event,
) -> Result<Consumed, DynError>
pub(super) fn event_add_default_variable( &mut self, event: &Event, ) -> Result<Consumed, DynError>
Perform event of adding a new variable
component to this ModelState
.
The field values will be generated or predefined (“default”) constants will be used. New ID will be generated, the same string will be used for its name, and variable will have empty update function.
This event will be broken into sub-events (raw addition of the variable, and re-positioning).
source§impl ModelState
impl ModelState
Implementation for refresh
(getter) events.
sourcepub(super) fn refresh_whole_model(
&self,
full_path: &[String],
) -> Result<Event, DynError>
pub(super) fn refresh_whole_model( &self, full_path: &[String], ) -> Result<Event, DynError>
Get a whole model.
sourcepub(super) fn refresh_variables(
&self,
full_path: &[String],
) -> Result<Event, DynError>
pub(super) fn refresh_variables( &self, full_path: &[String], ) -> Result<Event, DynError>
Get a list of all variables.
sourcepub(super) fn refresh_uninterpreted_fns(
&self,
full_path: &[String],
) -> Result<Event, DynError>
pub(super) fn refresh_uninterpreted_fns( &self, full_path: &[String], ) -> Result<Event, DynError>
Get a list of all uninterpreted fns.
sourcepub(super) fn refresh_regulations(
&self,
full_path: &[String],
) -> Result<Event, DynError>
pub(super) fn refresh_regulations( &self, full_path: &[String], ) -> Result<Event, DynError>
Get a list of all regulations.
Trait Implementations§
source§impl Clone for ModelState
impl Clone for ModelState
source§fn clone(&self) -> ModelState
fn clone(&self) -> ModelState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ModelState
impl Debug for ModelState
source§impl Default for ModelState
impl Default for ModelState
source§fn default() -> ModelState
fn default() -> ModelState
Default model object with no Variables, Uninterpreted Functions, or Regulations yet. It contains a single empty default Layout.
source§impl Manager for ModelState
impl Manager for ModelState
source§fn generate_id<T>(
&self,
ideal_id: &str,
is_taken: &dyn Fn(&Self, &T) -> bool,
num_indices: usize,
start_index: Option<usize>,
) -> T
fn generate_id<T>( &self, ideal_id: &str, is_taken: &dyn Fn(&Self, &T) -> bool, num_indices: usize, start_index: Option<usize>, ) -> T
T
for a certain component of a manager (e.g., generate a
VariableId
for a Variable
in a ModelState
). Read moresource§fn assert_ids_unique_and_used<T>(
&self,
id_list: &Vec<&str>,
assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>,
) -> Result<(), String>
fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
source§fn assert_ids_unique_and_new<T>(
&self,
id_list: &Vec<&str>,
assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>,
) -> Result<(), String>
fn assert_ids_unique_and_new<T>( &self, id_list: &Vec<&str>, assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
source§impl PartialEq for ModelState
impl PartialEq for ModelState
source§impl SessionHelper for ModelState
impl SessionHelper for ModelState
source§fn starts_with<'a, 'b>(
prefix: &str,
at_path: &'a [&'b str],
) -> Option<&'a [&'b str]>
fn starts_with<'a, 'b>( prefix: &str, at_path: &'a [&'b str], ) -> Option<&'a [&'b str]>
at_path
starts with a specific first segment.
If yes, returns the remaining part of the path.source§fn matches(expected: &[&str], at_path: &[&str]) -> bool
fn matches(expected: &[&str], at_path: &[&str]) -> bool
at_path
is exactlysource§fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>
fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>
source§fn invalid_path_error_specific<T>(
path: &[&str],
component: &str,
) -> Result<T, DynError>
fn invalid_path_error_specific<T>( path: &[&str], component: &str, ) -> Result<T, DynError>
component
.source§fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>
fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>
source§impl SessionState for ModelState
impl SessionState for ModelState
impl StructuralPartialEq for ModelState
Auto Trait Implementations§
impl Freeze for ModelState
impl RefUnwindSafe for ModelState
impl Send for ModelState
impl Sync for ModelState
impl Unpin for ModelState
impl UnwindSafe for ModelState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)