08.02.2013 Views

New Statistical Algorithms for the Analysis of Mass - FU Berlin, FB MI ...

New Statistical Algorithms for the Analysis of Mass - FU Berlin, FB MI ...

New Statistical Algorithms for the Analysis of Mass - FU Berlin, FB MI ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

160CHAPTER 6. PROTEO<strong>MI</strong>CS.NET - PRODUCT-ORIENTED CASE STUDIES<br />

Approach<br />

Matlab Scripts The scripting language Matlab is quite popular <strong>for</strong> quick<br />

coding <strong>of</strong> ma<strong>the</strong>matical algorithms. A typical algorithm gets some input parameters<br />

and data and <strong>the</strong>n computes and returns <strong>the</strong> results. To allow almost<br />

any user-defined matlab script to be run within a QAD Grid two things must<br />

be done: (a) a special Matlab worker must be started at <strong>the</strong> Grid nodes that<br />

will <strong>the</strong>n run <strong>the</strong> user-defined Matlab scripts and (b) <strong>the</strong> function call <strong>of</strong> <strong>the</strong><br />

user-defined Matlab script must be changed to take two more parameters. If<br />

<strong>the</strong> user-defined script is called from <strong>the</strong> Matlab worker <strong>the</strong>se two additional<br />

parameters contain (1) a string “MCP” and (2) an object reference to <strong>the</strong><br />

underlying QAD Grid worker. Through this <strong>the</strong> base QAD Grid worker functions<br />

(see section 5.4.1) can be used, such as writing log entries or change<br />

<strong>the</strong> worker’s status. If <strong>the</strong> Matlab worker is started at a QAD Grid node it<br />

per<strong>for</strong>ms <strong>the</strong> following steps:<br />

1. Start Matlab at <strong>the</strong> Grid node<br />

2. Start <strong>the</strong> Matlab worker script<br />

3. Within <strong>the</strong> Matlab worker:<br />

� Wait until a new Matlab task is available<br />

� Request <strong>the</strong> name <strong>of</strong> <strong>the</strong> user-defined Matlab script to be started<br />

� Request <strong>the</strong> parameters <strong>for</strong> <strong>the</strong> user-defined Matlab script<br />

� Start <strong>the</strong> user-defined Matlab script<br />

The Matlab worker core that gets <strong>the</strong> parameters from <strong>the</strong> QAD Grid and<br />

starts <strong>the</strong> user-defined script is implemented as shown in listing 6.2:<br />

Listing 6.2: Minimal code <strong>for</strong> using <strong>the</strong> a Matlab worker.<br />

1 params = jPROTEO<strong>MI</strong>CSWORKER MATLAB MCP. g e t n e x t t a s k ( ) ;<br />

2<br />

3 i f ( params ˜= [ ] )<br />

4 % param1 : name o f s c r i p t<br />

5 % param2 − param8 : params f o r c a l l e d s c r i p t<br />

6 m s c r i p t = char ( params ( 1 ) ) ;<br />

7<br />

8 . . .<br />

9<br />

10 c = [ m s c r i p t ’ ( ”MCP” , jPROTEO<strong>MI</strong>CSWORKER MATLAB MCP ’ ] ;<br />

11 <strong>for</strong> i = 2 : 9<br />

12 i f ( ˜ isempty ( char ( params ( i ) ) ) )<br />

13 c = [ c ’ , ” ’ char ( params ( i ) ) ’ ” ’ ] ;<br />

14 end<br />

15 end<br />

16 c = [ c ’ ) ’ ] ;<br />

17<br />

18 jPROTEO<strong>MI</strong>CSWORKER MATLAB MCP. c h a n g e s t a t e ( [ ’ P r o c e s s i n g Task ID : ’<br />

19 id ’ − c a l l i n g : ’ c ] ) ;<br />

20 c = strrep ( c , ’ ” ’ , ’ ’ ’ ’ ) ;<br />

21<br />

22 % e x e c u t e matlab s c r i p t<br />

23 eval ( c ) ;<br />

24 end ;<br />

Line 1 requests a new task from <strong>the</strong> QAD Grid. If a new job is available<br />

<strong>the</strong> 9-dimensional array “params” contains <strong>the</strong> parameters <strong>of</strong> this task. The

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!