\newpage

\subsection{package PIANOS.generator}

This package contains classes that generate different parts of the Fortran program.

\subsubsection{FortranMain}

This class generates the Fortran module main (see \ref{modulemain}). 

\vspace{.5cm}
\textbf{Public methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateMain (String callParameters, ComputationalModel model) throws IOException, InvalidModelException, IllegalParametersException, MissingFunctionException & void & Generates and writes the Fortran module main.f90. \\
\hline
\end{tabular}
\vspace{.5cm}

\textbf{Private methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateUpdateOne (String parameters, ComputationalModel model)  & ArrayList<String> & Generates the subroutine update\_one. Note: This method has not been implemented and it does nothing! \\
\hline
generateUpdateAll (String parameters, ComputationalModel model) throws InvalidModelException, IllegalParametersException, MissingFunctionException & ArrayList<String> & Generates the subroutine update\_all. \\
\hline
setSpatialStartValue (Variable var) throws InvalidModelException & ArrayList<String> & Generates code that calculates the initial value for a spatial variable var. \\
\hline
setFunctionalStartValue (Variable var) & ArrayList<String> & Generates code that calculates the initial value for a functional non-spatial variable var. \\
\hline
\end{tabular}

\newpage
\subsubsection{Acceptation}

Acceptation generates parts of the subroutine update\_all: new value generation, acceptation formulae and acceptation codes (things to do when a proposal is accepted). FortranMain calls the methods of this class.

\vspace{.5cm}
\textbf{Public methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
setTopologicalList (ArrayList<Variable> list) & void & Sets the topological variable list needed in the following methods. This method should be called before calling any other methods of this class.\\
\hline
generateNewValueCode (Variable variable) & ArrayList<String> & Generates code that fetches a proposed new value for a parameter from its buffer or if the buffer is empty, calls the Fortran subroutine `generate'.\\
\hline
generateNewValues FunctionalCode(Variable variable) throws InvalidModelException & ArrayList<String> & Generates code that calculates new values for functional parameters depending on the variable. \\
\hline
generateAcceptationFormula (Variable variable) throws InvalidModelException & ArrayList<String> & Generates code that calculates the acceptation probability for the new value.\\
\hline
generateAcceptationCode (Variable variable, String strategy) throws InvalidModelExcpetion & ArrayList<String> & Generates code that decides whether the new value is accepted and makes the necessary changes: updates the value of the current parameter and all functional parameters depending on it. \\
\hline
\end{tabular}

\vspace{.5cm}
\textbf{Private methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateSpatialDeps (Variable functional, String indexing, boolean spatialY) & ArrayList<String> & Sets correct indexing for functional variables with spatial dependencies.  For example: q = sum(\&x) and p = q/2.0. When x is updated (the spatial target) first q is calculated for all neighbours of x, then all neighbours of x get a new p to match their new q values. This method is used when generating the new value calculation for p. This methods doesn't generate any loops.\\
\hline
\end{tabular}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
acceptationAffectedOf (Variable variable, Variable depending) & ArrayList<String> & Generates code which updates the value of depending when the value of variable is accepted. Depending is assumed to be non-spatial.\\
generateUpdateOneFunctional (Variable depending) & ArrayList<String> & Generates code that replaces the value of depending with its new value.\\
\hline
generateNewValueForOne Functional (Variable functional, Set<Variable> newToBeUsed) throws InvalidModelException & ArrayList<String> & Generates code which calculates the new value for functional by using the new values of the variables belonging to the set newToBeUsed and the current values of other variables. \\
\hline
generateAcceptationFormula Global (Variable variable) & ArrayList<String> & Generates code that calculates the acceptation probability for a global variable. \\
\hline
generateAcceptationFormula OneDimensional (Variable variable) & ArrayList<String> & Generates code that calculates the acceptation probability for an one-dimensional variable. \\
\hline
generateAcceptationFormula TwoDimensional (Variable variable) & ArrayList<String> & Generates code that calculates the acceptation probability for a two-dimensional variable. \\
\hline
generateLikelihoodFormula Global (Variable depending, Set<Variable> newToBeUsed) & ArrayList<String> & Generates code that calculates the likelihood probability of a global variable depending by using new values of the variables belonging to newToBeUsed, that is: P(depending | new values of variables in newToBeUsed) / P(depending | values of variables in newToBeUsed). \\
\hline
generateLikelihoodFormula OneDimensional (Variable depending, Set<Variable> newToBeUsed) & ArrayList<String> & Generates code that calculates the likelihood probability of an one-dimensional variable depending by using new values of the variables belonging to newToBeUsed, that is: P(depending | new values of variables in newToBeUsed) / P(depending | values of variables in newToBeUsed). \\
\hline
generateLikelihoodFormula TwoDimensional (Variable depending, Set<Variable> newToBeUsed) & ArrayList<String> & Generates code that calculates the likelihood probability of a two-dimensional variable depending by using new values of the variables belonging to newToBeUsed, that is: P(depending | new values of variables in newToBeUsed) / P(depending | values of variables in newToBeUsed). \\
\hline
generateTransitionFormula (Variable variable) & ArrayList<String> & Generates code that calculates the transition probability for variable, that is q(variable', variable) / q(variable, variable'). \\
\hline
\end{tabular}

\newpage
\subsubsection{Input}

This class is used to generate the Fortran module `input'. See \ref{moduleinput}.

\vspace{.5cm}
\textbf{Public methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateInput (String callParameters, ComputationalModel model) throws IOException, SyntaxException & void & Generates and writes the Fortran module input.f90. \\
\hline
\end{tabular}

\vspace{.5cm}
\textbf{Private methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateReadData (LinkedList<Variable> variables, LinkedList<Entity> entities, String callParameters) throws SyntaxException & ArrayList<String> & Generates the subroutine read\_data. \\
\hline
generateSetInitialValues (String file, LinkedList<Variable> variables, LinkedList<Entity> entities, String callParameters) & ArrayList<String> & Generates the subroutine setInitialValues. \\
\hline
generateReadSpatial (int neighbours, LinkedList<Entity> entities & ArrayList<String> & Generates the subroutine set\_spatial. \\
\hline
\end{tabular}

\subsubsection{Output}

This class is used to generate the Fortran module `output'. See \ref{moduleoutput}.

\vspace{.5cm}
\textbf{Public methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateOutput (String callParameters, ComputationalModel model) throws IOException & void & Generates and writes the Fortran module output.f90. \\
\hline
\end{tabular}

\newpage
\textbf{Private methods}

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateWriteOutput (ComputationalModel model, String callParameters) & ArrayList<String> & Generates the subroutine write\_output. \\
\hline
generateWriteSummary (ComputationalModel model, String callParameters) & ArrayList<String> & Generates the subroutine write\_summary. \\
\hline
generateWriteLastValues (ComputationalModel model, String callParameters) & ArrayList<String> & Generates the subroutine write\_last\_values. \\
\hline
\end{tabular}

\subsubsection{Proposal}

This class is used to generate the Fortran module `proposal'. See \ref{moduleproposal}.

\begin{tabular}[]{| p{5.5cm} | l | p{7.5cm} |}
\hline
\textbf{Operation}&\textbf{Return type}&\textbf{Description} \\
\hline
generateProposal (ComputationalModel model) throws InvalidProposalException, IllegalParametersException, MissingFunctionException, IOException & void & Generates and writes the Fortran module proposal.f90. \\
\hline
\end{tabular}
