Skip to content

Commit

Permalink
Removes unneeded compile folders, removes output class, and add full …
Browse files Browse the repository at this point in the history
…compile code only generation (#164)
  • Loading branch information
StephenNneji authored Nov 2, 2023
1 parent 45c5486 commit 9da2745
Show file tree
Hide file tree
Showing 51 changed files with 62 additions and 5,128 deletions.
36 changes: 2 additions & 34 deletions API/RAT.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
function [outProblemDef,result] = RAT(problemDefInput,controls)

persistent isInitialised

if isempty(isInitialised)
isInitialised = false;
end


[problemDef,problemDefCells,problemDefLimits,priors,controls] = parseClassToStructs(problemDefInput,controls);
[problemDef,~] = packparams(problemDef,problemDefCells,problemDefLimits,controls.checks);

Expand Down Expand Up @@ -41,28 +34,6 @@
% coder.varsize('problemDef.fitconstr',[Inf,2],[1,0]);
% coder.varsize('problemDef.otherconstr',[Inf,2],[1,0]);

% Set up the output class and events.
% Only do this once so it can be modified
% by other apps using RAT (i.e. Rascal)
if ~isInitialised
ratOut = outputClass();
ratListener = listener(ratOut,'ratUpdate',@defaultOutputFunction);
%ratListener = listener(ratOut,'ratUpdate',@bayesAddInfoText);
setappdata(0,'ratOut',{ratOut ; ratListener});
isInitialised = true;
end

% This creates an output class from RAT from which updates are sent.
% To use it, register an output function with ratOut using the listener
% class. To supress the default listener (outputs to command window only)
% being called, this must be manually deleted (delete(ratListener)).
% To trigger output within RAT...
%
% ratOut = getappdata(0,'ratOut');
% ratOutHandle = ratOut{1};
% ratOut.customEventData.textUpdate = 'new text';
% ratOut.triggerEvent;

% Set controls.calCls always to 1
% if we are doing customXY
switch lower(problemDef.modelType)
Expand All @@ -75,12 +46,11 @@
% If display is not silent print a
% line confirminf RAT is starting
if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('Starting RAT ________________________________________________________________________________________________ \n'));
fprintf('Starting RAT ________________________________________________________________________________________________\n\n');
end

tic
[outProblemStruct,problem,result,bayesResults] = RATMain_mex(problemDef,problemDefCells,problemDefLimits,controls,priors);
sendTextOutput(sprintf('\n'));

if ~strcmpi(controls.display,'off')
toc
Expand Down Expand Up @@ -112,9 +82,7 @@
outProblemDef = parseOutToProjectClass(problemDefInput,outProblemStruct,problem,result);

if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('\nFinished RAT ______________________________________________________________________________________________ \n\n'));
fprintf('\nFinished RAT ______________________________________________________________________________________________ \n\n');
end

end


8 changes: 4 additions & 4 deletions API/RATMain.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
outProblemDef = problemDef;
case 'simplex'
if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('\nRunning simplex\n\n'));
fprintf('\nRunning simplex\n\n');
end
[outProblemDef,problem,results] = runSimplex(problemDef,problemDefCells,problemDefLimits,controls);
case 'de'
if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('\nRunning Differential Evolution\n\n'));
fprintf('\nRunning Differential Evolution\n\n');
end
[outProblemDef,problem,results] = runDE(problemDef,problemDefCells,problemDefLimits,controls);
case 'ns'
if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('\nRunning Nested Sampler\n\n'));
fprintf('\nRunning Nested Sampler\n\n');
end
[outProblemDef,problem,results,bayesResults] = runNestedSampler(problemDef,problemDefCells,problemDefLimits,controls,priors);
case 'dream'
if ~strcmpi(controls.display,'off')
sendTextOutput(sprintf('\nRunning DREAM\n\n'));
fprintf('\nRunning DREAM\n\n');
end
[outProblemDef,problem,results,bayesResults] = runDREAM(problemDef,problemDefCells,problemDefLimits,controls,priors);
end
Expand Down
13 changes: 0 additions & 13 deletions API/outputFunction/defaultOutputFunction.m

This file was deleted.

25 changes: 0 additions & 25 deletions API/outputFunction/outputClass.m

This file was deleted.

19 changes: 8 additions & 11 deletions API/outputFunction/sendTextOutput.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
function sendTextOutput(text)
function sendTextOutput(outText)

persistent ratOut
% This is an overloaded version of 'sendTextOutput' for the compile.
% The 'real' one is the output class. We will think of a better solution
% later on.
% if isnumeric(outText)
% outText = sprintf('%g',outText);
% end

if isempty(ratOut)
ratOut = getappdata(0,'ratOut');
outputClass = ratOut{1};
end
fprintf('%s \n',outText);

try
outputClass.customEventData.textUpdate = text;
outputClass.triggerEvent;
catch
disp(text);
end
11 changes: 0 additions & 11 deletions API/outputFunction/specialEventDataClass.m

This file was deleted.

2 changes: 0 additions & 2 deletions addPaths.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
fullfile(root,'API','outputFunction');
fullfile(root,'API','projectClass');

fullfile(root,'compile','DE');
eventCompilePath;
fullfile(root,'compile','customWrapper');
fullfile(root,'compile','reflectivityCalculation');
fullfile(root,'compile','fullCompile');
fullfile(root,'compile','simplex');
fullfile(root,'compile');

fullfile(root,'minimisers','DREAM');
Expand Down
14 changes: 1 addition & 13 deletions buildScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,14 @@
% Go to the correct compile directory
compilePath = fullfile(thisPath,'compile','reflectivityCalculation');
cd(compilePath);

% Run the compile script whist in that directory (ensures mex file ends up
% in the correct place)
reflectivityCalculationCompileScript

% Now we need to change the defined paths to generate the source code. At
% the moment, RAT uses a 'feval' call to the base workspace to excecute
% Matlab custom model files. This will fail for standalone codegen. So, we
% need to change RAT paths to exclude these files from the source generation
% setCompilePaths('lib');
%
% Now generate the source....
reflectivityCalculationCodeOnlyScript;

compilePath = fullfile(thisPath,'compile','fullCompile');
cd(compilePath);
ratMainCompileScript;
ratMainCodeGen;

% Finally, change the paths back or the tests might fail...
% setCompilePaths('mex');
compilePath = fullfile(thisPath, 'compile', 'events');
cd(compilePath);
eventCompileScript;
Expand Down
37 changes: 0 additions & 37 deletions compile/DE/%reflectivityCalculationWrapper.m

This file was deleted.

17 changes: 0 additions & 17 deletions compile/DE/DECompileScript.m

This file was deleted.

Binary file removed compile/DE/runDE_mex.mexmaci64
Binary file not shown.
12 changes: 0 additions & 12 deletions compile/DE/sendTextOutput.m

This file was deleted.

9 changes: 0 additions & 9 deletions compile/Dram_compile/%reflectivityCalculationWrapper.m

This file was deleted.

17 changes: 0 additions & 17 deletions compile/Dram_compile/DramCompileScript.m

This file was deleted.

Binary file removed compile/Dram_compile/alphaDev/A-count.mat
Binary file not shown.
16 changes: 0 additions & 16 deletions compile/Dram_compile/alphaDev/alphaMain.m

This file was deleted.

Loading

0 comments on commit 9da2745

Please sign in to comment.