All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.alchemist.model.interfaces.Condition Maven / Gradle / Ivy

There is a newer version: 20.0.1
Show newest version
/*
 * Copyright (C) 2010-2019, Danilo Pianini and contributors listed in the main project's alchemist/build.gradle file.
 *
 * This file is part of Alchemist, and is distributed under the terms of the
 * GNU General Public License, with a linking exception,
 * as described in the file LICENSE in the Alchemist distribution's top directory.
 */
package it.unibo.alchemist.model.interfaces;

import org.danilopianini.util.ListSet;

import java.io.Serializable;

/**
 * @param 
 *            The type which describes the concentration of a molecule
 * 
 *            Interface of a condition. Every condition must implement this
 *            interface.
 * 
 */
public interface Condition extends Serializable {

    /**
     * This method allows to clone this action on a new node. It may result
     * useful to support runtime creation of nodes with the same reaction
     * programming, e.g. for morphogenesis.
     * 
     * @param node
     *            The node where to clone this {@link Condition}
     * @param reaction
     *            The {@link Reaction} where to clone this {@link Condition}
     * @return the cloned action
     */
    Condition cloneCondition(Node node, Reaction reaction);

    /**
     * @return The context for this condition.
     */
    Context getContext();

    /**
     * @return The list of molecules whose concentration may influence the truth
     *         value of this condition
     */
    ListSet getInboundDependencies();

    /**
     * @return the node this Condition belongs to
     */
    Node getNode();

    /**
     * This method is a support for the propensity calculation inside the
     * Reactions. It allows this condition to influence the rate calculation in
     * some way. It's up to the reaction to decide whether to use or not this
     * information, and how.
     *
     * @return how this condition may influence the propensity.
     */
    double getPropensityContribution();

    /**
     * @return true if the condition is satisfied in current environment.
     */
    boolean isValid();

    /**
     * This method is called by the {@link it.unibo.alchemist.core.interfaces.Simulation} once the {@link Reaction}
     * whose this {@link Condition} belongs to is the next one to be executed, and
     * all its conditions passed (namely, the next operation will be the reaction
     * execution). It can be used to perform sanity checks, as well as for
     * registering the status of the simulated world for future comparisons.
     * Defaults to an empty implementation.
     */
    default void reactionReady() { };
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy