pub struct Computation<T: Context> { /* private fields */ }
Expand description

The computation struct contains an intermediate result of a fixpoint computation and provides methods for continuing the fixpoint computation or extracting the (intermediate or final) results.

Usage

let mut computation = Computation::new(context, optional_default_node_value);

// set starting node values with computation.set_node_value(..)
// ...

computation.compute();

// get the resulting node values
if let Some(node_value) = computation.get_node_value(node_index) {
    // ...
};

Implementations§

source§

impl<T: Context> Computation<T>

source

pub fn new(fp_context: T, default_value: Option<T::NodeValue>) -> Self

Create a new fixpoint computation from a fixpoint problem, the corresponding graph and a default value for all nodes if one should exists.

source

pub fn from_node_priority_list( fp_context: T, default_value: Option<T::NodeValue>, priority_sorted_nodes: Vec<NodeIndex> ) -> Self

Create a new fixpoint computation from a fixpoint problem, an optional default value and the list of nodes of the graph ordered by the priority for the worklist algorithm. The worklist algorithm will try to stabilize the nodes with a higher index in the priority_sorted_nodes array before those with a lower index.

source

pub fn get_node_value(&self, node: NodeIndex) -> Option<&T::NodeValue>

Get the value of a node.

source

pub fn set_node_value(&mut self, node: NodeIndex, value: T::NodeValue)

Set the value of a node and mark the node as not yet stabilized.

source

pub fn compute_with_max_steps(&mut self, max_steps: u64)

Compute the fixpoint of the fixpoint problem. Each node will be visited at most max_steps times. If a node does not stabilize after max_steps visits, the end result will not be a fixpoint but only an intermediate result of a fixpoint computation.

source

pub fn compute(&mut self)

Compute the fixpoint of the fixpoint problem. If the fixpoint algorithm does not converge to a fixpoint, this function will not terminate.

source

pub fn node_values(&self) -> &FnvHashMap<NodeIndex, T::NodeValue>

Get a reference to the internal map where one can look up the current values of all nodes

source

pub fn node_values_mut(&mut self) -> impl Iterator<Item = &mut T::NodeValue>

Get a mutable iterator over all node values. Also add all nodes that have values to the worklist, because one can change all their values through the iterator.

source

pub fn get_graph(&self) -> &DiGraph<T::NodeLabel, T::EdgeLabel>

Get a reference to the underlying graph

source

pub fn get_context(&self) -> &T

Get a reference to the underlying context object

source

pub fn has_stabilized(&self) -> bool

Returns True if the computation has stabilized, i.e. the internal worklist is empty.

source

pub fn get_worklist(&self) -> Vec<NodeIndex>

Return a list of all nodes which are marked as not-stabilized

Trait Implementations§

source§

impl ToJsonCompact for Computation<GeneralizedContext<'_, TaComputationContext<'_, '_>>>

source§

fn to_json_compact(&self) -> Value

Returns a json representation of values of type self that is suitable for debugging purposes. Read more
source§

fn print_compact_json(&self)

Print values of type Self for debugging purposes.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Computation<T>

§

impl<T> Send for Computation<T>
where T: Send, <T as Context>::NodeValue: Send,

§

impl<T> Sync for Computation<T>
where T: Sync, <T as Context>::NodeValue: Sync,

§

impl<T> Unpin for Computation<T>
where T: Unpin, <T as Context>::NodeValue: Unpin,

§

impl<T> UnwindSafe for Computation<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.