130 error(
" FileTrajectoryData cannot be used as java is not enabled. ");
133 data_dir = fullfile(
KerMor.
App.TempDirectory,sprintf(
" temp_ftd_%s ",...
135 elseif ischar(datadir)
138 error(
" Invalid argument: %s ",
class(datadir));
140 this =
this@data.FileDataCollection(data_dir);
161 s = this.
getData([mu; inputidx],
" x ",
" ctime ");
186 function [colvec<double>x , colvec<double>mu , integerinputidx , doublectime ] =
getTrajectoryNr(nr) {
187 s = this.
getDataNr(nr,
" x ",
" mu ",
" inputidx ",
" ctime ");
190 inputidx = s.inputidx;
210 newd =
size(x,1); newmu = length(mu);
211 if isempty(this.sizes) ||
all(this.sizes == 0)
212 this.sizes= [newd newmu];
213 elseif newd ~= this.sizes(1)
214 error(
" Invalid trajectory dimension. Existing: %d, new: %d ",this.sizes(1),newd);
217 exists = this.
hasData([mu; inputidx]);
219 if isempty(this.trajlen)
220 this.trajlen=
size(x,2);
221 elseif this.trajlen ~=
size(x,2)
222 error(
" Invalid trajectory length. Existing: %d, new: %d ",this.trajlen,
size(x,2));
226 this.width= this.width +
size(x,2);
230 if ~this.ReplaceExisting && exists
231 warning(
" KerMor:FileTrajectoryData ",
" Trajectory already present and replacing is disabled. ");
236 traj.inputidx= inputidx;
238 this.
addData([mu; inputidx], traj);
291 this.trajlen=
size(s.x,2);
334 if isempty(this.sizes)
353 if isempty(this.bbmin)
357 this.bbmin= min(this.bbmin,m);
358 this.bbmax= max(this.bbmin,M);
371 static function this =
loadobj(this,initfrom) {
374 if ~isa(
this,
" data.FileTrajectoryData ")
376 this = data.FileTrajectoryData(initfrom.DataDirectory);
379 if nargin == 2 || created
380 this.sizes= initfrom.sizes;
381 this.bbmin= initfrom.bbmin;
382 this.bbmax= initfrom.bbmax;
383 this.trajlen= initfrom.trajlen;
388 this =
loadobj@data.FileDataCollection(
this, initfrom);
390 this =
loadobj@data.FileDataCollection(
this);
411 m = data.FileTrajectoryData;
416 tr(:,:,i) = rand(30,50);
426 m.addTrajectory(tr(:,:,i),p(:,i),[],1);
428 res = res && m.getNumTrajectories == T;
433 [x, pi] = m.getTrajectoryNr(i);
434 pos = pos | sum(sum(repmat(x,[1 1 T]) - tr,1),2) == 0;
435 ppos = ppos | sum(repmat(pi,1,T) - p,1) == 0;
437 x = m.getTrajectory(p(:,i),[]);
438 res = res && isequal(x,tr(:,:,i));
440 res = res &&
all(pos) &&
all(ppos);
445 m.addTrajectory(tr(:,:,i),[],in(i),1);
447 res = res && m.getNumTrajectories == T;
452 [x, ~, ini] = m.getTrajectoryNr(i);
453 pos = pos | sum(sum(repmat(x,[1 1 T]) - tr,1),2) == 0;
454 ipos = ipos | repmat(ini,1,T)-in == 0;
456 x = m.getTrajectory([],in(i));
457 res = res && isequal(x,tr(:,:,i));
459 res = res &&
all(pos) &&
all(ipos);
464 m.addTrajectory(tr(:,:,i),p(:,i),in(i),1);
466 res = res && m.getNumTrajectories == T;
472 [x, pi, ini] = m.getTrajectoryNr(i);
473 pos = pos | sum(sum(repmat(x,[1 1 T]) - tr,1),2) == 0;
474 ppos = ppos | sum(repmat(pi,1,T) - p,1) == 0;
475 ipos = ipos | repmat(ini,1,T)-in == 0;
477 x = m.getTrajectory(p(:,i),in(i));
478 res = res && isequal(x,tr(:,:,i));
480 res = res &&
all(pos) &&
all(ppos) &&
all(ipos);
function res = hasData(keydata)
function [ colvec< double > x , colvec< double > mu , integer inputidx , double ctime ] = getTrajectoryNr(nr)
Gets the trajectory with the number nr.
Collection of generally useful functions.
logical ReplaceExisting
Flag that indicates if a warning should be issued if a trajectory already exists and is about to be r...
function [ n , m ] = size(dim)
function [ d , mud ] = getTrajectoryDoFs()
Returns the degrees of freedom for the trajectories and parameter size.
function consolidate(models.BaseFullModel model)
Rebuild the hashmap for the current FileData using the current ParamSamples and the models training i...
static function gen = generateID()
Generates a new unique ID.
static function this = loadobj(this, initfrom)
Loads a FileTrajectoryData instance.
The base class for any KerMor detailed model.
SampleCount
The number of samples contained in the model data.
function [ colvec< double > x , double ctime ] = getTrajectory(colvec< double > mu,integer inputidx)
Gets a system's trajectory for the given and inputindex. Returns [] if no trajectory is found in the...
function struct data = getDataNr(nr, varargin)
Retrieves data from the nr-st collection element.
static function res = test_FileTrajectoryData()
logical UniformTrajectories
Flag that checks if newly added trajectories must have the size of already existing trajectories...
function addTrajectory(colvec< double > x,colvec< double > mu,integer inputidx,double ctime)
Adds a trajectory to the ModelData instance.
matrix ParamSamples
A Model's parameter samples as column vector collection.
function clearTrajectories()
Clears all stored trajectory data.
function [ colvec< double > x , X ] = getBoundingBox()
Gets the bounding box of the state space of all trajectories.
function n = getCollectionSize()
FileDataCollection: Basic class for storing data given a hashable key value.
data.ModelData Data
The full model's data container. Defaults to an empty container.
function n = getNumTrajectories()
Gets the total number of trajectories.
integer TrainingInputCount
Gets the number of inputs used for training.
double MinRelSingularValueSize
The minimum relative value of singular values that triggers selection of the compared to the largest ...
function addData(keydata, data)
Global configuration class for all KerMor run-time settings.
FileTrajectoryData(datadir)
Creates a new filesystem-based trajectory data container.
function n = getNumBlocks()
% data.ABlockedData implementations
function struct data = getData(rowvec< double > keydata, varargin)
methods(Access=protected) Retrieves data from the collection element of a given key.
static function KerMor theinstance = App()
The singleton KerMor instance.
FileTrajectoryData: Trajectory data stored in external files.
Data class that contains a model's large data, including subspace matrices, trajectories and approxim...
function l = getTotalLength()
Length of the stored trajectories.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...
static function [ double bmin , double bmax ] = getBoundingBox(double vectors)
Gets the bounding box for a matrix containing column vectors.