11 import java.io.IOException;
31 import org.apache.commons.math.ode.DerivativeException;
32 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
58 private double[] mu = null;
59 private int inidx = -1;
63 this.inidx = InputIdx;
81 Util.vecAdd(xDot, f.evaluate(t, x, mu));
83 Util.vecAdd(xDot, B.evaluate(t, mu).operate(
u.
evaluate(t, inidx)));
101 res.dim = Integer.parseInt(mng.getModelXMLTagValue(
"dim"));
105 loadCoreFun(mng, res);
107 loadInputs(mng, res);
109 loadMassMatrix(mng, res);
111 if (
"dscomponents.LinearOutputConv".equals(mng.getModelXMLTagValue(
"outputconvtype"))) {
115 if (
"dscomponents.ConstInitialValue".equals(mng.getModelXMLTagValue(
"initialvaluetype"))) {
116 res.x0 =
new ConstInitialValue(r.readRawDoubleVector(mng.getInStream(
"x0.bin")));
126 if (mng.xmlTagExists(
"kermor_model.inputconv")) {
128 hlp = mng.getModelXMLAttribute(
"type",
"kermor_model.inputconv");
129 if (
"dscomponents.LinearInputConv".equals(hlp)) {
131 }
else if (
"dscomponents.AffLinInputConv".equals(hlp)) {
132 IAffineCoefficients coeff = null;
133 coeff = (IAffineCoefficients) mng.loadModelClass(mng.getModelXMLTagValue(
"inputconv.coeffclass"));
134 AffParamMatrix a =
new AffParamMatrix(r.
readMatrix(mng.getInStream(
"B.bin")), res.dim, coeff);
135 res.B =
new AffineInputConv(a);
140 private static void loadCoreFun(AModelManager mng, ReducedSystem res)
throws IOException, MathReaderException,
141 ModelManagerException {
142 MathObjectReader r = mng.getMathObjReader();
143 String type = mng.getModelXMLAttribute(
"type",
"corefun");
144 if (
"dscomponents.ParamTimeKernelCoreFun".equals(type)) {
145 KernelExpansion k =
new KernelExpansion();
146 k.ma = r.readMatrix(mng.getInStream(
"Ma.bin"));
148 k.StateKernel = loadKernel(mng,
"statekernel",
"kernel.bin");
149 k.xi = r.readMatrix(mng.getInStream(
"xi.bin"));
152 k.TimeKernel = loadKernel(mng,
"timekernel",
"timekernel.bin");
153 k.ti = r.readVector(mng.getInStream(
"ti.bin"));
156 k.ParamKernel = loadKernel(mng,
"paramkernel",
"paramkernel.bin");
157 k.mui = r.readMatrix(mng.getInStream(
"mui.bin"));
161 }
else if (
"dscomponents.LinearCoreFun".equals(type)) {
162 res.f =
new LinearCoreFun(r.
readMatrix(mng.getInStream(
"A.bin")));
163 }
else if (
"dscomponents.AffLinCoreFun".equals(type)) {
164 IAffineCoefficients coeff = null;
165 coeff = (IAffineCoefficients) mng.loadModelClass(mng.getModelXMLTagValue(
"corefun.coeffclass"));
166 AffParamMatrix a =
new AffParamMatrix(r.
readMatrix(mng.getInStream(
"A.bin")), res.dim, coeff);
167 res.f =
new AffParamTimeCoreFun(a);
169 throw new RuntimeException(
"Unknown core function type: " + type);
173 private static void loadMassMatrix(AModelManager mng, ReducedSystem res)
throws IOException, ModelManagerException {
175 MathObjectReader r = mng.getMathObjReader();
177 if (mng.xmlTagExists(
"kermor_model.massmatrix")) {
178 hlp = mng.getModelXMLAttribute(
"type",
"kermor_model.massmatrix");
179 if (
"dscomponents.ConstMassMatrix".equals(hlp)) {
180 res.M =
new ConstMassMatrix(r.readMatrix(mng.getInStream(
"M.bin")));
181 }
else if (
"dscomponents.AffLinMassMatrix".equals(hlp)) {
182 IAffineCoefficients coeff = (IAffineCoefficients) mng.loadModelClass(mng
183 .getModelXMLTagValue(
"massmatrix.coeffclass"));
184 AffParamMatrix a =
new AffParamMatrix(r.readMatrix(mng.getInStream(
"B.bin")), res.dim, coeff);
185 res.B =
new AffineInputConv(a);
186 throw new RuntimeException(
"Not yet fully implemented.");
191 private static IKernel loadKernel(AModelManager mng, String typestr, String datafile)
throws MathReaderException,
194 MathObjectReader r =
new MathObjectReader();
195 String type = mng.getModelXMLTagValue(typestr);
196 if (
"kernels.GaussKernel".equals(type)) {
197 double[] g = r.readRawDoubleVector(mng.getInStream(datafile));
198 res =
new GaussKernel(g[0]);
199 }
else if (
"kernels.LinearKernel".equals(type)) {
200 res =
new LinearKernel();
void setConfig(double[] mu, int InputIdx)
Implements a constant mass matrix of the dynamical system.
Interface for kernel implementations in JKerMor.
Constant linear output conversion .
Base class for implementation of a series of time/parameter-dependent affine coefficients.
Reading matrices and vectors with a bunch of convenient overloads for different sources and output fo...
Implementation of the Gaussian kernel .
Interface for initial values of dynamical systems.
Constant linear dynamical system core function .
Interface for dynamical system mass matrices .
This class serves as base class for accessing various types of models at different locations...
RealMatrix readMatrix(InputStream in)
Reads a matrix from an InputStream, pointing to a binary file.
Represents a constant initial value for dynamical systems.
This Exception gets thrown when an error occurs regarding the functionality of the ModelManager...
Implements a kernel expansion with optional time kernel and parameter kernel .
Interface for any dynamical system core function.
static ReducedSystem load(AModelManager mng)
Affine parametric matrix class.
This class implements a time/parameter-affine linear core function .
Interface for dynamical system output conversion matrices .
Main reduced dynamical system class.
Implements a linear scalar product kernel .
void computeDerivatives(double t, double[] x, double[] xDot)