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