123 this =
this@approx.algorithms.ABase;
125 this.
CoeffConfig= general.interpolation.InterpolConfig;
137 copy = approx.algorithms.Componentwise;
138 copy =
clone@approx.algorithms.ABase(
this, copy);
164 [
X,
Y] = meshgrid(1:nc,1:nco);
166 h = pm.nextPlot(
" abs ",
" Absolute errors (train) ",
" expansion config ",
" coeff comp config ");
168 h = pm.nextPlot(
" rel ",
" Relative errors (train) ",
" expansion config ",
" coeff comp config ");
171 h = pm.nextPlot(
" abs ",
" Absolute errors (val) ",
" expansion config ",
" coeff comp config ");
173 h = pm.nextPlot(
" rel ",
" Relative errors (val) ",
" expansion config ",
" coeff comp config ");
194 str = [str sprintf(
" Best coefficient comp configuration at index %d:\n%s\n ",this.
BestCoeffConfig,...
195 cc.getConfigurationString(
this.BestCoeffConfig))];
196 rangetab = rangetab.append(cc.getValueRanges);
198 str = [str sprintf(
" Configuration ranges:\n%s\n ",...
230 hlp = algk.ValidationErrors(algk.BestExpConfig,algk.BestCoeffConfig);
248 kexp.Centers.ti= atd.
ti;
249 kexp.Centers.mui= atd.
mui;
251 nc = ec.getNumConfigurations;
256 error(
" No coefficient computation configurations set. See CoeffConfig ");
260 hlp = zeros(nc, nco);
270 pi =
ProcessIndicator(
" Trying %d configurations (%d kernel, %d coeffcomp) ",...
271 nc*nco,
false,nc*nco,nc,nco);
274 fprintf(
" Applying expansion config %s\n ",ec.getConfigurationString(kcidx,
false));
276 kexp = ec.configureInstance(kcidx);
280 cc.Prototype.init(kexp);
284 this.ccomp= cc.configureInstance(coidx);
287 fprintf(
" Applying %s config %s\n ",
class(this.ccomp),cc.getConfigurationString(coidx,
false));
292 sf = this.computeCoeffs(kexp, atd.
fxi, []);
296 [val, maxidx] = this.
getError(kexp, atd);
297 rel = val / (norm(atd.
fxi(:,maxidx))+eps);
302 [val, maxidx] = this.
getError(kexp, avd);
303 rel = val / (norm(avd.fxi(:,maxidx))+eps);
315 fprintf(
" better: %.5e (rel %.5e) ",val,rel);
319 fprintf(
" worse : %.5e (rel %.5e) ",val,rel);
329 kexp = ec.configureInstance(bestcidx);
344 function integersf = computeCoeffs(kexp,fxi,initialalpha) {
345 if nargin < 4 || isempty(initialalpha)
346 initialalpha =
double.empty(size(fxi,1),0);
349 sf = this.computeCoeffsParallel(kexp, fxi, initialalpha);
351 sf = this.computeCoeffsSerial(kexp, fxi, initialalpha);
376 function
integersf = computeCoeffsSerial(kernels.KernelExpansion kexp,fxi,initialalpha) {
379 n = size(kexp.Centers.xi,2);
380 kexp.Ma= zeros(fdims, n);
381 if this.ccomp.MultiTargetComputation
383 fprintf(
" Computing approximation for all %d dimensions...\n ",fdims);
386 [ai, svidx, sf] = this.ccomp.computeKernelCoefficients(fxi,initialalpha);
387 kexp.Ma(:,svidx) = ai;
391 fprintf(
" Computing approximation for dimension %d/%d ... %2.0f %%\n ",fdim,fdims,(fdim/fdims)*100);
394 [ai, svidx, sf] = this.ccomp.computeKernelCoefficients(fxi(fdim,:),initialalpha(fdim,:));
395 kexp.Ma(fdim,svidx) = ai;
420 fprintf(
" Starting parallel component-wise approximation computation of %d dimensions on %d workers...\n ",fdims,matlabpool(
" size "));
421 Ma = zeros(fdims, n);
422 sf = zeros(fdims, 1);
423 parfor fdim = 1:fdims
425 [ai, sv, sf(fdim)] = this.ccomp.computeKernelCoefficients(...
426 fxi(fdim,:),initialalpha(fdim,:));
455 #if 0 //mtoc++: 'set.CoeffConfig'
457 if ~isempty(value) && ~isa(value,
" IClassConfig ")
458 error(" Property value must implement the
IClassConfig interface ");
469 if ~isa(
this,
" approx.algorithms.Componentwise ")
470 newinst = approx.algorithms.Componentwise;
471 if isfield(
this,
" SingleRuntimes ")
474 this =
loadobj@approx.algorithms.ABase(newinst,
this);
476 this =
loadobj@approx.algorithms.ABase(
this);
484 m = models.pcd.PCDModel(1);
487 m.EnableTrajectoryCaching=
false;
490 ec = kernels.config.ExpansionConfig;
491 ec.StateConfig= kernels.config.GaussConfig(
" G ",.1:.3);
493 a = approx.algorithms.Componentwise;
495 a.CoeffConfig= general.interpolation.InterpolConfig;
497 ap = approx.KernelApprox(m.System);
501 m.System.Params(1).Desired = 2;
502 m.SpaceReducer= spacereduction.PODGreedy;
503 m.SpaceReducer.Eps= 1e-2;
504 m.offlineGenerations;
506 mu = m.getRandomParam;
507 r = m.buildReducedModel;
510 a.CoeffConfig= general.regression.EpsSVRConfig([.1 .15; 1 2]);
511 svr = general.regression.ScalarEpsSVR_SMO;
513 a.CoeffConfig.Prototype= svr;
515 m.off5_computeApproximation;
517 r = m.buildReducedModel;
matrix< double > ValidationErrors
For each configuration, contains a row with the maximum errors on the validation data. The number of columns depends on the type of algorithm implemented by the subclasses.
matrix< double > Ma
The coefficient data for each dimension.
IClassConfig: Abstract interface for a set of configurations that can be applied to a given algorithm...
matrix< double > MaxRelErrors
For each configuration, contains a row with the maximum relative errors on the training data...
matrix< integer > StopFlags
For each effective configuration, the stop flags are stored here.
data.FileMatrix xi
The state space samples , stored row-wise in a data.FileMatrix instance.
LogPlot: Class with static functions for logarithmic plotting.
virtual function integer n = getNumConfigurations()
Returns the number of configurations that can be applied.
data.FileMatrix fxi
The evaluations of , stored row-wise in a data.FileMatrix.
function [ str , rangetab ] = getApproximationSummary()
matrix< double > SingleRuntimes
The times needed for the coefficients to compute for each exp/coeffcomp configuration.
integer BestExpConfig
Index of the best expansion config determined by the algorithm.
function kernels.KernelExpansion kexp = templateComputeApproximation(data.ApproxTrainData atd, avd)
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
static function res = test_Componentwise()
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
integer BestCoeffConfig
The index of the best coefficient computation configuration.
matrix< double > ValidationRelErrors
For each configuration, contains a row with the maximum relative errors on the validation data...
kernels.config.ExpansionConfig ExpConfig
The different kernel expansion configurations to try.
function mink = collectFromExpConfigSplit(algs)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
static function handle p = logsurf(handle h,matrix< double > X,matrix< double > Y,matrix< double > Z, varargin)
Creates a nice surface plot in a logarithmic scale with the given data.
function pm = plotSummary(pm)
Overrides the approx.algorithms.ABase function.
rowvec ti
The time samples .
function copy = clone()
Clones the instance.
ComputeParallel
Flag whether the code should be run in parallel or not.
double LastCompTime
The computation time for the last run in seconds.
static function this = loadobj()
function [ double val , integer idx , rowvec errs ] = getError(kernels.KernelExpansion kexp,data.ApproxTrainData atd)
Computes the error according to the chosen error function (see ErrorFun property) with respect to the...
ICloneable Prototype
The prototype class that is to be used as base class before configuring a new instance.
disp
Handle object disp method which is called by the display method. See the MATLAB disp function...
function n = getNumConfigurations()
Returns the number of configurations that can be applied.
matrix mui
The parameter samples used computing the parent trajectories of .
matrix< double > MaxErrors
For each configuration, contains a row with the maximum errors on the training data. The number of columns depends on the type of algorithm implemented by the subclasses.
IParallelizable Interface to indicate parallel computation capability of the implementing classes...
function nc = getTotalNumConfigurations()
ABase: Base class for any approximation generation algorithms for kernel expansions,.
Global configuration class for all KerMor run-time settings.
IClassConfig CoeffConfig
The different coefficient computation algorithm configurations to try. The IClassConfig.Prototype is used as actual algorithm, and needs to implement the IKernelCoeffComp interface.
Componentwise: Component-wise kernel approximation with fixed center set.
ApproxTrainData: Data class for approximation training data, containing several useful bounding box p...
struct Centers
The kernel centers used in the approximation.
static function KerMor theinstance = App()
The singleton KerMor instance.
function A = toMemoryMatrix()
Converts this FileMatrix to a full double matrix.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...
KernelExpansion: Base class for state-space kernel expansions.