/**************************************************************** Copyright (C) 1997 Lucent Technologies All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the name of Lucent or any of its entities not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ typedef struct Edagpars { /* stuff initialized to nonzero values */ real hffactor; int FUNNEL_MIN_; int maxfwd_; int need_funcadd_; int vrefGulp_; int want_derivs_; int ihd_limit_; real (*Objval) ANSI((ASL*, int nobj, real *X, fint *nerror)); void (*Objgrd) ANSI((ASL*, int nobj, real *X, real *G, fint *nerror)); void (*Conval) ANSI((ASL*, real *X, real *R, fint *nerror)); void (*Jacval) ANSI((ASL*, real *X, real *J, fint *nerror)); real (*Conival)ANSI((ASL*, int ncon, real *X, fint *ne)); void (*Congrd) ANSI((ASL*, int nc, real *X, real *G, fint *nerror)); void (*Hvcomp) ANSI((ASL*,real *hv,real *p,int no,real *ow,real *y)); void (*Hvinit) ANSI((ASL*, int, int, real*, real*)); void (*Hesset) ANSI((ASL*,int flags,int no,int nno,int nc,int nnc)); void (*Xknown) ANSI((ASL*, real*, fint*)); void (*Duthes) ANSI((ASL*, real *H, int nobj, real *ow, real *y)); void (*Fulhes) ANSI((ASL*, real *H,fint LH, int no, real *ow, real *y)); void (*Sphes) ANSI((ASL*, SputInfo**, real *H, int nobj, real *ow, real *y)); fint (*Sphset) ANSI((ASL*, SputInfo**, int nobj, int ow, int y, int both)); } Edagpars; typedef struct Edaginfo { int ASLtype; /* stuff initialized to zero values */ int amplflag_; int need_nl_; func_info **funcs_, *funcsfirst_, *funcslast_; int (*xscanf_) ANSI((EdRead*, const char*, ...)); func_info *fhash_[NFHASH]; real *adjoints_; /* partials of result w.r.t. current oper. */ real *adjoints_nv1_; /* internal use: start of portion to zero */ real *LUrhs_, /* constraint lower (and, if Urhsx == 0, */ /* upper) bounds */ *Urhsx_, /* constraint upper bounds (if nonzero) */ *X0_, /* initial guess (if nonzero) */ *LUv_, /* variable lower (and, if Uvx == 0, upper) */ /* bounds */ *Uvx_, /* variable upper bounds (if nonzero) */ *Lastx_, /* internal use: copy of X */ *pi0_; /* dual initial guess */ char *objtype_; /* object type array: 0 == min, 1 == max */ char *havex0_; /* if nonzero, havex0_[i] != 0 ==> */ /* X0_[i] was specified: this lets you */ /* tell explicit 0's from default 0's */ char *havepi0_; /* analogous to havex0_, but for dual values */ real *A_vals_; /* if nonzero, store linear Jacobian elements */ /* in A_vals, A_rownos, and A_colstarts */ /* rather than in Cgrad_ */ /* for storing linear Jacobian nonzeros */ int *A_rownos_, /* row numbers corresponding to A_vals_ */ *A_colstarts_; /* offsets of columns in A_vals_ */ cgrad **Cgrad_; /* constraint gradient info. (linear part) */ ograd **Ograd_; /* objective gradient info. (linear part) */ int Fortran_; /* adjustment to A_rownos and A_colstarts */ int amax_; /* number of adjoint cells */ /* stuff for common expressions (from "defined" vars) */ int c_vars_; int comb_; int combc_; int comc1_; int comc_; int como1_; int como_; int lnc_; /* no. of linear network constraints */ int nbv_; /* no. of linear binary variables */ int niv_; /* no. of linear integer variables */ int nlc_; /* total no. of nonlinear constraints */ int n_eqn_; /* number of equality constraints or -1 */ /* if unknown (ampl prior to 19970627) */ int n_cc_; /* total complementarity conditions */ int nlcc_; /* nonlinear complementarity conditions */ int nlnc_; /* no. of nonlinear network constraints */ int nlo_; /* no. of nonlinear objectives */ int nlvb_; /* no. of nonlinear variables in both */ /* constraints and objectives */ int nlvc_; /* no. of nonlinear variables in constraints */ int nlvo_; /* no. of nonlinear variables in objectives */ /* nlvc_ and nlvo_ include nlvb_ */ int nlvbi_; /* integer nonlinear variables in both */ /* constraints and objectives */ int nlvci_; /* integer nonlinear vars just in constraints */ int nlvoi_; /* integer nonlinear vars just in objectives */ int nwv_; /* no. of (linear) network variables (arcs) */ int nzc_; /* no. of nonzeros in constraints' Jacobian */ int nzo_; /* no. of nonzeros in all objective gradients */ int n_var_; /* total no. of variables */ int n_con_; /* total no. of constraints */ int n_obj_; /* total no. of objectives */ int n_prob; /* 1 (for use with SufDesc): SufDesc.u has */ /* (&asl->i.n_var_)[SufDesc.kind & ASL_Sufkind_mask] entries */ int n_conjac_[2]; /* Conval and Jacval operate on constraint i */ /* for n_conjac_[0] <= i < n_conjac_[1]. */ /* Initialized by jac0dim to 0 and n_con. */ /* internal stuff */ int ncom0_; int ncom1_; int nderps_; int nfunc_; int nzjac_; int o_vars_; int want_deriv_; int x0kind_; size_t x0len_; char *filename_; /* stub + current extension */ char *stub_end_; /* copy new extension (starting with ".") */ /* here to adjust filename */ Char *archan_; /* channel for reading from AMPL */ Char *awchan_; /* channel from writing to AMPL */ int binary_nl_; /* 0 = ASCII format, 1 = binary */ int return_nofile_; /* 0 ==> jacdim0 should exit if stub.nl */ /* does not exist; 1 ==> return 0 */ int plterms_; /* no. of piecewise-linear terms */ int maxrownamelen_; /* length of longest constraint name */ /* (if stub.row exists) */ int maxcolnamelen_; /* length of longest constraint name */ /* (if stub.col exists) */ int co_index_; /* set this to (constraint number - 1) or */ /* -(objective number) to identify the */ /* constraint or objective being evaluated */ /* (used in report_where()) */ int cv_index_; /* used internally */ Jmp_buf *err_jmp_; /* If nonzero when an error is detected, */ /* longjmp here (without printing an error */ /* message). */ Jmp_buf *err_jmp1_; /* If nonzero when an error is detected */ /* (and err_jmp_ == 0), longjmp here after */ /* printing an error message. */ fint ampl_options_[10]; fint obj_no_; /* objective number (for write_sol and */ /* read_sol) */ int nranges_; /* no. of ranges (constraints with */ /* negInfinity < lhs < rhs < Infinity) */ int want_xpi0_; /* & 1 ==> allocate X0_ if an */ /* initial guess is available */ /* & 2 ==> allocate pi0_ if a dual */ /* initial guess is available */ /* starting subscripts for cexp1's: request by */ /* assigning these pointers before invoking edagread */ int *c_cexp1st_; /* cexp1 starts for constraints */ int *o_cexp1st_; /* cexp1 starts for objectives */ /* for complementarity constraints */ int *cvar_; /* cvar[i] > 0 means constraint i complements */ /* variable cvar[i] - 1 */ unsigned size_expr_n_; /* size for struct expr_n, for nlc */ /* extra info for writesol */ real ampl_vbtol_; /* relocated adjoints for common expressions */ /* (used by nlc; request by allocating) */ int **zaC_; /* for common expressions */ int **zac_; /* for constraints */ int **zao_; /* for objectives */ /* for nlc */ int skip_int_derivs_; /* for suffixes */ int nsuffixes; SufDesc *suffixes; /* for sparse gradients */ int **zerograds_; int congrd_mode; /* How to treat arg G to Congrd: */ /* 0 == expand to n_var vector (default) */ /* 1 == compact storage in G */ /* 2 == use goff fields of struct cgrad */ int x_known; /* used by xknown(), xunknown() */ Long xknown_ignore; /* for debugging: ignore xknown */ size_t zap_J; /* used by dense_j */ int nxval; /* used by conival */ int *ncxval; /* for conival */ int *noxval; /* for objval (not yet used) */ SputInfo *sputinfo_; /* used by sputhes() */ /* for ASL_free */ Char **Mbnext, **Mblast, *Mb; /* for mem */ char *memNext, *memLast; /* for user-defined functions */ AmplExports ae; /* for con_name(), obj_name(), var_name() */ char **conames; char **varnames; int vcochecked; /* for possible user-specific use */ Char *uinfo; /* for reading alternate binary formats */ void (*iadjfcn) ANSI((void*, unsigned long)); void (*dadjfcn) ANSI((void*, unsigned long)); /* for scaling */ real *cscale; /* constraints */ real *vscale; /* variables */ real *lscale; /* Lagrange-multiplier scale */ } Edaginfo; struct ASL { Edagpars p; Edaginfo i; }; #define A_colstarts asl->i.A_colstarts_ #define A_rownos asl->i.A_rownos_ #define A_vals asl->i.A_vals_ #define Cgrad asl->i.Cgrad_ #define Fortran asl->i.Fortran_ #define LUrhs asl->i.LUrhs_ #define LUv asl->i.LUv_ #define Lastx asl->i.Lastx_ #define Ograd asl->i.Ograd_ #define Urhsx asl->i.Urhsx_ #define Uvx asl->i.Uvx_ #define X0 asl->i.X0_ #define adjoints asl->i.adjoints_ #define adjoints_nv1 asl->i.adjoints_nv1_ #define amax asl->i.amax_ #define ampl_options asl->i.ampl_options_ #define ampl_vbtol asl->i.ampl_vbtol_ #define amplflag asl->i.amplflag_ #define archan asl->i.archan_ #define awchan asl->i.awchan_ #define binary_nl asl->i.binary_nl_ #define c_cexp1st asl->i.c_cexp1st_ #define c_vars asl->i.c_vars_ #define co_index asl->i.co_index_ #define comb asl->i.comb_ #define combc asl->i.combc_ #define comc asl->i.comc_ #define comc1 asl->i.comc1_ #define como asl->i.como_ #define como1 asl->i.como1_ #define cv_index asl->i.cv_index_ #define cvar asl->i.cvar_ #define err_jmp asl->i.err_jmp_ #define err_jmp1 asl->i.err_jmp1_ #define fhash asl->i.fhash_ #define filename asl->i.filename_ #define funcs asl->i.funcs_ #define funcsfirst asl->i.funcsfirst_ #define funcslast asl->i.funcslast_ #define havepi0 asl->i.havepi0_ #define havex0 asl->i.havex0_ #define lnc asl->i.lnc_ #define maxcolnamelen asl->i.maxcolnamelen_ #define maxrownamelen asl->i.maxrownamelen_ #define n_cc asl->i.n_cc_ #define n_con asl->i.n_con_ #define n_conjac asl->i.n_conjac_ #define n_obj asl->i.n_obj_ #define n_var asl->i.n_var_ #define nbv asl->i.nbv_ #define ncom0 asl->i.ncom0_ #define ncom1 asl->i.ncom1_ #define nderps asl->i.nderps_ #define need_nl asl->i.need_nl_ #define n_eqn asl->i.n_eqn_ #define nfunc asl->i.nfunc_ #define niv asl->i.niv_ #define nlc asl->i.nlc_ #define nlcc asl->i.nlcc_ #define nlnc asl->i.nlnc_ #define nlo asl->i.nlo_ #define nlogv asl->i.nbv_ /* nbv used to be called nlogv */ #define nlvb asl->i.nlvb_ #define nlvbi asl->i.nlvbi_ #define nlvc asl->i.nlvc_ #define nlvci asl->i.nlvci_ #define nlvo asl->i.nlvo_ #define nlvoi asl->i.nlvoi_ #define nranges asl->i.nranges_ #define nwv asl->i.nwv_ #define nzc asl->i.nzc_ #define nzjac asl->i.nzjac_ #define nzo asl->i.nzo_ #define o_cexp1st asl->i.o_cexp1st_ #define o_vars asl->i.o_vars_ #define obj_no asl->i.obj_no_ #define objtype asl->i.objtype_ #define pi0 asl->i.pi0_ #define plterms asl->i.plterms_ #define return_nofile asl->i.return_nofile_ #define size_expr_n asl->i.size_expr_n_ #define skip_int_derivs asl->i.skip_int_derivs_ #define sputinfo asl->i.sputinfo_ #define stub_end asl->i.stub_end_ #define want_deriv asl->i.want_deriv_ #define want_xpi0 asl->i.want_xpi0_ #define x0kind asl->i.x0kind_ #define x0len asl->i.x0len_ #define xscanf asl->i.xscanf_ #define zaC asl->i.zaC_ #define zac asl->i.zac_ #define zao asl->i.zao_ #define zerograds asl->i.zerograds_ #define M1alloc(n) M1alloc_ASL(&asl->i,n) #define M1free M1free_ASL #define M1record(n) M1record_ASL(&asl->i,n) #define M1zapalloc(n) M1zapalloc_ASL(&asl->i,n) #define Mach Mach_ASL #define ascanf ascanf_ASL #define badline badline_ASL #define badread badread_ASL #define bscanf bscanf_ASL #define der0prop der0prop_ASL #define derprop derprop_ASL #define dynlink dynlink_ASL #define edag_peek edag_peek_ASL #define edagread_one edag_one_ASL #define fpecatch fpecatch_ASL #define func_add func_add_ASL #define func_lookup func_lookup_ASL #define g_fmt g_fmt_ASL #define g_fmtp g_fmtp_ASL #define g_fmtop g_fmtop_ASL #define g_fmt_E gfmt_E_ASL #define g_fmt_decpt gfmt_decpt_ASL #define htcl htcl_ASL #define mem(n) mem_ASL((ASL*)asl,n) #define mymalloc mymalloc_ASL #define mypow mypow_ASL #define myralloc myralloc_ASL #define obj_prec obj_prec_ASL #define optype op_type_ASL #define pr_unknown pr_unknown_ASL #define read_line read_line_ASL #define report_where report_where_ASL #define scream scream_ASL #define what_prog what_prog_ASL