Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schedgen
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
veriT
schedgen
Commits
917206c2
Commit
917206c2
authored
3 years ago
by
Hans-Jörg
Browse files
Options
Downloads
Patches
Plain Diff
Add option to generate a schedule greedily
parent
6c6410f0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
schedgen/opt/schedule.py
+25
-1
25 additions, 1 deletion
schedgen/opt/schedule.py
schedgen/schedgen-optimize.py
+71
-62
71 additions, 62 deletions
schedgen/schedgen-optimize.py
with
96 additions
and
63 deletions
schedgen/opt/schedule.py
+
25
−
1
View file @
917206c2
...
...
@@ -57,7 +57,31 @@ class OptimizeSchedule:
self
.
epsilon
=
epsilon
self
.
time_slices
.
sort
()
def
find_optimal_schedule
(
self
,
frame
,
overlord
=
None
,
threads
=
2
,
logics
=
"
None
"
):
def
find_greedy_schedule
(
self
,
frame
,
logics
=
None
):
remaining_time
=
self
.
timeout
best_score
=
0
schedule
=
[]
while
remaining_time
>
self
.
time_slices
[
0
]:
for
strategy
,
solving_times
in
frame
.
iteritems
():
for
slice
in
self
.
time_slices
:
if
slice
>
remaining_time
:
continue
solved
=
solving_times
.
loc
[
solving_times
<
(
slice
-
self
.
epsilon
)]
if
len
(
solved
)
>
best_score
:
best_solved
=
solved
best_score
=
len
(
solved
)
best
=
(
slice
,
strategy
)
if
best
is
not
None
:
remaining_time
=
remaining_time
-
best
[
0
]
frame
=
frame
[
~
frame
.
index
.
isin
(
best_solved
.
index
)]
schedule
.
append
(
best
)
best_score
=
0
best
=
None
else
:
return
schedule
return
schedule
def
find_optimal_schedule
(
self
,
frame
,
overlord
=
None
,
threads
=
2
,
logics
=
None
):
"""
Create LP problem
"""
...
...
This diff is collapsed.
Click to expand it.
schedgen/schedgen-optimize.py
+
71
−
62
View file @
917206c2
...
...
@@ -62,6 +62,12 @@ args_parser.add_argument(
action
=
"
store_true
"
,
help
=
"
Use the CSV parser instead of the GridTPT parser to read experimental data.
"
,
)
args_parser
.
add_argument
(
"
--greedy
"
,
dest
=
"
greedy
"
,
help
=
"
Generate a greedy schedule instead of an optimal one.
"
,
action
=
"
store_true
"
,
)
args_parser
.
add_argument
(
"
-f
"
,
"
--full
"
,
...
...
@@ -267,72 +273,75 @@ if __name__ == "__main__":
schedule_optimizer
=
OptimizeSchedule
(
time_slices
,
timeout
,
epsilon
)
# Format: (time, strategy)
schedule
=
schedule_optimizer
.
find_optimal_schedule
(
exps
,
overlord
=
args
.
overlord
,
threads
=
args
.
threads
,
logics
=
logics
)
if
len
(
schedule
)
==
0
:
message
(
"
Error: got empty schedule.
"
,
logics
)
exit
(
1
)
if
len
(
schedule
)
==
1
:
message
(
"
Have singular best step:
"
,
logics
)
t
,
best_opt
=
schedule
[
0
]
longest
=
time_slices
[
-
1
]
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
best_opt
}
'"
,
logics
)
order_optimizer
=
OptimizeOrder
(
exps
)
_
,
best_time
,
best_solves
=
order_optimizer
.
runtime
([(
longest
,
best_opt
)])
best_count
=
best_solves
.
sum
()
message
(
f
"
This solves
{
best_count
}
in
{
best_time
}
s.
"
,
logics
)
for
e
in
exps
:
_
,
time
,
solves
=
order_optimizer
.
runtime
([(
longest
,
e
)])
new_count
=
solves
.
sum
()
if
new_count
>
best_count
:
message
(
"
Something went wrong: optimizer returned a better schedule.
"
,
logics
,
)
exit
(
1
)
if
new_count
==
best_count
and
time
<
best_time
:
best_time
=
time
best_opt
=
e
message
(
"
The best schedule is:
"
,
logics
)
message
(
f
"
Run
\t
'
{
best_opt
}
'"
,
logics
)
message
(
f
"
This solves
{
best_count
}
in
{
best_time
}
s.
"
,
logics
)
after_solved
=
best_solves
after_count
=
best_count
after_total_time
=
best_time
best_schedule
=
[(
t
,
best_opt
)]
if
args
.
greedy
:
best_schedule
=
schedule_optimizer
.
find_greedy_schedule
(
exps
,
logics
=
logics
)
else
:
message
(
"
Solution:
"
,
logics
)
for
(
t
,
e
)
in
schedule
:
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
e
}
'"
,
logics
)
schedule
=
schedule_optimizer
.
find_optimal_schedule
(
exps
,
overlord
=
args
.
overlord
,
threads
=
args
.
threads
,
logics
=
logics
)
order_optimizer
=
OptimizeOrder
(
exps
)
if
len
(
schedule
)
==
0
:
message
(
"
Error: got empty schedule.
"
,
logics
)
exit
(
1
)
if
len
(
schedule
)
==
1
:
message
(
"
Have singular best step:
"
,
logics
)
t
,
best_opt
=
schedule
[
0
]
longest
=
time_slices
[
-
1
]
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
best_opt
}
'"
,
logics
)
order_optimizer
=
OptimizeOrder
(
exps
)
_
,
best_time
,
best_solves
=
order_optimizer
.
runtime
([(
longest
,
best_opt
)])
best_count
=
best_solves
.
sum
()
message
(
f
"
This solves
{
best_count
}
in
{
best_time
}
s.
"
,
logics
)
for
e
in
exps
:
_
,
time
,
solves
=
order_optimizer
.
runtime
([(
longest
,
e
)])
new_count
=
solves
.
sum
()
if
new_count
>
best_count
:
message
(
"
Something went wrong: optimizer returned a better schedule.
"
,
logics
,
)
exit
(
1
)
if
new_count
==
best_count
and
time
<
best_time
:
best_time
=
time
best_opt
=
e
message
(
"
The best schedule is:
"
,
logics
)
message
(
f
"
Run
\t
'
{
best_opt
}
'"
,
logics
)
message
(
f
"
This solves
{
best_count
}
in
{
best_time
}
s.
"
,
logics
)
after_solved
=
best_solves
after_count
=
best_count
after_total_time
=
best_time
best_schedule
=
[(
t
,
best_opt
)]
else
:
message
(
"
Solution:
"
,
logics
)
for
(
t
,
e
)
in
schedule
:
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
e
}
'"
,
logics
)
(
before_wait
,
before_total_time
,
before_solved
,
)
=
order_optimizer
.
runtime
(
schedule
)
before_count
=
before_solved
.
value_counts
().
loc
[
True
]
message
(
f
"
Current schedule solves
{
before_count
}
/
{
before_solved
.
count
()
}
in
{
before_total_time
:
.
2
f
}
s.
"
,
logics
,
)
order_optimizer
=
OptimizeOrder
(
exps
)
message
(
"
Calculating best order.
"
,
logics
)
best_schedule
=
order_optimizer
.
find_optimal_order
(
schedule
)
message
(
"
\n
Optimal schedule:
"
,
logics
)
for
(
t
,
e
)
in
best_schedule
:
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
e
}
'"
,
logics
)
after_wait
,
after_total_time
,
after_solved
=
order_optimizer
.
runtime
(
best_schedule
)
after_count
=
after_solved
.
value_counts
().
loc
[
True
]
message
(
f
"
This schedule solves
{
after_count
}
/
{
after_solved
.
count
()
}
in
{
after_total_time
:
.
2
f
}
s.
"
,
logics
,
)
(
before_wait
,
before_total_time
,
before_solved
,
)
=
order_optimizer
.
runtime
(
schedule
)
before_count
=
before_solved
.
value_counts
().
loc
[
True
]
message
(
f
"
Current schedule solves
{
before_count
}
/
{
before_solved
.
count
()
}
in
{
before_total_time
:
.
2
f
}
s.
"
,
logics
,
)
message
(
"
Calculating best order.
"
,
logics
)
best_schedule
=
order_optimizer
.
find_optimal_order
(
schedule
)
message
(
"
\n
Optimal schedule:
"
,
logics
)
for
(
t
,
e
)
in
best_schedule
:
message
(
f
"
For
{
t
:
.
2
f
}
s
\t
'
{
e
}
'"
,
logics
)
after_wait
,
after_total_time
,
after_solved
=
order_optimizer
.
runtime
(
best_schedule
)
after_count
=
after_solved
.
value_counts
().
loc
[
True
]
message
(
f
"
This schedule solves
{
after_count
}
/
{
after_solved
.
count
()
}
in
{
after_total_time
:
.
2
f
}
s.
"
,
logics
,
)
if
pre_schedule
:
message
(
"
Merging with pre-schedule.
"
,
logics
)
...
...
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