Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.protelis;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.hash.Hashing;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import it.unibo.alchemist.model.molecules.SimpleMolecule;
import it.unibo.alchemist.model.maps.positions.LatLongPosition;
import it.unibo.alchemist.protelis.properties.ProtelisDevice;
import it.unibo.alchemist.model.Environment;
import it.unibo.alchemist.model.GeoPosition;
import it.unibo.alchemist.model.maps.MapEnvironment;
import it.unibo.alchemist.model.Molecule;
import it.unibo.alchemist.model.Node;
import it.unibo.alchemist.model.Position;
import it.unibo.alchemist.model.Position2D;
import it.unibo.alchemist.model.Reaction;
import it.unibo.alchemist.protelis.AlchemistNetworkManager;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.math3.random.RandomGenerator;
import org.protelis.lang.datatype.DatatypeFactory;
import org.protelis.lang.datatype.DeviceUID;
import org.protelis.lang.datatype.Field;
import org.protelis.lang.datatype.Tuple;
import org.protelis.vm.LocalizedDevice;
import org.protelis.vm.SpatiallyEmbeddedDevice;
import org.protelis.vm.TimeAwareDevice;
import org.protelis.vm.impl.AbstractExecutionContext;
import javax.annotation.Nonnull;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
/**
* @param
position type
*/
public final class AlchemistExecutionContext
>
extends AbstractExecutionContext>
implements SpatiallyEmbeddedDevice, LocalizedDevice, TimeAwareDevice {
private static final String INTENTIONAL = "This is intentional";
/**
* Put this {@link Molecule} inside nodes that should compute distances using routes.
* It only makes sense in case the environment is a {@link MapEnvironment}
*/
public static final Molecule USE_ROUTES_AS_DISTANCES = new SimpleMolecule("ROUTES_AS_DISTANCE");
/**
* Put this {@link Molecule} inside nodes that should compute distances using routes approximating them.
* It only makes sense in case the environment is a {@link MapEnvironment}
*/
public static final Molecule APPROXIMATE_NBR_RANGE = new SimpleMolecule("APPROXIMATE_NBR_RANGE");
@SuppressWarnings("unchecked")
private final LoadingCache
cache = CacheBuilder.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.maximumSize(100)
.build(new CacheLoader<>() {
@Nonnull
@Override
public Double load(@Nonnull final P dest) {
if (environment instanceof MapEnvironment) {
if (dest instanceof GeoPosition) {
return ((MapEnvironment