`struct logrel_term*`

.
*/
#define LogTermBinLeft(t) ( ((struct LogRelBinary *)t) -> left)
/**<
* Retrieve the lhs of a binary logical relation.
* Parameter and return values are `struct logrel_term*`

.
*/
#define LogTermBinRight(t) ( ((struct LogRelBinary *)t) -> right)
/**<
* Retrieve the rhs of a binary logical relation.
* Parameter and return values are `struct logrel_term*`

.
*/
extern struct logrel_term *LogRelINF_Lhs(CONST struct logrelation *lrel);
/**<
* Returns the lhs of an infix logical relation. This may be NULL,
* if the logical relation has not been set for infix scanning.
*/
extern struct logrel_term *LogRelINF_Rhs(CONST struct logrelation *lrel);
/**<
* Return the rhs of an infix logical relation. This may be NULL
* if the logical relation has not been set up for infix scanning.
*/
extern CONST struct gl_list_t *LogRelBoolVarList(CONST struct logrelation *lrel);
/**<
* Returns the unique incident variable list which is owned by the
* logical relation. *DO NOT MODIFY*. It is for the convenience of those
* desirous of a READ_ONLY look. It is a list of instance pointers,
* which maybe NULL.
*/
extern CONST struct gl_list_t *LogRelSatRelList(CONST struct logrelation *lrel);
/**<
* Returns the unique relation list which is owned by the
* logical relation. *DO NOT MODIFY*. It is for the convenience of those
* desirous of a READ_ONLY look. It is a list of instance pointers,
* which maybe NULL.
*/
ASC_DLLSPEC int LogRelResidual(CONST struct logrelation *lrel);
/**<
* Return the boolean residual of the logical relation.
*/
extern void SetLogRelResidual(struct logrelation *lrel, int value);
/**<
* Set the value of the logical relation residual.
*/
ASC_DLLSPEC int LogRelIsCond(CONST struct logrelation *lrel);
/**<
* Return the value of the logiscond flag of the logicalrelation.
*/
extern void SetLogRelIsCond(struct logrelation *lrel);
/**<
* Sets the value of the logiscond field of the logical relation to 1
*/
extern int LogRelNominal(CONST struct logrelation *lrel);
/**<
* Return the nominal of the logical relation.
*/
extern void SetLogRelNominal(struct logrelation *lrel, int i);
/**<
* Sets the value of the nominal field of the logical relation to the
* value of i
*/
extern int FindTolInSatTermOfLogRel(struct Instance *lrelinst,
struct Instance *condinst,
double *tolerance);
/**<
* Look in the logrelation instance lrelinst for a SATISFIED term involving
* the instance condinst. When found, it will find the obtain tolerance
* specified in the SATISFIED term (if such a value is given) and it will
* assign it to the *tolerance. If the condinst is a logrel (mistakenly),
* or if the SATISFIED term does not specify a value for the tolerance,
* it will assign the default value DEFTOLERANCE to *tolerance.
* status !=0 indicates it did not find a term containing the instance.
*/
/*
*---------------------------------------------------------------------------
* Calculation routines
*---------------------------------------------------------------------------
*/
/*
* Calculation of the Logical Residuals of a logical relation :
* LogRelCalcResidualPostfix
* LogRelCalcResidualInfix
* and calculation of the values(s) of a boolean variable which make a
* logical relation to be satisfied:
* LogRelFindBoolValues
*
* IMPORTANT:
* The solution of conditional model implicates the presence of
* SATISFIED terms (satisfaction of Boundary conditions)
* in some of the logical relations. Because the freedom that the
* modeling language gives to the user, sometimes is very difficult
* to know if the change of the truth value of a SATISFIED term is
* really meaningful to the configuration of the conditional problem.
* A boundary may be crossed, but still the boolean dependent on that
* condition may not change; furthermore, even a change in that boolean
* may not affect the configuration of the problem because a change
* of configuration may require the satisfaction of several conditions
* simultaneously.
* The easier way to test if the crossing of a boundary affects the current
* configuration is to solve the logical relations assuming such a
* crossing and finding if the configuration of the problem changes.
* This task is performed here by using the "perturb" flag and a list
* of pointers to the relation instance which constitutes the boundary(ies).
* The activation of the perturbation flag causes the calculation
* routines to INVERT the truth value of the SATISFIED terms containing
* the relation instances pointed by the list of pointers.
* The flag and the list of pointers are needed because the SATISFIED term
* is not an instance by itself and we have access to it only trough the
* logrel instance.
* Another option would be to modify the values of the variables incident
* in the boundary until the truth value of the SATISFIED changes by itself,
* but this would have to be iteratively (i.e. more expensive), since it
* would be required to perform gradient calculations in
* order to know how the change of the value of some variable will modify
* the residual of the boundary. Other question that we would need to
* answer is how many variables should be modified simultaneously,etc.
* Notice that this is not necessary because we do not care about a change
* in the real values of the variables incident in the boundary (and, as
* a matter of fact, we do not want ot modify the current values), we only
* want to know what would it happen with the value of logical variables
* if the truth value of the SATISFIED term changes.
*
* A third option would be to keep the information about the number
* of subregions in the conditional model and the values for the booleans
* which make them active. This is unaceptable for problems involving
* a big number of boundary conditions, since the problem is combinatorial.
*
* IN GENERAL, ANY USER INTERESTED IN THESE CALCULATION ROUTINES FOR
* PURPOSES OF SOLVING PURE LOGIC PROBLEMS (NOT CONTAINING BOUNDARIES),
* SHOULD NOT CONSIDER THE
* PARAMETERS EXPLAINED ABOVE. IT IS RECOMMENDED THAT HE/SHE SHOULD
* USE THE MACRO
* LogRelCalcResidual
* WHICH CALL THE CALCULATION ROUTINES WITHOUT CONSIDERING THOSE
* PARAMETERS.
*/
extern int LogRelCalcResidualPostfix(struct Instance *i,
int *res,
int perturb,
struct gl_list_t *instances);
/**<
* Sets *res to the logical residual of the logical relation. The logical
* residual is evaluating by comparing the truth values of the two terms
* of the logical relation. If the logical relation is an equality, a
* residual of 1 (TRUE) means that the two terms has the same truth value,
* if they do not, the residual is zero. Similar reasoning applies when
* the logical relation is an inequality.
* Uses postfix evaluation.
* If *perturb !=0, that means that we will invert the truth value of
* the SATISFIED terms involving the relation instances pointed by the
* gl_list.
* status != 0 implies a problem.
*/
extern int LogRelCalcResidualInfix(struct Instance *i,
int *res,
int perturb,
struct gl_list_t *instances);
/**<
* Sets *res to the logical residual of the logical relation. The logical
* residual is evaluating by comparing the truth values of the two terms
* of the logical relation. If the logical relation is an equality, a
* residual of 1 (TRUE) means that the two terms has the same truth value,
* if they do not, the residual is zero. Similar reasoning applies when
* the logical relation is an inequality.
* Uses infix evaluation.
* If *perturb !=0, that means that we will invert the truth value of
* the SATISFIED terms involving the relation instances pointed by the
* gl_list
* status != 0 implies a problem.
*/
extern int *LogRelFindBoolValues(struct Instance *i,
unsigned long *dvarnum,
int *able,
int *nsolns,
int perturb,
struct gl_list_t *instances);
/**<
* LogRelFindBoolValues WILL find a booolean solution if there is one.
* The user must pass in a pointer to a
* struct logrelation. The calling function should check able and/or
* nsolns before accessing the information in the soln_list.
* nsolns < 0 : severe problems, soln_list will be NULL
* nsolns = 0 : No solution found
* nsolns > 0 : The soln_status equals the number of roots found
* nsolns is at most two for logical operations.
* The calling function should NOT free the soln_list.
* If *perturb !=0, that means that we will invert the truth value of
* the SATISFIED terms involving the relation instances pointed by the
* gl_list in order to find the boolean values wanted.
*/
#define LogRelCalcResidual(i,r) LogRelCalcResidualPostfix(i,r,0,NULL)
/**<
* Macro for users interested in the calculation of pure logic relations.
* Not conditional modeling.
*/
/* @} */
#endif /* ASC_LOGRELATION_UTIL_H */