Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
topupopt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmag
topupopt
Commits
d3c7d492
Commit
d3c7d492
authored
Apr 25, 2024
by
Pedro L. Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
Finished consecutive_qpk method and added respetive tests.
parent
d83c6f96
No related branches found
No related tags found
1 merge request
!6
Stats
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/topupopt/problems/esipp/time.py
+7
-2
7 additions, 2 deletions
src/topupopt/problems/esipp/time.py
tests/test_esipp_time.py
+136
-0
136 additions, 0 deletions
tests/test_esipp_time.py
with
143 additions
and
2 deletions
src/topupopt/problems/esipp/time.py
+
7
−
2
View file @
d3c7d492
...
...
@@ -134,8 +134,13 @@ class TimeFrame:
def
consecutive_qpk
(
self
,
qpk_keyed_dict
:
dict
)
->
bool
:
"
Returns True if all (q,p,k) tuple keys are valid and consecutive.
"
# TODO: here
raise
NotImplementedError
# all k intervals have to be consecutive for each (q,p) pair
set_qp
=
set
(
qpk
[
0
:
2
]
for
qpk
in
qpk_keyed_dict
.
keys
())
for
qp
in
set_qp
:
for
k
in
range
(
self
.
number_time_intervals
(
qp
[
0
])):
if
(
*
qp
,
k
)
not
in
qpk_keyed_dict
:
return
False
return
True
# *************************************************************************
# *************************************************************************
...
...
This diff is collapsed.
Click to expand it.
tests/test_esipp_time.py
+
136
−
0
View file @
d3c7d492
...
...
@@ -202,6 +202,28 @@ class TestTimeFrame:
assert
not
tf
.
complete_qpk
(
{(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
}
)
# qpk: consecutive
assert
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
,
(
0
,
2
,
0
):
1
,
(
0
,
2
,
1
):
1
,
}
)
# qpk: not consecutive
assert
not
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
1
):
1
,
(
0
,
1
,
2
):
1
,
(
0
,
2
,
0
):
1
,
(
0
,
2
,
1
):
1
,
}
)
qk_dict
=
{
qk
:
None
for
qk
in
tf
.
qk
()}
qp_dict
=
{
qp
:
None
for
qp
in
tf
.
qp
()}
...
...
@@ -357,6 +379,28 @@ class TestTimeFrame:
assert
not
tf
.
complete_qpk
(
{(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
1
,
1
,
0
):
1
,
(
1
,
1
,
1
):
1
}
)
# qpk: consecutive
assert
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
1
,
1
,
0
):
1
,
(
1
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
}
)
# qpk: not consecutive
assert
not
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
3
):
1
,
(
1
,
1
,
0
):
1
,
(
1
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
}
)
qk_dict
=
{
qk
:
None
for
qk
in
tf
.
qk
()}
qp_dict
=
{
qp
:
None
for
qp
in
tf
.
qp
()}
...
...
@@ -507,6 +551,30 @@ class TestTimeFrame:
(
1
,
2
,
1
):
1
,
}
)
# qpk: consecutive
assert
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
(
1
,
2
,
2
):
1
,
}
)
# qpk: not consecutive
assert
not
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
(
1
,
2
,
3
):
1
,
}
)
qk_dict
=
{
qk
:
None
for
qk
in
tf
.
qk
()}
qp_dict
=
{
qp
:
None
for
qp
in
tf
.
qp
()}
...
...
@@ -672,6 +740,40 @@ class TestTimeFrame:
(
1
,
2
,
1
):
1
,
}
)
# qpk: consecutive
assert
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
,
(
0
,
2
,
0
):
1
,
(
0
,
2
,
1
):
1
,
(
1
,
0
,
0
):
1
,
(
1
,
0
,
1
):
1
,
(
1
,
1
,
0
):
1
,
(
1
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
}
)
# qpk: not consecutive
assert
not
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
0
,
1
,
0
):
1
,
(
0
,
1
,
1
):
1
,
(
0
,
2
,
0
):
1
,
(
0
,
2
,
2
):
1
,
(
1
,
0
,
0
):
1
,
(
1
,
0
,
1
):
1
,
(
1
,
1
,
0
):
1
,
(
1
,
1
,
1
):
1
,
(
1
,
2
,
0
):
1
,
(
1
,
2
,
1
):
1
,
}
)
qk_dict
=
{
qk
:
None
for
qk
in
tf
.
qk
()}
qp_dict
=
{
qp
:
None
for
qp
in
tf
.
qp
()}
...
...
@@ -905,6 +1007,40 @@ class TestTimeFrame:
# (5, 2, 1): 1,
}
)
# qpk: consecutive
assert
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
1
,
0
,
0
):
1
,
(
2
,
1
,
0
):
1
,
(
3
,
1
,
0
):
1
,
(
4
,
2
,
0
):
1
,
(
5
,
2
,
0
):
1
,
(
0
,
0
,
1
):
1
,
(
1
,
0
,
1
):
1
,
(
2
,
1
,
1
):
1
,
(
3
,
1
,
1
):
1
,
(
4
,
2
,
1
):
1
,
(
5
,
2
,
1
):
1
,
}
)
# qpk: not consecutive
assert
not
tf
.
consecutive_qpk
(
{
(
0
,
0
,
0
):
1
,
(
1
,
0
,
0
):
1
,
(
2
,
1
,
0
):
1
,
(
3
,
1
,
0
):
1
,
(
4
,
2
,
0
):
1
,
(
5
,
2
,
0
):
1
,
(
0
,
0
,
2
):
1
,
(
1
,
0
,
1
):
1
,
(
2
,
1
,
1
):
1
,
(
3
,
1
,
1
):
1
,
(
4
,
2
,
1
):
1
,
(
5
,
2
,
1
):
1
,
}
)
qk_dict
=
{
qk
:
None
for
qk
in
tf
.
qk
()}
qp_dict
=
{
qp
:
None
for
qp
in
tf
.
qp
()}
...
...
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