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

it.unibo.alchemist.model.movestrategies.speed.ConstantSpeed Maven / Gradle / Ivy

Go to download

Abstract, incarnation independent implementations of the Alchemist's interfaces. Provides support for those who want to write incarnations.

There is a newer version: 35.0.1
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.movestrategies.speed;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import it.unibo.alchemist.model.Node;
import it.unibo.alchemist.model.Position;
import it.unibo.alchemist.model.Reaction;
import it.unibo.alchemist.model.movestrategies.SpeedSelectionStrategy;

/**
 * This strategy makes the node move at an average constant speed, which is
 * influenced by the {@link it.unibo.alchemist.model.TimeDistribution} of the {@link Reaction} hosting
 * this {@link it.unibo.alchemist.model.Action}. This action tries to normalize on the {@link Reaction}
 * rate, but if the {@link it.unibo.alchemist.model.TimeDistribution} has a high variance, the movements
 * on the map will inherit this tract.
 *
 * @param  Concentration type
 * @param 

Position type * */ public final class ConstantSpeed> implements SpeedSelectionStrategy { private static final long serialVersionUID = 1746429998480123049L; private final double speed; private final Reaction reaction; /** * @param reaction * the reaction * @param speed * the speed, in meters/second */ @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "This is intentional") public ConstantSpeed(final Reaction reaction, final double speed) { if (speed < 0) { throw new IllegalArgumentException("Speed must be positive"); } this.speed = speed; this.reaction = reaction; } @Override public double getNodeMovementLength(final P target) { return speed / reaction.getRate(); } @Override public ConstantSpeed cloneIfNeeded(final Node destination, final Reaction reaction) { return new ConstantSpeed<>(reaction, speed); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy