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

it.unibo.alchemist.model.biochemistry.conditions.GenericMoleculeUnderLevel Maven / Gradle / Ivy

There is a newer version: 35.0.2
Show newest version
/*
 * Copyright (C) 2010-2023, Danilo Pianini and contributors
 * listed, for each module, in the respective subproject's build.gradle.kts 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.biochemistry.conditions;

import it.unibo.alchemist.model.Molecule;
import it.unibo.alchemist.model.Node;
import it.unibo.alchemist.model.Reaction;

/**
 * @param  the concentration type
 */
public final class GenericMoleculeUnderLevel extends
        GenericMoleculePresent {

    /**
     * 
     */
    private static final long serialVersionUID = -5646651431692309010L;

    /**
     * @param mol the molecule
     * @param n the node
     * @param quantity how many molecules should be present
     */
    public GenericMoleculeUnderLevel(final Node n, final Molecule mol, final T quantity) {
        super(n, mol, quantity);
    }

    /**
     * @return true if the concentration of the molecule is lower the value.
     */
    @Override
    public boolean isValid() {
        return getNode().getConcentration(getMolecule()).doubleValue() < getQuantity().doubleValue();
    }

    @Override
    public GenericMoleculeUnderLevel cloneCondition(final Node node, final Reaction r) {
        return new GenericMoleculeUnderLevel<>(node, getMolecule(), getQuantity());
    }

    /**
     * @return the propensity influence computed as max(0, T-[M]), where T is
     *         the threshold chosen and [M] is the current concentration of the
     *         molecule
     */
    @Override
    public double getPropensityContribution() {
        final double qty = getQuantity().doubleValue();
        final double c = getNode().getConcentration(getMolecule())
                .doubleValue();
        return Math.max(0, qty - c);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy