public Position calculateAlpha(List<Krill> herd, Krill krill, HerdParameters parameters) { Position localAlpha = calculateAlphaLocal(herd, krill, parameters); Position targetAlpha = calculateAlphaTarget(parameters,krill); return localAlpha + targetAlpha; }
public Position calculateAlpha(List <Krill> herd, Krill krill, HerdParameters parameters) { Position localAlpha = calculateAlphaLocal(herd, krill, parameters); Position targetAlpha = calculateAlphaTarget(parameters, krill); return(localAlpha + targetAlpha); }
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; }
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()); }
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; }
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); }
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()); }
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); }
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); } }
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); } }
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); } } }
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); } }
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); } }
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); }
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; }
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); } }
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); } }
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); } } }
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); } } }
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; }
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 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); } } }
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; }
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 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(); }
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(); }
public float calculateRelatedFitness(float krillFitness, float neighbourFitness, HerdParameters parameters) { return((krillFitness - neighbourFitness) / parameters.getRelatedFitnessValue()); }
public float calculateRelatedFitness(float krillFitness,float neighbourFitness, HerdParameters parameters) { return (krillFitness - neighbourFitness) / parameters.getRelatedFitnessValue(); }
private float calculateIterationRatio(HerdParameters parameters) { return 1.0f - parameters.getIterationRatio(); }
private void init() { algorithmParameters = new HerdParameters(); herd = krillSetter.initHerd(carTransform, krillViz); }
private float calculateIterationRatio(HerdParameters parameters) { return(1.0f - parameters.getIterationRatio()); }
private float calculateCoefficient(HerdParameters parameters) { return(2.0f * (Random.Range(0.0f, 1.0f) + parameters.getIterationRatio())); }
private float calculateCoefficient(HerdParameters parameters) { return 2.0f * (Random.Range(0.0f,1.0f) + parameters.getIterationRatio()); }
private Position getAlphaPosition(List <Krill> herd, Krill krill, HerdParameters parameters) { Position alphaPosition = alphaCalculator.calculateAlpha(herd, krill, parameters); return(alphaPosition * parameters.N_MAX); }
public void updatePosition(Vector3 carPosition, HerdParameters parameters) { position = position + (motionInduced + diffusionMotion) * parameters.delta_t; visualizeKrill(carPosition); }
private Position getAlphaPosition(List<Krill> herd,Krill krill, HerdParameters parameters) { Position alphaPosition = alphaCalculator.calculateAlpha(herd,krill,parameters); return alphaPosition * parameters.N_MAX; }
private void init() { algorithmParameters = new HerdParameters(); herd = krillSetter.initHerd(carTransform,krillViz); }