nlp.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /****************************************************************
  2. Copyright (C) 1997-1998, 2001 Lucent Technologies
  3. All Rights Reserved
  4. Permission to use, copy, modify, and distribute this software and
  5. its documentation for any purpose and without fee is hereby
  6. granted, provided that the above copyright notice appear in all
  7. copies and that both that the copyright notice and this
  8. permission notice and warranty disclaimer appear in supporting
  9. documentation, and that the name of Lucent or any of its entities
  10. not be used in advertising or publicity pertaining to
  11. distribution of the software without specific, written prior
  12. permission.
  13. LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  14. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  15. IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
  16. SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  18. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  20. THIS SOFTWARE.
  21. ****************************************************************/
  22. #ifndef NLP_H_included
  23. #define NLP_H_included
  24. #ifndef ASL_included
  25. #include "asl.h"
  26. #endif
  27. typedef struct argpair argpair;
  28. typedef struct cde cde;
  29. typedef struct cexp cexp;
  30. typedef struct cexp1 cexp1;
  31. typedef struct de de;
  32. typedef union ei ei;
  33. typedef struct expr expr;
  34. typedef struct expr_f expr_f;
  35. typedef struct expr_h expr_h;
  36. typedef struct expr_if expr_if;
  37. typedef struct expr_v expr_v;
  38. typedef struct expr_va expr_va;
  39. typedef struct funnel funnel;
  40. typedef struct list list;
  41. typedef real efunc ANSI((expr * A_ASL));
  42. #define r_ops r_ops_ASL
  43. #define obj1val obj1val_ASL
  44. #define obj1grd obj1grd_ASL
  45. #define con1val con1val_ASL
  46. #define jac1val jac1val_ASL
  47. #define con1ival con1ival_ASL
  48. #define con1grd con1grd_ASL
  49. #define lcon1val lcon1val_ASL
  50. #define x1known x1known_ASL
  51. union
  52. ei {
  53. expr *e;
  54. expr **ep;
  55. expr_if *eif;
  56. expr_n *en;
  57. int i;
  58. plterm *p;
  59. de *d;
  60. real *rp;
  61. derp *D;
  62. cexp *ce;
  63. };
  64. struct
  65. expr {
  66. efunc *op;
  67. int a;
  68. real dL;
  69. ei L, R;
  70. real dR;
  71. };
  72. struct
  73. expr_v {
  74. efunc *op;
  75. int a;
  76. real v;
  77. };
  78. struct
  79. expr_if {
  80. efunc *op;
  81. int a;
  82. expr *e, *T, *F;
  83. derp *D, *dT, *dF, *d0;
  84. ei Tv, Fv;
  85. expr_if *next, *next2;
  86. };
  87. struct
  88. expr_va {
  89. efunc *op;
  90. int a;
  91. ei L, R;
  92. expr_va *next, *next2;
  93. derp *d0;
  94. };
  95. struct
  96. cde {
  97. expr *e;
  98. derp *d;
  99. int zaplen;
  100. };
  101. struct
  102. de {
  103. expr *e;
  104. derp *d;
  105. ei dv;
  106. };
  107. struct
  108. list {
  109. list *next;
  110. ei item;
  111. };
  112. struct
  113. cexp1 {
  114. expr *e;
  115. int nlin;
  116. linpart *L;
  117. };
  118. struct
  119. cexp {
  120. expr *e;
  121. int nlin;
  122. linpart *L;
  123. funnel *funneled;
  124. list *cref;
  125. ei z;
  126. int zlen;
  127. derp *d;
  128. int *vref;
  129. };
  130. struct
  131. funnel {
  132. funnel *next;
  133. cexp *ce;
  134. derp *fulld;
  135. cplist *cl;
  136. cde fcde;
  137. };
  138. struct
  139. argpair {
  140. expr *e;
  141. union {
  142. char **s;
  143. real *v;
  144. } u;
  145. };
  146. struct
  147. expr_f {
  148. efunc *op;
  149. int a;
  150. func_info *fi;
  151. arglist *al;
  152. argpair *ap, *ape, *sap, *sape;
  153. expr *args[1];
  154. };
  155. struct
  156. expr_h {
  157. efunc *op;
  158. int a;
  159. char sym[1];
  160. };
  161. typedef struct
  162. Edag1info {
  163. cde *con_de_; /* constraint deriv. and expr. info */
  164. cde *lcon_de_; /* logical constraints */
  165. cde *obj_de_; /* objective deriv. and expr. info */
  166. expr_v *var_e_; /* variable values (and related items) */
  167. /* stuff for "defined" variables */
  168. funnel *f_b_;
  169. funnel *f_c_;
  170. funnel *f_o_;
  171. expr_v *var_ex_,
  172. *var_ex1_;
  173. cexp *cexps_;
  174. cexp1 *cexps1_;
  175. efunc **r_ops_;
  176. char *c_class; /* class of each constraint: */
  177. /* 0 = constant */
  178. /* 1 = linear */
  179. /* 2 = quadratic */
  180. /* 3 = general nonlinear */
  181. char *o_class; /* class of each objective */
  182. char *v_class; /* class of each defined variable */
  183. int c_class_max; /* max of c_class values */
  184. int o_class_max; /* max of o_class values */
  185. /* The above are only computed if requested */
  186. /* by the ASL_find_c_class and */
  187. /* ASL_find_o_class bits of the flags arg */
  188. /* to pfgh_read() and pfg_read() */
  189. } Edag1info;
  190. typedef struct
  191. ASL_fg {
  192. Edagpars p;
  193. Edaginfo i;
  194. Edag1info I;
  195. } ASL_fg;
  196. #ifdef __cplusplus
  197. extern "C" {
  198. #endif
  199. extern efunc *r_ops_ASL[];
  200. extern void com1eval_ASL ANSI((ASL_fg*, int, int));
  201. extern void comeval_ASL ANSI((ASL_fg*, int, int));
  202. extern void funnelset_ASL ANSI((ASL_fg*, funnel *));
  203. extern real obj1val ANSI((ASL*, int nobj, real *X, fint *nerror));
  204. extern void obj1grd ANSI((ASL*, int nobj, real *X, real *G, fint *nerror));
  205. extern void con1val ANSI((ASL*, real *X, real *F, fint *nerror));
  206. extern void jac1val ANSI((ASL*, real *X, real *JAC, fint *nerror));
  207. extern real con1ival ANSI((ASL*,int nc, real *X, fint *ne));
  208. extern void con1grd ANSI((ASL*, int nc, real *X, real *G, fint *nerror));
  209. extern int lcon1val ANSI((ASL*,int nc, real *X, fint *ne));
  210. extern int x0_check_ASL ANSI((ASL_fg*, real *));
  211. extern void x1known ANSI((ASL*, real*, fint*));
  212. #ifdef __cplusplus
  213. }
  214. #endif
  215. #define comeval(a,b) comeval_ASL((ASL_fg*)asl,a,b)
  216. #define com1eval(a,b) com1eval_ASL((ASL_fg*)asl,a,b)
  217. #define funnelset(a) funnelset_ASL((ASL_fg*)asl,a)
  218. #define cexps asl->I.cexps_
  219. #define cexps1 asl->I.cexps1_
  220. #define con_de asl->I.con_de_
  221. #define f_b asl->I.f_b_
  222. #define f_c asl->I.f_c_
  223. #define f_o asl->I.f_o_
  224. #define lcon_de asl->I.lcon_de_
  225. #define obj_de asl->I.obj_de_
  226. #define var_e asl->I.var_e_
  227. #define var_ex asl->I.var_ex_
  228. #define var_ex1 asl->I.var_ex1_
  229. #undef f_OPNUM
  230. #define f_OPNUM (efunc*)f_OPNUM_ASL
  231. #endif /* NLP_H_included */