8.3.3.3. Input file
Input file formats supported by TCodeEval objects, include:
TFlatScript, Input file is created from scratch. Values are given in order separated by a blank separator. The default behaviour with respect to strings and vectors for this file, is to look like the DataServer format (from the Launcher module): strings have no specific beginning/ending characters, as for the vectors whose delimiter is chosen to be a comma.TLineScript, Input file is created from scratch. EachTAttributevalues are written on a specific line. Changing attribute means changing line. It is the equivalent of the Column format (from the Launcher module).TKeyScript, Input file is created from an original file. EachTAttributeis associated to a keyword. Values are substituted using a “keyword = value” pattern.TFlagScript, Input file is created from a template file. EachTAttributeis associated to a keyword. Each keyword is substituted directly by the current value.
TXmlScript is not provided in this version
The addInput method is used to declare parameters for all these file types. For TFlatScript and
TLineScript, it takes a single argument: a pointer to a TAttribute object, while in the two
other cases, the same first argument is completed by a const char * for the key. The declaration
order is only significant when no key is specified (so for the TFlatScript and TLineScript files).
// Input File Flat format case
TFlatScript finp1("input_rosenbrock_with_values_rows.dat");
finp1.addInput(&x); // Adding attributes in the correct order, one-by-one
finp1.addInput(&y);
// Or Input File Key format case
TKeyScript kinp1("input_rosenbrock_with_keys.dat");
kinp1.addInput(&x, "x"); // Adding attributes in the correct order, one-by-one
kinp1.addInput(&y, "y");
A more condensed version of this addInput method exists for all these input types: the
setInputs method. Here as well, it takes an extra compulsory argument, an integer which equals
the number of attributes to come. The rest of the arguments are either a single pointer to a
TAttribute object for the TFlatScript and TLineScript objects, or a pair composed of the
same pointer directly followed by the key (for the two other input file types). Starting back
from our example written above, one could condensate this into these lines:
// Input File Flat format case
TFlatScript finp2("input_rosenbrock_with_values_rows.dat");
finp2.setInputs(2, &x, &y); // Adding attributes in the correct order, all at once
// Or Input File Key format case
TKeyScript kinp2("input_rosenbrock_with_keys.dat");
kinp2.setInputs(2, &x, "x", &y, "y"); // Adding attributes in the correct order, all at once
Once done, the input files are provided to the TCodeEval object, using the addInputFile method,
as shown below:
// Add to the TCodeEval
TCodeEval code("rosenbrock -r"); // put "rosenbrock -k" instead for key
code.addInputFile(&finp1); // put &kinp1 instead for key