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
Merge requests
!6
Stats
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Stats
stats
into
master
Overview
0
Commits
14
Pipelines
0
Changes
2
Merged
Stats
pmag
requested to merge
stats
into
master
May 30, 2024
Overview
0
Commits
14
Pipelines
0
Changes
2
Problem statistics
Profile generation
Graph simplification
Tests for the above
0
0
Merge request reports
Viewing commit
d3c7d492
Prev
Next
Show latest version
2 files
+
143
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
d3c7d492
Finished consecutive_qpk method and added respetive tests.
· d3c7d492
Pedro L. Magalhães
authored
Apr 25, 2024
src/topupopt/problems/esipp/time.py
+
31
−
3
View file @ 4fa48ce4
Edit in single-file editor
Open in Web IDE
Show full file
@@ -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
# *************************************************************************
# *************************************************************************
@@ -241,6 +246,29 @@ class TimeFrame:
# *************************************************************************
# *************************************************************************
def
assessments_overlap
(
self
)
->
bool
:
"
Returns True if any period is covered by more than one assessment.
"
# if there is only one assessment, return False
if
self
.
number_assessments
()
==
1
:
return
False
else
:
# if there is more than one assessment, check whether two or more
# cover the same period
qs
=
tuple
(
self
.
assessments
)
# for each assessment
for
q1
,
q2
in
zip
(
qs
,
qs
[
1
:]):
# for each period in one assessment (q1)
for
p
in
self
.
reporting_periods
[
q1
]:
# check if it is covered by the other assessment (q2)
if
p
in
self
.
reporting_periods
[
q2
]:
# p is covered by at least two assessments (q1 and q2)
return
True
# if no period is covered by more than one assessment, return False
return
False
# *************************************************************************
# *************************************************************************
# *****************************************************************************
# *****************************************************************************
@@ -279,7 +307,7 @@ class EconomicTimeFrame(TimeFrame):
# dict: 1 value per p and q
self
.
_discount_rates
=
dict
(
discount_rates_q
)
else
:
raise
Valu
eError
(
'
Unrecognised inputs.
'
)
raise
Typ
eError
(
'
Unrecognised inputs.
'
)
# TODO: validate the discount rate object
Loading