eq=(y^2-1)*z+(2*y*t-2)*x eq=2+(-10*t+(-10+2*y*t)*y)*y+((4+4*y^2)*z+(4+4*y*t-x*z)*x)*x eq=(2*y*t-2)*z+(t^2-1)*x eq=2+(4*x+(4-x*z)*z)*z+((-10+4*z^2)*y+(-10+4*x*z+2*y*t)*t)*tis a valid formula file in parser format. There is however a limitation on the number of unknowns which cannot exceed 200. Note that the variable names in a formula file may be any name composed with lower and upper cases, integer numbers and underscore, with the constraint that the first character should be a letter. Note also that a MAPLE library enables to produce a formula file directly from MAPLE equations (see section 12.3).
The parser may handle almost any complex analytical equation based on the most classical mathematical functions, using MAPLE notation. Currently you may use the following operators:
Min(3,3*x1,3*x2+x3,4*(x2+x1))for x1 in [-1,1], x2 in [0,2], x3 in [3,10] will return the interval [-4,-4]
The parser may also handle intervals. For example you may evaluate an equation in which some coefficients are intervals. In the equation these coefficients should be indicated using the MAPLE notation as in the following example:
INTERVAL(0.1 .. sin(1))
The formula file name will be used as an input in all the procedures described in the following sections. As for the variable you must fill the text variable variable_name_IS defined by
char variable_name_IS;with the name of you variable and set the integer variable Unknowns_Number_IS to the number of unknowns in your equations as in
strcpy(variable_name_IS,"x"); strcpy(variable_name_IS,"y"); Unknowns_Number_IS=2;Note that the variable names may be any name composed with lower and upper cases, integer numbers and underscore, with the constraint that the first character should be a letter.
In the following procedures we will then use an interval vector to define the ranges for the unknowns. In this vector the ranges are ordered so that this order will correspond to the order in the declaration of the variable name (in the previous example the first range will be the range for x and the second range will be the range for y).
int Evaluate_Interval_With_Parser( char *texte,INTERVAL_VECTOR &P,int Unknowns,INTERVAL &Value)The parameters are:
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
int Evaluate_Interval_With_Parser( char *texte,INTERVAL_VECTOR &P,int Unknowns,int NbEq,INTERVAL_VECTOR &Value)The parameters are:
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,"x1"); strcpy(variable_name_IS,"x2"); strcpy(variable_name_IS,"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 equationsInstead 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
int Init_Evaluate_Equations_With_Parser(char *texte,int *EqStart)The parameters are:
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:
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:
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:
The program Evaluation provided in the ALIAS distribution is a simple example of the use of the evaluation through the parser. In its simplest form it takes as first argument a formula file and as second argument a range file (see section 12.2 for the definition of a range file) and print the interval evaluation of all the equations:
Evaluation [formula file] [range file]A third integer argument n1 may be the number of the equation we want to evaluate (the number start at 1), while if a fourth integer argument n2 is present the evaluation of the equations from n1 to n2 will be printed.
psi 0 0.2 x 1 2.5If f denotes a formula file and r a range file then you may run:
Interval_Solver -F f -R rIn that case the program will call the procedure Solve_General_Interval12.1 of the ALIAS library.
Instead of using the Solve_General_Interval procedure of ALIAS you may use the
Solve_General_Gradient_Interval procedure which requires the gradient of the equations. The gradient equations are defined in a formula file (e.g. g) and you may then run:
Interval_Solver -F f -G g -R rNote that the equations in the gradient formula file should be ordered with respect to the unknowns using the same ordering than the one used in the range file. Thus for the range file:
x 1 2.5 y 0 0.2and the formula file f:
eq=y+3*x eq=x^2+x*ydenoted eq1, eq2, the first line of the gradient formula file should be deq1/dx, the second line deq1/dy and so on, which will lead to the following gradient file:
eq=3 eq=1 eq=2*x+y eq=x
Similarly, instead of using the Solve_General_Gradient_Interval procedure of ALIAS you may use the Solve_General_JH_Interval procedure which requires the gradient and hessian of the equations. The hessian equations are defined in a formula file (e.g. h) and you may then run:
Interval_Solver -F f -G g -H h -R rNote that the hessian formula file should respect the same ordering than for the gradient formula file. For our previous example the hessian file will be:
eq=0 eq=0 eq=0 eq=0 eq=2 eq=1 eq=1 eq=0Note also that the various formula files may be easily obtained by using the MAPLE procedures described in the next section (12.3).
The result of the computation will be written in a result file. Each line of the result file gives the range for one of the unknowns, using the same ordering than for the range file (in our example the range of x, followed by the range for y). A range is indicated by two reals separated by a blanc character. If instead of range the result file contain the keyword FAILED it means that the solver has been unable to solve the equations. This keyword is followed by an integer which indicate the reason of the failure:
Whatever the used solving procedure, some parameters are to be set. The solver will prompt you to give the values of these parameters. If you want to avoid this interactive behavior you may define the parameters in a configuration file and the solver will proceed directly to the solution. A configuration file consists in a list of keywords followed by a value. Most of these keywords refers to parameters in the solving procedure of ALIAS, please refer to the corresponding section for their meaning:
-I [inequalities file]inequalities file is a formula file, called the inequalities file that describe equations in the same manner than a formula file. But the solver will output as solutions only the ranges for which all the equations in the inequalities file may be positive or equal to 0 and eliminate the solutions ranges for which at least one equation is strictly negative. Note that the algorithm stops only according to the values of the equations or the diameter of the ranges and not according to the values of the inequalities.
eq1:=x^2-x*cos(y)-x1:x1 may be considered as a parameter while x, y are the unknowns. Each line of the parameter file indicates a name of a parameter and its value. Thus
x1 1is a valid parameter file. Then you may use the programs of the MAPLE library (see section 12.3) to generate the parser files for the solver: these programs enable to specify that x1 is not an unknown. The generated files will contain the parameter x1 and if you want to solve a particular occurrence of the parametric system you just have to add an argument to the command line of the generic solver:
-P [parameter file]and if you want to study another occurrence (for example when the value of x1 is 2) you just have to change the value in the parameter file.
Some specific parameters with special names may also be used to speed up the computation, see section 126.96.36.199.
readlib(lib_IS): eq1:=y**2*z+2*x*y*t-2*x-z: eq2:=-x**3*z+4*x*y**2*z+4*x**2*y*t+2*y**3*t+4*x**2-10*y**2+4*x*z-10*y*t+2: eq3:=2*y*z*t+x*t**2-x-2*z: eq4:=-x*z**3+4*y*z**2*t+4*x*z*t**2+2*y*t**3+4*x*z+4*z**2-10*y*t-10*t**2+2: write_equation([eq1,eq2,eq3,eq4],"fcap"): write_gradient_equation([eq1,eq2,eq3,eq4],"gcap",[x,y,z,t]): write_hessian_equation([eq1,eq2,eq3,eq4],"hcap",[x,y,z,t]):The formula file for the 4 equations will be written in the file fcap while the jacobian and hessian will be written in the file gcap, hcap. Note that the range file should define the ranges for the unknowns in the order x,y,z,t.
We will then try to improve the obtained ranges by using Kantorovitch theorem. We consider the middle point of the ranges and test if Kantorovitch is able to determine a ball centered at this point for which Newton method will converge toward the unique solution in the ball. If the answer is positive we will use Newton with as starting point the center of the ball: the result, a point, is stored as one of the result ranges. The intersection of the ball with the initial range will then be computed and if non empty will be stored for further processing.
We may indeed perform an in-depth analysis. The previous process is applied on the initial range and will lead to a set of ranges (possibly to the same ranges than the initial one); we may then bisect the obtained ranges and reiterate the process on the resulting ranges, discarding those for which the interval evaluation for at least one of the equations does not include 0. We define a depth level for the algorithm as the number of bisection steps that will be used in the process (a depth 0 means that no bisection will be done).
A formal-numerical approach has been used to develop this generic analyzer. Basically it takes as input a MAPLE file, called the formula file, which define the analytical form of the equations of the system and a range file in in which are defined both the names of the variables and their initial ranges (a range file may contain more than one set of ranges for the unknowns). The convention in the formula file is to define each equation of the system in the MAPLE file as a sentence prefixed by the key-word eqn where n is the number of the equation starting at 1. For example
eq1:=y**2*z+2*x*y*t-2*x-z: eq2:=-x**3*z+4*x*y**2*z+4*x**2*y*t+2*y**3*t+4*x**2-10*y**2+4*x*z-10*y*t+2: eq3:=2*y*z*t+x*t**2-x-2*z: eq4:=-x*z**3+4*y*z**2*t+4*x*z*t**2+2*y*t**3+4*x*z+4*z**2-10*y*t-10*t**2+2:is a valid formula file, describing a set of 4 equations. The range file has as many lines as unknowns and each line start by the name of the variable followed by two numbers indicating the range for the variable. For example
x -100 100 y -100 100 z -100 100 t -100 100is a valid range file for the previous formula file. The analyzer is able to deal with infinity in the ranges: instead of using numbers you may indicate infinity or -infinity. In a first step the analyzer will use MAPLE to produce various intermediary files which are needed for the algorithm to proceed (see section 188.8.131.52). For example it will write in the /tmp/Equation file a description of the system compatible with the syntax used by the parser. Similarly you will find in the /tmp/Gradient_Equation and Hessian_Equation files a description of the gradient and hessian of the system. As soon as all the necessary files have been written, the algorithms described in the previous section will be used.
The result of the analyzer is a file (by default .result_IA) that describe the possibles ranges which may contain real roots of the system. This file may then be used as input for the solver. The analyzer will also produced the .gradient_IA file that indicate the value of the gradient matrices for each of the out ranges.
The analyzer is run by using the syntax:
Interval_Analyzer -F [formula file] [-G] [-H] -R [range file]In this list of argument only the -F, -R are compulsory. The -G option indicates that you will use the monotonicity of the equations (evaluated through an interval evaluation of the gradient) to improve the interval evaluation of the equations. The -H indicates that you will also use Kantorovitch theorem to isolate the real roots of the equations. In that case if you have equations and unknowns with , then Kantorovitch will be applied on the first equations.
This program will then ask you the maximum number of ranges that may be created by the algorithm, an accuracy on the value of the equations that will be used to stop the computation of the Newton scheme, a minimal value for the maximal diameter for the output ranges (which is not used right now), a depth level, a maximal diameter for the ranges over which Kantorovitch is not used and the value of the debug level (0 if the program is to be run quietly, 1 to see how many boxes are dealt with and 2 for a full debug). Note that if you are using the -H option and have equations and unknowns, with and if the algorithm returns roots of the system (i.e. the output ranges are reduced to a point) it will mean that these points are guaranteed roots of the first equations (you may use the Newton scheme with a lower on these roots and you will still get a root), while the absolute values of the remaining equations at these points will be lower than but there is no guarantee that these points are effectively roots of these equations.
Alternatively you may use a configuration file to give values for these parameters.
A configuration file consists in a list of keywords followed by a value.
Iteration 1000 AccuracyF 0.00001 Debug 0 Kanto 0.5 Level 2 Location_IS /u/ALIAS/Mapleis a valid configuration file. It indicates that at most 1000 ranges may be created (this is not the maximal number of ranges at the end of the algorithm but the maximal number of ranges that may be created at any time in the algorithm), that the accuracy for the Newton scheme is 0.00001, that the algorithm will run quietly, that Kantorovitch will be used as soon as the maximal diameter of the considered range is lower than 0.5 and that the depth level will be 2. We indicate also in which directory is located the library lib_IS. files are located.
You use the configuration file with the syntax:
Interval_Analyzer -F [formula file] -G -H -R [range file] -C [configuration file]So a typical analysis and solving process will be done by using the two following command lines (which are basically identical to what is used in the script script_solver provided in the standard distribution of ALIAS):
Interval_Analyzer -F equation.maple -G -H -R range -C conf_analyzer Interval_Solver -F /tmp/Equation -G /tmp/Gradient_Equation -H /tmp/Hessian_Equation -R .result_IA -GI .gradient_IA -C conf_solverYou will then have the result of the solution of your system in the file .result_IS.
Interval_Analyzer -F [formula] [-G -H] -R [range] -I [inequalities]inequalities is a MAPLE file, called the inequalities file that describe equations in the same manner than a formula file. But the analyzer will output as possible ranges only the ranges for which all the equations in the inequalities file may be positive or equal to 0 and eliminate the ranges for which at least one equation is strictly negative.
As soon as these files have been generated once it is not necessary to re-compute them. To indicate that these quantities have been already processed it is is sufficient to include the following sentence in the configuration file:
Directory nameInstead of computing these files the analyzer will look for them in the directory name. Thus for example after running the analyzer for the first time without this sentence in the configuration file you may analyze the same system without processing the file by indicating in your configuration file:
eq1:=x^2-x*cos(y)-x1:x1 may be considered as a parameter. On the first run of the analyzer the intermediary files described in the previous section will be generated and at run time the value of x1 will be substituted by the value indicated in the parameter file. After this first run and if you want to analyze the system with another value for x1 you may use the pre-processing mechanism described in the previous section and just change the value of x1 in the parameter file. See section 184.108.40.206 for an example of the analysis of parametric system.
Each line of the parameter file indicates a name of a parameter and its value. Thus
x1 1is a valid parameter file. To indicate a parameter file to the analyzer use the -P argument followed by the name of the parameter file.
A special case of parameter may be used to speed up the computation. Assume that you have a system with large numerical constants (by "large" we mean that the string representing the numerical values has a large number of characters). Each evaluation of your system will require first to read the strings representing the numerical constants and then to convert it in a float number. It may therefore be interesting to store once the constants values and to substitute them in the analytical form of the equations by symbols which may be attached to these values. This may be done by substituting the numerical constants by symbols of the form _IA where is an integer starting from 0. These parameters have then to be stored in a parameter file. Thus, for example, consider the equations:
eq1:=1.12345678901*x1+4.563213456789222:Using MAPLE you may easily change this equation to:
eq1:=_IA0*x1+_IA1:and store the values in a parameter file:
_IA0 1.12345678901 _IA1 4.563213456789222When reading the parameter file the program will store in a special array the value of the parameters whose name start by the symbol _IA. Then, when the parser find a symbol starting with this symbol it will determine the number following this keyword (which is the value of the index in the parameter table) and will just substitute the corresponding value found in the parameter table. Hence when evaluating an expression the parser will have to read less character and avoid unnecessary conversion from a string to a double. Note that these parameters must be numbered in sequence, starting from 0.
eq1:=x^2-x*cos(y)-1: eq2:=y^2-cos(x)-1:for which we want to determine if real roots exist in the range [-5,5], [-5,5]. With a depth level 0 (no bisection is done) the analyzer proposes the following ranges as possibly containing a real root:
Range 1( x y) [-0.86812856880248989722,-0.86812856880248989722] [-1.28306500467802298,-1.28306500467802298] Range 2( x y) [1.219833908062562422,1.219833908062562422] [-1.1592247392497665448,-1.1592247392497665448] Range 3( x y) [1.2198350997243703198,1.2198367316341245381] [-1.159223547587958647,-1.1592195879408853099] Range 4( x y) [-0.86812856880248978619,-0.86812856880248978619] [1.28306500467802298,1.28306500467802298] Range 5( x y) [1.219833908062562422,1.219833908062562422] [1.1592247392497667668,1.1592247392497667668] Range 6( x y) [1.2198352388536839452,1.2198367316341249822] [1.1592195879408850878,1.1592236867169092296]this 6 ranges, 4 are reduced to point and are therefore a result of the application of the Newton scheme. The other 4 ranges are very close to one of the solution, but the algorithm has not been able to eliminate them. With a depth level of 1 the algorithm proposes directly the four solutions of this system:
Range 1( x y) [-0.86812741994331155126,-0.86812741994331155126] [-1.2830653469203250339,-1.2830653469203250339] Range 2( x y) [1.2198339926936523359,1.2198339926936523359] [-1.1592245852349318813,-1.1592245852349318813] Range 3( x y) [-0.86812741994331166229,-0.86812741994331166229] [1.2830653469203250339,1.2830653469203250339] Range 4( x y) [1.219833901899016082,1.219833901899016082] [1.159224777165462017,1.159224777165462017]Note that the initial range [-5,5] may be largely expanded without modifying the result and with only a low amount of additional computation time. For example for the range [-1000,1000] for both variables the computation time remains the same.
The previous system may be considered as a special occurrence of the system:
eq1:=x^2-x*cos(y)-x1: eq2:=y^2-cos(x)-1:where the parameter x1 has value 1. This special case of the generic system may be analyzed by indicating in a parameter file:
x1 1Now just by changing the value of x1 in this file to
x1 2and modifying the configuration file to include the sentence:
Directory /tmpwe will get the solutions:
Range 1( x y) [-1.2271026453420417202,-1.2271026453420417202] [-1.1562745250557344701,-1.1562745250557344701] Range 2( x y) [1.757647484313144215,1.757647484313144215] [-0.90234927430355182931,-0.90234927430355182931] Range 3( x y) [-1.2271026453420417202,-1.2271026453420417202] [1.1562722309470763182,1.1562722309470763182] Range 4( x y) [1.757647484313144215,1.757647484313144215] [0.90234927430355205136,0.90234927430355205136]
int Equation_Analyzer(int Dimension,int Dimension_Eq,int MaxBox, char *formula_file,char *gradient_file,char *hessian_file, char *inequalities_file,char *dimension_file,char *coeff_file, char *gradient_coeff_file, int method,int nb_inequalities,int equation_processed, INTERVAL_VECTOR &Input, double Acc_Var,double Acc_Eq,double Acc_Kanto, int Depth_Level, INTERVAL_MATRIX &Range, int *Nb_Range);with:
Beside these arguments you must fill the string array variable_name_IS with the name of the unknowns. If you have a parametric system you must indicate the name of the parameters in the string array parameter_name_IS, their values in the array of doubles parameter_value_IS and set the integer variable Nb_Parameter_IA to the number of parameters.
header_parser.h header_Solve_General_Interval.h header_Utilities_Interval.hIf you are planing to use the analyzer you must include the library lib_UP.a. In your program you must avoid to use variables whose name include the symbols _IA and _IS.
The following programs are equivalent to the standard ALIAS programs except that they use the parser.
int Kantorovitch_Analyzer(int Dimension, char *Function_File,char *Gradient_File, char *Hessian_File, VECTOR &Input,double *eps); int Newton(int Dimension, char * TheIntervalFunction_File, char * Gradient_File, VECTOR &Input,double Accuracy,int Max_Iter,VECTOR &Residu); int Solve_General_Interval(int Dimension_Var,int Dimension_Eq, char * TheIntervalFunction_File, INTERVAL_VECTOR & TheDomain, int Order, int Iteration, int Stop_First_Sol, double Accuracy_Variable, double Accuracy, double Dist_Sol_Diff, INTERVAL_MATRIX & Solution,int Nb_Max_Solution, int nb_inequalities,char *Ineq_File); int Solve_General_Gradient_Interval(int Dimension,int Dimension_Eq, char * TheIntervalFunction_File, char * Gradient_File, INTERVAL_VECTOR & TheDomain, int Order, int Iteration, int Stop_First_Sol, double Accuracy_Variable, double Accuracy, double Dist_Sol_Diff, INTERVAL_MATRIX & Solution,int Nb_Max_Solution, int nb_inequalities,char *Ineq_File); int Solve_General_Gradient_Interval(int Dimension,int Dimension_Eq, char * TheIntervalFunction_File, char * Gradient_File, INTERVAL_VECTOR & TheDomain, int Order, int Iteration, int Stop_First_Sol, double Accuracy_Variable, double Accuracy, double Dist_Sol_Diff, INTERVAL_MATRIX & Solution,int Nb_Max_Solution, INTEGER_VECTOR &Init_Grad, int nb_inequalities, char *Ineq_File); int Solve_General_JH_Interval(int Dimension,int Dimension_Eq, char * TheIntervalFunction_File, char * Gradient_File, char * Hessian_File, INTERVAL_VECTOR & TheDomain, int Order, int Iteration, int Stop_First_Sol, double Accuracy_Variable, double Accuracy, INTERVAL_MATRIX & Solution, INTEGER_VECTOR & Is_Kanto, int Apply_Kanto, int Nb_Max_Solution, int nb,char *file);