Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matlab worker #25

Open
wants to merge 13 commits into
base: development
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
%RANDOMVARIABLE This class is abstract and defines presettings for
% several specializations.
%
% For more detailed information, see
% <https://cossan.co.uk/wiki/index.php/@RandomVariable>.
%
% Properties:
% Mean
% Std
% Shift
% See also: RandomVariableSet, Input

%{
This file is part of OpenCossan <https://cossan.co.uk>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
classdef RandomVariableSet < opencossan.common.CossanObject
%RANDOMVARIABLESET Constructs object RandomVariableSet
%
% See also: RandomVariable, Input

%{
This file is part of OpenCossan <https://cossan.co.uk>.
Expand Down Expand Up @@ -58,6 +60,7 @@
["Correlation", "Covariance"],{[],[]}, varargin{:});
end

% Now we define all the inputs not filtered out by the parsers
obj@opencossan.common.CossanObject(super_args{:});

if nargin > 0
Expand Down Expand Up @@ -116,26 +119,31 @@
end

methods (Static)
function obj = fromIidRandomVariables(rv,n,varargin)
function obj = fromIidRandomVariables(varargin)
% Required input arguments:
% * Number: Number of Random Variable in the set
% * RandomVariable: IID Random variable
%
% Optional arguments
% * NamePrefix: Prefix used to construct IID random variables
%
import opencossan.common.inputs.random.RandomVariableSet
p = inputParser;
p.FunctionName = 'opencossan.common.inputs.random.RandomVariableSet.fromIidRandomVariables';
p.addRequired('rv')
p.addRequired('n');

p.parse(rv,n);
[required, varargin] = opencossan.common.utilities.parseRequiredNameValuePairs(...
["Number","RandomVariable"], varargin{:});

[optional, varargin] = opencossan.common.utilities.parseOptionalNameValuePairs(...
"basename", {"RV"}, varargin{:});
[optional, superArg] = opencossan.common.utilities.parseOptionalNameValuePairs(...
"NamePrefix","RV_", varargin{:});


members(1:p.Results.n) = p.Results.rv;
members(1:required.number) = required.randomvariable;

names = strings(1,n);
for i = 1:p.Results.n
names(i) = sprintf("%s_%d", optional.basename, i);
names = strings(1,required.number);
for i = 1:required.number
names(i) = sprintf("%s%d", optional.nameprefix, i);
end

varargin = [varargin {'members', members, 'names', names}];
varargin = [superArg {'members', members, 'names', names}];
obj = RandomVariableSet(varargin{:});
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classdef CovarianceFunction < opencossan.workers.Mio
classdef CovarianceFunction < opencossan.workers.MatlabWorker
%COVARIANCEFUNCTION This class defines the covariance function for a
%stochastic process.
%
Expand All @@ -22,7 +22,7 @@

% Call constructor of opencossan.workers.Mio

Xobj = Xobj@opencossan.workers.Mio(varargin{:});
Xobj = Xobj@opencossan.workers.MatlabWorker(varargin{:});

if nargin==0
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classdef (Abstract) StochasticProcess < opencossan.workers.Mio
classdef (Abstract) StochasticProcess < opencossan.workers.MatlabWorker
%STOCHASTICPROCESS The abstract class defines a random process (or a
%random field) to represent the evolution of some random value, or
%system, over time or space
Expand Down
8 changes: 4 additions & 4 deletions +opencossan/+common/@Model/Model.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@

% Check that all names required by the evaluator are
% present in the input
assert(all(ismember(obj.Evaluator.Cinputnames,...
assert(all(ismember(obj.Evaluator.InputNames,...
obj.InputNames)),'OpenCossan:Model:MissingInputs',...
'The Input object must contain all inputs required by the Evaluator: ''%s''', ...
strjoin(obj.Evaluator.Cinputnames,''', '''));
strjoin(obj.Evaluator.InputNames,''', '''));
end
end

Expand All @@ -62,11 +62,11 @@
obj = setGridProperties(obj, varargin); % Add execution details (i.e. Grid configuration)

function names = get.OutputNames(obj)
names = obj.Evaluator.Coutputnames;
names = obj.Evaluator.OutputNames;
end

function names = get.InputNames(obj)
names = obj.Input.Names;
names = obj.Evaluator.InputNames;
end
end
end
59 changes: 59 additions & 0 deletions +opencossan/+highperformancecomputing/@Job/Job.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
classdef Job < opencossan.common.CossanObject
%JOB This class provide information of job prepared and submitted to a
%cluster or grid computing.
%
% See also: JobManager, Evaluator

%{
This file is part of OpenCossan <https://cossan.co.uk>.
Copyright (C) 2006-2020 COSSAN WORKING GROUP

OpenCossan is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License or,
(at your option) any later version.

OpenCossan is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenCossan. If not, see <http://www.gnu.org/licenses/>.
%}

properties
ID(1,:) {mustBeInteger}
Name
State
Dependences
ScriptName
end

methods
function obj = Job(varargin)

if nargin == 0
superArg = {};
else

[requiredArgs, varargin] = opencossan.common.utilities.parseRequiredNameValuePairs(...
["ID","Status"], varargin{:});

[optionalArgs, superArg] = opencossan.common.utilities.parseOptionalNameValuePairs(...
["Name","Dependences"],{[],[]}, varargin{:});
end

obj@opencossan.common.CossanObject(superArg{:});

if nargin > 0
obj.ID=requiredArgs.id;
obj.State=requiredArgs.state;
obj.Name=optionalArgs.name;
obj.Dependences=optionalArgs.dependences;
end
end

end
end

Loading