Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VioLinn_Sim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ida-rtslab
public-code
VioLinn_Sim
Commits
d15df919
Commit
d15df919
authored
4 years ago
by
Klervie Toczé
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.inria.fr/afahs/voila-orch_sim
parents
579f82c7
79999137
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
voila.py
+23
-5
23 additions, 5 deletions
voila.py
with
23 additions
and
5 deletions
voila.py
+
23
−
5
View file @
d15df919
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment