6 import java.io.BufferedReader;
7 import java.io.IOException;
8 import java.lang.reflect.InvocationTargetException;
9 import java.lang.reflect.Method;
11 import org.apache.commons.math.linear.RealVector;
29 private static final String DEBUG_TAG =
"QNTransientSCMSystem";
39 private double[][] C_J_RB_coeffs;
44 private RealVector current_RB_coeffs;
47 private RealVector saved_RB_coeffs;
50 private double SCM_theta_c_scaling;
67 current_RB_coeffs = RB_coeffs;
78 Class<?> partypes[] =
new Class[1];
79 partypes[0] =
double[].class;
81 meth = sys.oldAffFcnCl.getMethod(
"evaluateC", partypes);
82 }
catch (NoSuchMethodException nsme) {
83 throw new RuntimeException(
"getMethod for evaluateC failed", nsme);
88 Object arglist[] =
new Object[1];
89 arglist[0] = sys.getParams().getCurrent();
91 Object theta_obj = meth.invoke(sys.oldAffFcnObj, arglist);
92 theta_val = (Double) theta_obj;
93 }
catch (IllegalAccessException iae) {
94 throw new RuntimeException(iae);
95 }
catch (InvocationTargetException ite) {
96 throw new RuntimeException(ite.getCause());
99 return SCM_theta_c_scaling * theta_val.doubleValue();
118 return current_RB_coeffs.getEntry(q) * theta_c_value;
124 Class<?> partypes[] =
new Class[2];
125 partypes[0] = Integer.TYPE;
126 partypes[1] =
double[].class;
128 meth = sys.oldAffFcnCl.getMethod(
"evaluateA", partypes);
129 }
catch (NoSuchMethodException nsme) {
130 throw new RuntimeException(
"getMethod for evaluateA failed", nsme);
135 Object arglist[] =
new Object[2];
137 arglist[1] = sys.getParams().getCurrent();
139 Object theta_obj = meth.invoke(sys.oldAffFcnObj, arglist);
140 theta_val = (Double) theta_obj;
141 }
catch (IllegalAccessException iae) {
142 throw new RuntimeException(iae);
143 }
catch (InvocationTargetException ite) {
144 throw new RuntimeException(ite.getCause());
147 return theta_val.doubleValue();
156 super.get_current_parameters_from_C_J(index);
159 current_RB_coeffs.setEntry(i, C_J_RB_coeffs[index][i]);
167 super.save_current_parameters();
169 saved_RB_coeffs = current_RB_coeffs.copy();
177 super.reload_current_parameters();
190 BufferedReader reader = m.getBufReader(
"n_bfs.dat");
192 String line = reader.readLine();
196 n_bfs = Integer.parseInt(line);
198 Log.d(DEBUG_TAG,
"Finished reading n_bfs.dat");
201 super.loadOfflineData(m);
209 BufferedReader reader = m.getBufReader(
"C_J_RB_coeffs.dat");
210 String line = reader.readLine();
213 tokens = line.split(
" ");
217 for (
int i = 0; i < C_J_stability_vector.length; i++) {
219 C_J_RB_coeffs[i][j] = Double.parseDouble(tokens[count]);
224 Log.d(DEBUG_TAG,
"Finished reading C_J_RB_coeffs.dat");
235 super.readConfiguration(m);
237 SCM_theta_c_scaling = infile.call(
"SCM_theta_c_scaling", 1.);
238 Log.d(DEBUG_TAG,
"SCM_theta_c_scaling = " + SCM_theta_c_scaling);
void save_current_parameters()
Override to also save the RB coefficients.
void set_n_basis_functions(int n_bfs_in)
Base class for quadratically nonlinear RB systems including the SCM method for error bound computatio...
void loadOfflineData(AModelManager m)
Override read_offline_data in order to read in the extra data in the QNTransient case.
Utility helper class from rbAppMIT included for compatibility of rbAppMIT model loading.
double eval_theta_c()
Evaluate theta_c (for the quadratic nonlinearity) at the current parameter.
This class provides the Online stage for the reduced basis method for elliptic steady state problems...
void set_current_RB_coeffs(RealVector RB_coeffs)
Set the current RB coefficients.
int get_n_basis_functions()
Get/set the number of basis functions.
QNTransientSCMSystem(RBSystem sys)
void reload_current_parameters()
Override to also load the RB coefficients.
This class implements the Online stage of the Successive Constraint Method for coercive problems...
This class serves as base class for accessing various types of models at different locations...
void readConfiguration(AModelManager m)
Provides a Log class imitating the Android Log class when not used on android systems.
double[] C_J_stability_vector
The values of the stability factor at the greedily selected parameters.
static final String parameters_filename
Inherited from the rbAppMIT models to read the model parameters.
double thetaQa(int q)
Override eval_theta_q_a in order to account for the affine terms related to basis functions...
int getQa()
Override get_Q_a since we have n_bfs extra terms.
Exception imported from rbappmit.
Class with constants used throughout JRB.
void get_current_parameters_from_C_J(int index)
Override to also load the RB coefficients.