Next: Example of use of
Up: Using the ALIAS parser
Previous: Evaluating a single formula
Contents
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:
- texte: the name of the file describing the analytical form
of the equation
- P: the ranges for the unknowns
- Unknowns: the number of unknowns
- NbEq: the number of equations
- Value: the interval evaluation of the equations
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:
- texte: the name of the formula file
- EqStart: an array of integer with size equal to the number
of equations in the formula file
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:
- texte: the name of the file describing the analytical form
of the equation
- P: the ranges for the unknowns
- Unknowns: the number of unknowns
- NbEq: the number of equations
- EqToRead: the number of the equation that has to be
evaluated (the equation number start at 1)
- EqStart: the array of integer produced by the
initialization procedure for the formula file
- Value: the interval evaluation of the equation EqToRead
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:
- texte: the name of the file describing the analytical form
of the equation
- P: the ranges for the unknowns
- Unknowns: the number of unknowns
- NbEq: the number of equations
- EqToRead1: the number of the first equation that has to be
evaluated (the equation number start at 1)
- EqToRead2: the number of the last equation that has to be
evaluated
- EqStart: the array of integer produced by the
initialization procedure for the formula file
- Value: the interval evaluation of the equation EqToRead
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:
- Unknowns: the number of unknowns
- NbEq: the number of equations
- texte: the name of the file describing the analytical form
of the equation
- gradient: the name of the parser file giving the gradient matrix
of the equations. The order in this file is to define successively the
derivative of the first equation with respect to each variable, then
the derivative of the second equation and so on
- P: the ranges for the unknowns
- Value: the interval evaluation of the NbEq equations
- Exact: if 0 stop processing the equations as soon as the
interval evaluation of the n-th equation does not include 0 (the
interval evaluation of the remaining n,..,NbEq equations will be
set to 1. If 1 the procedure computes the interval evaluation of all
the equations
Next: Example of use of
Up: Using the ALIAS parser
Previous: Evaluating a single formula
Contents
Jean-Pierre Merlet
2012-12-20