psinfo.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. #ifdef PSHVREAD
  23. #ifndef PSINFO_H2_included
  24. #define PSINFO_H2_included
  25. #undef PSINFO_H_included
  26. #ifndef NLP_H2_included
  27. #include "nlp2.h"
  28. #endif
  29. #define cde cde2
  30. #define la_ref la_ref2
  31. #define linarg linarg2
  32. #define range range2
  33. #define rhead rhead2
  34. #define psb_elem psb_elem2
  35. #define psg_elem psg_elem2
  36. #define ps_func ps_func2
  37. #define dv_info dv_info2
  38. #define split_ce split_ce2
  39. #define ps_info ps_info2
  40. #define psinfo psinfo2
  41. #endif /* PSINFO_H2_included */
  42. #else /* PSHVREAD */
  43. #ifndef PSINFO_H1_included
  44. #define PSINFO_H1_included
  45. #undef PSINFO_H_included
  46. #ifndef NLP_H_included
  47. #include "nlp.h"
  48. #endif
  49. #endif
  50. #endif /* PSHVREAD */
  51. #ifndef PSINFO_H_included
  52. #define PSINFO_H_included
  53. typedef struct la_ref la_ref;
  54. typedef struct linarg linarg;
  55. typedef struct range range;
  56. struct
  57. la_ref {
  58. la_ref *next;
  59. expr **ep;
  60. real c;
  61. real scale;
  62. };
  63. struct
  64. linarg {
  65. linarg *hnext; /* for hashing */
  66. linarg *tnext; /* next linear argument to this term */
  67. linarg *lnext; /* for adjusting v->op */
  68. la_ref *refs; /* references */
  69. expr_v *v; /* variable that evaluates this linear term */
  70. ograd *nz; /* the nonzeros */
  71. int nnz; /* number of nonzeros (to help hashing) */
  72. int termno; /* helps tell whether new to this term */
  73. };
  74. typedef struct
  75. rhead {
  76. range *next, *prev;
  77. } rhead;
  78. #ifndef PSINFO_H0_included
  79. #define MBLK_KMAX 30
  80. #endif /* PSINFO_H0_included */
  81. typedef struct psb_elem psb_elem;
  82. struct
  83. range {
  84. rhead rlist; /* list of all ranges */
  85. range *hnext; /* for hashing U */
  86. range *hunext; /* for hashing unit vectors */
  87. int n; /* rows in U */
  88. int nv; /* variables involved in U */
  89. int nintv; /* number of internal variables (non-unit */
  90. /* rows in U) */
  91. int lasttermno; /* termno of prev. use in this term */
  92. /* -1 ==> not yet used in this constr or obj. */
  93. /* Set to least variable (1st = 0) in this */
  94. /* range at the end of psedread. */
  95. int lastgroupno; /* groupno at last use of this term */
  96. psb_elem *refs; /* constraints and objectives with this range */
  97. int *ui; /* unit vectors defining this range */
  98. /* (for n >= nv) */
  99. linarg **lap; /* nonzeros in U */
  100. int *cei; /* common expressions: union over refs */
  101. real *hest; /* nonzero ==> internal Hessian triangle */
  102. /* computed by hvpinit */
  103. };
  104. struct
  105. psb_elem { /* basic element of partially-separable func */
  106. psb_elem *next; /* for range.refs */
  107. range *U;
  108. int *ce; /* common exprs if nonzero: ce[i], 1 <= i <= ce[0] */
  109. cde D; /* derivative and expr info */
  110. int conno; /* constraint no. (if >= 0) or -2 - obj no. */
  111. int termno;
  112. int groupno;
  113. };
  114. typedef struct
  115. psg_elem { /* group element details of partially-separable func */
  116. real g0; /* constant term */
  117. real g1; /* first deriv of g */
  118. real g2; /* 2nd deriv of g */
  119. real scale; /* temporary(?!!) until we introduce unary OPSCALE */
  120. expr_n esum; /* esum.v = result of summing g0, E and L */
  121. expr *g; /* unary operator */
  122. expr *ge; /* "last" unary operator */
  123. ograd *og; /* first deriv = g1 times og */
  124. int nlin; /* number of linear terms */
  125. int ns; /* number of nonlinear terms */
  126. linpart *L; /* the linear terms */
  127. psb_elem *E; /* the nonlinear terms */
  128. } psg_elem;
  129. typedef struct
  130. ps_func {
  131. int nb; /* number of basic terms */
  132. int ng; /* number of group terms */
  133. int nxval; /* for psgcomp */
  134. psb_elem *b; /* the basic terms */
  135. psg_elem *g; /* the group terms */
  136. } ps_func;
  137. typedef struct
  138. dv_info { /* defined variable info */
  139. ograd *ll; /* list of linear defined vars referenced */
  140. linarg **nl; /* nonlinear part, followed by 0 */
  141. real scale; /* scale factor for linear term */
  142. linarg *lt; /* linear term of nonlinear defined var */
  143. } dv_info;
  144. typedef struct
  145. split_ce {
  146. range *r;
  147. int *ce; /* common expressions */
  148. } split_ce;
  149. #ifdef PSHVREAD
  150. struct
  151. hes_fun {
  152. hes_fun *hfthread;
  153. cexp2 *c;
  154. real *grdhes;
  155. ograd *og;
  156. expr_v **vp;
  157. int n;
  158. };
  159. typedef struct Hesoprod Hesoprod;
  160. struct
  161. Hesoprod {
  162. Hesoprod *next;
  163. ograd *left, *right;
  164. real coef;
  165. };
  166. typedef struct uHeswork uHeswork;
  167. struct
  168. uHeswork {
  169. uHeswork *next;
  170. int k;
  171. range *r;
  172. int *ui, *uie;
  173. ograd *ogp[1]; /* scratch of length r->n */
  174. };
  175. typedef struct Umultinfo Umultinfo;
  176. struct
  177. Umultinfo {
  178. Umultinfo *next;
  179. ograd *og, *og0;
  180. expr_v *v;
  181. int i;
  182. };
  183. typedef struct Ihinfo Ihinfo;
  184. struct
  185. Ihinfo {
  186. Ihinfo *next; /* for chaining ihinfo's with positive count */
  187. range *r; /* list, on prev, of ranges with this ihd */
  188. real *hest; /* hest memory to free */
  189. int ihd; /* internal Hessian dimension, min(n,nv) */
  190. int k; /* htcl(nr*(ihd*(ihd+1)/2)*sizeof(real)) */
  191. int nr; /* number of ranges with this ihd */
  192. };
  193. #endif /* PSHVREAD */
  194. typedef struct
  195. ps_info {
  196. Long merge; /* for noadjust = 1 */
  197. ps_func *cps;
  198. ps_func *ops;
  199. dv_info *dv;
  200. expr_v **vp; /* for values of common variables */
  201. rhead rlist;
  202. linarg *lalist; /* all linargs */
  203. int *dvsp0; /* dvsp0[i] = subscript of first var into which */
  204. /* cexp i was split, 0 <= i <= ncom */
  205. int nc1; /* common expressions for just this function */
  206. int ns0; /* initial number of elements */
  207. int ncom; /* number of common expressions before splitting */
  208. int ndupdt; /* duplicate linear terms in different terms */
  209. int ndupst; /* duplicate linear terms in the same term */
  210. int nlttot; /* total number of distinct linear terms */
  211. int ndvspcand; /* # of defined variable candidates for splitting */
  212. int ndvsplit; /* number of defined variables actually split */
  213. int ndvspin; /* number of incoming terms from split defined vars */
  214. int ndvspout; /* number of terms from split defined variables */
  215. int max_var1_; /* used in psedread and pshvread */
  216. int nv0_; /* used in psedread and pshvread */
  217. #ifdef PSHVREAD
  218. /* Stuff for partially separable Hessian computations... */
  219. /* These arrays are allocated and zero-initialized by hes_setup, */
  220. /* which also supplies the cei field to ranges. */
  221. range **rtodo; /* rtodo[i] = ranges first incident on col i */
  222. uHeswork **utodo; /* unit ranges affecting this col */
  223. Hesoprod **otodo;/* otodo[i] = contributions to col i dispatched */
  224. /* by previous rtodo entries */
  225. Hesoprod *hop_free;
  226. real *dOscratch;/* length = nmax (below) */
  227. int *iOscratch; /* length = nmax */
  228. Ihinfo *ihi;
  229. Ihinfo *ihi1; /* first with positive count */
  230. int hes_setup_called;
  231. int nmax; /* max{r in ranges} r->n */
  232. int ihdcur; /* Current max internal Hessian dimension, */
  233. /* set by hvpinit. */
  234. int ihdmax; /* max possible ihd (limited by ihe_limit) */
  235. int ihdmin; /* min possible ihd > 0 and <= ihdmax, or 0 */
  236. int khesoprod; /* used in new_Hesoprod in sputhes.c */
  237. int pshv_g1; /* whether pshv_prod should multiply by g1 */
  238. int linmultr; /* linear common terms used in more than one range */
  239. int linhesfun; /* linear common terms in Hessian funnels */
  240. int nlmultr; /* nonlin common terms used in more than one range */
  241. int nlhesfun; /* nonlin common terms in Hessian funnels */
  242. int ncongroups; /* # of groups in constraints */
  243. int nobjgroups; /* # of groups in objectives */
  244. int nhvprod; /* # of Hessian-vector products at this Hessian */
  245. int npsgcomp; /* Has psgcomp been called? For sphes_setup. */
  246. expr_va *valist; /* for sphes_setup */
  247. expr_if *iflist; /* for sphes_setup */
  248. int *zlsave; /* for S->_zl */
  249. #endif /* PSHVREAD */
  250. split_ce *Split_ce; /* for sphes_setup */
  251. } ps_info;
  252. #ifdef PSHVREAD
  253. typedef struct
  254. ASL_pfgh {
  255. Edagpars p;
  256. Edaginfo i;
  257. Char *mblk_free[MBLK_KMAX];
  258. Edag2info I;
  259. ps_info2 P;
  260. } ASL_pfgh;
  261. #else
  262. typedef struct
  263. ASL_pfg {
  264. Edagpars p;
  265. Edaginfo i;
  266. Char *mblk_free[MBLK_KMAX];
  267. Edag1info I;
  268. ps_info P;
  269. } ASL_pfg;
  270. #endif /* PSHVREAD */
  271. #ifdef __cplusplus
  272. extern "C" {
  273. #endif
  274. #ifndef PSINFO_H0_included
  275. #define PSINFO_H0_included
  276. typedef unsigned Long Ulong;
  277. #endif /* PSINFO_H0_included */
  278. #ifdef PSHVREAD
  279. extern void duthes_ASL(ASL*, real *H, int nobj, real *ow, real *y);
  280. extern void fullhes_ASL(ASL*, real*H, fint LH, int nobj, real*ow, real*y);
  281. extern void hvpinit_ASL(ASL*, int ndhmax, int nobj, real *ow, real *y);
  282. extern ASL_pfgh *pscheck_ASL(ASL*, const char*);
  283. extern void pshv_prod_ASL(ASL_pfgh*, range*r, int nobj, real*ow, real*y);
  284. extern fint sphes_setup_ASL(ASL*, SputInfo**, int nobj, int ow, int y, int ul);
  285. extern void sphes_ASL(ASL*, SputInfo**, real *H, int nobj, real*ow, real *y);
  286. extern void xpsg_check_ASL(ASL_pfgh*, int nobj, real *ow, real *y);
  287. #else /* PSHVREAD */
  288. extern void xp1known_ASL(ASL*, real*, fint*);
  289. #endif /* PSHVREAD */
  290. #ifdef __cplusplus
  291. }
  292. #endif
  293. #define pshv_prod(r,no,ow,y) pshv_prod_ASL(asl,r,no,ow,y)
  294. #endif /* PSINFO_H_included */