Commit 6ccbc90e authored by Julian Zobel's avatar Julian Zobel
Browse files

First adaptations for social group movement

parent acff5b18
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.topology.movement.modularosm.groups.groupforming;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.SocialGroupMovementModel;
/**
* This interface specifies the GroupFormingStrategy, which basically handles the creation and deletion of groups.
* @author Marcel Verst
* @version 1.0, 22.11.2018
*/
public interface IGroupFormingBehavior {
/**
* Initializes class variables.
*
* @author Marcel Verst
*/
void initialize(SocialGroupMovementModel movementModel);
/**
* Manages the group handling. Calls processes for creating and deleting groups.
*
* Groups are only created if conditions are met and enough candidates are there to form a group.
* Groups are deleted if the group leader reached its destination and thus all other members also
* reached their destination.
*
* @param SimLocationActuator The host to be checked.
* @param PositionVector The destination of the host.
*
* @author Marcel Verst
*/
void manageGroups();
/**
* Checks for each POI how many hosts are currently present. Selects out of all present hosts per POI a set of group
* candidates which is then used to create a group.
*
* @param SimLocationActuator The current host.
*
* @author Marcel Verst
*/
void runGroupBuildingProcess();
/**
* Checks if the given host is a leader and reached the its destination. If the destination is reached,
* the group of the leader is removed.
*
* @param SimLocationActuator The host to be checked.
* @param PositionVector The destination of the host.
*
* @author Marcel Verst
*/
void runGroupDeletionProcess();
double getProbabilityToJoin();
}
\ No newline at end of file
......@@ -34,6 +34,7 @@ import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* Abstract base class for Transition Strategies ({@link ITransitionStrategy}s) using {@link AttractionPoint}s.
......@@ -107,13 +108,5 @@ public abstract class AbstractAttractionBasedTransitionStrategy implements ITran
protected long getPauseTime(AttractionPoint attractionPoint) {
return getRandomUniformDistributionPauseTime(attractionPoint);
}
public void setDefaultPauseTime(long defaultPauseTimeMin, long defaultPauseTimeMax) {
assert defaultPauseTimeMax >= 0 && defaultPauseTimeMin >= 0;
assert defaultPauseTimeMax >= defaultPauseTimeMin;
this.defaultPauseTimeMax = defaultPauseTimeMax;
this.defaultPauseTimeMin = defaultPauseTimeMin;
}
}
}
......@@ -31,6 +31,7 @@ import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* With this transition strategy, nodes are roaming around {@link AttractionPoint}s that have a radius. As the {@link ModularMovementModel}
......@@ -53,6 +54,15 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
private boolean useGaussianDistributedPauseTime = false;
@XMLConfigurableConstructor({ "defaultPauseTimeMin", "defaultPauseTimeMax" })
public InAreaRoamingTransitionStrategy(long defaultPauseTimeMin, long defaultPauseTimeMax) {
assert defaultPauseTimeMax >= 0 && defaultPauseTimeMin >= 0;
assert defaultPauseTimeMax >= defaultPauseTimeMin;
this.defaultPauseTimeMax = defaultPauseTimeMax;
this.defaultPauseTimeMin = defaultPauseTimeMin;
}
@Override
public void addComponent(SimLocationActuator comp) {
this.roamingStates.put(comp, roamingTransitionState.TRANSITION);
......@@ -85,7 +95,7 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
return gaussianDistributionPauseTime(defaultPauseTimeMax - defaultPauseTimeMin, 0.5*(defaultPauseTimeMax - defaultPauseTimeMin));
}
else {
return getPauseTime(attractionPoint);
return super.getPauseTime(attractionPoint);
}
}
......@@ -169,8 +179,5 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
AttractionPoint assignment = candidates.get(rnd.nextInt(candidates.size()));
return assignment;
}
}
}
......@@ -21,7 +21,6 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm.transition;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
......@@ -37,13 +36,13 @@ import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.api.topology.social.SocialView;
import de.tud.kom.p2psim.impl.simengine.Simulator;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionGenerator;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* This is a {@link TransitionStrategy} for the Social Case. It will be try to
......@@ -70,10 +69,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
* an Event, with a delay between min- and maxPauseTime. After this delay, it
* will be tried to assign a new {@link AttractionPoint} like the described
* above.
*
*
*
* @author Christoph Muenker
* @version 1.0, 02.07.2013
*
* <hr>
*
*
*
*/
public class SocialTransitionStrategy extends AbstractAttractionBasedTransitionStrategy implements EventHandler {
......@@ -91,10 +94,6 @@ public class SocialTransitionStrategy extends AbstractAttractionBasedTransitionS
private Map<SimHost, SimLocationActuator> mapHostMs = new HashMap<SimHost, SimLocationActuator>();
private double minPauseTime = Simulator.MINUTE_UNIT * 0.5;
private double maxPauseTime = Simulator.MINUTE_UNIT * 100;
private double socialFactor = 0.8;
private long numberOfFavoritePlaces = 4;
......@@ -103,6 +102,16 @@ public class SocialTransitionStrategy extends AbstractAttractionBasedTransitionS
private boolean init = false;
@XMLConfigurableConstructor({ "defaultPauseTimeMin", "defaultPauseTimeMax" })
public SocialTransitionStrategy(long defaultPauseTimeMin, long defaultPauseTimeMax) {
assert defaultPauseTimeMax >= 0 && defaultPauseTimeMin >= 0;
assert defaultPauseTimeMax >= defaultPauseTimeMin;
this.defaultPauseTimeMax = defaultPauseTimeMax;
this.defaultPauseTimeMin = defaultPauseTimeMin;
}
private void init() {
if (!init) {
if (socialId == null) {
......@@ -118,7 +127,7 @@ public class SocialTransitionStrategy extends AbstractAttractionBasedTransitionS
"Cannot find the right socialView. Is the socialId correct?");
}
if (minPauseTime > maxPauseTime) {
if (defaultPauseTimeMin > defaultPauseTimeMax) {
throw new ConfigurationException(
"MinPauseTime should be smaller then maxPauseTime.");
}
......
......@@ -27,6 +27,7 @@ import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractio
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* A simplified transition strategy taking only the weights of an AP into account.
......@@ -42,6 +43,15 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*
*/
public class WeightedTransitionStrategy extends AbstractAttractionBasedTransitionStrategy implements EventHandler {
@XMLConfigurableConstructor({ "defaultPauseTimeMin", "defaultPauseTimeMax" })
public WeightedTransitionStrategy(long defaultPauseTimeMin, long defaultPauseTimeMax) {
assert defaultPauseTimeMax >= 0 && defaultPauseTimeMin >= 0;
assert defaultPauseTimeMax >= defaultPauseTimeMin;
this.defaultPauseTimeMax = defaultPauseTimeMax;
this.defaultPauseTimeMin = defaultPauseTimeMin;
}
@Override
public void addComponent(SimLocationActuator ms) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment