13.7.10. Macro “relauncherCodeMultiTypeKey.C

13.7.10.1. Objective

The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Producing outputs, with a Key format, obtained by doing:

multitype -mtKey

The resulting output file, named _output_multitype_mt_Key_.dat looks like:

w1 = nine
v1 = -0.512095
v1 = 0.039669
v1 = -1.3834
v1 = 1.37667
v1 = 0.220672
v1 = 0.633267
v1 = 1.37027
v1 = -0.765636
v2 = 14.1981
v2 = 14.0855
v2 = 10.7848
v2 = 9.45476
v2 = 9.17308
v2 = 6.60804
v2 = 10.0711
v2 = 14.1761
v2 = 10.318
v2 = 12.5095
v2 = 15.6614
v2 = 10.3452
v2 = 9.41101
v2 = 7.47887
f1 = 32.2723
w2 = eight

13.7.10.2. Macro Uranie

    TDataServer *tds = new TDataServer("foo", "multitype usecase");

    TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
    TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1);

    // Create the TDataServer and create the seed attribute
    tds->addAttribute( new TUniformDistribution("seed",0,100000));

    //Create DOE
    TSampling *tsam = new TSampling(tds,"lhs",100);
    tsam->generateSample();

    // Create output attribute pointers
    TAttribute *w1 = new TAttribute("w1", TAttribute::kString);
    TAttribute *w2 = new TAttribute("w2", TAttribute::kString);
    TAttribute *v1 = new TAttribute("v1", TAttribute::kVector);
    TAttribute *v2 = new TAttribute("v2", TAttribute::kVector);
    TAttribute *f1 = new TAttribute("f1");

    // Create the input files
    TFlatScript inputFile("multitype_input.dat");
    inputFile.setInputs(1, tds->getAttribute("seed"), "seed");    

    // Create the output files
    TKeyResult outputFile("_output_multitype_mt_Key_.dat");
    outputFile.addOutput(w1, "w1");
    outputFile.addOutput(v1, "v1");
    outputFile.addOutput(v2, "v2");
    outputFile.addOutput(f1, "f1");
    outputFile.addOutput(w2, "w2");

    // Create the user's evaluation function
    TCodeEval eval("multitype -mtKey");
    eval.addInputFile(&inputFile); // Add the input file
    eval.addOutputFile(&outputFile); // Add the output file

    //Create the runner
    TSequentialRun runner(&eval);

    // Start the slaves
    runner.startSlave();                                           
    if (runner.onMaster())
    {

        // Create the launcher
        TLauncher2 lanceur(tds, &runner);
        lanceur.solverLoop();
          
        // Stop the slave processes
        runner.stopSlave();
        
    }        

    //Produce control plot
    pad->Draw(); 
    pad->cd();
    tds->drawPairs("w1:v1:v2:f1:w2");

The beginning of the code is pretty common to many other macros: creating a dataserver and input attributes (here the only one is the seed, needed for the random generator to produce vectors and strings). A sampling object is created as well to produce a 100-points design-of-experiments and the output attributes are created, as such:

    // Create output attribute pointers
    TAttribute *w1 = new TAttribute("w1", TAttribute::kString);
    TAttribute *w2 = new TAttribute("w2", TAttribute::kString);
    TAttribute *v1 = new TAttribute("v1", TAttribute::kVector);
    TAttribute *v2 = new TAttribute("v2", TAttribute::kVector);
    TAttribute *f1 = new TAttribute("f1");

This is where the specificity of the vector and string is precised. It will be passed on to the rest of the code automatically. The rest is common to many relauncher job (for instance Macro “relauncherCodeFlowrateSequential.C”) with the only difference being that the output file is a key type one. It results in the following plots.

13.7.10.3. Graph

../../_images/relauncherCodeMultiTypeKey.png

Figure 13.53 Graph of the macro “relauncherCodeMultiTypeKey.C”