Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build-bib, build-latex] Solver + consistency section, fix bug with backslash plague in bib file #101

Merged
merged 9 commits into from
Mar 19, 2024
20 changes: 17 additions & 3 deletions .utils/biblatex_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,26 @@ def merge_bib(path):
return filtered_bib_data


def save_bib(bib_data, file):
bib_data.to_file(file, bib_format="bibtex")
def save_bib(bib_data, file, manual_backslash_plague_fix=True):
if manual_backslash_plague_fix:
astr = bib_data.to_string(bib_format='bibtex')
astr = astr.replace("\\\\\\\&", "\&")
astr = astr.replace("\\\\\\&", "\&")
astr = astr.replace("\\\\\&", "\&")
astr = astr.replace("\\\\&", "\&")
astr = astr.replace("\\\&", "\&")
astr = astr.replace("\\&", "\&")
# astr = astr.replace("\_", "_")
# astr = astr.replace("\&", "&")
# astr = astr.replace("\%", "%")
with open(file, "w") as f_handle:
f_handle.write(astr)
else:
bib_data.to_file(file, bib_format="bibtex")


if __name__ == "__main__":
working_directory = sys.argv[1]
output_file = sys.argv[2]
filtered_bib_data = merge_bib(working_directory)
save_bib(filtered_bib_data, output_file)
save_bib(filtered_bib_data, output_file, manual_backslash_plague_fix=True)
Binary file modified main.pdf
Binary file not shown.
5 changes: 1 addition & 4 deletions tex/appendix/lagrangian.tex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ \subsubsection{Discrete adjoint}
Given that for every choice of the parameter $\theta$ we have $G(U; \theta) = 0$, we have that $I(U, \theta) = L(U, \theta)$.
Then, the gradient of $L$ with respect to the vector parameter $\theta$ can be computed as
\begin{align}
\begin{split}
\frac{dL}{d\theta}
=
\frac{dI}{d\theta}
Expand All @@ -33,9 +32,7 @@ \subsubsection{Discrete adjoint}
&=
\frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U}
+
\left( \frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U} \right) \frac{\partial U}{\partial \theta}.
\end{split}
\label{eq:appendix-discrete-adjoint}
\left( \frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U} \right) \frac{\partial U}{\partial \theta}. \label{eq:appendix-discrete-adjoint}
\end{align}
The important trick in the last term involved grouping all the terms involving the sensitivity $\frac{\partial U}{\partial \theta}$ together.
In order to avoid the computation of the sensitivity at all, we can define $\lambda$ as the vector that makes the last term in the right hand side of Equation \eqref{eq:appendix-discrete-adjoint} which results in the same results we obtained in Equation \eqref{eq:adjoint-state-equation} and \eqref{eq:def_adjoint}, that is,
Expand Down
Loading