next up previous contents
Next: Example of use of Up: Using the ALIAS parser Previous: Evaluating a single formula   Contents

Evaluating multiple equations

Using the parser you may evaluate more than one equation described in a single formula file. Each equation in the file should be prefixed by the symbol eq= like in:
 
eq=-x1^2-x2+x3
eq=x1^2-x2+x3
eq=round(x3)
All equations in a system of equations may be evaluated by using the procedure
Evaluate_Interval_With_Parser with the following syntax:
 
int Evaluate_Interval_With_Parser(
        char *texte,INTERVAL_VECTOR &P,int Unknowns,int NbEq,INTERVAL_VECTOR &Value)
The parameters are: This procedure returns 1 if the equations have been successfully evaluated, 0 or a negative number otherwise.

Thus for evaluating the formula described by the formula file toto:

 
eq=-x1^2-x2+x3
eq=x1^2-x2+x3
eq=round(x3)
for the ranges x1 in [-1,1], x2 in [0,2], x3 in [1.1,2.3] you may use the following piece of code:
 
INTERVAL_VECTOR P(3);
INTERVAL_VECTOR F(3);
strcpy(variable_name_IS[0],"x1");
strcpy(variable_name_IS[1],"x2");
strcpy(variable_name_IS[1],"x3");
Unknowns_Number_IS=3;

P(1)=INTERVAL(-1,1);//range for x1
P(2)=INTERVAL(0,2);//range for x2
P(3)=INTERVAL(1.1,2.3);//range for x3

Evaluate_Interval_With_Parser("toto",P,3,3,F);
cout<<F<<endl;//interval evaluation of the 3 equations
Instead of evaluating the whole system of equations we may have to evaluate one or more particular equation(s) of the system. The following procedures enable to evaluate efficiently particular equations in a system but before using them we need to do some initialization. This is done by calling once the procedure
Init_Evaluate_Equations_With_Parser with the syntax:
 
int Init_Evaluate_Equations_With_Parser(char *texte,int *EqStart)
The parameters are: This procedure returns the number of equations of the system described in the formula file and -1 if the formula file does not exist. It must be used on each formula file with one particular CharEq per file.

After this initialization the following procedure may be used to evaluate one particular equation in a system:

 
int Evaluate_Equations_With_Parser(char *texte,INTERVAL_VECTOR &P,int Unknowns,
                int NbEq,int EqToRead,int *EqStart,INTERVAL &Value)
The parameters are: This procedure will return 1 on a successful completion. It returns 0 if there was a problem in the evaluation and -1 if the numbering of the equations as indicated in EqToRead is not correct. We may also evaluate more than one equation in a system with:
 
int Evaluate_Equations_With_Parser(char *texte,INTERVAL_VECTOR &P,int Unknowns,
                int NbEq,int EqToRead1,int EqToRead2,int *EqStart,INTERVAL &Value)
The parameters are: This procedure will return 1 on a successful completion. It returns 0 if there was a problem in the evaluation and -1 if the numbering of the equations as indicated in EqToRead1 or EqToRead2 is not correct. We may also use the gradient of the equations to improve the evaluation. The syntax is:
 
int Evaluate_Equations_With_Parser_Gradient(int Unknowns,int NbEq,char *texte,
                   char *gradient,INTERVAL_VECTOR &P, INTERVAL_VECTOR &Value,int Exact)
The parameters are:


next up previous contents
Next: Example of use of Up: Using the ALIAS parser Previous: Evaluating a single formula   Contents
Jean-Pierre Merlet 2012-12-20