Skip to content
Snippets Groups Projects
Commit e7c3391c authored by tuhe's avatar tuhe
Browse files

Port of s_tag and readme.md work

parent 4f169120
No related branches found
No related tags found
No related merge requests found
Showing
with 1798 additions and 3 deletions
...@@ -94,7 +94,65 @@ Hello World" ...@@ -94,7 +94,65 @@ Hello World"
``` ```
All these files can be directly imported into `LaTeX` using e.g. `minted`: You never need to mix `LaTeX` code and python again! All these files can be directly imported into `LaTeX` using e.g. `minted`: You never need to mix `LaTeX` code and python again!
## References:
Bibliography references can be loaded from `references.bib`-files and in-document references from the `.aux` file.
For this example, we will insert references shown in the `examples/latex/index.tex`-document. To do so, we can use these tags:
```python
def myfun(): #!s
"""
To solve this exercise, look at \ref{eq1} in \ref{sec1}.
You can also look at \cite{bertsekasII} and \cite{herlau}
More specifically, look at \cite[Equation 117]{bertsekasII} and \cite[\ref{fig1}]{herlau}
We can also write a special tag to reduce repetition: \nref{fig1} and \nref{sec1}.
"""
return 42 #!s
```
We can manually compile this example by first loading the aux-files and the bibliographies as follows:
```python
# load_references.py
from snipper.citations import get_bibtex, get_aux
bibfile = "latex/library.bib"
auxfile = 'latex/index.aux'
bibtex = get_bibtex(bibfile)
aux = get_aux(auxfile)
```
Next, we load the python file containing the reference code and fix all references based on the aux and bibliography data.
```python
# load_references.py
file = "citations.py"
with open(file, 'r') as f:
lines = f.read().splitlines()
lines = fix_aux(lines, aux=aux)
lines = fix_aux_special(lines, aux=aux, command='\\nref', bibref='herlau')
lines = fix_bibtex(lines, bibtex=bibtex)
with open('output/citations.py', 'w') as f:
f.write("\n".join(lines))
```
The middle command is a convenience feature: It allows us to specify a special citation command `\nref{..}` which always compiles to `\cite[\ref{...}]{herlau}`. This is useful if e.g. `herlau` is the bibtex key for your lecture notes. The result is as follows:
```python
"""
{{copyright}}
References:
[Ber07] Dimitri P. Bertsekas. Dynamic Programming and Optimal Control, Vol. II. Athena Scientific, 3rd edition, 2007. ISBN 1886529302.
[Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021.
"""
def myfun(): #!s
"""
To solve this exercise, look at eq. (1) in Section 1.
You can also look at (Ber07) and (Her21)
More specifically, look at (Ber07, Equation 117) and (Her21, Figure 1)
We can also write a special tag to reduce repetition: (Her21, Figure 1) and (Her21, Section 1).
"""
return 42 #!s
```
Note this example uses the low-level api. Normally you would just pass the bibtex and aux-file to the main censor-file command.
## Additional features: ## Additional features:
- Include references using `\cite` and `\ref`: This works by parsing your `LaTeX` `.aux` files and automatically keep your
references in code synchronized with your written material. See the 02465 students repository for examples: None of the references to the exercise material or lecture notes are hard-coded!
- You can name tags using `#!s=bar` to get a `foo_bar.py` snippet. This is useful when you need to cut multiple sessions. This also works for the other tags. - You can name tags using `#!s=bar` to get a `foo_bar.py` snippet. This is useful when you need to cut multiple sessions. This also works for the other tags.
\ No newline at end of file
# Snipper
A lightweight framework for removing code from student solutions.
## Installation
```console
pip install codesnipper
```
## What it does
This project address the following three challenges for administering a python-based course
- You need to maintain a (working) version for debugging as well as a version handed out to students (with code missing)
- You ideally want to make references in source code to course material *"(see equation 2.1 in exercise 5)"* but these tend to go out of date
- You want to include code snippets and code output in lectures notes/exercises/beamer slides
- You want to automatically create student solutions
This framework address these problems and allow you to maintain a **single**, working project repository.
The project is currently used in **02465** at DTU. An example of student code can be found at:
- https://gitlab.gbar.dtu.dk/02465material/02465students/blob/master/irlc/ex02/dp.py
A set of lectures notes where all code examples/output are automatically generated from the working repository can be found a
- https://lab.compute.dtu.dk/tuhe/books (see **Sequential decision making**)
## How it works
The basic functionality is quite simple. You start with your working script in your private repository and add special tags to the script.
In this case I have added the tags `#!b` (cut a block) and `#!f` (cut function scope).
```python
def myfun(): #!f The error I am going to raise
""" The function docstring will not be removed"""
print("This is a function")
return 42
def a_long_function():
a = 234
print("a line")
print("a line") #!b
print("a line")
print("a line") #!b Insert three missing print statements.
print("a line")
return a
if __name__ == "__main__":
myfun()
```
This will produce the following file:
```python
def myfun():
""" The function docstring will not be removed"""
# TODO: 2 lines missing.
raise NotImplementedError("The error I am going to raise")
def a_long_function():
a = 234
print("a line")
# TODO: 3 lines missing.
raise NotImplementedError("Insert three missing print statements.")
print("a line")
return a
if __name__ == "__main__":
myfun()
```
You can also use the framework to capture code snippets, outputs and interactive python output.
To do this, save the following in `foo.py`
```python
def myfun(): #!s This snippet will be saved to foo.py in the output directory.
print("Hello") #!s
print("Do not capture me")
for i in range(4): #!o
print("Output", i)
print("Goodbuy world") #!o
print("don't capture me")
# Interactive pythong example
print("Hello World") #!i #!i # this is a single-line cutout.
````
These block-tags will create a file `foo.py` (in the output directory) containing
```python
def myfun():
print("Hello")
```
A file `foo.txt` containing the captured output
```txt
Output 0
Output 1
Output 2
Output 3
Goodbuy world
```
and a typeset version of an interactive python session in `foo.pyi` (use `pycon` in minted; this gitlab server appears not to support `pycon`)
```pycon
>>> print("hello world")
Hello World"
```
All these files can be directly imported into `LaTeX` using e.g. `minted`: You never need to mix `LaTeX` code and python again!
## References:
Bibliography references can be loaded from `references.bib`-files and in-document references from the `.aux` file.
For this example, we will insert references shown in the `examples/latex/index.tex`-document. To do so, we can use these tags:
```python
{{ citations_orig_py }}
```
We can manually compile this example by first loading the aux-files and the bibliographies as follows:
```python
{{ load_references_a_py }}
```
Next, we load the python file containing the reference code and fix all references based on the aux and bibliography data.
```python
{{ load_references_b_py }}
```
The middle command is a convenience feature: It allows us to specify a special citation command `\nref{..}` which always compiles to `\cite[\ref{...}]{herlau}`. This is useful if e.g. `herlau` is the bibtex key for your lecture notes. The result is as follows:
```python
{{ citations_py }}
```
Note this example uses the low-level api. Normally you would just pass the bibtex and aux-file to the main censor-file command.
## Additional features:
- You can name tags using `#!s=bar` to get a `foo_bar.py` snippet. This is useful when you need to cut multiple sessions. This also works for the other tags.
import slider.convert
from slider.beamer_nup import beamer_nup
import jinja2
from slider import convert
import os
import shutil
from slider.slider_cli import slider_cli
# from example.load_references import reference_example
# reference_example()
def my_nup(path):
dir = os.path.dirname(path)
base = os.path.basename(dir)
out = beamer_nup(path, output="./" + base + "_nup.pdf", nup=2)
out_png = convert.pdf2png(out, scale_to=600)
print(out_png)
if __name__ == "__main__":
from snipper.fix_s import save_s
from snipper.snipper_main import censor_file
#
# EX_BASE = "../examples"
# np = EX_BASE + "/new_project"
# if os.path.isdir(np):
# shutil.rmtree(np)
# os.makedirs(np)
# slider_cli(latexfile=f"{np}/index.tex", force=True)
# np_basic1 = EX_BASE + "/basic1"
# if os.path.isdir(np_basic1):
# shutil.rmtree(np_basic1)
# shutil.copytree(np, np_basic1)
# shutil.copyfile("myoverlay.svg", np_basic1 +"/osvgs/myoverlay.svg")
# slider_cli(latexfile=f"{np_basic1}/index.tex")
#
#
# my_nup(np + "/index.pdf")
# my_nup(f"{np_basic1}/index.pdf")
#
# # convert.pdf2png(np + "/index.pdf", "./index0.png")
# output = np +"/index_2up.pdf"
#
# data = {}
# data['resources'] = 'https://gitlab.compute.dtu.dk/tuhe/slider/-/raw/main'
# with open(np + "/index.tex", 'r') as f:
# data['basic0_tex'] = f.read()
data = {}
# Build the docs.
import glob
with open("../example/citations.py", 'r') as f:
data['citations_orig_py'] = f.read()
for file in glob.glob("../example/output/*.*"):
with open(file, 'r') as f:
data[os.path.basename(file).replace(".", "_")] = f.read()
with open("README.jinja.md", 'r') as f:
s = jinja2.Environment(loader=jinja2.FileSystemLoader([".", "../example"])).from_string(f.read()).render(data)
with open("../README.md",'w') as f:
f.write(s)
pass
\ No newline at end of file
File added
def myfun(): #!s
"""
To solve this exercise, look at \ref{eq1} in \ref{sec1}.
You can also look at \cite{bertsekasII} and \cite{herlau}
More specifically, look at \cite[Equation 117]{bertsekasII} and \cite[\ref{fig1}]{herlau}
We can also write a special tag to reduce repetition: \nref{fig1} and \nref{sec1}.
"""
return 42 #!s
def mysum(a,b): #!f Implement the sum-function here #!s=b
"""
Return the sum of a and b
"""
return a+b #!s=b
#!s=a
def print_information(s):
print("s is", s) #!b
print("s printed twice", s, s) #!b Print s once and twice.
print("s printed three times", s, s, s)
#!s=a
# Let's both capture output and also typeset it is an interactive python session.
print("Hello world") #!i
for j in range(3): #!o
print(f"{j=}") #!o
print("Goodbuuy world") #!i
# Cut a single line and put it in the 'b' snippet.
3 * 45 #!s=b #!s=b
if __name__ == "__main__":
mysum(2,2)
print_information("Cat")
File added
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldcontentsline\contentsline
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\contentsline\oldcontentsline
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\providecommand\HyField@AuxAddToCoFields[2]{}
\providecommand\babel@aux[2]{}
\@nameuse{bbl@beforestart}
\citation{bertsekasII}
\citation{rosolia2018data}
\citation{herlau}
\bibstyle{alpha}
\bibdata{library}
\bibcite{bertsekasII}{Ber07}
\bibcite{herlau}{Her21}
\bibcite{rosolia2018data}{RZB18}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces A figure}}{1}{figure.1}\protected@file@percent }
\newlabel{fig1}{{1}{1}{A figure}{figure.1}{}}
\newlabel{fig1@cref}{{[figure][1][]1}{[1][1][]1}}
\babel@aux{english}{}
\@writefile{toc}{\contentsline {section}{\numberline {1}First section}{1}{section.1}\protected@file@percent }
\newlabel{sec1}{{1}{1}{First section}{section.1}{}}
\newlabel{sec1@cref}{{[section][1][]1}{[1][1][]1}}
\newlabel{eq1}{{1}{1}{First section}{equation.1.1}{}}
\newlabel{eq1@cref}{{[equation][1][]1}{[1][1][]1}}
\gdef \@abspage@last{1}
\begin{thebibliography}{RZB18}
\bibitem[Ber07]{bertsekasII}
Dimitri~P. Bertsekas.
\newblock {\em Dynamic Programming and Optimal Control, Vol. II}.
\newblock Athena Scientific, 3rd edition, 2007.
\bibitem[Her21]{herlau}
Tue Herlau.
\newblock Sequential decision making.
\newblock (See \textbf{02465\_Notes.pdf}), 2021.
\bibitem[RZB18]{rosolia2018data}
Ugo Rosolia, Xiaojing Zhang, and Francesco Borrelli.
\newblock Data-driven predictive control for autonomous systems.
\newblock {\em Annual Review of Control, Robotics, and Autonomous Systems},
1:259--286, 2018.
\end{thebibliography}
This is BibTeX, Version 0.99d
Capacity: max_strings=200000, hash_size=200000, hash_prime=170003
The top-level auxiliary file: index.aux
Reallocating 'name_of_file' (item size: 1) to 6 items.
The style file: alpha.bst
Reallocating 'name_of_file' (item size: 1) to 8 items.
Database file #1: library.bib
You've used 3 entries,
2543 wiz_defined-function locations,
577 strings with 4836 characters,
and the built_in function-call counts, 984 in all, are:
= -- 97
> -- 41
< -- 2
+ -- 13
- -- 13
* -- 64
:= -- 178
add.period$ -- 9
call.type$ -- 3
change.case$ -- 17
chr.to.int$ -- 3
cite$ -- 3
duplicate$ -- 40
empty$ -- 69
format.name$ -- 18
if$ -- 191
int.to.chr$ -- 1
int.to.str$ -- 0
missing$ -- 3
newline$ -- 18
num.names$ -- 9
pop$ -- 14
preamble$ -- 1
purify$ -- 20
quote$ -- 0
skip$ -- 32
stack$ -- 0
substring$ -- 46
swap$ -- 2
text.length$ -- 2
text.prefix$ -- 2
top$ -- 0
type$ -- 20
warning$ -- 0
while$ -- 9
width$ -- 4
write$ -- 40
This diff is collapsed.
\BOOKMARK [1][-]{section.1}{\376\377\000F\000i\000r\000s\000t\000\040\000s\000e\000c\000t\000i\000o\000n}{}% 1
File added
File added
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT EDIT THIS FILE. IT WILL BE AUTOMATICALLY OVERWRITTEN
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TeX-command-extra-options: "-shell-escape"
\documentclass[12pt,twoside]{article}
\usepackage[table]{xcolor} % important to avoid options clash.
%\input{book_preamble}
%\input{02465shared_preamble}
%\input{structure.tex}
\usepackage{url}
\usepackage{graphics}
%\usepackage{fancybox}
\usepackage{multicol}
\usepackage{rotate}
%\usepackage{epsf}
\usepackage{rotating}
%\usepackage{color}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{pifont}
\usepackage{latexsym}
\usepackage[english]{babel}
\usepackage{epstopdf}
\usepackage{etoolbox}
%\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multirow,epstopdf}
%\usepackage{cite}
\usepackage{fancyhdr}
\usepackage{booktabs}
%\usepackage[most]{tcolorbox}
\definecolor{LightGray}{HTML}{EEEEEE}
\usepackage{cleveref}
\usepackage{todonotes}
%\pagestyle{fancy}
\usepackage{minted}
\usepackage{cleveref}
\begin{document}
\section{First section}\label{sec1}.
Math is hard \cite{bertsekasII,rosolia2018data,herlau} as can also be seen from \cref{eq1} and from \cref{fig1}.
\begin{equation}
2+2 = 4 \label{eq1}
\end{equation}
\begin{figure}\centering
\includegraphics[width=.8\linewidth]{br}\caption{A figure}\label{fig1}
\end{figure}
\bibliographystyle{alpha}
\bibliography{library}
\end{document}
\ No newline at end of file
@unpublished{herlau,
author = {Tue Herlau},
title = {Sequential Decision Making},
year = {2021},
note = {(See \textbf{02465\_Notes.pdf})}
}
@misc{brown2020combining,
title={Combining Deep Reinforcement Learning and Search for Imperfect-Information Games},
author={Noam Brown and Anton Bakhtin and Adam Lerer and Qucheng Gong},
year={2020},
eprint={2007.13544},
archivePrefix={arXiv},
primaryClass={cs.GT}
}
@unpublished{aa203,
author = {James Harrison},
title = {Optimal and Learning-based Control Combined Course Notes},
year = {2020},
note = {(See \textbf{AA203combined.pdf})},
url = {https://github.com/StanfordASL/AA203-Notes/}
}
@book{bertsekasII,
author = {Bertsekas, Dimitri P.},
title = {Dynamic Programming and Optimal Control, Vol. II},
year = {2007},
isbn = {1886529302},
publisher = {Athena Scientific},
edition = {3rd},
abstract = {A major revision of the second volume of a textbook on the far-ranging algorithmic methododogy of Dynamic Programming, which can be used for optimal control, Markovian decision problems, planning and sequential decision making under uncertainty, and discrete/combinatorial optimization. The second volume is oriented towards mathematical analysis and computation, and treats infinite horizon problems extensively. New features of the 3rd edition are: 1) A major enlargement in size and scope: the length has increased by more than 50%, and most of the old material has been restructured and/or revised. 2) Extensive coverage (more than 100 pages) of recent research on simulation-based approximate dynamic programming (neuro-dynamic programming), which allow the practical application of dynamic programming to large and complex problems. 3) An in-depth development of the average cost problem (more than 100 pages), including a full analysis of multichain problems, and an extensive analysis of infinite-spaces problems. 4) An introduction to infinite state space stochastic shortest path problems. 5) Expansion of the theory and use of contraction mappings in infinite state space problems and in neuro-dynamic programming. 6) A substantive appendix on the mathematical measure-theoretic issues that must be addressed for a rigorous theory of stochastic dynamic programming. Much supplementary material can be found in the book's web page: http://www.athenasc.com/dpbook.html}
}
@article{rosolia2018data,
title={Data-driven predictive control for autonomous systems},
author={Rosolia, Ugo and Zhang, Xiaojing and Borrelli, Francesco},
journal={Annual Review of Control, Robotics, and Autonomous Systems},
volume={1},
pages={259--286},
year={2018},
publisher={Annual Reviews}
}
@article{rosolia2017learning2,
title={Learning model predictive control for iterative tasks: A computationally efficient approach for linear system},
author={Rosolia, Ugo and Borrelli, Francesco},
journal={IFAC-PapersOnLine},
volume={50},
number={1},
pages={3142--3147},
year={2017},
publisher={Elsevier}
}
@article{rosolia2017learning,
title={Learning model predictive control for iterative tasks. a data-driven control framework},
author={Rosolia, Ugo and Borrelli, Francesco},
journal={IEEE Transactions on Automatic Control},
volume={63},
number={7},
pages={1883--1896},
year={2017},
publisher={IEEE}
}
@book{caldentey,
author = {René Caldentey},
publisher = {Stern School of Business, New York University},
title = {Dynamic Programming with Applications},
year = {2011},
note= {(see \textbf{caldentey.pdf})},
url = {http://people.stern.nyu.edu/rcaldent/courses/DP-ClassNotes-HEC.pdf}
}
@book{herlau02450,
author = {Herlau, Tue and Mørup, Morten and Schmidt, Mikkel N.},
publisher = {02450 Lecture notes},
title = {Introduction to Machine Learning and Data Mining},
year = {2020},
note= {(See \textbf{02450Book.pdf})},
}
@inproceedings{rosolia,
title={Autonomous racing using learning model predictive control},
author={Rosolia, Ugo and Carvalho, Ashwin and Borrelli, Francesco},
booktitle={2017 American Control Conference (ACC)},
pages={5115--5120},
year={2017},
organization={IEEE},
note= {(See \textbf{rosolia2017.pdf})},
}
@book{sutton,
added-at = {2019-07-13T10:11:53.000+0200},
author = {Sutton, Richard S. and Barto, Andrew G.},
edition = {Second},
keywords = {},
publisher = {The MIT Press},
timestamp = {2019-07-13T10:11:53.000+0200},
title = {Reinforcement Learning: An Introduction},
url = {http://incompleteideas.net/book/the-book-2nd.html},
year = {2018 },
note= {(See \textbf{sutton2018.pdf})},
}
@unpublished{cemgil,
author = {Ali Taylan Cemgil},
title = {A Tutorial Introduction to Monte Carlo methods, Markov Chain Monte Carlo and Particle Filtering},
year = {2012},
note = {(See \textbf{cemgil2012.pdf})},
url = {https://www.cmpe.boun.edu.tr/~cemgil/Courses/cmpe548/cmpe58n-lecture-notes.pdf},
}
@article{kelly,
title={An introduction to trajectory optimization: How to do your own direct collocation},
author={Kelly, Matthew},
journal={SIAM Review},
volume={59},
number={4},
pages={849--904},
year={2017},
publisher={SIAM},
url = {https://epubs.siam.org/doi/pdf/10.1137/16M1062569},
note = {(See \textbf{kelly2017.pdf})},
}
@article{bertsekas,
title={Reinforcement learning and optimal control},
author={Bertsekas, Dimitri P},
journal={Athena Scientific},
year={2019},
url={http://web.mit.edu/dimitrib/www/RL_1-SHORT-INTERNET-POSTED.pdf},
note= {(See \textbf{bertsekas2019.pdf})},
}
@inproceedings{tassa,
title={Synthesis and stabilization of complex behaviors through online trajectory optimization},
author={Tassa, Yuval and Erez, Tom and Todorov, Emanuel},
booktitle={2012 IEEE/RSJ International Conference on Intelligent Robots and Systems},
pages={4906--4913},
year={2012},
organization={IEEE},
url={https://ieeexplore.ieee.org/abstract/document/6386025},
note= {(See \textbf{tassa2012.pdf})},
}
@book{betts2010practical,
title={Practical methods for optimal control and estimation using nonlinear programming},
author={Betts, John T},
volume={19},
year={2010},
publisher={Siam}
}
@book{bertsekas1995dynamic,
title={Dynamic programming and optimal control},
author={Bertsekas, Dimitri P and Bertsekas, Dimitri P and Bertsekas, Dimitri P and Bertsekas, Dimitri P},
volume={1},
number={2},
year={1995},
publisher={Athena scientific Belmont, MA}
}
@article{bellman1957markovian,
title={A Markovian decision process},
author={Bellman, Richard},
journal={Journal of mathematics and mechanics},
pages={679--684},
year={1957},
publisher={JSTOR}
}
@inproceedings{bertsekas2010distributed,
title={Distributed asynchronous policy iteration in dynamic programming},
author={Bertsekas, Dimitri P and Yu, Huizhen},
booktitle={2010 48th Annual Allerton Conference on Communication, Control, and Computing (Allerton)},
pages={1368--1375},
year={2010},
organization={IEEE}
}
@inproceedings{Gal2016,
title={Improving {PILCO} with {B}ayesian neural network dynamics models},
author={Gal, Yarin and McAllister, Rowan and Rasmussen, Carl Edward},
booktitle={Data-Efficient Machine Learning workshop, International Conference on Machine Learning},
year={2016},
note= {(See \textbf{gal2016.pdf})},
}
@book{bertsekasvolI,
title={Dynamic Programming and Optimal Control},
author={Bertsekas, D.P.},
number={v. 1},
isbn={9781886529267},
lccn={lc00091281},
series={Athena Scientific optimization and computation series},
year={2005},
publisher={Athena Scientific}
}
@book{russell2002artificial,
title={Artificial Intelligence: a modern approach},
author={Russell, Stuart J. and Norvig, Peter},
edition={3},
year={2009},
publisher={Pearson}
}
% Deep learning related
@inproceedings{hessel2018rainbow,
title={Rainbow: Combining improvements in deep reinforcement learning},
author={Hessel, Matteo and Modayil, Joseph and Van Hasselt, Hado and Schaul, Tom and Ostrovski, Georg and Dabney, Will and Horgan, Dan and Piot, Bilal and Azar, Mohammad and Silver, David},
booktitle={Thirty-Second AAAI Conference on Artificial Intelligence},
year={2018}
}
@article{wang2015dueling,
title={Dueling network architectures for deep reinforcement learning},
author={Wang, Ziyu and Schaul, Tom and Hessel, Matteo and Van Hasselt, Hado and Lanctot, Marc and De Freitas, Nando},
journal={arXiv preprint arXiv:1511.06581},
year={2015}
}
% MC intro chapter:
@article{metropolisrrtt53,
added-at = {2011-05-09T23:10:52.000+0200},
author = {Metropolis, A. W. and Rosenbluth, A. W. and Rosenbluth, M. N. and Teller, A. H. and Teller, E.},
biburl = {https://www.bibsonomy.org/bibtex/24b3752b2936a9c524e2f0ca70e63d537/josephausterwei},
interhash = {09015548d3568943e67d50619297521e},
intrahash = {4b3752b2936a9c524e2f0ca70e63d537},
journal = {Journal of Chemical Physics},
keywords = {imported},
pages = {1087-1092},
timestamp = {2011-05-10T10:42:42.000+0200},
title = {Equations of state calculations by fast computing machines},
volume = 21,
year = 1953
}
@book{brooksmcbook,
added-at = {2019-11-27T16:57:20.000+0100},
author = {Brooks, Steve and Gelman, Andrew and Jones, Galin L. and Meng, Xiao-Li},
biburl = {https://www.bibsonomy.org/bibtex/221d785dfbbec4874e3aa0b1e4df45639/kirk86},
description = {Handbook of Markov Chain Monte Carlo},
interhash = {0b127e40d41a970274484b65a7e0744f},
intrahash = {21d785dfbbec4874e3aa0b1e4df45639},
keywords = {book mcmc},
timestamp = {2019-11-27T16:59:18.000+0100},
title = {Handbook of Markov Chain Monte Carlo
},
publisher={Chapman \& Hall},
url = {http://www.mcmchandbook.net/HandbookTableofContents.html},
year = 2011
}
@book{GVK516124188,
added-at = {2009-08-21T12:21:08.000+0200},
address = {Singapore [u.a.]},
author = {Rosenthal, {Jeffrey S.}},
biburl = {https://www.bibsonomy.org/bibtex/21ebbf183aa3295652ca2ac4e29dea8a8/fbw_hannover},
edition = {Reprinted},
interhash = {6b3625b54aac7aa32af07e7d91994cd3},
intrahash = {1ebbf183aa3295652ca2ac4e29dea8a8},
isbn = {9810243030},
keywords = {Wahrscheinlichkeitsrechnung Wahrscheinlichkeitstheorie},
pagetotal = {XIV, 177},
ppn_gvk = {516124188},
publisher = {World Scientific},
timestamp = {2009-08-21T12:21:56.000+0200},
title = {A first look at rigorous probability theory},
url = {http://gso.gbv.de/DB=2.1/CMD?ACT=SRCHA&SRT=YOP&IKT=1016&TRM=ppn+516124188&sourceid=fbw_bibsonomy},
year = 2005
}
@article{MET49,
added-at = {2009-03-03T17:19:04.000+0100},
author = {Metropolis, N. and Ulam, S.},
biburl = {https://www.bibsonomy.org/bibtex/23a9872b3a3572e446d5cedf42f2dc7d3/bronckobuster},
interhash = {f23e8d1798ee5feb71cd41eea30d830d},
intrahash = {3a9872b3a3572e446d5cedf42f2dc7d3},
journal = {J.~Am.~Stat.~Assoc.},
keywords = {imported},
nota = {mm:},
pages = 335,
timestamp = {2009-03-03T17:19:30.000+0100},
title = {The Monte Carlo method},
volume = 44,
year = 1949
}
import os
def reference_example():
# Load references and insert them.
from snipper.citations import get_bibtex, get_aux #!s=a
bibfile = "latex/library.bib"
auxfile = 'latex/index.aux'
bibtex = get_bibtex(bibfile)
aux = get_aux(auxfile) #!s
print(list(bibtex.keys())[:5])
print(aux)
from snipper.fix_cite import fix_aux, fix_aux_special, fix_bibtex
from snipper.fix_s import save_s
file = "citations.py" #!s=b
with open(file, 'r') as f:
lines = f.read().splitlines()
lines = fix_aux(lines, aux=aux)
lines = fix_aux_special(lines, aux=aux, command='\\nref', bibref='herlau')
lines = fix_bibtex(lines, bibtex=bibtex)
with open('output/citations.py', 'w') as f:
f.write("\n".join(lines)) #!s=b
# save_s(lines, output_dir="./output", file_path=file)
with open(__file__, 'r') as f:
save_s(f.read().splitlines(), output_dir="./output", file_path=os.path.basename(__file__) )
if __name__ == "__main__":
reference_example()
\ No newline at end of file
"""
{{copyright}}
References:
[Ber07] Dimitri P. Bertsekas. Dynamic Programming and Optimal Control, Vol. II. Athena Scientific, 3rd edition, 2007. ISBN 1886529302.
[Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021.
"""
def myfun(): #!s
"""
To solve this exercise, look at eq. (1) in Section 1.
You can also look at (Ber07) and (Her21)
More specifically, look at (Ber07, Equation 117) and (Her21, Figure 1)
We can also write a special tag to reduce repetition: (Her21, Figure 1) and (Her21, Section 1).
"""
return 42 #!s
\ No newline at end of file
# load_references.py
from snipper.citations import get_bibtex, get_aux
bibfile = "latex/library.bib"
auxfile = 'latex/index.aux'
bibtex = get_bibtex(bibfile)
aux = get_aux(auxfile)
\ No newline at end of file
# load_references.py
file = "citations.py"
with open(file, 'r') as f:
lines = f.read().splitlines()
lines = fix_aux(lines, aux=aux)
lines = fix_aux_special(lines, aux=aux, command='\\nref', bibref='herlau')
lines = fix_bibtex(lines, bibtex=bibtex)
with open('output/citations.py', 'w') as f:
f.write("\n".join(lines))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment