示例#1
0
 private Position calculateBetaBest(Krill krill, HerdParameters parameters)
 {
     Position bestRelatedPosition = tendencyCalculator.calculateRelatedPosition(krill.getBestPosition(),krill.getPosition());
     float bestFitness = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(),krill.getBestPositionFitness(),parameters);
     //Debug.Log("best fitness "  + bestFitness);
     bestRelatedPosition = bestRelatedPosition * bestFitness;
     return bestRelatedPosition;
 }
    private float calculateSenseDistance(List<Krill> herd, Krill krill)
    {
        float distance = 0.0f;
        foreach(Krill other in herd){
            distance += krill.getPosition().distanceFrom(other.getPosition());
        }

        return distance/(5.0f * herd.Count);
    }
示例#3
0
    private Position calculateAlphaTarget(HerdParameters parameters, Krill krill)
    {
        Position relatedPosition = tendencyCalculator.calculateRelatedPosition(parameters.getBestFitnessPosition(), krill.getPosition());
        float relatedFitness = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(),parameters.getBestFitnessValue(), parameters);

           	relatedPosition = relatedPosition * relatedFitness;
        relatedPosition = relatedPosition * calculateCoefficient(parameters);

        return relatedPosition;
    }
示例#4
0
 public void updateBestWorstKrill(Krill krill)
 {
     if(krill.getFitnessValue() < bestFitnessValue){
         bestKrill = krill;
         bestFitnessValue = krill.getFitnessValue();
         bestFitnessPosition = krill.getPosition().getClone();
     }
     if(krill.getFitnessValue() > worstFitnessValue){
         worstFitnessValue = krill.getFitnessValue();
     }
 }
    private float calculateSenseDistance(List <Krill> herd, Krill krill)
    {
        float distance = 0.0f;

        foreach (Krill other in herd)
        {
            distance += krill.getPosition().distanceFrom(other.getPosition());
        }

        return(distance / (5.0f * herd.Count));
    }
示例#6
0
 public void updateBestWorstKrill(Krill krill)
 {
     if (krill.getFitnessValue() < bestFitnessValue)
     {
         bestKrill           = krill;
         bestFitnessValue    = krill.getFitnessValue();
         bestFitnessPosition = krill.getPosition().getClone();
     }
     if (krill.getFitnessValue() > worstFitnessValue)
     {
         worstFitnessValue = krill.getFitnessValue();
     }
 }
示例#7
0
    private Position calculateAlphaLocal(List<Krill> neighbours, Krill krill, HerdParameters parameters)
    {
        Position alphaLocal = new Position();

        foreach (Krill neighbour in neighbours) {
            Position relatedPosition = tendencyCalculator.calculateRelatedPosition(neighbour.getPosition(), krill.getPosition());
            float relatedFitness = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(),neighbour.getFitnessValue(), parameters);

            relatedPosition = relatedPosition * relatedFitness;
            alphaLocal = alphaLocal + relatedPosition;
        }
        return alphaLocal;
    }
    public List<Krill> determinateNeighbours(List<Krill> herd, Krill krill)
    {
        List<Krill> neighbours = new List<Krill>();
        float senseDistance = calculateSenseDistance(herd,krill);

        foreach(Krill other in herd){

            if(!(krill==other)){
                float distance = krill.getPosition().distanceFrom(other.getPosition());
                if(distance <= senseDistance){
                    neighbours.Add(other);
                }
            }
        }
        return neighbours;
    }
    public List <Krill> determinateNeighbours(List <Krill> herd, Krill krill)
    {
        List <Krill> neighbours    = new List <Krill>();
        float        senseDistance = calculateSenseDistance(herd, krill);

        foreach (Krill other in herd)
        {
            if (!(krill == other))
            {
                float distance = krill.getPosition().distanceFrom(other.getPosition());
                if (distance <= senseDistance)
                {
                    neighbours.Add(other);
                }
            }
        }
        return(neighbours);
    }
示例#10
0
    private Position calculateAlphaTarget(HerdParameters parameters, Krill krill)
    {
        Position relatedPosition = tendencyCalculator.calculateRelatedPosition(parameters.getBestFitnessPosition(), krill.getPosition());
        float    relatedFitness  = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), parameters.getBestFitnessValue(), parameters);

        relatedPosition = relatedPosition * relatedFitness;
        relatedPosition = relatedPosition * calculateCoefficient(parameters);

        return(relatedPosition);
    }
示例#11
0
    private Position calculateAlphaLocal(List <Krill> neighbours, Krill krill, HerdParameters parameters)
    {
        Position alphaLocal = new Position();

        foreach (Krill neighbour in neighbours)
        {
            Position relatedPosition = tendencyCalculator.calculateRelatedPosition(neighbour.getPosition(), krill.getPosition());
            float    relatedFitness  = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), neighbour.getFitnessValue(), parameters);

            relatedPosition = relatedPosition * relatedFitness;
            alphaLocal      = alphaLocal + relatedPosition;
        }
        return(alphaLocal);
    }
示例#12
0
 public int getVerticalInput()
 {
     bestKrill = herd.simulate();
     return(angleDirection(bestKrill.getPosition().toVector3()));
 }
示例#13
0
 public int getVerticalInput()
 {
     bestKrill = herd.simulate();
     return angleDirection(bestKrill.getPosition().toVector3());
 }
示例#14
0
    private Position calculateBetaBest(Krill krill, HerdParameters parameters)
    {
        Position bestRelatedPosition = tendencyCalculator.calculateRelatedPosition(krill.getBestPosition(), krill.getPosition());
        float    bestFitness         = tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), krill.getBestPositionFitness(), parameters);

        //Debug.Log("best fitness "  + bestFitness);
        bestRelatedPosition = bestRelatedPosition * bestFitness;
        return(bestRelatedPosition);
    }