Skip to content
Snippets Groups Projects
Commit d15df919 authored by Klervie Toczé's avatar Klervie Toczé
Browse files
parents 579f82c7 79999137
No related branches found
No related tags found
No related merge requests found
......@@ -135,12 +135,14 @@ def CalculateFitness(Current,Previous,NodeObjects,Epsilon,Cs,Ca,fitnessAlpha):
#We want to also have the cost from 0 to 100
nbDedicated=len(GetNodesOfType("D",NodeObjects))
nbSpare=len(GetNodesOfType("S",NodeObjects))
minCost=Cd
#minCost=Cd
maxCost=(nbDedicated-1)*(Cd+Cr)+Cd+nbSpare*(Cs+Ca+Cr)
percentCost=((Cost-minCost)/(maxCost-minCost))*100
#percentCost=((Cost-minCost)/(maxCost-minCost))*100
#alpha=0.5 #Fitness parameter
fitness=fitnessAlpha*(100-Epsilon)+(1-fitnessAlpha)*percentCost
#fitness=fitnessAlpha*(100-Epsilon)+(1-fitnessAlpha)*percentCost
percentCost=(Cost/maxCost)
fitness=fitnessAlpha*Epsilon+(1-fitnessAlpha)*percentCost
return fitness
......@@ -372,6 +374,12 @@ def GetBestWithCost(Cases,SaturationPerPod,VProximity,Ep0, Previous, NodeObjects
#Also get all the suitable cases (i.e. below the threshold)
if case.Ep < Ep0:
SuitableCases.append(case)
if SuitableCases==[]:
for case in Cases:
if case.Ep < MinEp+0.1:
SuitableCases.append(Case)
#If we have suitable cases, we want to return the one with minimum cost as the best
#Otherwise, we return the current best
if SuitableCases != []:
......@@ -385,10 +393,12 @@ def GetBestWithCost(Cases,SaturationPerPod,VProximity,Ep0, Previous, NodeObjects
MinCost=case.Cost
MinCostCase=case
BestCase=MinCostCase
return BestCase
def GetBestWithFitness(Cases,SaturationPerPod,VProximity,Ep0, Previous, NodeObjects,Cs,Ca,fitnessAlpha):
assert fitnessAlpha>=0 and fitnessAlpha<=1; "The value of alpha "+fitnessAlpha+" is out of range"
MinEp=100
BestCase=Cases[0]
SuitableCases=[]
......@@ -408,12 +418,16 @@ def GetBestWithFitness(Cases,SaturationPerPod,VProximity,Ep0, Previous, NodeObje
SuitableCases.append(case)
#If we have suitable cases, we want to return the one with minimum cost as the best
#Otherwise, we return the current best
if SuitableCases==[]:
for case in Cases:
if case.Ep < MinEp+0.1:
SuitableCases.append(Case)
if SuitableCases != []:
MaxFitness=CalculateFitness(SuitableCases[0],Previous,NodeObjects,SuitableCases[0].Ep,Cs,Ca,fitnessAlpha)
MaxFitnessCase=SuitableCases[0]
for case in SuitableCases:
case.Fitness=CalculateFitness(case,Previous,NodeObjects,case.Ep,Cs,Ca,fitnessAlpha)
if case.Fitness>MaxFitness:
if case.Fitness<MaxFitness:
MaxFitness=case.Fitness
MaxFitnessCase=case
BestCase=MaxFitnessCase
......@@ -958,6 +972,8 @@ def FixSaturationQoSFitness(Nodes,NodeObjects,SelectedNodes,start,TempCase,FullT
if number!=0: # number=0 should return the solution, in this case else will be skipped and the function will go to the if number==0 directly
print("debug 16")
return Cases
else:
return Best
else: # No scale up with one D solution was found, we have to try S
NewCases,Number,Condition=AutoScale(VProximity,Ep0,SaturationPerPod,
Timeout,TempCase,ProbMat,TestMat,NodeObjects,
......@@ -1039,6 +1055,8 @@ def FixProximityQoSFitness(Nodes,NodeObjects,SelectedNodes,start,TempCase,FullTe
if number!=0: # number=0 should return the solution, in this case else will be skipped and the function will go to the if number==0 directly
print("debug 19")
return Cases
else:
return Best
else:
NewCases,Number,Condition=AutoScale(VProximity,Ep0,SaturationPerPod,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment