1 /****************************************************************
2 Copyright (C) 1997 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 /* For LPs (and IPs and MIPs), objconst(n) is the constant term
26  * for objective n (first objective has n = 0).
27  */
28 #define SKIP_NL2_DEFINES
29 #include "nlp.h"
30 #include "nlp2.h"
31 #include "asl_pfg.h"
32 #include "asl_pfgh.h"
33 #undef f_OPNUM
34 #include "r_opn0.hd"	/* for f_OPNUM */
35 
36  real
37 #ifdef KR_headers
objconst_ASL(asl,n)38 objconst_ASL(asl, n) ASL *asl; int n;
39 #else
40 objconst_ASL(ASL *asl, int n)
41 #endif
42 {
43 	expr_n *e;
44 	efunc_n *opnum = f_OPNUM_ASL;
45 	static char who[] = "objconst";
46 
47 	if (!asl)
48 		badasl_ASL(asl,0,who);
49 	else if (asl->i.ASLtype < ASL_read_f || asl->i.ASLtype >ASL_read_pfgh)
50 		badasl_ASL(asl,ASL_read_f,who);
51 
52 	if (n >= 0 && n < n_obj) {
53 		switch(asl->i.ASLtype) {
54 		  case ASL_read_fgh:
55 			e = (expr_n*)(((ASL_fgh*)asl)->I.obj2_de_ + n)->e;
56 			break;
57 		  case ASL_read_pfg:
58 			e = (expr_n*)(((ASL_pfg*)asl)->I.obj_de_ + n)->e;
59 			opnum = (efunc_n*)f_OPNUM;
60 			break;
61 		  case ASL_read_pfgh:
62 			e = (expr_n*)(((ASL_pfgh*)asl)->I.obj2_de_ + n)->e;
63 			opnum = (efunc_n*)f_OPNUM;
64 			break;
65 		  default:
66 			e = (expr_n*)(((ASL_fg*)asl)->I.obj_de_ + n)->e;
67 		  }
68 		if (e->op == opnum)
69 			return e->v;
70 		}
71 	return 0;
72 	}
73