Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IMC Problem A
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Mancini, Kevin
IMC Problem A
Commits
75274871
Commit
75274871
authored
1 year ago
by
Mancini, Kevin
Browse files
Options
Downloads
Plain Diff
Merge branch 'adam-feature' into 'master'
small changes See merge request
!15
parents
63122fe9
1643d1f4
Loading
Loading
1 merge request
!15
small changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
huawei_networkmultipathloadbalancing.py
+9
-8
9 additions, 8 deletions
huawei_networkmultipathloadbalancing.py
with
9 additions
and
8 deletions
huawei_networkmultipathloadbalancing.py
+
9
−
8
View file @
75274871
...
...
@@ -17,7 +17,6 @@ class UserSolution(Solution):
self
.
used_bw_in
=
0
self
.
used_bw_out
=
0
self
.
used_size
=
0
self
.
failed_requests
=
0
self
.
nodes_info_dict
=
{}
for
node_info
in
nodes_info
:
self
.
nodes_info_dict
.
update
({
node_info
[
4
]:
node_info
})
...
...
@@ -54,8 +53,6 @@ class UserSolution(Solution):
self
.
used_bw_in
=
0
self
.
used_bw_out
=
0
local_failures
=
self
.
failed_requests
for
i
,
request
in
enumerate
(
request_list
):
if
self
.
size
>=
request
.
data_size
+
self
.
used_size
:
self
.
used_size
+=
request
.
data_size
...
...
@@ -64,8 +61,6 @@ class UserSolution(Solution):
for
j
in
range
(
request
.
data_size
):
new_msg
=
Message
(
-
1
,
self
.
node_id
,
request
.
target_node_id
,
request
.
request_id
,
j
,
request
.
begin_time
)
self
.
messages
[
request
.
begin_time
][(
request
.
request_id
,
j
)]
=
new_msg
else
:
self
.
failed_requests
+=
1
def
ask_round_solution
(
self
,
neighbor_info_list
:
List
[
SwitchStatsInfo
])
->
List
[
Message
]:
sending_messages
:
List
[
Message
]
=
[]
...
...
@@ -81,7 +76,13 @@ class UserSolution(Solution):
neighbor_dict
.
update
({
neighbor_info
.
info
[
6
]:
neighbor_info
.
info
})
for
begin_time
in
range
(
self
.
max_time_seen
+
2
):
for
message
in
list
(
self
.
messages
[
begin_time
].
values
()):
all_messages
=
list
(
self
.
messages
[
begin_time
].
values
())
# sort the messages starting with the ones with the fewest requests
request_counts
=
{}
for
message
in
all_messages
:
request_counts
[
message
.
request_id
]
=
request_counts
.
get
(
message
.
request_id
,
0
)
+
1
all_messages
.
sort
(
key
=
lambda
message
:
request_counts
[
message
.
request_id
])
for
message
in
all_messages
:
if
self
.
bw_out
-
self
.
used_bw_out
<=
0
or
self
.
used_bw_out
+
len
(
sending_messages
)
>=
self
.
bw_out
:
return
sending_messages
...
...
@@ -93,7 +94,7 @@ class UserSolution(Solution):
next_node
=
rnd
.
choice
(
self
.
aggregates
)
else
:
used_rate
=
[
neighbor_dict
.
get
(
aggregate
)[
4
]
/
neighbor_dict
.
get
(
aggregate
)[
5
]
for
aggregate
in
self
.
aggregates
]
if
min
(
used_rate
)
<
0.
8
5
:
if
min
(
used_rate
)
<
0.
7
5
:
next_node
=
self
.
aggregates
[
used_rate
.
index
(
min
(
used_rate
))]
else
:
continue
...
...
@@ -108,7 +109,7 @@ class UserSolution(Solution):
break
if
next_node
is
None
:
used_rate
=
[
neighbor_dict
.
get
(
core
)[
4
]
/
neighbor_dict
.
get
(
core
)[
5
]
for
core
in
self
.
cores
]
if
min
(
used_rate
)
<
0.
8
5
:
if
min
(
used_rate
)
<
0.
7
5
:
next_node
=
self
.
cores
[
used_rate
.
index
(
min
(
used_rate
))]
else
:
continue
...
...
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