[6304] | 1 | %VERBOSE class definition
|
---|
| 2 | %
|
---|
[6583] | 3 | % Available verbosity levels:
|
---|
| 4 | % mprocessor : model processing
|
---|
| 5 | % module : modules
|
---|
| 6 | % solution : solution sequence
|
---|
| 7 | % solver : solver info (extensive)
|
---|
| 8 | % convergence : convergence criteria
|
---|
| 9 | % control : control method
|
---|
| 10 | % qmu : sensitivity analysis
|
---|
[13435] | 11 | % autodiff : AD analysis
|
---|
[6583] | 12 | %
|
---|
[6304] | 13 | % Usage:
|
---|
| 14 | % verbose=verbose();
|
---|
| 15 | % verbose=verbose(3);
|
---|
[15427] | 16 | % verbose=verbose('all');
|
---|
[6304] | 17 | % verbose=verbose('001100');
|
---|
| 18 | % verbose=verbose('module',true,'solver',false);
|
---|
| 19 |
|
---|
[6315] | 20 | %WARNING: some parts of this file are Synchronized with src/c/shared/Numerics/Verbosity.h
|
---|
| 21 | % Do not modify these sections. See src/c/shared/Numerics/README for more info
|
---|
| 22 |
|
---|
[6304] | 23 | classdef verbose
|
---|
[6315] | 24 | properties (SetAccess=public)
|
---|
[12365] | 25 | % {{{
|
---|
[6315] | 26 | %BEGINFIELDS
|
---|
[13435] | 27 | mprocessor=false;
|
---|
| 28 | module=false;
|
---|
| 29 | solution=false;
|
---|
| 30 | solver=false;
|
---|
| 31 | convergence=false;
|
---|
| 32 | control=false;
|
---|
| 33 | qmu=false;
|
---|
| 34 | autodiff=false;
|
---|
[6315] | 35 | %ENDFIELDS
|
---|
| 36 | % }}}
|
---|
| 37 | end
|
---|
| 38 | %}}}
|
---|
| 39 | methods
|
---|
[19040] | 40 | function createxml(self,fid) % {{{
|
---|
| 41 | fprintf(fid, '\n\n');
|
---|
| 42 | fprintf(fid, '%s\n', '<!-- verbose -->');
|
---|
| 43 |
|
---|
| 44 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="mprocessor" type="', class(self.mprocessor),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.mprocessor),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 45 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="module" type="', class(self.module),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.module),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 46 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solution" type="', class(self.solution),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.solution),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 47 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="solver" type="', class(self.solver),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.solver),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 48 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="convergence" type="', class(self.convergence),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.convergence),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 49 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="control" type="', class(self.control),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.control),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 50 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n%s\n', '<parameter key ="qmu" type="', class(self.qmu),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.qmu),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 51 | fprintf(fid,'%s%s%s\n%s\n%s%s%s\n%s\n', '<parameter key ="autodiff" type="', class(self.autodiff),'" optional="false">', ' <section name="verbose" />',' <option value="',convert2str(self.autodiff),'" type="string" default="true"></option>',' <help> </help>','</parameter>');
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | end % }}}
|
---|
[12365] | 55 | function verbose=verbose(varargin) % {{{
|
---|
[6304] | 56 |
|
---|
[11867] | 57 | switch(nargin),
|
---|
| 58 | case 0,
|
---|
[14558] | 59 | verbose.solution=true;
|
---|
| 60 | verbose.qmu=true;
|
---|
| 61 | verbose.control=true;
|
---|
[11867] | 62 | case 1,
|
---|
| 63 | binary=varargin{1};
|
---|
[12938] | 64 | if ischar(binary),
|
---|
[11867] | 65 | if strcmpi(binary,'all'),
|
---|
| 66 | binary=2^11-1; %all ones
|
---|
| 67 | verbose=BinaryToVerbose(verbose,binary);
|
---|
| 68 | verbose.solver=false; %Do not use by default
|
---|
| 69 | else
|
---|
| 70 | binary=bin2dec(binary);
|
---|
| 71 | verbose=BinaryToVerbose(verbose,binary);
|
---|
| 72 | end
|
---|
[12938] | 73 | elseif isnumeric(binary),
|
---|
| 74 | verbose=BinaryToVerbose(verbose,binary);
|
---|
[11867] | 75 | end
|
---|
| 76 | otherwise,
|
---|
| 77 | %Use options to initialize object
|
---|
| 78 | verbose=AssignObjectFields(pairoptions(varargin{:}),verbose);
|
---|
[6304] | 79 |
|
---|
[11867] | 80 | %Cast to logicals
|
---|
| 81 | listproperties=properties('verbose');
|
---|
| 82 | for i=1:numel(listproperties),
|
---|
| 83 | fieldname=listproperties{i};
|
---|
| 84 | fieldvalue=verbose.(fieldname);
|
---|
| 85 | if (islogical(fieldvalue) | isnumeric(fieldvalue)) & numel(fieldvalue)==1,
|
---|
[7872] | 86 | verbose.(fieldname)=logical(fieldvalue);
|
---|
| 87 | else
|
---|
| 88 | error('verbose supported field values are logicals only (true or false)');
|
---|
| 89 | end
|
---|
[6315] | 90 | end
|
---|
| 91 | end
|
---|
| 92 | end
|
---|
| 93 | %}}}
|
---|
[12365] | 94 | function binary=VerboseToBinary(verbose) % {{{
|
---|
[6304] | 95 |
|
---|
[6315] | 96 | %BEGINVERB2BIN
|
---|
| 97 | binary=0;
|
---|
[6323] | 98 | if (verbose.mprocessor), binary=bitor(binary,1); end
|
---|
| 99 | if (verbose.module), binary=bitor(binary,2); end
|
---|
| 100 | if (verbose.solution), binary=bitor(binary,4); end
|
---|
[6315] | 101 | if (verbose.solver), binary=bitor(binary,8); end
|
---|
[6323] | 102 | if (verbose.convergence), binary=bitor(binary,16); end
|
---|
| 103 | if (verbose.control), binary=bitor(binary,32); end
|
---|
| 104 | if (verbose.qmu), binary=bitor(binary,64); end
|
---|
[13435] | 105 | if (verbose.autodiff), binary=bitor(binary,128); end
|
---|
[6315] | 106 | %ENDVERB2BIN
|
---|
[6304] | 107 |
|
---|
[6315] | 108 | end
|
---|
| 109 | %}}}
|
---|
[12365] | 110 | function verbose=BinaryToVerbose(verbose,binary) % {{{
|
---|
[6304] | 111 |
|
---|
[6315] | 112 | %BEGINBIN2VERB
|
---|
[13435] | 113 | if bitand(binary,1), verbose.mprocessor=true; else verbose.mprocessor=false; end
|
---|
| 114 | if bitand(binary,2), verbose.module=true; else verbose.module=false; end
|
---|
| 115 | if bitand(binary,4), verbose.solution=true; else verbose.solution=false; end
|
---|
| 116 | if bitand(binary,8), verbose.solver=true; else verbose.solver=false; end
|
---|
| 117 | if bitand(binary,16), verbose.convergence=true; else verbose.convergence=false; end
|
---|
| 118 | if bitand(binary,32), verbose.control=true; else verbose.control=false; end
|
---|
| 119 | if bitand(binary,64), verbose.qmu=true; else verbose.qmu=false; end
|
---|
| 120 | if bitand(binary,128), verbose.autodiff=true; else verbose.autodiff=false; end
|
---|
[6315] | 121 | %ENDBIN2VERB
|
---|
[6304] | 122 |
|
---|
[6315] | 123 | end
|
---|
| 124 | %}}}
|
---|
[19040] | 125 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
[9739] | 126 |
|
---|
| 127 | end % }}}
|
---|
[12365] | 128 | function disp(verbose) % {{{
|
---|
[13646] | 129 |
|
---|
[6315] | 130 | %BEGINDISP
|
---|
| 131 | disp(sprintf('class ''%s'' = ',class(verbose)));
|
---|
[6324] | 132 | disp(sprintf(' %15s : %s','mprocessor',mat2str(verbose.mprocessor)));
|
---|
| 133 | disp(sprintf(' %15s : %s','module',mat2str(verbose.module)));
|
---|
| 134 | disp(sprintf(' %15s : %s','solution',mat2str(verbose.solution)));
|
---|
| 135 | disp(sprintf(' %15s : %s','solver',mat2str(verbose.solver)));
|
---|
| 136 | disp(sprintf(' %15s : %s','convergence',mat2str(verbose.convergence)));
|
---|
| 137 | disp(sprintf(' %15s : %s','control',mat2str(verbose.control)));
|
---|
| 138 | disp(sprintf(' %15s : %s','qmu',mat2str(verbose.qmu)));
|
---|
[13435] | 139 | disp(sprintf(' %15s : %s','autodiff',mat2str(verbose.autodiff)));
|
---|
[6315] | 140 | %ENDDISP
|
---|
[6304] | 141 |
|
---|
[6315] | 142 | end
|
---|
| 143 | %}}}
|
---|
[19040] | 144 | function marshall(self,md,fid) % {{{
|
---|
| 145 | WriteData(fid,'data',VerboseToBinary(self),'enum',VerboseEnum(),'format','Integer');
|
---|
[10969] | 146 | end % }}}
|
---|
[6304] | 147 | end
|
---|
| 148 | end
|
---|