asl.h 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. /****************************************************************
  2. Copyright (C) 1997-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 ASL_included
  23. #define ASL_included
  24. #include "arith.h" /* for Long and Double_Align */
  25. #include "math.h"
  26. #include "stdio1.h"
  27. #ifndef Stderr
  28. extern FILE *Stderr;
  29. #endif
  30. #include "string.h"
  31. #ifdef KR_headers
  32. #define Const /* */
  33. #define VOID /*void*/
  34. extern char *malloc(), *realloc();
  35. extern double strtod();
  36. #else
  37. #define Const const
  38. #define VOID void
  39. #include "stdlib.h"
  40. #endif
  41. #include "errno.h"
  42. #ifdef __cplusplus
  43. #define Cextern extern "C"
  44. extern "C" {
  45. #else
  46. #define Cextern extern
  47. #endif
  48. #ifndef real
  49. #define real double
  50. #endif
  51. #ifndef Long
  52. #define Long long
  53. #endif
  54. #ifndef F2C_INCLUDE
  55. typedef Long fint;
  56. typedef Long ftnlen;
  57. #endif
  58. #ifndef Intcast
  59. #define Intcast (size_t)
  60. #endif
  61. #ifndef Not_Used
  62. #define Not_Used(x) x = x /* silence non-use warnings */
  63. #endif
  64. #define Malloc(x) mymalloc((size_t)(x))
  65. #define Realloc(x,y) myralloc(x,(size_t)(y))
  66. #define Sizeof(x) sizeof(x)
  67. /* prior to 20110912, Sizeof(x) was (fint)sizeof(x) */
  68. /* Place qsortv declaration ahead of funcadd.h in case Permit_AE_redefs is #defined. */
  69. extern void qsortv(void*, size_t, size_t, int(*)(const void*,const void*,void*), void*);
  70. #ifndef FUNCADD_H_INCLUDED
  71. #ifndef Permit_AE_redefs
  72. #define No_AE_redefs
  73. #endif
  74. #include "funcadd.h"
  75. #endif
  76. #include "setjmp.h"
  77. typedef size_t (*Fwrite)(const void*, size_t, size_t, FILE*);
  78. typedef int (*Add_Indicator)(void*, int, int, int, int, int*, real*, real);
  79. typedef struct {jmp_buf jb;} Jmp_buf;
  80. typedef struct ASL ASL;
  81. typedef struct MPEC_Adjust MPEC_Adjust;
  82. typedef struct Objrep Objrep;
  83. typedef struct Option_Info Option_Info;
  84. typedef struct cgrad cgrad;
  85. typedef struct cplist cplist;
  86. typedef struct derp derp;
  87. typedef struct expr_n expr_n;
  88. typedef struct func_info func_info;
  89. typedef struct linpart linpart;
  90. typedef struct ograd ograd;
  91. typedef struct plterm plterm;
  92. typedef struct relo relo;
  93. typedef struct
  94. SputInfo {
  95. fint *hcolstarts;
  96. fint *hrownos;
  97. fint *hcs[2];
  98. fint *hrn[2];
  99. fint *ulinc;
  100. fint *ulcopy;
  101. fint *ulinc0;
  102. fint *ulcopy0;
  103. fint *ulcend;
  104. fint nod;
  105. int nobj; /* from sphsetup() */
  106. int ow; /* from sphsetup() */
  107. int y; /* from sphsetup() */
  108. int khinfo; /* mblk size in sphes_setup */
  109. int khinfob;
  110. int uptri; /* from sphsetup() */
  111. int *uptolow;
  112. } SputInfo;
  113. typedef union
  114. uirp {
  115. int i;
  116. real *rp;
  117. void *vp;
  118. } uirp;
  119. struct
  120. cgrad {
  121. real coef;
  122. cgrad *next;
  123. int varno;
  124. int goff;
  125. };
  126. struct
  127. cplist {
  128. cplist *next;
  129. uirp ca;
  130. real *cfa;
  131. };
  132. struct
  133. derp {
  134. derp *next;
  135. uirp a, b, c;
  136. };
  137. typedef real efunc_n(expr_n*);
  138. struct
  139. expr_n {
  140. efunc_n *op;
  141. real v;
  142. };
  143. struct
  144. func_info {
  145. func_info *next, *fnext;
  146. Const char *name;
  147. ufunc *funcp;
  148. int ftype;
  149. int nargs;
  150. void *funcinfo;
  151. int findex; /* for fg_write */
  152. };
  153. struct
  154. linpart {
  155. uirp v;
  156. real fac;
  157. };
  158. struct
  159. ograd {
  160. real coef;
  161. ograd *next;
  162. int varno;
  163. };
  164. struct
  165. plterm {
  166. int n; /* number of slopes */
  167. real bs[1]; /* slope 1, bkpt 1, slope 2, bkpt 2, ..., slope n */
  168. };
  169. struct
  170. relo {
  171. relo *next, *next2;
  172. derp *D, *Dnext, *Dcond;
  173. };
  174. typedef struct
  175. EdRead_ASL {
  176. ASL *asl;
  177. FILE *nl;
  178. void *S; /* Static */
  179. Long Line;
  180. int lineinc;
  181. int can_end;
  182. char rl_buf[80];
  183. void (*iadjfcn)(void*, unsigned long);
  184. void (*dadjfcn)(void*, unsigned long);
  185. } EdRead_ASL;
  186. #define EdRead EdRead_ASL
  187. typedef struct ASLhead ASLhead; struct
  188. ASLhead { ASLhead *next, *prev; };
  189. #define NFHASH 23
  190. typedef struct
  191. Edagpars {
  192. ASLhead h;
  193. /* stuff initialized to nonzero values */
  194. real hffactor;
  195. int FUNNEL_MIN_;
  196. int maxfwd_;
  197. int need_funcadd_;
  198. int vrefGulp_;
  199. int want_derivs_;
  200. int ihd_limit_;
  201. int solve_code_;
  202. real (*Objval) (ASL*, int nobj, real *X, fint *nerror);
  203. real (*Objval_nomap) (ASL*, int nobj, real *X, fint *nerror);
  204. void (*Objgrd) (ASL*, int nobj, real *X, real *G, fint *nerror);
  205. void (*Objgrd_nomap) (ASL*, int nobj, real *X, real *G, fint *nerror);
  206. void (*Conval) (ASL*, real *X, real *R, fint *nerror);
  207. void (*Jacval) (ASL*, real *X, real *J, fint *nerror);
  208. real (*Conival) (ASL*, int ncon, real *X, fint *nerror);
  209. real (*Conival_nomap) (ASL*, int ncon, real *X, fint *nerror);
  210. void (*Congrd) (ASL*, int nc, real *X, real *G, fint *nerror);
  211. void (*Congrd_nomap) (ASL*, int nc, real *X, real *G, fint *nerror);
  212. void (*Hvcomp) (ASL*, real *hv, real *p, int no, real *ow, real *y);
  213. void (*Hvcomp_nomap) (ASL*, real *hv, real *p, int no, real *ow, real *y);
  214. void (*Hvinit) (ASL*, int hid_limit, int nobj, real *ow, real *y);
  215. void (*Hvinit_nomap) (ASL*, int hid_limit, int nobj, real *ow, real *y);
  216. void (*Hesset) (ASL*, int flags, int no, int nno, int nc, int nnc);
  217. int (*Lconval) (ASL*, int ncon, real *X, fint *nerror);
  218. void (*Xknown) (ASL*, real*, fint*);
  219. void (*Duthes) (ASL*, real *H, int nobj, real *ow, real *y);
  220. void (*Duthes_nomap) (ASL*, real *H, int nobj, real *ow, real *y);
  221. void (*Fulhes) (ASL*, real *H, fint LH, int no, real *ow, real *y);
  222. void (*Fulhes_nomap) (ASL*, real *H, fint LH, int no, real *ow, real *y);
  223. void (*Sphes) (ASL*, SputInfo**, real *H, int nobj, real *ow, real *y);
  224. void (*Sphes_nomap) (ASL*, SputInfo**, real *H, int nobj, real *ow, real *y);
  225. fint (*Sphset) (ASL*, SputInfo**, int nobj, int ow, int y, int uptri);
  226. fint (*Sphset_nomap) (ASL*, SputInfo**, int nobj, int ow, int y, int uptri);
  227. } Edagpars;
  228. extern Edagpars edagpars_ASL;
  229. #define objval(np,x,ne) (*((ASL*)asl)->p.Objval)((ASL*)asl,np,x,ne)
  230. #define objgrd(np,x,g,ne) (*((ASL*)asl)->p.Objgrd)((ASL*)asl,np,x,g,ne)
  231. #define conval(x,r,ne) (*((ASL*)asl)->p.Conval)((ASL*)asl,x,r,ne)
  232. #define jacval(x,j,ne) (*((ASL*)asl)->p.Jacval)((ASL*)asl,x,j,ne)
  233. #define conival(i,x,ne) (*((ASL*)asl)->p.Conival)((ASL*)asl,i,x,ne)
  234. #define congrd(i,x,g,ne) (*((ASL*)asl)->p.Congrd)((ASL*)asl,i,x,g,ne)
  235. #define hvcomp(hv,P,no,ow,y) (*((ASL*)asl)->p.Hvcomp)((ASL*)asl,hv,P,no,ow,y)
  236. #define hvinit(no,ow,y) (*((ASL*)asl)->p.Hvinit)((ASL*)asl,ihd_limit,no,ow,y)
  237. #define hesset(f,o,n,c,nc) (*((ASL*)asl)->p.Hesset)((ASL*)asl,f,o,n,c,nc)
  238. #define duthes(h,n,ow,y) (*((ASL*)asl)->p.Duthes)((ASL*)asl,h,n,ow,y)
  239. #define fullhes(h,lh,n,ow,y) (*((ASL*)asl)->p.Fulhes)((ASL*)asl,h,lh,n,ow,y)
  240. #define lconval(i,x,ne) (*((ASL*)asl)->p.Lconval)((ASL*)asl,i,x,ne)
  241. #define sphes(h,no,ow,y) (*((ASL*)asl)->p.Sphes)( (ASL*)asl,0,h,no,ow,y)
  242. #define sphsetup(no,ow,y,b) (*((ASL*)asl)->p.Sphset)((ASL*)asl,0,no,ow,y,b)
  243. #define xknown(x) (*((ASL*)asl)->p.Xknown)((ASL*)asl,x,0)
  244. #define xknowne(x,ne) (*((ASL*)asl)->p.Xknown)((ASL*)asl,x,ne)
  245. #define xunknown() (asl->i.x_known = 0)
  246. #define FUNNEL_MIN asl->p.FUNNEL_MIN_
  247. #define ihd_limit asl->p.ihd_limit_
  248. #define maxfwd asl->p.maxfwd_
  249. #define need_funcadd asl->p.need_funcadd_
  250. #define solve_code asl->p.solve_code_
  251. #define solve_result_num asl->p.solve_code_
  252. #define vrefGulp asl->p.vrefGulp_
  253. #define want_derivs asl->p.want_derivs_
  254. typedef struct
  255. SufDesc { /* suffix description */
  256. char *sufname; /* suffix name */
  257. char *table; /* for return to AMPL, suffix_table value */
  258. int kind;
  259. int nextra; /* extra entries to allocate in u.i or u.r */
  260. struct { /* was union, but this made debugging harder */
  261. int *i;
  262. real *r;
  263. } u;
  264. struct SufDesc *next;
  265. /* The number of entries in u.i or u.r is */
  266. /* (&asl->i.n_var_)[kind & ASL_Sufkind_mask] . */
  267. } SufDesc;
  268. enum { /* kind bits for SufDesc */
  269. ASL_Sufkind_var = 0,
  270. ASL_Sufkind_con = 1,
  271. ASL_Sufkind_obj = 2,
  272. ASL_Sufkind_prob = 3,
  273. ASL_Sufkind_mask = 3, /* mask for getting one of the above */
  274. /* values from SufDesc.kind */
  275. ASL_Sufkind_real = 4, /* use SufDesc.u.r rather than .i */
  276. ASL_Sufkind_iodcl = 8, /* tell AMPL to make this an INOUT suffix */
  277. ASL_Sufkind_output = 16,/* return this suffix to AMPL */
  278. ASL_Sufkind_input = 32, /* input values were received from AMPL */
  279. ASL_Sufkind_outonly = 64/* reject as an input value */
  280. };
  281. typedef struct
  282. SufDecl { /* Pass array of SufDecl's to suf_declare(). */
  283. char *name;
  284. char *table;
  285. int kind;
  286. int nextra;
  287. } SufDecl;
  288. typedef struct Exitcall Exitcall; struct
  289. Exitcall {
  290. Exitcall *prev;
  291. Exitfunc *ef;
  292. void *v;
  293. };
  294. typedef struct DerivErrInfo DerivErrInfo;
  295. typedef struct
  296. Edaginfo {
  297. int ASLtype;
  298. /* stuff initialized to zero values */
  299. int amplflag_;
  300. int need_nl_;
  301. func_info **funcs_, *funcsfirst_, *funcslast_;
  302. int (*xscanf_)(EdRead*, const char*, ...);
  303. func_info *fhash_[NFHASH];
  304. real *adjoints_; /* partials of result w.r.t. current oper. */
  305. real *adjoints_nv1_; /* internal use: start of portion to zero */
  306. real *LUrhs_, /* constraint lower (and, if Urhsx == 0, */
  307. /* upper) bounds */
  308. *Urhsx_, /* constraint upper bounds (if nonzero) */
  309. *X0_, /* initial guess (if nonzero) */
  310. *LUv_, /* variable lower (and, if Uvx == 0, upper) */
  311. /* bounds */
  312. *Uvx_, /* variable upper bounds (if nonzero) */
  313. *Lastx_, /* internal use: copy of X */
  314. *pi0_; /* dual initial guess */
  315. char *objtype_; /* object type array: 0 == min, 1 == max */
  316. char *havex0_; /* if nonzero, havex0_[i] != 0 ==> */
  317. /* X0_[i] was specified: this lets you */
  318. /* tell explicit 0's from default 0's */
  319. char *havepi0_; /* analogous to havex0_, but for dual values */
  320. real *A_vals_; /* If nonzero, store constant Jacobian values */
  321. /* (possibly 0 when nonlinearities are involved) */
  322. /* in A_vals, A_rownos, and A_colstarts, */
  323. /* rather than in Cgrad_. */
  324. int *A_rownos_, /* row numbers corresponding to A_vals_ */
  325. *A_colstarts_; /* offsets of columns in A_vals_ */
  326. cgrad **Cgrad_; /* constraint gradient info. (linear part) */
  327. ograd **Ograd_; /* objective gradient info. (linear part) */
  328. cgrad **Cgrad0; /* unmapped */
  329. int Fortran_; /* adjustment to A_rownos, A_colstarts, */
  330. /* ccind1, and ccind2 */
  331. int amax_; /* number of adjoint cells */
  332. /* stuff for common expressions (from "defined" vars) */
  333. int c_vars_;
  334. int comb_;
  335. int combc_;
  336. int comc1_;
  337. int comc_;
  338. int como1_;
  339. int como_;
  340. int lnc_; /* no. of linear network constraints */
  341. int nbv_; /* no. of linear binary variables */
  342. int niv_; /* no. of linear non-binary integer variables */
  343. int nlc_; /* total no. of nonlinear constraints */
  344. int n_eqn_; /* number of equality constraints or -1 */
  345. /* if unknown (ampl prior to 19970627) */
  346. int n_cc_; /* total complementarity conditions */
  347. int nlcc_; /* nonlinear complementarity conditions */
  348. int ndcc_; /* number of complementarities involving */
  349. /* double inequalities (for ASL_cc_simplify) */
  350. int nzlb_; /* number of complemented variables with a */
  351. /* nonzero lower bound (for ASL_cc_simplify) */
  352. int nlnc_; /* no. of nonlinear network constraints */
  353. int nlo_; /* no. of nonlinear objectives */
  354. int nlvb_; /* no. of nonlinear variables in both */
  355. /* constraints and objectives */
  356. int nlvc_; /* no. of nonlinear variables in constraints */
  357. int nlvo_; /* no. of nonlinear variables in objectives */
  358. /* nlvc_ and nlvo_ include nlvb_ */
  359. int nlvbi_; /* integer nonlinear variables in both */
  360. /* constraints and objectives */
  361. int nlvci_; /* integer nonlinear vars just in constraints */
  362. int nlvoi_; /* integer nonlinear vars just in objectives */
  363. int nwv_; /* no. of (linear) network variables (arcs) */
  364. int nzc_; /* no. of nonzeros in constraints' Jacobian */
  365. int nzo_; /* no. of nonzeros in all objective gradients */
  366. int n_var_; /* total no. of variables */
  367. int n_con_; /* total no. of constraints */
  368. int n_obj_; /* total no. of objectives */
  369. int n_prob; /* 1 (for use with SufDesc): SufDesc.u has */
  370. /* (&asl->i.n_var_)[SufDesc.kind & ASL_Sufkind_mask] entries */
  371. int n_lcon_; /* no. of logical constraints */
  372. int flags; /* 1 = want output suffixes */
  373. int n_conjac_[2]; /* Conval and Jacval operate on constraint i */
  374. /* for n_conjac_[0] <= i < n_conjac_[1]. */
  375. /* Initialized by jac0dim to 0 and n_con. */
  376. /* The .nl reader may adjust these values when */
  377. /* processing ASL_cc_simplify or ASL_obj_replace. */
  378. /* internal stuff */
  379. int nclcon_; /* n_con + n_lcon */
  380. int ncom0_;
  381. int ncom1_;
  382. int nderps_;
  383. int nfunc_;
  384. int nzjac_;
  385. int o_vars_;
  386. int want_deriv_;
  387. int x0kind_;
  388. int rflags; /* flags given to the .nl reader */
  389. size_t x0len_;
  390. char *filename_; /* stub + current extension */
  391. char *stub_end_; /* copy new extension (starting with ".") */
  392. /* here to adjust filename */
  393. void *archan_; /* channel for reading from AMPL */
  394. void *awchan_; /* channel from writing to AMPL */
  395. int binary_nl_; /* 0 = ASCII format, 1 = binary */
  396. int return_nofile_; /* 0 ==> jacdim0 should exit if stub.nl */
  397. /* does not exist; 1 ==> return 0 */
  398. int plterms_; /* no. of piecewise-linear terms */
  399. int maxrownamelen_; /* length of longest constraint name */
  400. /* (if stub.row exists) */
  401. int maxcolnamelen_; /* length of longest constraint name */
  402. /* (if stub.col exists) */
  403. int co_index_; /* set this to (constraint number - 1) or */
  404. /* -(objective number) to identify the */
  405. /* constraint or objective being evaluated */
  406. /* (used in report_where()) */
  407. int cv_index_; /* used internally */
  408. Jmp_buf *err_jmp_; /* If nonzero when an error is detected, */
  409. /* longjmp here (without printing an error */
  410. /* message). */
  411. Jmp_buf *err_jmp1_; /* If nonzero when an error is detected */
  412. /* (and err_jmp_ == 0), longjmp here after */
  413. /* printing an error message. */
  414. fint ampl_options_[10];
  415. fint obj_no_; /* objective number (for write_sol and */
  416. /* read_sol) */
  417. int nranges_; /* no. of ranges (constraints with */
  418. /* negInfinity < lhs < rhs < Infinity) */
  419. int want_xpi0_; /* & 1 ==> allocate X0_ if an */
  420. /* initial guess is available */
  421. /* & 2 ==> allocate pi0_ if a dual */
  422. /* initial guess is available */
  423. /* starting subscripts for cexp1's: request by */
  424. /* assigning these pointers before invoking edagread */
  425. int *c_cexp1st_; /* cexp1 starts for constraints */
  426. int *o_cexp1st_; /* cexp1 starts for objectives */
  427. /* for complementarity constraints */
  428. int *cvar_; /* cvar[i] > 0 means constraint i complements */
  429. /* variable cvar[i] - 1 */
  430. int *ccind1, *ccind2; /* populated when ASL_cc_simplify is */
  431. /* "on" in the flags argument to the .nl reader */
  432. unsigned size_expr_n_; /* size for struct expr_n, for nlc */
  433. /* extra info for write_sol */
  434. real ampl_vbtol_;
  435. /* relocated adjoints for common expressions */
  436. /* (used by nlc; request by allocating) */
  437. int **zaC_; /* for common expressions */
  438. int **zac_; /* for constraints */
  439. int **zao_; /* for objectives */
  440. /* for nlc */
  441. int skip_int_derivs_;
  442. /* for suffixes */
  443. int nsuffixes;
  444. int nsufext[4];
  445. int nsuff[4];
  446. SufDesc *suffixes[4];
  447. /* for sparse gradients */
  448. int **zerograds_;
  449. int congrd_mode; /* How to treat arg G to Congrd: */
  450. /* 0 == expand to n_var vector (default) */
  451. /* 1 == compact storage in G */
  452. /* 2 == use goff fields of struct cgrad */
  453. int x_known; /* used by xknown(), xunknown() */
  454. Long xknown_ignore; /* for debugging: ignore xknown */
  455. size_t zap_J; /* used by dense_j */
  456. int nxval; /* used by conival and objval */
  457. int nlvog; /* objgrd(np,x,g,ne) sets g[i] = 0 */
  458. /* if the objective does not depend on x[i] */
  459. /* and i < nlvog (or i < max(c_vars, o_vars) */
  460. /* if nlvog is left at 0); nlvog must be set */
  461. /* before the .nl reader is called. */
  462. int *ncxval; /* for conival */
  463. int *noxval; /* for objval */
  464. SputInfo *sputinfo_; /* used by sputhes() */
  465. /* for ASL_free */
  466. void **Mbnext, **Mblast, *Mb;
  467. /* for mem */
  468. char *memNext, *memLast;
  469. /* for user-defined functions */
  470. AmplExports *ae;
  471. /* for con_name(), obj_name(), var_name() */
  472. char **connames;
  473. char **lconnames;
  474. char **objnames;
  475. char **varnames;
  476. int vcochecked;
  477. /* for possible user-specific use */
  478. void *uinfo;
  479. /* for reading alternate binary formats */
  480. void (*iadjfcn)(void*, unsigned long);
  481. void (*dadjfcn)(void*, unsigned long);
  482. /* for scaling */
  483. real *cscale; /* constraints */
  484. real *vscale; /* variables */
  485. real *lscale; /* Lagrange-multiplier scale */
  486. /* for at_reset() */
  487. Exitcall *arlast;
  488. Exitcall *arnext;
  489. Exitcall *arprev;
  490. /* for suf_sos() */
  491. SufDesc *csd;
  492. SufDesc *rsd;
  493. int n_var0; /* number of variables before suf_sos() */
  494. int n_con0; /* number of constraints before suf_sos() */
  495. int n_var1; /* index of next variable to be added */
  496. int n_con1; /* index of next constraint to be added */
  497. int *vmap; /* for mapping variables, length n_var */
  498. int *cmap; /* for mapping constraints, length n_con */
  499. int *vzap; /* for zeroing primal variables in eliminated suf_sos */
  500. /* constraints: vzmap[i] for 1 <= i <= vzmap[0] */
  501. int *czap; /* for zeroing dual variables of eliminated suf_sos */
  502. /* constraints: czap[i] for 1 <= i <= czmap[0] */
  503. int *vminv; /* inverse of vmap; allocated on demand */
  504. /* for modifying objectives */
  505. Objrep **Or;
  506. real *orscratch; /* scratch (if needed) */
  507. /* for simplifying complementarities */
  508. MPEC_Adjust *mpa;
  509. /* for derivative errors */
  510. DerivErrInfo *Derrs, *Derrs0;
  511. } Edaginfo;
  512. struct
  513. ASL {
  514. Edagpars p;
  515. Edaginfo i;
  516. };
  517. typedef struct
  518. NewVCO {
  519. int nnv; /* number of new variables */
  520. int nnc; /* number of new constraints */
  521. int nno; /* number of new objectives */
  522. ograd **newc; /* new constraint nonzeros */
  523. ograd **newo; /* new objective nonzeros */
  524. real *LUnv; /* nnv variable lower bounds or, if Unv is null, */
  525. /* nnv (lower,upper) bound pairs */
  526. real *Unv; /* null or nnv variable upper bounds */
  527. real *LUnc; /* nnc constraint lower bounds or, if Unc is null, */
  528. /* nnc (lower,upper) bound pairs */
  529. real *Unc; /* null or nnc constraint upper bounds */
  530. real *oc; /* null or nno objective constants */
  531. char *ot; /* objective types (1 = max, 0 = min) */
  532. /* taken to be all zeros (min) if null */
  533. real *x0; /* null or nnv primal initial guesses */
  534. real *d0; /* null or nnc dual initial guesses */
  535. } NewVCO;
  536. struct
  537. TMInfo {
  538. union {
  539. TMInfo *prev;
  540. double align;
  541. } u;
  542. };
  543. #define A_colstarts asl->i.A_colstarts_
  544. #define A_rownos asl->i.A_rownos_
  545. #define A_vals asl->i.A_vals_
  546. #define Cgrad asl->i.Cgrad_
  547. #define Fortran asl->i.Fortran_
  548. #define LUrhs asl->i.LUrhs_
  549. #define LUv asl->i.LUv_
  550. #define Lastx asl->i.Lastx_
  551. #define Ograd asl->i.Ograd_
  552. #define Urhsx asl->i.Urhsx_
  553. #define Uvx asl->i.Uvx_
  554. #define X0 asl->i.X0_
  555. #define adjoints asl->i.adjoints_
  556. #define adjoints_nv1 asl->i.adjoints_nv1_
  557. #define amax asl->i.amax_
  558. #define ampl_options asl->i.ampl_options_
  559. #define ampl_vbtol asl->i.ampl_vbtol_
  560. #define amplflag asl->i.amplflag_
  561. #define archan asl->i.archan_
  562. #define awchan asl->i.awchan_
  563. #define binary_nl asl->i.binary_nl_
  564. #define c_cexp1st asl->i.c_cexp1st_
  565. #define c_vars asl->i.c_vars_
  566. #define co_index asl->i.co_index_
  567. #define comb asl->i.comb_
  568. #define combc asl->i.combc_
  569. #define comc asl->i.comc_
  570. #define comc1 asl->i.comc1_
  571. #define como asl->i.como_
  572. #define como1 asl->i.como1_
  573. #define cv_index asl->i.cv_index_
  574. #define cvar asl->i.cvar_
  575. #define err_jmp asl->i.err_jmp_
  576. #define err_jmp1 asl->i.err_jmp1_
  577. #define fhash asl->i.fhash_
  578. #define filename asl->i.filename_
  579. #define funcs asl->i.funcs_
  580. #define funcsfirst asl->i.funcsfirst_
  581. #define funcslast asl->i.funcslast_
  582. #define havepi0 asl->i.havepi0_
  583. #define havex0 asl->i.havex0_
  584. #define lnc asl->i.lnc_
  585. #define maxcolnamelen asl->i.maxcolnamelen_
  586. #define maxrownamelen asl->i.maxrownamelen_
  587. #define n_cc asl->i.n_cc_
  588. #define n_con asl->i.n_con_
  589. #define n_conjac asl->i.n_conjac_
  590. #define n_obj asl->i.n_obj_
  591. #define n_var asl->i.n_var_
  592. #define nbv asl->i.nbv_
  593. #define nclcon asl->i.nclcon_
  594. #define ncom0 asl->i.ncom0_
  595. #define ncom1 asl->i.ncom1_
  596. #define nderps asl->i.nderps_
  597. #define need_nl asl->i.need_nl_
  598. #define n_eqn asl->i.n_eqn_
  599. #define nfunc asl->i.nfunc_
  600. #define niv asl->i.niv_
  601. #define nlc asl->i.nlc_
  602. #define nlcc asl->i.nlcc_
  603. #define nlnc asl->i.nlnc_
  604. #define nlo asl->i.nlo_
  605. #define n_lcon asl->i.n_lcon_
  606. #define nlogv asl->i.nbv_ /* nbv used to be called nlogv */
  607. #define nlvb asl->i.nlvb_
  608. #define nlvbi asl->i.nlvbi_
  609. #define nlvc asl->i.nlvc_
  610. #define nlvci asl->i.nlvci_
  611. #define nlvo asl->i.nlvo_
  612. #define nlvoi asl->i.nlvoi_
  613. #define nranges asl->i.nranges_
  614. #define nwv asl->i.nwv_
  615. #define nzc asl->i.nzc_
  616. #define nzjac asl->i.nzjac_
  617. #define nzo asl->i.nzo_
  618. #define o_cexp1st asl->i.o_cexp1st_
  619. #define o_vars asl->i.o_vars_
  620. #define obj_no asl->i.obj_no_
  621. #define objtype asl->i.objtype_
  622. #define pi0 asl->i.pi0_
  623. #define plterms asl->i.plterms_
  624. #define return_nofile asl->i.return_nofile_
  625. #define size_expr_n asl->i.size_expr_n_
  626. #define skip_int_derivs asl->i.skip_int_derivs_
  627. #define sputinfo asl->i.sputinfo_
  628. #define stub_end asl->i.stub_end_
  629. #define want_deriv asl->i.want_deriv_
  630. #define want_xpi0 asl->i.want_xpi0_
  631. #define x0kind asl->i.x0kind_
  632. #define x0len asl->i.x0len_
  633. #define xscanf asl->i.xscanf_
  634. #define zaC asl->i.zaC_
  635. #define zac asl->i.zac_
  636. #define zao asl->i.zao_
  637. #define zerograds asl->i.zerograds_
  638. #define M1alloc(n) M1alloc_ASL(&asl->i,n)
  639. #define M1free M1free_ASL
  640. #define M1record(n) M1record_ASL(&asl->i,n)
  641. #define M1zapalloc(n) M1zapalloc_ASL(&asl->i,n)
  642. #define Mach Mach_ASL
  643. #define ascanf ascanf_ASL
  644. #define badline badline_ASL
  645. #define badread badread_ASL
  646. #define bscanf bscanf_ASL
  647. #define derprop derprop_ASL
  648. #define dynlink dynlink_ASL
  649. #define edag_peek edag_peek_ASL
  650. #define edagread_one edag_one_ASL
  651. #define fpecatch fpecatch_ASL
  652. #define fpe_jmpbuf fpe_jmpbuf_ASL
  653. #define func_add func_add_ASL
  654. #define func_lookup func_lookup_ASL
  655. #define g_fmt g_fmt_ASL
  656. #define g_fmtp g_fmtp_ASL
  657. #define g_fmtop g_fmtop_ASL
  658. #define g_fmt_E gfmt_E_ASL
  659. #define g_fmt_decpt gfmt_decpt_ASL
  660. #define htcl htcl_ASL
  661. #define mem(n) mem_ASL((ASL*)asl,n)
  662. #define mymalloc mymalloc_ASL
  663. #define mypow mypow_ASL
  664. #define myralloc myralloc_ASL
  665. #define obj_prec obj_prec_ASL
  666. #define optype op_type_ASL
  667. #define optypeb op_typeb_ASL
  668. #define pr_unknown pr_unknown_ASL
  669. #define read_line read_line_ASL
  670. #define report_where report_where_ASL
  671. #define scream scream_ASL
  672. #define what_prog what_prog_ASL
  673. extern real Infinity, edagread_one, negInfinity;
  674. extern char g_fmt_E, *progname;
  675. extern int g_fmt_decpt;
  676. extern ASL *cur_ASL;
  677. enum { /* mode bits for ASLtype */
  678. ASL_read_f = 1,
  679. ASL_read_fg = 2,
  680. ASL_read_fgh = 3,
  681. ASL_read_pfg = 4,
  682. ASL_read_pfgh = 5
  683. };
  684. enum { /* bits for x0kind */
  685. ASL_have_conval = 1,
  686. ASL_have_objcom = 2,
  687. ASL_first_x = 4,
  688. ASL_have_funnel = 8, /* in con[12]ival */
  689. ASL_need_funnel = 16, /* in pshvprod */
  690. ASL_have_concom = 32
  691. };
  692. enum ASL_reader_flag_bits { /* bits in flags arg */
  693. /* values just relevant to pfg_read and pfgh_read: */
  694. /* If you do not need the sparsity pattern, */
  695. /* you can omit linear coefficients of zero. */
  696. ASL_J_zerodrop = 1, /* Omit 0 linear terms in constraint derivs. */
  697. ASL_G_zerodrop = 2, /* Omit 0 linear terms in objective derivs. */
  698. ASL_GJ_zerodrop = 3, /* Omit both kinds of zero linear terms. */
  699. ASL_findOgroups = 4, /* Find objective group structure. */
  700. ASL_findCgroups = 8, /* Find constraint group structure. */
  701. ASL_findgroups = 12, /* Find both group structures; you want this */
  702. /* unless you're a solver like LANCELOT that */
  703. /* deals explicitly with group structure. */
  704. ASL_find_c_class = 32, /* Find c_class and c_class_max: see nlp.h */
  705. ASL_find_o_class = 64, /* Find o_class and o_class_max: or nlp2.h */
  706. ASL_find_co_class = 96, /* Find all four */
  707. /* applicable to all .nl file readers: */
  708. ASL_return_read_err = 16,
  709. ASL_keep_all_suffixes = 0x80,
  710. ASL_allow_CLP = 0x1000, /* permit CLP extensions */
  711. ASL_find_default_no_groups = 0x2000, /* Assume ASL_findgroups */
  712. /* when this bit is off. */
  713. /* When ASL_find_default_no_groups is on, pfg_read and pfgh_read */
  714. /* only honor explicit specification of the ASL_findgroups bits. */
  715. /* Stuff for fg_wread: */
  716. ASL_omit_all_suffixes = 0x100,
  717. ASL_keep_derivs = 0x200,
  718. ASL_allow_missing_funcs = 0x400,
  719. ASL_forbid_missing_funcs = 0x800,
  720. /* problem adjustments */
  721. ASL_no_linear_cc_rhs_adjust = 0x4000, /* Omit constant term adjustment */
  722. /* of linear complementarities. */
  723. ASL_cc_simplify = 0x8000, /* Provide arrays ccind1 and ccind2 and */
  724. /* modify complementarities (possibly */
  725. /* increasing n_cc) so the complementarity */
  726. /* constraints have the form */
  727. /* _svar[i] >= 0 complements _svar[j] >= 0 */
  728. /* for i = ccind1[k] - Fortran */
  729. /* and j = ccind2[k] - Fortran, */
  730. /* 0 <= k < n_cc. */
  731. ASL_obj_replace_ineq = 0x10000, /* Whether to replace an objective of the */
  732. /* form minimize or maximize const*var and */
  733. /* a corresponding constraint of the form */
  734. /* var relop expr with const*expr, where */
  735. /* relop is either >= or <=, depending */
  736. /* on the sense of optimization, and var */
  737. /* does not appear elsewhere. */
  738. ASL_obj_replace_eq = 0x20000, /* Similar to ASL_obj_replace, but where */
  739. /* relop is == . */
  740. ASL_rowwise_jac = 0x40000, /* Whether Jacobian nonzeros should be stored */
  741. /* row-wise rather than column-wise, in which */
  742. /* case the A_colstarts array provides offsets */
  743. /* of rows rather than columns. */
  744. ASL_want_A_vals = 0x80000, /* Allocate and use A_vals (if NULL), allowing */
  745. /* space needed for ASL_cc_simplify. */
  746. ASL_sep_U_arrays = 0x100000 /* Allocate and use Uvx and Urhsx */
  747. };
  748. enum ASL_reader_error_codes {
  749. /* return codes from .nl readers with flag ASL_ret_read_err */
  750. ASL_readerr_none = 0, /* all went well */
  751. ASL_readerr_nofile = 1, /* cannot open .nl file */
  752. ASL_readerr_nonlin = 2, /* model involves nonlinearities (ed0read) */
  753. ASL_readerr_argerr = 3, /* user-defined function with bad args */
  754. ASL_readerr_unavail= 4, /* user-defined function not available */
  755. ASL_readerr_corrupt= 5, /* corrupt .nl file */
  756. ASL_readerr_bug = 6, /* bug in .nl reader */
  757. ASL_readerr_CLP = 7 /* solver cannot handle CLP extensions */
  758. };
  759. enum ASL_suf_sos_flags { /* bits in flags parameter of suf_sos() */
  760. ASL_suf_sos_explict_free = 1, /* caller will explicitly free */
  761. /* returned arrays */
  762. ASL_suf_sos_ignore_sosno = 2, /* ignore .sosno */
  763. ASL_suf_sos_ignore_amplsos = 4 /* ignore SOS information from */
  764. /* transformations of piecewise- */
  765. /* linear terms (etc.) by AMPL */
  766. };
  767. enum ASL_write_flags {
  768. ASL_write_ASCII = 1,
  769. ASL_write_CR = 2
  770. };
  771. enum ASL_writer_error_codes {
  772. ASL_writeerr_openfail = 1,
  773. ASL_writeerr_badrops = 2,
  774. ASL_writeerr_badcexp1st = 3,
  775. ASL_writeerr_badNewVCO = 4
  776. };
  777. #define f_OPNUM f_OPNUM_ASL
  778. #undef basename
  779. #define basename basename_ASL
  780. #ifndef Sig_ret_type
  781. #define Sig_ret_type void
  782. #endif
  783. extern ASL *ASL_alloc(int);
  784. extern void ASL_free(ASL**);
  785. extern long ASLdate_ASL;
  786. extern void Del_mblk_ASL(ASL*, int, void*);
  787. extern EdRead *EdReadInit_ASL(EdRead*, ASL*, FILE*, void*);
  788. extern void LUcopy_ASL(int, real*, real*, real*);
  789. extern void *M1alloc_ASL(Edaginfo*, size_t);
  790. extern void M1free(Edaginfo*, void**, void**);
  791. extern void **M1record_ASL(Edaginfo*, void*);
  792. extern void *M1zapalloc_ASL(Edaginfo*, size_t);
  793. extern void MAIN__(VOID);
  794. extern void Mach_ASL(VOID);
  795. extern void No_derivs_ASL(const char*);
  796. extern int Sprintf(char*, const char*, ...);
  797. extern void Stderr_init_ASL(void);
  798. extern void Suf_read_ASL(EdRead*, int);
  799. extern void adjust_zerograds_ASL(ASL*, int);
  800. extern int already_ASL(const char*);
  801. extern int ascanf(EdRead*, const char*, ...);
  802. extern void auxinfo_ASL(AmplExports*);
  803. extern void *b_search_ASL(void *ow, int owsize, int n, char **sp, char **peq);
  804. extern void badasl_ASL(ASL*,int,const char*);
  805. extern void badline(EdRead*);
  806. extern void badread(EdRead*);
  807. extern char *basename(const char*);
  808. extern int bscanf(EdRead*, const char*, ...);
  809. extern char *con_name_ASL(ASL*,int);
  810. extern char *con_name_nomap_ASL(ASL*,int);
  811. extern int conadj_ASL(ASL*,int*,int);
  812. extern void congrd_(fint *N, fint *I, real *X, real *G, fint *nerror);
  813. extern real cnival_(fint *N, fint *I, real *X, fint *nerror);
  814. extern void conscale_ASL(ASL*, int, real, fint*);
  815. extern void conval_(fint *M, fint *N, real *X, real *F, fint *nerror);
  816. extern void delprb_(VOID);
  817. extern void dense_j_ASL(ASL*);
  818. extern void densej_(VOID);
  819. extern void deriv_errchk_ASL(ASL*, fint*, int coi, int n);
  820. extern void deriv_errclear_ASL(Edaginfo*);
  821. extern void derprop(derp *);
  822. extern char *dtoa(double, int, int, int*, int*, char **);
  823. extern ufunc *dynlink_ASL(const char*);
  824. extern int edag_peek(EdRead*);
  825. extern void equ_adjust_ASL(ASL*, int*, int*);
  826. extern void exit_ASL(EdRead*,int);
  827. extern real f_OPNUM(expr_n*);
  828. extern int f_read_ASL(ASL*, FILE*, int);
  829. extern int fg_read_ASL(ASL*, FILE*, int);
  830. extern int fg_wread_ASL(ASL*, FILE*, int);
  831. extern int fgh_read_ASL(ASL*, FILE*, int);
  832. extern int fg_write_ASL(ASL*, const char*, NewVCO*, int);
  833. extern void fintrouble_ASL(ASL*, func_info*, const char*, TMInfo*);
  834. extern void flagsave_ASL(ASL*, int);
  835. extern void freedtoa(char*);
  836. extern func_info *func_lookup(ASL*, const char*, int add);
  837. extern void func_add(ASL*);
  838. extern int g_fmt(char*, double);
  839. extern int g_fmtop(char*, double);
  840. extern int g_fmtp(char*, double, int);
  841. extern void gen_rownos_ASL(ASL*);
  842. extern ASL *get_cur_ASL(VOID);
  843. extern int *get_vcmap_ASL(ASL*, int);
  844. extern int *get_vminv_ASL(ASL*);
  845. extern char *getenv_ASL(const char*);
  846. extern int htcl_ASL(unsigned int);
  847. extern void hvcomp_(real *hv, real *p, fint *nobj, real *ow, real *y);
  848. extern void hvinit_(fint *nobj, real *ow, real *y);
  849. extern int indicator_constrs_ASL(ASL*, void*, Add_Indicator, int errinfo[2]);
  850. extern void intcatch_ASL(ASL*, void (*)(int,void*), void*);
  851. extern void introuble_ASL(ASL*, const char *who, real a, int jv);
  852. extern void introuble2_ASL(ASL*, const char *who, real a, real b, int jv);
  853. extern FILE *jac0dim_ASL(ASL*, char *stub, ftnlen stub_len);
  854. extern int jac1dim_ASL(ASL*,char *stub, fint *M, fint *N, fint *NO,
  855. fint *NZ, fint *MXROW, fint *MXCOL, ftnlen stub_len);
  856. extern int jac2dim_ASL (ASL*,char *stub, fint *M, fint *N, fint *NO,
  857. fint *NZ, fint *MXROW, fint *MXCOL, ftnlen stub_len);
  858. extern FILE *jac_dim_ASL(ASL*, char *stub, fint *M, fint *N, fint *NO,
  859. fint *NZ, fint *MXROW, fint *MXCOL, ftnlen stub_len);
  860. extern int jacdim_(char *stub, fint *M, fint *N, fint *NO, fint *NZ,
  861. fint *MXROW, fint *MXCOL, ftnlen stub_len);
  862. extern void jacinc_(fint *M, fint *N, fint *NZ,
  863. fint *JP, short *JI, real *X, real *L, real *U,
  864. real *Lrhs, real *Urhs, real *Inf);
  865. extern int jacpdim_ASL(ASL*,char *stub, fint *M, fint *N, fint *NO,
  866. fint *NZ, fint *MXROW, fint *MXCOL, ftnlen stub_len);
  867. extern void jacval_(fint *M, fint *N, fint *NZ, real *X,
  868. real *JAC, fint *nerror);
  869. extern Sig_ret_type fpecatch(int);
  870. extern jmp_buf fpe_jmpbuf_ASL;
  871. extern void lagscale_ASL(ASL*, real, fint*);
  872. extern char *lcon_name_ASL(ASL*,int);
  873. extern void mainexit_ASL(int);
  874. extern void *mem_ASL(ASL*, unsigned int);
  875. extern int mip_pri_ASL(ASL*,int**startp,int**nump,int**prip,fint pmax);
  876. extern void mnnzchk_ASL(ASL*asl,fint*M,fint*N,fint*NZ,const char*who);
  877. extern void mpec_adjust_ASL(ASL*);
  878. extern void mpec_auxvars_ASL(ASL*, real *c, real *x);
  879. extern fint mqpcheck_ASL(ASL*, int co, fint **rowqp, fint **colqp, real **delsqp);
  880. extern void *mymalloc(size_t);
  881. extern real mypow(real,real);
  882. extern void *myralloc(void *, size_t);
  883. extern void *new_mblk_ASL(ASL*, int k);
  884. extern int nl_obj_ASL(ASL*,int);
  885. extern fint nqpcheck_ASL(ASL*, int co, fint **rowqp, fint **colqp, real **delsqp);
  886. extern char *obj_name_ASL(ASL*,int);
  887. extern int obj_prec(VOID);
  888. extern void obj_adj_ASL(ASL*);
  889. extern void obj_adj_xy_ASL(ASL *asl, real *x, real *x0, real *y);
  890. extern real objconst_ASL(ASL*,int);
  891. extern void objgrd_(fint *N, real *X, fint *NOBJ, real *G, fint *nerror);
  892. extern real objval_(fint *N, real *X, fint *NOBJ, fint *nerror);
  893. extern char optype[], optypeb[];
  894. extern int pfg_read_ASL(ASL*, FILE*, int flags);
  895. extern int pfgh_read_ASL(ASL*, FILE*, int flags);
  896. extern char *pr_unknown(FILE*, char*);
  897. extern int prob_adj_ASL(ASL*);
  898. extern void qp_opify_ASL(ASL*);
  899. extern int qp_read_ASL(ASL*, FILE*, int);
  900. extern fint qpcheck_ASL(ASL*, fint **rowqp, fint **colqp, real **delsqp);
  901. extern char *read_line(EdRead*);
  902. extern char *read_sol_ASL(ASL*, real**xp, real **yp);
  903. extern void report_where(ASL*);
  904. extern void scream(EdRead*, int rc, const char *fmt, ...);
  905. extern ASL *set_cur_ASL(ASL*); /* returns previous value */
  906. extern real set_randseed_ASL(real nseed); /* returns new seed, usually nseed, but */
  907. /* automaticaally chosen if nseed == 0. */
  908. extern void show_funcs_ASL(ASL*);
  909. extern void sigcatch_ASL(VOID);
  910. extern void* sos_add_ASL(ASL*, FILE*, int);
  911. extern int sos_finish_ASL(ASL*,void**,int,int*,int**,int*,int**,int**,real**);
  912. extern void student_check_ASL(ASL*);
  913. extern void suf_declare_ASL(ASL*, SufDecl*, int);
  914. extern SufDesc *suf_get_ASL(ASL*, const char*, int);
  915. extern SufDesc *suf_iput_ASL(ASL*, const char*, int, int*);
  916. extern SufDesc *suf_rput_ASL(ASL*, const char*, int, real*);
  917. extern int suf_sos_ASL(ASL*,int,int*,char**,int**,int*,int**,int**,real**);
  918. extern char *var_name_ASL(ASL*,int);
  919. extern char *var_name_nomap_ASL(ASL*,int);
  920. extern void varscale_ASL(ASL*, int, real, fint*);
  921. extern void what_prog(VOID);
  922. extern void write_sol_ASL(ASL*, const char *msg, double *x, double *y, Option_Info*);
  923. extern int write_solf_ASL(ASL*, const char *msg, double *x, double *y, Option_Info *,
  924. const char*);
  925. extern int write_solfx_ASL(ASL*, const char *msg, double *x, double *y, Option_Info *,
  926. Fwrite, Fwrite, Fwrite, const char*);
  927. extern void wrsolw_(char *msg, fint *nmsg, real *x, real *y, fint *wantsol,
  928. ftnlen msg_len);
  929. extern void wrtsol_(char *msg, fint *nmsg, real *x, real *y,
  930. ftnlen msg_len);
  931. extern real xectim_(VOID);
  932. extern void xknowe_(real *x, fint *nerror);
  933. extern void xknown_(real *x);
  934. extern void xunkno_(VOID);
  935. extern void zero_div_ASL(ASL*, real, const char*);
  936. #ifndef No_dtoa
  937. extern double strtod_ASL(Const char*, char**);
  938. #ifndef strtod /* if not set by previous funcadd.h */
  939. #define strtod strtod_ASL
  940. #endif
  941. #endif
  942. #ifdef __cplusplus
  943. }
  944. #endif
  945. #define con_name(n) con_name_ASL((ASL*)asl,n)
  946. #define conadj(cv) conadj_ASL((ASL*)asl,cv,1)
  947. #define conscale(i,s,ie) conscale_ASL((ASL*)asl,i,s,ie)
  948. #define dense_j() dense_j_ASL((ASL*)asl)
  949. #define edagread(f) fg_read_ASL((ASL*)asl,f,0) /* dreg */
  950. #define equ_adjust(x,y) equ_adjust_ASL((ASL*)asl,x,y)
  951. #define f_read(a,b) f_read_ASL((ASL*)asl,a,b)
  952. #define fg_read(a,b) fg_read_ASL((ASL*)asl,a,b)
  953. #define fg_wread(a,b) fg_wread_ASL((ASL*)asl,a,b)
  954. #define fg_write(a,b,c) fg_write_ASL((ASL*)asl,a,b,c)
  955. #define fgh_read(a,b) fgh_read_ASL((ASL*)asl,a,b)
  956. #define gen_rownos() gen_rownos_ASL((ASL*)asl)
  957. #undef getenv
  958. #define getenv getenv_ASL
  959. #define int_catch(f,v) intcatch_ASL((ASL*)asl,f,v)
  960. #define jac0dim(stub,len) jac0dim_ASL((ASL*)asl,stub,len)
  961. #define jac1dim(s,m,n,no,nz,mxr,mxc,L) jac1dim_ASL((ASL*)asl,s,m,n,no,nz,mxr,mxc,L)
  962. #define jac2dim(s,m,n,no,nz,mxr,mxc,L) jac2dim_ASL((ASL*)asl,s,m,n,no,nz,mxr,mxc,L)
  963. #define jacdim(stub,M,N,NO,NZ,MXR,MXC,len) jac_dim_ASL((ASL*)asl,stub,M,N,NO,NZ,MXR,MXC,len)
  964. #define jacdim0(stub,len) jac0dim_ASL((ASL*)asl,stub,len)
  965. #define jacpdim(s,m,n,no,nz,mxr,mxc,L) jacpdim_ASL((ASL*)asl,s,m,n,no,nz,mxr,mxc,L)
  966. #define lagscale(s,ie) lagscale_ASL((ASL*)asl,s,ie)
  967. #define lcon_name(n) lcon_name_ASL((ASL*)asl,n)
  968. #define mip_pri(a,b,c,d) mip_pri_ASL((ASL*)asl,a,b,c,d)
  969. #define mqpcheck(a,b,c,d) mqpcheck_ASL((ASL*)asl,a,b,c,d)
  970. #define nl_obj(n) nl_obj_ASL((ASL*)asl,n)
  971. #define nqpcheck(a,b,c,d) nqpcheck_ASL((ASL*)asl,a,b,c,d)
  972. #define obj_name(n) obj_name_ASL((ASL*)asl,n)
  973. #define objconst(n) objconst_ASL((ASL*)asl,n)
  974. #define pfg_read(a,b) pfg_read_ASL((ASL*)asl,a,b)
  975. #define pfgh_read(a,b) pfgh_read_ASL((ASL*)asl,a,b)
  976. #define qp_opify() qp_opify_ASL((ASL*)asl)
  977. #define qp_read(a,b) qp_read_ASL((ASL*)asl,a,b)
  978. #define qpcheck(a,b,c) qpcheck_ASL((ASL*)asl,a,b,c)
  979. #define read_soln(x,y) read_sol_ASL((ASL*)asl,x,y)
  980. #define show_funcs() show_funcs_ASL((ASL*)asl)
  981. #define sos_add(a,b) sos_add_ASL((ASL*)asl,a,b)
  982. #define sos_finish(a,b,c,d,e,f,g,h) sos_finish_ASL((ASL*)asl,a,b,c,d,e,f,g,h)
  983. #define suf_declare(x,n) suf_declare_ASL((ASL*)asl,x,(int)(n))
  984. #define suf_get(s,i) suf_get_ASL((ASL*)asl,s,i)
  985. #define suf_iput(n,i,x) suf_iput_ASL((ASL*)asl,n,i,x)
  986. #define suf_rput(n,i,x) suf_rput_ASL((ASL*)asl,n,i,x)
  987. #define suf_sos(a,b,c,d,e,f,g,h) suf_sos_ASL((ASL*)asl,a,b,c,d,e,f,g,h)
  988. #define var_name(n) var_name_ASL((ASL*)asl,n)
  989. #define varscale(i,s,ie) varscale_ASL((ASL*)asl,i,s,ie)
  990. #define write_sol(m,x,y,oi) write_sol_ASL((ASL*)asl,m,x,y,oi)
  991. #define write_soln(m,x,y) write_sol_ASL((ASL*)asl,m,x,y,0)
  992. #ifdef KR_headers
  993. #define del_mblk(a,b) Del_mblk_ASL((ASL*)asl, a, (void*)(b))
  994. #else
  995. #define del_mblk(a,b) Del_mblk_ASL((ASL*)asl,a,b)
  996. #endif
  997. #define new_mblk(n) new_mblk_ASL((ASL*)asl,n)
  998. #define exit mainexit_ASL
  999. #ifdef MULTIPLE_THREADS
  1000. #define A_ASL , ASL *asl
  1001. #define C_ASL , (ASL*)asl
  1002. #define D_ASL ASL *asl;
  1003. #define K_ASL , asl
  1004. #ifndef MEM_LOCK
  1005. #define MEM_LOCK 3
  1006. #endif
  1007. #ifndef MBLK_LOCK
  1008. #define MBLK_LOCK 4
  1009. #endif
  1010. #ifndef HESOPROD_LOCK
  1011. #define HESOPROD_LOCK 5
  1012. #endif
  1013. #else /* MULTIPLE_THREADS */
  1014. #define A_ASL /*nothing*/
  1015. #define C_ASL /*nothing*/
  1016. #define D_ASL /*nothing*/
  1017. #define K_ASL /*nothing*/
  1018. #define ACQUIRE_DTOA_LOCK(n) /*nothing*/
  1019. #define FREE_DTOA_LOCK(n) /*nothing*/
  1020. #endif /* MULTIPLE_THREADS */
  1021. #define ASL_CHECK(a,n,w) if(!a||a->i.ASLtype!=n)badasl_ASL(a,n,w);cur_ASL=a;
  1022. #endif /* ASL_included */