Function newton_rootfinder::xml_parser::from_xml_jacobian
source · [−]pub fn from_xml_jacobian(
filepath: &str
) -> (SolverParameters, Vec<IterativeParams>, Vec<NormalizationMethod>, Vec<NormalizationMethod>)
Expand description
Parser for a solver operating with a model with the jacobian provided
XML structure
Root
It is expected to be an .xml
document with a root node called nrf
(newton root finder)
Three child nodes are expected:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<nrf>
<solver>...</solver>
<iteratives>...</iteratives>
<residuals>...</residuals>
</nrf>
Solver node
The <solver> node contains must contains the parameters of the SolverParameters struct, i.e :
- max_iter
- damping (true or false)
- tolerance
- problem_size
- resolution_method: (see crate::solver::ResolutionMethod)
- “NR” for Newton-Raphson
- “SN” for Stationary Newton
- “BROY1” for Broyden First Method approximating the jacobian
- “BROY2” for Broyden Second Method approximating the jacobian
- “GRST1” for Greenstadt First Method approximating the jacobian
- “GRST2” for Greenstadt Second Method approximating the jacobian
- “BROY1_INV” for Broyden First Method approximating the inverse jacobian
- “BROY2_INV” for Broyden Second Method approximating the inverse jacobian
- “GRST1_INV” for Greenstadt First Method approximating the inverse jacobian
- “GRST2_INV” for Greenstadt Second Method approximating the inverse jacobian
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<nrf>
<solver problem_size="2" max_iter="60" tolerance="1e-6" damping="true" resolution_method="NewtonRaphson"/>
<iteratives>...</iteratives>
<residuals>...</residuals>
</nrf>
Iteratives node
The <iteratives> node contains all the default values for the parameters of the IterativeParams
constructor:
- min_value
- max_value
- max_step_abs
- max_step_rel
Its childen will be the
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<nrf>
<solver>...</solver>
<iteratives min_value="-inf" max_value="inf" max_step_abs="inf" max_step_rel="inf">
<iterative id="0">
<iterative id="1" max_step_abs="100">
</iteratives>
<residuals>...</residuals>
</nrf>
The first one will take the default values, the second also except for max_step_abs that will be equal to 100.
Residuals node
The <residuals> node contains all the default values for the parameters of the ResidualConfig
constructor:
- stopping_criteria
- update_method
Its childen will be the
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<nrf>
<solver>...</solver>
<iteratives>...</iteratives>
<residuals stopping_criteria="Adapt" update_method="Abs">
<residual id="0">
<residual id="1" stopping_criteria="Abs">
</residuals>
</nrf>
The first one will take the default values, the second also except for stopping_criteria that will be equal to Abs.
Trick
You can add any attribute that is not used by the parser, for example if you want to name variables to recognize them:
<iterative id="0" var_name="myVarName">
Examples
use newton_rootfinder as nrf;
const FILEPATH: &'static str = "./my_path/my_configuration_file.xml";
let (solver_parameters, iteratives_vec, stopping_criterias, update_methods) =
nrf::xml_parser::from_xml_finite_diff(&FILEPATH);
let iteratives = nrf::iteratives::Iteratives::new(&iteratives_vec);
let residuals_config =
nrf::residuals::ResidualsConfig::new(&stopping_criterias, &update_methods);
let problem_size = solver_parameters.get_problem_size();
let init = nalgebra::DVector::zeros(5);
let mut rf = nrf::solver::RootFinder::new(
solver_parameters,
init,
&iteratives,
&residuals_config,
);