-
Notifications
You must be signed in to change notification settings - Fork 1
/
EngineFactory.m
63 lines (57 loc) · 1.94 KB
/
EngineFactory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
classdef EngineFactory < Factory
properties (Constant, Access = protected)
defaults = {
'', @Engine, ...
'XYZ', @Engine, ...
'RLL', @EngineRLL, ...
'Aero', @EngineAero, ...
'AeroDelta', @EngineAeroDelta, ...
'Ctrl', @EngineCtrl, 'Control', @EngineCtrl, ...
'Guid', @EngineGuid, 'Guidance', @EngineGuid, ...
'GuidRate', @EngineGuidRate, 'GuidanceRate', @EngineGuidRate, ...
'GuidAlt', @EngineGuidAlt, 'GuidanceAltitude', @EngineGuidAlt, ...
'GuidAltPoly', @EngineGuidAltPoly, 'GuidanceAltitudePolynomial', @EngineGuidAltPoly, ...
'RL', @EngineRL, 'ReinforcementLearning', @EngineRL, ...
'RLFree', @EngineRLFree, 'ReinforcementLearningFree', @EngineRLFree, ...
'RLStochastic', @EngineRLStochastic, 'ReinforcementLearningStochastic', @EngineRLStochastic
};
exception = 'Unkown engine type provided';
end
methods
function self = EngineFactory(varargin)
self@Factory(varargin);
end
function en = generate(self, data)
% data := 'integration' structure from case *.json
% Generate Engine (note: first argument defines class)
% Note: key-value options are left untouched
en = self.constructor(data.engine);
% Basic options
en.options('RelTol', data.reltol, 'AbsTol', data.abstol, 'TimeStep', data.timestep, 'MaxTime', data.maxtime, 'MaxLoad', data.maxload, 'ShowWarnings', data.verbose, 'Policy', data.policy);
% Check if integrator is a valid function
integrator = str2func(data.solver);
try
nargin(integrator);
en.options('Integrator', integrator);
catch
integrator = str2func(['util.' data.solver]);
try
nargin(integrator);
en.options('Integrator', integrator);
catch
warning('Invalid integrator function provided. Reverting back to default...');
end
end
end
end
methods (Static)
% Static property: DICTIONARY
function out = dictionary(in)
persistent DICTIONARY;
if nargin
DICTIONARY = in;
end
out = DICTIONARY;
end
end
end