109 this =
this@approx.algorithms.AAdaptiveBase;
114 copy = approx.algorithms.VKOGA;
115 copy =
clone@approx.algorithms.AAdaptiveBase(
this, copy);
145 this.
AllExpansions= eval(sprintf(
" %s.empty ",
class(ec.Prototype)));
150 fxinorm(fxinorm == 0) = 1;
152 vxi = avd.xi.toMemoryMatrix;
153 vfxi = avd.fxi.toMemoryMatrix;
155 vfxinorm(vfxinorm == 0) = 1;
165 pi =
ProcessIndicator(
" VKOGA approximation for %d kernel configurations ",nc,
false,nc);
170 kexp = ec.configureInstance(cidx);
173 if isa(kexp.Kernel,
" kernels.ARBFKernel ")
174 Kdiag = kexp.Kernel.evaluate(xi(:,1),xi(:,1))*ones(1,N);
178 Kdiag(
k) = kexp.Kernel.evaluate(xi(
k,1),xi(
k,1));
184 NV(:,1) = kexp.getKernelMatrixColumn(this.
initialidx, xi, atd.
ti, atd.
mui);
187 c = zeros(size(atd.
fxi,1),
this.MaxExpansionSize);
191 sumNsq = (NV(:,1).^2)^
t;
198 this.
VKOGABound(cidx, m) = 1/max(Kdiag - sumNsq);
205 fresidual = fresidual - c(:,m)*(NV(:,m))^
t;
216 fprintf(
" VKOGA stopping criteria holds: Max expansion size %d reached.\nResidual error %.7e > %.7e, Max relative error %.7e > %.7e\n ",...
223 fprintf(
" VKOGA stopping criteria holds: Relative error %.7e < %.7e\n ",this.
MaxRelErrors(cidx,m),this.
MaxRelErr);
238 div = Kdiag - sumNsq;
239 div(used(1:m)) = Inf;
244 sum_fresidual = sum(fresidual.^2,1) ./ div;
246 [~, maxidx] = max(sum_fresidual);
247 tN = kexp.getKernelMatrixColumn(maxidx, xi, atd.
ti, atd.
mui) - NV(:,1:m)*NV(maxidx,1:m)^
t;
252 if sumNsq(maxidx) > 1
254 fprintf(
" VKOGA emergency stop at iteration %d: Power function value > 1 detected.\nResidual error %.7e > %.7e, Max relative error %.7e > %.7e\n ",...
262 tNnorm = sqrt(Kdiag(maxidx)-sumNsq(maxidx));
264 c(:,m) = fresidual(:,maxidx)./tNnorm;
265 sumNsq = sumNsq + (NV(:,m).^2)^
t;
276 kexp.setCentersFromATD(atd, used(1:m));
278 kexp.Base= NV(used(1:m),1:m);
283 e = this.
ErrorFun(vfxi - kexp.evaluate(vxi,avd.ti,avd.mui));
303 bestused = used(1:m);
314 error(
" No centers found ");
318 kexp.setCentersFromATD(atd, bestused);
324 kexp.Base= bestNV(bestused,1:length(bestused));
339 fprintf(
" VKOMP best kernel config index:%d for VKOGA with f/P-Greedy=%s, exp-size:%d\n ",...
366 if ~isa(
this,
" approx.algorithms.VKOGA ")
367 a = approx.algorithms.VKOGA;
368 if isfield(
this,
" UsefPGreedy ") && ~isempty(this.
UsefPGreedy)
370 elseif isfield(
this,
" UseOGA ")
371 a.UsefPGreedy= this.UseOGA;
373 if isfield(
this,
" MaxAbsResidualErr ")
376 if isfield(
this,
" bestNewtonBasisValuesOnATD ")
379 if isfield(
this,
" basis_norms ")
382 if isfield(
this,
" stopFlags ")
383 a.StopFlags= this.stopFlags;
385 this =
loadobj@approx.algorithms.AAdaptiveBase(a,
this);
398 demos.VKOGA.VKOGA_1D_nD(1,
false);
399 demos.VKOGA.VKOGA_1D_nD(1,
true);
400 demos.VKOGA.VKOGA_1D_nD(2,
false);
401 demos.VKOGA.VKOGA_1D_nD(2,
true);
402 demos.VKOGA.VKOGA_1D_nD(3,
false,10);
403 demos.VKOGA.VKOGA_1D_nD(3,
true);
404 demos.VKOGA.VKOGA_1D_nD(4,
false,10);
405 demos.VKOGA.VKOGA_1D_nD(4,
true);
418 [f, r] = testing.TestFunctions.F8;
420 x1 = r(1,1):step:r(1,2);
421 x2 = r(2,1):step:r(2,2);
422 [
X,
Y] = meshgrid(x1,x2);
423 xi = [
X(:)
" ; Y(:) "];
426 atd = data.ApproxTrainData(xi,[],[]);
430 alg = approx.algorithms.VKOGA;
431 alg.MaxExpansionSize= 100;
432 alg.UsefPGreedy=
true;
433 ec = kernels.config.ExpansionConfig;
434 ec.Prototype.Kernel= kernels.Wendland;
436 ec.StateConfig= kernels.config.WendlandConfig(...
437 " G ",c(1,:),
" S ",c(2,:),
" Dim ",1);
440 kexp = alg.computeApproximation(atd);
447 h = pm.nextPlot(
" fun ",
" Function ",
" x ",
" f(x) ");
448 Z =
reshape(fxi,length(x1),[]);
451 h = pm.nextPlot(
" fun ",
" Approximation ",
" x ",
" kexp(x) ");
452 aZ =
reshape(kexp.evaluate(xi),length(x1),[]);
455 h = pm.nextPlot(
" fun ",
" Error ",
" x ",
" f(x)-kexp(x) ");
456 surf(h,
X,
Y,abs(Z-aZ));
458 h = pm.nextPlot(
" nfun ",
" Last Newton Basis Function ",
" x ",
" N(x) ");
459 Z =
reshape(alg.bestNewtonBasisValuesOnATD(:,end),length(x1),[]);
462 alg.plotSummary(pm,
" test_VKOGA ");
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.
static const REL_ERROR
Relative error tolerance reached.
Collection of generally useful functions.
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.
static const ABS_ERROR
Absolute error tolerance reached.
static function comb = createCombinations(ranges, varargin)
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector pe...
data.FileMatrix fxi
The evaluations of , stored row-wise in a data.FileMatrix.
integer BestExpConfig
Index of the best expansion config determined by the algorithm.
function kernels.KernelExpansion kexp = startAdaptiveExtension(data.ApproxTrainData atd, avd)
Starts the adaptive extension of the VKOGA algorithm.
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
matrix< double > ValidationRelErrors
For each configuration, contains a row with the maximum relative errors on the validation data...
VKOGA: Vectorial kernel orthogonal greedy algorithm.
kernels.config.ExpansionConfig ExpConfig
The different kernel expansion configurations to try.
logical UsefPGreedy
Flag on whether to use the f/P-Greedy variant instead of f-Greedy.
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
function copy = clone()
Clones the instance.
rowvec ti
The time samples .
static function [ res , d ] = test_VKOGA2D1D()
Tests the VKOGA algorithm.
Used
The indices of the effectively used centers during the.
static const NEGATIVE_POWFUN
Stop flag from the VKOGA algorithm.
function_handle ErrorFun
The error function to apply on each data vector.
static function res = test_VKOGA1DnD()
Tests the VKOGA algorithm by running the demos.
double MaxAbsResidualErr
Stopping criteria for the VKOGA algorithm. The execution for on expansion configuration is stopped if...
static function this = loadobj()
function n = getNumConfigurations()
Returns the number of configurations that can be applied.
char ValidationErrorMeasure
Determines which error measure is to use to select the "best" solution w.r.t. to the validation data ...
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.
Base class for adaptive component-wise kernel approximation algorithms.
Global configuration class for all KerMor run-time settings.
ApproxTrainData: Data class for approximation training data, containing several useful bounding box p...
static function KerMor theinstance = App()
The singleton KerMor instance.
function A = toMemoryMatrix()
Converts this FileMatrix to a full double matrix.
A MatLab character array.
double MaxRelErr
Stopping condition property. Maximum relative error that may occur.
bestNewtonBasisValuesOnATD
ProcessIndicator: A simple class that indicates process either via waitbar or text output...
colvec< double > ExpansionSizes
integer MaxExpansionSize
The maximum size of the expansion to produce.
static const MAX_SIZE
Maximum size reached.
StopFlag: Flags that algorithms can use to specify the reason for their termination.