Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
0
02465students
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
02465material
02465students
Commits
37aa3bb5
Commit
37aa3bb5
authored
1 month ago
by
tuhe
Browse files
Options
Downloads
Patches
Plain Diff
Documentation fixed
parent
26dcea51
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
irlc/ex02/dp.py
+4
-4
4 additions, 4 deletions
irlc/ex02/dp.py
with
4 additions
and
4 deletions
irlc/ex02/dp.py
+
4
−
4
View file @
37aa3bb5
...
...
@@ -7,18 +7,18 @@ References:
from
irlc.ex02.deterministic_inventory
import
DeterministicInventoryDPModel
from
irlc.ex02.dp_model
import
DPModel
def
DP_stochastic
(
model
:
DPModel
):
def
DP_stochastic
(
model
:
DPModel
)
->
tuple
[
list
[
dict
],
list
[
dict
]]
:
r
"""
Implement the stochastic DP algorithm. The implementation follows (Her25, Algorithm 1).
Once you are done, you should be able to call the function as:
.. runblock:: pycon
>>>
from
irlc.ex02.
graph_traversal
import
SmallGraphDP
>>>
from
irlc.ex02.
deterministic_inventory
import
DeterministicInventoryDPModel
>>>
from
irlc.ex02.dp
import
DP_stochastic
>>>
model
=
SmallGraphDP
(
t
=
5
)
# Instantiate the small graph with target n
ode
5
>>>
model
=
DeterministicInventoryDPModel
()
# Instantiate the deterministic DP m
ode
l
>>>
J
,
pi
=
DP_stochastic
(
model
)
>>>
print
(
pi
[
0
][
2
])
# Action taken in state ``x=2`` at time step ``k=0``.
>>>
print
(
pi
[
0
][
2
])
# Action taken in state ``x
_0
=2`` at time step ``k=0``.
:
param
model
:
An
instance
of
:
class
:
`irlc.ex02.dp_model.DPModel`
class
.
This
represents
the
problem
we
wish
to
solve
.
:
return
:
...
...
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