Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
afb0fd3b
Commit
afb0fd3b
authored
Apr 02, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin to score the solution based on the units throughput
parent
db59ade7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
dream/plugins/Batches/BatchesACO.py
dream/plugins/Batches/BatchesACO.py
+14
-13
No files found.
dream/plugins/Batches/BatchesACO.py
View file @
afb0fd3b
...
...
@@ -17,19 +17,20 @@ class BatchesACO(ACO):
def
_calculateAntScore
(
self
,
ant
):
"""Calculate the score of this ant.
"""
totalDelay
=
0
#set the total delay to 0
result
,
=
ant
[
'result'
][
'result_list'
]
#read the result as JSON
#loop through the elements
#loop through the elements
for
element
in
result
[
'elementList'
]:
element_family
=
element
.
get
(
'family'
,
None
)
#id the class is Job
if
element_family
==
'Job'
:
results
=
element
[
'results'
]
delay
=
float
(
results
.
get
(
'delay'
,
"0"
))
# A negative delay would mean we are ahead of schedule. This
# should not be considered better than being on time.
totalDelay
+=
max
(
delay
,
0
)
return
totalDelay
#id the class is Exit get the unitsThroughput
if
element_family
==
'Exit'
:
unitsThroughput
=
element
[
'results'
].
get
(
'unitsThroughput'
,
None
)
if
unitsThroughput
:
unitsThroughput
=
unitsThroughput
[
0
]
if
not
unitsThroughput
:
unitsThroughput
=
batchesThroughput
print
'score='
,
unitsThroughput
# return the negative value since they are ranked this way. XXX discuss this
return
-
unitsThroughput
# creates the collated scenarios, i.e. the list
# of options collated into a dictionary for ease of referencing in ManPy
...
...
@@ -45,10 +46,10 @@ class BatchesACO(ACO):
collated
[
str
(
i
)]
=
[
float
(
staticValue
)]
else
:
collated
[
str
(
i
)]
=
[]
value
=
minValue
value
=
float
(
minValue
)
while
1
:
collated
[
str
(
i
)].
append
(
round
(
float
(
value
),
2
))
value
+=
stepValue
value
+=
float
(
stepValue
)
if
value
>
maxValue
:
break
return
collated
...
...
@@ -70,7 +71,7 @@ class BatchesACO(ACO):
ant_data
=
copy
(
data
)
# below provisional values, to be updated (should the user set those?)
data
[
'general'
][
'numberOfSolutions'
]
=
1
data
[
"general"
][
"numberOfGenerations"
]
=
1
data
[
"general"
][
"numberOfGenerations"
]
=
4
data
[
"general"
][
"numberOfAntsPerGenerations"
]
=
2
ACO
.
run
(
self
,
data
)
return
data
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment