Function CaseCreateDifferenceFile(referenceCase, outputFilename, diffTypes, absoluteTolerance, relativeTolerance, outputPrecision, respectDomainCurrentCase)

CaseCreateDifferenceFile

With the procedure CaseCreateDifferenceFile you can create an AIMMS input file containing the differences between the current data and a reference case.

CaseCreateDifferenceFile(
        referenceCase,            ! (input) element in the set AllCases
        outputFilename,           ! (input) scalar string expression
        diffTypes,                ! (input)  indexed element parameter
        absoluteTolerance,        ! (optional) scalar expression
        relativeTolerance,        ! (optional) scalar expression
        outputPrecision,          ! (optional) scalar expression
        respectDomainCurrentCase  ! (optional) scalar expression
        )

Arguments

referenceCase

An element in the set AllCases specifying the case to which the current data should be compared.

outputFilename

A string expression specifying the name of the file the differences are written to.

diffTypes

An element parameter indexed over (a subset of) AllIdentifiers with range the predeclared set AllDifferencingModes.

absoluteTolerance

A scalar expression specifying the absolute tolerance when comparing numerical values. The range of this argument is \([0,inf)\), the default is the value of the option equality_absolute_tolerance.

relativeTolerance

A scalar expression specifying the relative tolerance when comparing numerical values. The range of this argument is \([0,1]\), the default is the value of the option equality_relative_tolerance.

outputPrecision

A scalar expression specifying how many decimals should be printed. The range of the argument is \(\{0\ldots{}20\}\), the default is the value of the option listing_precision.

respectDomainCurrentCase

A scalar expression specifying whether or not the current domain should be taken into account. When 0: The current domain is not taken into account and all differences are written to the output file. When 1: The current domain is taken into account; the differences are filtered according to the domain of the identifier.

Return Value

This procedure returns 0 upon failure, 1 upon success. When successful all differences between the current model data and the data in the reference case are written to a file.

Note

  • In a READ statement, when reading from an input file that was generated by CaseCreateDifferenceFile function with diffTypes equal to elementReplacement, elementAddition or elementMultiplication, the file is always read in merge mode, so that the diffTypes can be applied in a sensible way.

Example

Given two cases data/caseA.data and data/caseB.data containing:

caseA

caseB

caseB merged to caseA

p_num

77

88

88

p_dat(a)

11

11

11

p_dat(b)

22

20

20

p_dat(c)

33

33

p_dat(d)

44

44

Then the code:

 1CaseFileLoad(
 2    url                         :  "data/caseA.data",
 3    keepUnreferencedRuntimeLibs :  0);
 4_ep_diffTypes(i_caseManagementData) := 'elementReplacement' ;
 5CaseFileURLtoElement( "data/caseB.data", _ep_refCase, 1 );
 6CaseCreateDifferenceFile(
 7    referenceCase            :  _ep_refCase,
 8    outputFilename           :  "log/casediff.txt",
 9    diffTypes                :  _ep_diffTypes,
10    absoluteTolerance        :  0,
11    relativeTolerance        :  0,
12    outputPrecision          :  0,
13    respectDomainCurrentCase :  0);

Will produce the following contents in log/casediff.txt:

 1chapterData::sectionCaseManagement::s_chars += data
 2{ c } ;
 3chapterData::sectionCaseManagement::s_chars -= data
 4{ d } ;
 5
 6chapterData::sectionCaseManagement::p_num := 77 ;
 7
 8chapterData::sectionCaseManagement::p_dat :=$ data
 9{ b : 22,
10  c : 33,
11  d :  0 } ;