示例#1
0
    public Position calculateAlpha(List<Krill> herd, Krill krill, HerdParameters parameters)
    {
        Position localAlpha = calculateAlphaLocal(herd, krill, parameters);
        Position targetAlpha = calculateAlphaTarget(parameters,krill);

        return localAlpha + targetAlpha;
    }
示例#2
0
    public Position calculateAlpha(List <Krill> herd, Krill krill, HerdParameters parameters)
    {
        Position localAlpha  = calculateAlphaLocal(herd, krill, parameters);
        Position targetAlpha = calculateAlphaTarget(parameters, krill);

        return(localAlpha + targetAlpha);
    }
示例#3
0
 public Position calculateBeta(Krill krill, Food food, HerdParameters parameters)
 {
     Position betaFood = calculateBetaFood(food,krill);
     Position betaBest = calculateBetaBest(krill,parameters);
     //Debug.Log("Food " + betaFood + " best " + betaBest);
     return betaFood + betaBest;
 }
示例#4
0
 private void mutateKrill(Krill krill, List<Krill> herd, HerdParameters parameters)
 {
     int range = herd.Count / 2;
     Krill first = herd[Random.Range(0,range)];
     int secondIndex = Random.Range(range,herd.Count);
     Krill second = herd[secondIndex];
     //        krill.mutate(first,second,parameters.getBestFitnessKrill());
 }
示例#5
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;
 }
示例#6
0
    public Position calculateBeta(Krill krill, Food food, HerdParameters parameters)
    {
        Position betaFood = calculateBetaFood(food, krill);
        Position betaBest = calculateBetaBest(krill, parameters);

        //Debug.Log("Food " + betaFood + " best " + betaBest);
        return(betaFood + betaBest);
    }
示例#7
0
    private void mutateKrill(Krill krill, List <Krill> herd, HerdParameters parameters)
    {
        int   range       = herd.Count / 2;
        Krill first       = herd[Random.Range(0, range)];
        int   secondIndex = Random.Range(range, herd.Count);
        Krill second      = herd[secondIndex];
//        krill.mutate(first,second,parameters.getBestFitnessKrill());
    }
示例#8
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);
    }
示例#9
0
 public void calculateForagingMotion(List<Krill> herd, HerdParameters parameters, Food food)
 {
     foreach(Krill krill in herd){
          Position oldForaging = krill.getForagingMotion() * parameters.inertiaForagingWeight;
          Position betaPosition = betaCalculator.calculateBeta(krill,food,parameters);
          betaPosition = betaPosition * parameters.Vf;
          krill.setForagingMotion(betaPosition + oldForaging);
      }
 }
示例#10
0
    public void calculateDiffusionMotion(List<Krill> herd,HerdParameters parameters)
    {
        foreach(Krill krill in herd){
            Position randomizedPosition = randomizePosition();
            randomizedPosition = randomizedPosition * parameters.randomizeDMAX();
            randomizedPosition = randomizedPosition * calculateIterationRatio(parameters);

            krill.setDiffusionMotion(randomizedPosition);
        }
    }
示例#11
0
 public void crossoverHerd(List<Krill> herd, HerdParameters parameters)
 {
     foreach (Krill krill in herd) {
         float Cr = 0.2f * tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), parameters.getBestFitnessValue(), parameters);
         float ran = Random.Range(0.0f,1.0f);
         if (ran < Cr) {
             crossKrill(krill, herd);
         }
     }
 }
示例#12
0
    public void calculateMotion(List<Krill> herd, HerdParameters algorithmParameters)
    {
        foreach(Krill krill in herd){
            Position oldMotion = krill.getMotionInduced()*algorithmParameters.inertiaWeight;
            Position alphaPosition = getAlphaPosition(herd,krill,algorithmParameters);
            Position newMotionPosition = alphaPosition + oldMotion;

            krill.setMotionInduced(newMotionPosition);
        }
    }
示例#13
0
 public void calculateForagingMotion(List <Krill> herd, HerdParameters parameters, Food food)
 {
     foreach (Krill krill in herd)
     {
         Position oldForaging  = krill.getForagingMotion() * parameters.inertiaForagingWeight;
         Position betaPosition = betaCalculator.calculateBeta(krill, food, parameters);
         betaPosition = betaPosition * parameters.Vf;
         krill.setForagingMotion(betaPosition + oldForaging);
     }
 }
示例#14
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);
    }
示例#15
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;
    }
示例#16
0
    public void calculateDiffusionMotion(List <Krill> herd, HerdParameters parameters)
    {
        foreach (Krill krill in herd)
        {
            Position randomizedPosition = randomizePosition();
            randomizedPosition = randomizedPosition * parameters.randomizeDMAX();
            randomizedPosition = randomizedPosition * calculateIterationRatio(parameters);

            krill.setDiffusionMotion(randomizedPosition);
        }
    }
示例#17
0
    public void calculateMotion(List <Krill> herd, HerdParameters algorithmParameters)
    {
        foreach (Krill krill in herd)
        {
            Position oldMotion         = krill.getMotionInduced() * algorithmParameters.inertiaWeight;
            Position alphaPosition     = getAlphaPosition(herd, krill, algorithmParameters);
            Position newMotionPosition = alphaPosition + oldMotion;

            krill.setMotionInduced(newMotionPosition);
        }
    }
示例#18
0
    public void mutateHerd(List<Krill> herd, HerdParameters parameters)
    {
        foreach (Krill krill in herd) {
            float Mu = 0.05f / tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), parameters.getBestFitnessValue(), parameters);
            float ran = Random.Range(0.0f,1.0f);

            if (ran < Mu) {
                mutateKrill(krill, herd, parameters);
            }
        }
    }
示例#19
0
 public void crossoverHerd(List <Krill> herd, HerdParameters parameters)
 {
     foreach (Krill krill in herd)
     {
         float Cr  = 0.2f * tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), parameters.getBestFitnessValue(), parameters);
         float ran = Random.Range(0.0f, 1.0f);
         if (ran < Cr)
         {
             crossKrill(krill, herd);
         }
     }
 }
示例#20
0
 public CircleKrillSetter(HerdParameters parameters)
 {
     this.parameters = parameters;
     speeds = new float[5,2]{ {100.0f,120.0f} , {120.0f,160.0f}, {170.0f,200.0f},{120.0f,160.0f},{100.0f,120.0f}};
     //speeds = new float[3,2]{{120.0f,160.0f}, {170.0f,200.0f},{120.0f,160.0f}};
     //speeds = new float[7,2]{ {80.0f,100.0f} , {100.0f,120.0f}, {120.0f,160.0f},{160.0f,200.0f},{120.0f,160.0f},{100.0f,120.0f},{80.0f,100.0f}};
     partSize = (parameters.herdSize - parameters.herdSize%2)/2;
     angle = triangleAngleSize/(parameters.herdSize - parameters.herdSize%2);
     triangleArm = 2.0f * height * Mathf.Sqrt(3.0f)/3.0f;
     delta = (triangleArm - height)/partSize;
     herdSize = parameters.herdSize;
 }
示例#21
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;
    }
示例#22
0
    public void mutateHerd(List <Krill> herd, HerdParameters parameters)
    {
        foreach (Krill krill in herd)
        {
            float Mu  = 0.05f / tendencyCalculator.calculateRelatedFitness(krill.getFitnessValue(), parameters.getBestFitnessValue(), parameters);
            float ran = Random.Range(0.0f, 1.0f);

            if (ran < Mu)
            {
                mutateKrill(krill, herd, parameters);
            }
        }
    }
示例#23
0
 public CircleKrillSetter(HerdParameters parameters)
 {
     this.parameters = parameters;
     speeds          = new float[5, 2] {
         { 100.0f, 120.0f }, { 120.0f, 160.0f }, { 170.0f, 200.0f }, { 120.0f, 160.0f }, { 100.0f, 120.0f }
     };
     //speeds = new float[3,2]{{120.0f,160.0f}, {170.0f,200.0f},{120.0f,160.0f}};
     //speeds = new float[7,2]{ {80.0f,100.0f} , {100.0f,120.0f}, {120.0f,160.0f},{160.0f,200.0f},{120.0f,160.0f},{100.0f,120.0f},{80.0f,100.0f}};
     partSize    = (parameters.herdSize - parameters.herdSize % 2) / 2;
     angle       = triangleAngleSize / (parameters.herdSize - parameters.herdSize % 2);
     triangleArm = 2.0f * height * Mathf.Sqrt(3.0f) / 3.0f;
     delta       = (triangleArm - height) / partSize;
     herdSize    = parameters.herdSize;
 }
示例#24
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);
    }
示例#25
0
文件: Food.cs 项目: jacek-kurlit/cars
    public Food(HerdParameters herdParameters, Transform visualFoodTransform)
    {
        sectorManager =  GameObject.FindGameObjectWithTag("Sector").GetComponent<SectorsManager>();
        pointsCointainer = sectorManager.getContainerClone();

        List<Vector3> initialTrace = pointsCointainer.getAllMapPoints();

        positions = new Position[initialTrace.Count];
        visualFoodPosition = visualFoodTransform;
        this.herdParameters = herdParameters;

        for(int i = 0; i < initialTrace.Count; i++){
            positions[i] = new Position(initialTrace[i]);
        }

        initCenterPositions();
    }
示例#26
0
文件: Food.cs 项目: jacek-kurlit/cars
    public Food(HerdParameters herdParameters, Transform visualFoodTransform)
    {
        sectorManager    = GameObject.FindGameObjectWithTag("Sector").GetComponent <SectorsManager>();
        pointsCointainer = sectorManager.getContainerClone();

        List <Vector3> initialTrace = pointsCointainer.getAllMapPoints();

        positions           = new Position[initialTrace.Count];
        visualFoodPosition  = visualFoodTransform;
        this.herdParameters = herdParameters;

        for (int i = 0; i < initialTrace.Count; i++)
        {
            positions[i] = new Position(initialTrace[i]);
        }

        initCenterPositions();
    }
示例#27
0
 public float calculateRelatedFitness(float krillFitness, float neighbourFitness, HerdParameters parameters)
 {
     return((krillFitness - neighbourFitness) / parameters.getRelatedFitnessValue());
 }
示例#28
0
 public float calculateRelatedFitness(float krillFitness,float neighbourFitness, HerdParameters parameters)
 {
     return  (krillFitness - neighbourFitness) / parameters.getRelatedFitnessValue();
 }
示例#29
0
 private float calculateIterationRatio(HerdParameters parameters)
 {
     return 1.0f - parameters.getIterationRatio();
 }
示例#30
0
文件: Herd.cs 项目: jacek-kurlit/cars
 private void init()
 {
     algorithmParameters = new HerdParameters();
     herd = krillSetter.initHerd(carTransform, krillViz);
 }
示例#31
0
 private float calculateIterationRatio(HerdParameters parameters)
 {
     return(1.0f - parameters.getIterationRatio());
 }
示例#32
0
 private float calculateCoefficient(HerdParameters parameters)
 {
     return(2.0f * (Random.Range(0.0f, 1.0f) + parameters.getIterationRatio()));
 }
示例#33
0
 private float calculateCoefficient(HerdParameters parameters)
 {
     return 2.0f * (Random.Range(0.0f,1.0f) + parameters.getIterationRatio());
 }
示例#34
0
    private Position getAlphaPosition(List <Krill> herd, Krill krill, HerdParameters parameters)
    {
        Position alphaPosition = alphaCalculator.calculateAlpha(herd, krill, parameters);

        return(alphaPosition * parameters.N_MAX);
    }
示例#35
0
    public void updatePosition(Vector3 carPosition, HerdParameters parameters)
    {
        position = position + (motionInduced + diffusionMotion) * parameters.delta_t;

        visualizeKrill(carPosition);
    }
示例#36
0
 private Position getAlphaPosition(List<Krill> herd,Krill krill, HerdParameters parameters)
 {
     Position alphaPosition = alphaCalculator.calculateAlpha(herd,krill,parameters);
     return alphaPosition * parameters.N_MAX;
 }
示例#37
0
文件: Herd.cs 项目: jacek-kurlit/cars
 private void init()
 {
     algorithmParameters = new HerdParameters();
     herd = krillSetter.initHerd(carTransform,krillViz);
 }
示例#38
0
    public void updatePosition(Vector3 carPosition, HerdParameters parameters)
    {
        position = position + (motionInduced + diffusionMotion) * parameters.delta_t;

        visualizeKrill(carPosition);
    }