<commit_before>package swarm_sim.exploration;

import java.util.ArrayList;
import java.util.List;

import org.jgap.IChromosome;

import repast.simphony.context.Context;
import repast.simphony.random.RandomHelper;
import repast.simphony.space.SpatialMath;
import repast.simphony.space.continuous.NdPoint;
import swarm_sim.Agent;
import swarm_sim.Agent.AgentState;
import swarm_sim.IAgent;
import swarm_sim.IAgent.AgentType;
import swarm_sim.QuadTree.Node;
import swarm_sim.QuadTree;
import swarm_sim.SectorMap;
import swarm_sim.Strategy;
import swarm_sim.communication.CommunicationType;
import swarm_sim.communication.INetworkAgent;
import swarm_sim.communication.Message;
import swarm_sim.communication.Message.MessageType;
import swarm_sim.learning.GA;
import swarm_sim.perception.AngleSegment;
import swarm_sim.perception.Scan;
import swarm_sim.perception.Scan.AttractionType;
import swarm_sim.perception.Scan.GrowingDirection;
import swarm_sim.perception.ScanMoveDecision;

public class ComplexQTMemoryCommStrategy extends ExplorationStrategy {

    private static final int INFINITY = 99999999;

    private int consecutiveMoveCount = INFINITY;

    private double prevDirection = RandomHelper.nextDoubleFromTo(-Math.PI,
	    Math.PI);

    QuadTree quadTree;

    private Scan scanAgentRepell = new Scan(AttractionType.Repelling,
	    GrowingDirection.Inwards, 2, false, 0, 0.8 * config.commScope, 1,
	    1000);
    private Scan scanAgentAppeal = new Scan(AttractionType.Attracting,
	    GrowingDirection.Outwards, 0.2, false, 0.8 * config.commScope,
	    config.commScope, 1, 1);
    private Scan scanAgentMimic = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, config.commScope, 1, 5);
    private Scan scanPrevDirection = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, 1000, 1, 1000);
    private Scan scanUnknownSectors = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, 10000, 1, 1000);

    private ScanMoveDecision smd = new ScanMoveDecision(8, 6, 10, 0.05);

    public ComplexQTMemoryCommStrategy(IChromosome chrom,
	    Context<IAgent> context, Agent controllingAgent) {
	super(chrom, context, controllingAgent);

	int sectorsX = (int) (config.spaceWidth / config.perceptionScope);
	int sectorsY = (int) (config.spaceHeight / config.perceptionScope);

	if (sectorsX > config.spaceWidth)
	    sectorsX = config.spaceWidth;
	if (sectorsY > config.spaceHeight)
	    sectorsY = config.spaceHeight;

	this.quadTree = new QuadTree(config.spaceWidth, config.spaceHeight,
		config.perceptionScope);

	if (config.useGA) {
	    GA ga = GA.getInstance();

	    scanAgentRepell.setMergeWeight((double) chrom.getGene(
		    ga.RepellIndex).getAllele());
	    scanAgentAppeal.setMergeWeight((double) chrom.getGene(
		    ga.AppealIndex).getAllele());
	    scanAgentMimic.setMergeWeight((double) chrom.getGene(ga.MimicIndex)
		    .getAllele());
	    scanUnknownSectors.setMergeWeight((double) chrom.getGene(
		    ga.MemoryIndex).getAllele());
	    scanPrevDirection.setMergeWeight((double) chrom.getGene(
		    ga.PrevDirectionIndex).getAllele());

	    double repellAppealBorder = config.commScope
		    * (double) chrom.getGene(ga.AppealRepellBorderIndex)
			    .getAllele();
	    scanAgentRepell.setOuterBorderRadius(repellAppealBorder);
	    scanAgentAppeal.setInnerBorderRadius(repellAppealBorder);
	} else {
	    double winningOutput[] = new double[] { 0.15, 0.92, 0.69, 0.04,
		    0.99, 0.33 };

	    scanAgentRepell.setMergeWeight(winningOutput[0]);
	    scanAgentAppeal.setMergeWeight(winningOutput[1]);
	    scanAgentMimic.setMergeWeight(winningOutput[3]);
	    scanUnknownSectors.setMergeWeight(winningOutput[4]);
	    scanPrevDirection.setMergeWeight(winningOutput[5]);

	    double repellAppealBorder = config.commScope * winningOutput[2];
	    scanAgentRepell.setOuterBorderRadius(repellAppealBorder);
	    scanAgentAppeal.setInnerBorderRadius(repellAppealBorder);

	}
    }
<commit_msg>changed weights. GA needs to be done!<commit_after>package swarm_sim.exploration;

import java.util.ArrayList;
import java.util.List;

import org.jgap.IChromosome;

import repast.simphony.context.Context;
import repast.simphony.random.RandomHelper;
import repast.simphony.space.SpatialMath;
import repast.simphony.space.continuous.NdPoint;
import swarm_sim.Agent;
import swarm_sim.Agent.AgentState;
import swarm_sim.IAgent;
import swarm_sim.IAgent.AgentType;
import swarm_sim.QuadTree.Node;
import swarm_sim.QuadTree;
import swarm_sim.SectorMap;
import swarm_sim.Strategy;
import swarm_sim.communication.CommunicationType;
import swarm_sim.communication.INetworkAgent;
import swarm_sim.communication.Message;
import swarm_sim.communication.Message.MessageType;
import swarm_sim.learning.GA;
import swarm_sim.perception.AngleSegment;
import swarm_sim.perception.Scan;
import swarm_sim.perception.Scan.AttractionType;
import swarm_sim.perception.Scan.GrowingDirection;
import swarm_sim.perception.ScanMoveDecision;

public class ComplexQTMemoryCommStrategy extends ExplorationStrategy {

    private static final int INFINITY = 99999999;

    private int consecutiveMoveCount = INFINITY;

    private double prevDirection = RandomHelper.nextDoubleFromTo(-Math.PI,
	    Math.PI);

    QuadTree quadTree;

    private Scan scanAgentRepell = new Scan(AttractionType.Repelling,
	    GrowingDirection.Inwards, 2, false, 0, 0.8 * config.commScope, 1,
	    1000);
    private Scan scanAgentAppeal = new Scan(AttractionType.Attracting,
	    GrowingDirection.Outwards, 0.2, false, 0.8 * config.commScope,
	    config.commScope, 1, 1);
    private Scan scanAgentMimic = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, config.commScope, 1, 5);
    private Scan scanPrevDirection = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, 1000, 1, 1000);
    private Scan scanUnknownSectors = new Scan(AttractionType.Attracting,
	    GrowingDirection.Inwards, 1, true, 0, 10000, 1, 1000);

    private ScanMoveDecision smd = new ScanMoveDecision(8, 6, 10, 0.05);

    public ComplexQTMemoryCommStrategy(IChromosome chrom,
	    Context<IAgent> context, Agent controllingAgent) {
	super(chrom, context, controllingAgent);

	int sectorsX = (int) (config.spaceWidth / config.perceptionScope);
	int sectorsY = (int) (config.spaceHeight / config.perceptionScope);

	if (sectorsX > config.spaceWidth)
	    sectorsX = config.spaceWidth;
	if (sectorsY > config.spaceHeight)
	    sectorsY = config.spaceHeight;

	this.quadTree = new QuadTree(config.spaceWidth, config.spaceHeight,
		config.perceptionScope);

	if (config.useGA) {
	    GA ga = GA.getInstance();

	    scanAgentRepell.setMergeWeight((double) chrom.getGene(
		    ga.RepellIndex).getAllele());
	    scanAgentAppeal.setMergeWeight((double) chrom.getGene(
		    ga.AppealIndex).getAllele());
	    scanAgentMimic.setMergeWeight((double) chrom.getGene(ga.MimicIndex)
		    .getAllele());
	    scanUnknownSectors.setMergeWeight((double) chrom.getGene(
		    ga.MemoryIndex).getAllele());
	    scanPrevDirection.setMergeWeight((double) chrom.getGene(
		    ga.PrevDirectionIndex).getAllele());

	    double repellAppealBorder = config.commScope
		    * (double) chrom.getGene(ga.AppealRepellBorderIndex)
			    .getAllele();
	    scanAgentRepell.setOuterBorderRadius(repellAppealBorder);
	    scanAgentAppeal.setInnerBorderRadius(repellAppealBorder);
	} else {
	    //TODO: GA!
	    double winningOutput[] = new double[] { 0.9, 0.92, 0.69, 0.04,
		    0.99, 0.33 };

	    scanAgentRepell.setMergeWeight(winningOutput[0]);
	    scanAgentAppeal.setMergeWeight(winningOutput[1]);
	    scanAgentMimic.setMergeWeight(winningOutput[3]);
	    scanUnknownSectors.setMergeWeight(winningOutput[4]);
	    scanPrevDirection.setMergeWeight(winningOutput[5]);

	    double repellAppealBorder = config.commScope * winningOutput[2];
	    scanAgentRepell.setOuterBorderRadius(repellAppealBorder);
	    scanAgentAppeal.setInnerBorderRadius(repellAppealBorder);

	}
    }

{'fraction_non_alphanumeric': 0.09925373134328358, 'fraction_numerical': 0.020024875621890547, 'mean_word_length': 4.934317343173432, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6269708', 'n_tokens_mistral': 2833, 'n_tokens_neox': 2454, 'n_words': 466}