1 namespace spacereduction{
137 this.
registerProps(
" Eps ",
" MinRelImprovement ",
" MaxSubspaceSize ",
" InitialSpace ");
145 context =
" POD-Greedy ";
147 plotSummary@spacereduction.BaseSpaceReducer(
this, pm, context);
149 str = sprintf(
" %s: Error decay over training data\nEps:%g, MaxSize:%d, FXI: %d, FD: %d, BSpan: %d ",...
152 h = pm.nextPlot(
" podgreedy_gains ",str,
" subspace size ",
" Gain ");
155 warning(
" spacereduction:PODGreedy ",...
156 " Error data empty. Not providing summary. ");
170 bdata = data.JoinedBlockData(bdata, data.FinDiffBlockData(bdata));
173 bdata = data.JoinedBlockData(bdata, ...
179 error(
" No training fxi data found in ModelData. ");
193 o = general.Orthonormalizer;
198 fprintf(
" POD-Greedy: Computing initial space...\n ");
203 V = o.orthonormalize([V bdata.InputSpaceSpan(subset,:)]);
213 [err(end+1), idx] = this.getMaxErr(V(:,1:
k), bdata, subset);
223 x = bdata.getBlock(idx);
227 Vn = pod.computePOD(e);
228 V = o.orthonormalize([V Vn]);
229 [err(end+1), idx] = this.getMaxErr(V, bdata, subset);
231 impr(end+1) = (olderr-err(end))/olderr;
239 fprintf(
" POD-Greedy: Maximum predefined subspace size %d reached. Aborting.\n ",this.
MaxSubspaceSize);
242 fprintf(
" POD-Greedy: Maximum possible subspace size %d reached. Aborting.\n ",ss);
245 fprintf(
" POD-Greedy: Minimum relative improvement of %f not satisfied. Aborting.\n ",this.
MinRelImprovement);
248 fprintf(
" POD-Greedy: Finished with subspace size %d and error %e.\n ",size(V,2),err(end));
250 figure; subplot(1,2,1);
252 xlabel(
" POD-Greedy step "); ylabel(
" Error norms ");
253 title(
" L_2 norm sum over whole projection error trajectory vectors ");
256 xlabel(
" POD-Greedy step "); ylabel(
" Relative improvement ");
257 title(
" Error improvement relative to previous error ");
270 function [maxerr , midx ] = getMaxErr(V,md,reducable) {
276 fprintf(
" POD-Greedy: Computing maximum error over %d trajectories on %d workers for subspace size %d...\n ",n,matlabpool(
" size "),size(V,2));
283 hlp = sum(
Norm.
L2(x - V*(V^
t*x)));
285 fprintf(
" POD-Greedy: Error for block %d: %e\n ",i,hlp);
289 [maxerr, midx] = max(err);
291 for k=1:md.getNumBlocks;
294 e = sum(
Norm.
L2(x - V*(V^
t*x)));
302 fprintf(
" POD-Greedy: Max error with subspace size %d: %e\n ",size(V,2),maxerr);
316 m = models.BaseFullModel;
320 m.Sampler= sampling.GridSampler;
324 tg = spacereduction.PODGreedy;
328 m.ODESolver= solvers.ExplEuler(dt);
330 s = models.BaseFirstOrderSystem(m);
332 s.addParam(
" mu1 ",.5,
" Range ",[0 1],
" Desired ",4);
333 s.addParam(
" mu2 ",.6,
" Range ",[0 1],
" Desired ",5);
334 s.x0= dscomponents.ConstInitialValue(rand(dim,1)*5);
338 f = dscomponents.ParamTimeKernelCoreFun(m.System);
339 kexp = kernels.ParamTimeKernelExpansion;
340 kexp.Kernel= kernels.GaussKernel(40);
341 kexp.TimeKernel= kernels.NoKernel;
342 kexp.ParamKernel= kernels.GaussKernel(2);
343 kexp.Ma= rand(dim,sv);
344 kexp.Centers.xi= repmat(linspace(0,10,sv),dim,1);
345 kexp.Centers.ti= 1:sv;
346 kexp.Centers.mui= rand(2,sv);
350 m.offlineGenerations;
double Eps
The desired accuracy over all training trajectories.
matrix< double > InitialSpace
An initial space to use.
matrix< double > InputSpaceSpan
The orthonormalized vectors spanning the space of the input components.
The base class for any KerMor detailed model.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
PODGreedy: Greedy subspace computation over a fixed set of trajectories.
data.FileDataCollection TrajectoryFxiData
Evaluations of the system's nonlinearity on the trajectoriy data.
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
function plotSummary(pm, context)
ComputeParallel
Flag whether the code should be run in parallel or not.
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
integer MaxSubspaceSize
The maximum subspace size, EXCLUDING any non-reducable dimensions.
double MinRelImprovement
The minimum required relative error improvement compared to the previous error.
virtual function n = getNumTrajectories()
Gets the total number of trajectories.
data.ModelData Data
The full model's data container. Defaults to an empty container.
logical IncludeTrajectoryFxiData
Flag if to include values for each value, too.
IParallelizable Interface to indicate parallel computation capability of the implementing classes...
function [ V , W ] = generateReducedSpaceImpl(models.BaseFullModel model, subset)
rowvec< double > scaledTimes
The time steps Times in scaled time units .
static function test_PODGreedy()
static function rowvec< double > n = L2(matrix< double > x)
Returns the discrete norm for each column vector in x.
Global configuration class for all KerMor run-time settings.
static function KerMor theinstance = App()
The singleton KerMor instance.
Norm: Static class for commonly used norms on sets of vectors.
Base class for all space reduction algorithms.
function V = getInitialSpace(blockdata, pod, subset)
Computes the initial space, which is the first POD mode of the initial values!
dscomponents.LinearCoreFun A
Represents a linear or affine-linear component of the dynamical system.
data.ATrajectoryData TrajectoryData
The trajectory training data for the full model (only complete trajectories!)