1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/glpmpl.h Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,2583 @@
1.4 +/* glpmpl.h (GNU MathProg translator) */
1.5 +
1.6 +/***********************************************************************
1.7 +* This code is part of GLPK (GNU Linear Programming Kit).
1.8 +*
1.9 +* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
1.10 +* 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
1.11 +* Moscow Aviation Institute, Moscow, Russia. All rights reserved.
1.12 +* E-mail: <mao@gnu.org>.
1.13 +*
1.14 +* GLPK is free software: you can redistribute it and/or modify it
1.15 +* under the terms of the GNU General Public License as published by
1.16 +* the Free Software Foundation, either version 3 of the License, or
1.17 +* (at your option) any later version.
1.18 +*
1.19 +* GLPK is distributed in the hope that it will be useful, but WITHOUT
1.20 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.21 +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1.22 +* License for more details.
1.23 +*
1.24 +* You should have received a copy of the GNU General Public License
1.25 +* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
1.26 +***********************************************************************/
1.27 +
1.28 +#ifndef GLPMPL_H
1.29 +#define GLPMPL_H
1.30 +
1.31 +#include "glpavl.h"
1.32 +#include "glprng.h"
1.33 +
1.34 +typedef struct MPL MPL;
1.35 +typedef char STRING;
1.36 +typedef struct SYMBOL SYMBOL;
1.37 +typedef struct TUPLE TUPLE;
1.38 +typedef struct ARRAY ELEMSET;
1.39 +typedef struct ELEMVAR ELEMVAR;
1.40 +typedef struct FORMULA FORMULA;
1.41 +typedef struct ELEMCON ELEMCON;
1.42 +typedef union VALUE VALUE;
1.43 +typedef struct ARRAY ARRAY;
1.44 +typedef struct MEMBER MEMBER;
1.45 +#if 1
1.46 +/* many C compilers have DOMAIN declared in <math.h> :( */
1.47 +#undef DOMAIN
1.48 +#define DOMAIN DOMAIN1
1.49 +#endif
1.50 +typedef struct DOMAIN DOMAIN;
1.51 +typedef struct DOMAIN_BLOCK DOMAIN_BLOCK;
1.52 +typedef struct DOMAIN_SLOT DOMAIN_SLOT;
1.53 +typedef struct SET SET;
1.54 +typedef struct WITHIN WITHIN;
1.55 +typedef struct GADGET GADGET;
1.56 +typedef struct PARAMETER PARAMETER;
1.57 +typedef struct CONDITION CONDITION;
1.58 +typedef struct VARIABLE VARIABLE;
1.59 +typedef struct CONSTRAINT CONSTRAINT;
1.60 +typedef struct TABLE TABLE;
1.61 +typedef struct TABARG TABARG;
1.62 +typedef struct TABFLD TABFLD;
1.63 +typedef struct TABIN TABIN;
1.64 +typedef struct TABOUT TABOUT;
1.65 +typedef struct TABDCA TABDCA;
1.66 +typedef union OPERANDS OPERANDS;
1.67 +typedef struct ARG_LIST ARG_LIST;
1.68 +typedef struct CODE CODE;
1.69 +typedef struct CHECK CHECK;
1.70 +typedef struct DISPLAY DISPLAY;
1.71 +typedef struct DISPLAY1 DISPLAY1;
1.72 +typedef struct PRINTF PRINTF;
1.73 +typedef struct PRINTF1 PRINTF1;
1.74 +typedef struct FOR FOR;
1.75 +typedef struct STATEMENT STATEMENT;
1.76 +typedef struct TUPLE SLICE;
1.77 +
1.78 +/**********************************************************************/
1.79 +/* * * TRANSLATOR DATABASE * * */
1.80 +/**********************************************************************/
1.81 +
1.82 +#define A_BINARY 101 /* something binary */
1.83 +#define A_CHECK 102 /* check statement */
1.84 +#define A_CONSTRAINT 103 /* model constraint */
1.85 +#define A_DISPLAY 104 /* display statement */
1.86 +#define A_ELEMCON 105 /* elemental constraint/objective */
1.87 +#define A_ELEMSET 106 /* elemental set */
1.88 +#define A_ELEMVAR 107 /* elemental variable */
1.89 +#define A_EXPRESSION 108 /* expression */
1.90 +#define A_FOR 109 /* for statement */
1.91 +#define A_FORMULA 110 /* formula */
1.92 +#define A_INDEX 111 /* dummy index */
1.93 +#define A_INPUT 112 /* input table */
1.94 +#define A_INTEGER 113 /* something integer */
1.95 +#define A_LOGICAL 114 /* something logical */
1.96 +#define A_MAXIMIZE 115 /* objective has to be maximized */
1.97 +#define A_MINIMIZE 116 /* objective has to be minimized */
1.98 +#define A_NONE 117 /* nothing */
1.99 +#define A_NUMERIC 118 /* something numeric */
1.100 +#define A_OUTPUT 119 /* output table */
1.101 +#define A_PARAMETER 120 /* model parameter */
1.102 +#define A_PRINTF 121 /* printf statement */
1.103 +#define A_SET 122 /* model set */
1.104 +#define A_SOLVE 123 /* solve statement */
1.105 +#define A_SYMBOLIC 124 /* something symbolic */
1.106 +#define A_TABLE 125 /* data table */
1.107 +#define A_TUPLE 126 /* n-tuple */
1.108 +#define A_VARIABLE 127 /* model variable */
1.109 +
1.110 +#define MAX_LENGTH 100
1.111 +/* maximal length of any symbolic value (this includes symbolic names,
1.112 + numeric and string literals, and all symbolic values that may appear
1.113 + during the evaluation phase) */
1.114 +
1.115 +#define CONTEXT_SIZE 60
1.116 +/* size of the context queue, in characters */
1.117 +
1.118 +#define OUTBUF_SIZE 1024
1.119 +/* size of the output buffer, in characters */
1.120 +
1.121 +struct MPL
1.122 +{ /* translator database */
1.123 + /*--------------------------------------------------------------*/
1.124 + /* scanning segment */
1.125 + int line;
1.126 + /* number of the current text line */
1.127 + int c;
1.128 + /* the current character or EOF */
1.129 + int token;
1.130 + /* the current token: */
1.131 +#define T_EOF 201 /* end of file */
1.132 +#define T_NAME 202 /* symbolic name (model section only) */
1.133 +#define T_SYMBOL 203 /* symbol (data section only) */
1.134 +#define T_NUMBER 204 /* numeric literal */
1.135 +#define T_STRING 205 /* string literal */
1.136 +#define T_AND 206 /* and && */
1.137 +#define T_BY 207 /* by */
1.138 +#define T_CROSS 208 /* cross */
1.139 +#define T_DIFF 209 /* diff */
1.140 +#define T_DIV 210 /* div */
1.141 +#define T_ELSE 211 /* else */
1.142 +#define T_IF 212 /* if */
1.143 +#define T_IN 213 /* in */
1.144 +#define T_INFINITY 214 /* Infinity */
1.145 +#define T_INTER 215 /* inter */
1.146 +#define T_LESS 216 /* less */
1.147 +#define T_MOD 217 /* mod */
1.148 +#define T_NOT 218 /* not ! */
1.149 +#define T_OR 219 /* or || */
1.150 +#define T_SPTP 220 /* s.t. */
1.151 +#define T_SYMDIFF 221 /* symdiff */
1.152 +#define T_THEN 222 /* then */
1.153 +#define T_UNION 223 /* union */
1.154 +#define T_WITHIN 224 /* within */
1.155 +#define T_PLUS 225 /* + */
1.156 +#define T_MINUS 226 /* - */
1.157 +#define T_ASTERISK 227 /* * */
1.158 +#define T_SLASH 228 /* / */
1.159 +#define T_POWER 229 /* ^ ** */
1.160 +#define T_LT 230 /* < */
1.161 +#define T_LE 231 /* <= */
1.162 +#define T_EQ 232 /* = == */
1.163 +#define T_GE 233 /* >= */
1.164 +#define T_GT 234 /* > */
1.165 +#define T_NE 235 /* <> != */
1.166 +#define T_CONCAT 236 /* & */
1.167 +#define T_BAR 237 /* | */
1.168 +#define T_POINT 238 /* . */
1.169 +#define T_COMMA 239 /* , */
1.170 +#define T_COLON 240 /* : */
1.171 +#define T_SEMICOLON 241 /* ; */
1.172 +#define T_ASSIGN 242 /* := */
1.173 +#define T_DOTS 243 /* .. */
1.174 +#define T_LEFT 244 /* ( */
1.175 +#define T_RIGHT 245 /* ) */
1.176 +#define T_LBRACKET 246 /* [ */
1.177 +#define T_RBRACKET 247 /* ] */
1.178 +#define T_LBRACE 248 /* { */
1.179 +#define T_RBRACE 249 /* } */
1.180 +#define T_APPEND 250 /* >> */
1.181 +#define T_TILDE 251 /* ~ */
1.182 +#define T_INPUT 252 /* <- */
1.183 + int imlen;
1.184 + /* length of the current token */
1.185 + char *image; /* char image[MAX_LENGTH+1]; */
1.186 + /* image of the current token */
1.187 + double value;
1.188 + /* value of the current token (for T_NUMBER only) */
1.189 + int b_token;
1.190 + /* the previous token */
1.191 + int b_imlen;
1.192 + /* length of the previous token */
1.193 + char *b_image; /* char b_image[MAX_LENGTH+1]; */
1.194 + /* image of the previous token */
1.195 + double b_value;
1.196 + /* value of the previous token (if token is T_NUMBER) */
1.197 + int f_dots;
1.198 + /* if this flag is set, the next token should be recognized as
1.199 + T_DOTS, not as T_POINT */
1.200 + int f_scan;
1.201 + /* if this flag is set, the next token is already scanned */
1.202 + int f_token;
1.203 + /* the next token */
1.204 + int f_imlen;
1.205 + /* length of the next token */
1.206 + char *f_image; /* char f_image[MAX_LENGTH+1]; */
1.207 + /* image of the next token */
1.208 + double f_value;
1.209 + /* value of the next token (if token is T_NUMBER) */
1.210 + char *context; /* char context[CONTEXT_SIZE]; */
1.211 + /* context circular queue (not null-terminated!) */
1.212 + int c_ptr;
1.213 + /* pointer to the current position in the context queue */
1.214 + int flag_d;
1.215 + /* if this flag is set, the data section is being processed */
1.216 + /*--------------------------------------------------------------*/
1.217 + /* translating segment */
1.218 + DMP *pool;
1.219 + /* memory pool used to allocate all data instances created during
1.220 + the translation phase */
1.221 + AVL *tree;
1.222 + /* symbolic name table:
1.223 + node.type = A_INDEX => node.link -> DOMAIN_SLOT
1.224 + node.type = A_SET => node.link -> SET
1.225 + node.type = A_PARAMETER => node.link -> PARAMETER
1.226 + node.type = A_VARIABLE => node.link -> VARIABLE
1.227 + node.type = A_CONSTRANT => node.link -> CONSTRAINT */
1.228 + STATEMENT *model;
1.229 + /* linked list of model statements in the original order */
1.230 + int flag_x;
1.231 + /* if this flag is set, the current token being left parenthesis
1.232 + begins a slice that allows recognizing any undeclared symbolic
1.233 + names as dummy indices; this flag is automatically reset once
1.234 + the next token has been scanned */
1.235 + int as_within;
1.236 + /* the warning "in understood as within" has been issued */
1.237 + int as_in;
1.238 + /* the warning "within understood as in" has been issued */
1.239 + int as_binary;
1.240 + /* the warning "logical understood as binary" has been issued */
1.241 + int flag_s;
1.242 + /* if this flag is set, the solve statement has been parsed */
1.243 + /*--------------------------------------------------------------*/
1.244 + /* common segment */
1.245 + DMP *strings;
1.246 + /* memory pool to allocate STRING data structures */
1.247 + DMP *symbols;
1.248 + /* memory pool to allocate SYMBOL data structures */
1.249 + DMP *tuples;
1.250 + /* memory pool to allocate TUPLE data structures */
1.251 + DMP *arrays;
1.252 + /* memory pool to allocate ARRAY data structures */
1.253 + DMP *members;
1.254 + /* memory pool to allocate MEMBER data structures */
1.255 + DMP *elemvars;
1.256 + /* memory pool to allocate ELEMVAR data structures */
1.257 + DMP *formulae;
1.258 + /* memory pool to allocate FORMULA data structures */
1.259 + DMP *elemcons;
1.260 + /* memory pool to allocate ELEMCON data structures */
1.261 + ARRAY *a_list;
1.262 + /* linked list of all arrays in the database */
1.263 + char *sym_buf; /* char sym_buf[255+1]; */
1.264 + /* working buffer used by the routine format_symbol */
1.265 + char *tup_buf; /* char tup_buf[255+1]; */
1.266 + /* working buffer used by the routine format_tuple */
1.267 + /*--------------------------------------------------------------*/
1.268 + /* generating/postsolving segment */
1.269 + RNG *rand;
1.270 + /* pseudo-random number generator */
1.271 + int flag_p;
1.272 + /* if this flag is set, the postsolving phase is in effect */
1.273 + STATEMENT *stmt;
1.274 + /* model statement being currently executed */
1.275 + TABDCA *dca;
1.276 + /* pointer to table driver communication area for table statement
1.277 + currently executed */
1.278 + int m;
1.279 + /* number of rows in the problem, m >= 0 */
1.280 + int n;
1.281 + /* number of columns in the problem, n >= 0 */
1.282 + ELEMCON **row; /* ELEMCON *row[1+m]; */
1.283 + /* row[0] is not used;
1.284 + row[i] is elemental constraint or objective, which corresponds
1.285 + to i-th row of the problem, 1 <= i <= m */
1.286 + ELEMVAR **col; /* ELEMVAR *col[1+n]; */
1.287 + /* col[0] is not used;
1.288 + col[j] is elemental variable, which corresponds to j-th column
1.289 + of the problem, 1 <= j <= n */
1.290 + /*--------------------------------------------------------------*/
1.291 + /* input/output segment */
1.292 + XFILE *in_fp;
1.293 + /* stream assigned to the input text file */
1.294 + char *in_file;
1.295 + /* name of the input text file */
1.296 + XFILE *out_fp;
1.297 + /* stream assigned to the output text file used to write all data
1.298 + produced by display and printf statements; NULL means the data
1.299 + should be sent to stdout via the routine xprintf */
1.300 + char *out_file;
1.301 + /* name of the output text file */
1.302 +#if 0 /* 08/XI-2009 */
1.303 + char *out_buf; /* char out_buf[OUTBUF_SIZE] */
1.304 + /* buffer to accumulate output data */
1.305 + int out_cnt;
1.306 + /* count of data bytes stored in the output buffer */
1.307 +#endif
1.308 + XFILE *prt_fp;
1.309 + /* stream assigned to the print text file; may be NULL */
1.310 + char *prt_file;
1.311 + /* name of the output print file */
1.312 + /*--------------------------------------------------------------*/
1.313 + /* solver interface segment */
1.314 + jmp_buf jump;
1.315 + /* jump address for non-local go to in case of error */
1.316 + int phase;
1.317 + /* phase of processing:
1.318 + 0 - database is being or has been initialized
1.319 + 1 - model section is being or has been read
1.320 + 2 - data section is being or has been read
1.321 + 3 - model is being or has been generated/postsolved
1.322 + 4 - model processing error has occurred */
1.323 + char *mod_file;
1.324 + /* name of the input text file, which contains model section */
1.325 + char *mpl_buf; /* char mpl_buf[255+1]; */
1.326 + /* working buffer used by some interface routines */
1.327 +};
1.328 +
1.329 +/**********************************************************************/
1.330 +/* * * PROCESSING MODEL SECTION * * */
1.331 +/**********************************************************************/
1.332 +
1.333 +#define alloc(type) ((type *)dmp_get_atomv(mpl->pool, sizeof(type)))
1.334 +/* allocate atom of given type */
1.335 +
1.336 +#define enter_context _glp_mpl_enter_context
1.337 +void enter_context(MPL *mpl);
1.338 +/* enter current token into context queue */
1.339 +
1.340 +#define print_context _glp_mpl_print_context
1.341 +void print_context(MPL *mpl);
1.342 +/* print current content of context queue */
1.343 +
1.344 +#define get_char _glp_mpl_get_char
1.345 +void get_char(MPL *mpl);
1.346 +/* scan next character from input text file */
1.347 +
1.348 +#define append_char _glp_mpl_append_char
1.349 +void append_char(MPL *mpl);
1.350 +/* append character to current token */
1.351 +
1.352 +#define get_token _glp_mpl_get_token
1.353 +void get_token(MPL *mpl);
1.354 +/* scan next token from input text file */
1.355 +
1.356 +#define unget_token _glp_mpl_unget_token
1.357 +void unget_token(MPL *mpl);
1.358 +/* return current token back to input stream */
1.359 +
1.360 +#define is_keyword _glp_mpl_is_keyword
1.361 +int is_keyword(MPL *mpl, char *keyword);
1.362 +/* check if current token is given non-reserved keyword */
1.363 +
1.364 +#define is_reserved _glp_mpl_is_reserved
1.365 +int is_reserved(MPL *mpl);
1.366 +/* check if current token is reserved keyword */
1.367 +
1.368 +#define make_code _glp_mpl_make_code
1.369 +CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim);
1.370 +/* generate pseudo-code (basic routine) */
1.371 +
1.372 +#define make_unary _glp_mpl_make_unary
1.373 +CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim);
1.374 +/* generate pseudo-code for unary operation */
1.375 +
1.376 +#define make_binary _glp_mpl_make_binary
1.377 +CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
1.378 + int dim);
1.379 +/* generate pseudo-code for binary operation */
1.380 +
1.381 +#define make_ternary _glp_mpl_make_ternary
1.382 +CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
1.383 + int type, int dim);
1.384 +/* generate pseudo-code for ternary operation */
1.385 +
1.386 +#define numeric_literal _glp_mpl_numeric_literal
1.387 +CODE *numeric_literal(MPL *mpl);
1.388 +/* parse reference to numeric literal */
1.389 +
1.390 +#define string_literal _glp_mpl_string_literal
1.391 +CODE *string_literal(MPL *mpl);
1.392 +/* parse reference to string literal */
1.393 +
1.394 +#define create_arg_list _glp_mpl_create_arg_list
1.395 +ARG_LIST *create_arg_list(MPL *mpl);
1.396 +/* create empty operands list */
1.397 +
1.398 +#define expand_arg_list _glp_mpl_expand_arg_list
1.399 +ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x);
1.400 +/* append operand to operands list */
1.401 +
1.402 +#define arg_list_len _glp_mpl_arg_list_len
1.403 +int arg_list_len(MPL *mpl, ARG_LIST *list);
1.404 +/* determine length of operands list */
1.405 +
1.406 +#define subscript_list _glp_mpl_subscript_list
1.407 +ARG_LIST *subscript_list(MPL *mpl);
1.408 +/* parse subscript list */
1.409 +
1.410 +#define object_reference _glp_mpl_object_reference
1.411 +CODE *object_reference(MPL *mpl);
1.412 +/* parse reference to named object */
1.413 +
1.414 +#define numeric_argument _glp_mpl_numeric_argument
1.415 +CODE *numeric_argument(MPL *mpl, char *func);
1.416 +/* parse argument passed to built-in function */
1.417 +
1.418 +#define symbolic_argument _glp_mpl_symbolic_argument
1.419 +CODE *symbolic_argument(MPL *mpl, char *func);
1.420 +
1.421 +#define elemset_argument _glp_mpl_elemset_argument
1.422 +CODE *elemset_argument(MPL *mpl, char *func);
1.423 +
1.424 +#define function_reference _glp_mpl_function_reference
1.425 +CODE *function_reference(MPL *mpl);
1.426 +/* parse reference to built-in function */
1.427 +
1.428 +#define create_domain _glp_mpl_create_domain
1.429 +DOMAIN *create_domain(MPL *mpl);
1.430 +/* create empty domain */
1.431 +
1.432 +#define create_block _glp_mpl_create_block
1.433 +DOMAIN_BLOCK *create_block(MPL *mpl);
1.434 +/* create empty domain block */
1.435 +
1.436 +#define append_block _glp_mpl_append_block
1.437 +void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block);
1.438 +/* append domain block to specified domain */
1.439 +
1.440 +#define append_slot _glp_mpl_append_slot
1.441 +DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
1.442 + CODE *code);
1.443 +/* create and append new slot to domain block */
1.444 +
1.445 +#define expression_list _glp_mpl_expression_list
1.446 +CODE *expression_list(MPL *mpl);
1.447 +/* parse expression list */
1.448 +
1.449 +#define literal_set _glp_mpl_literal_set
1.450 +CODE *literal_set(MPL *mpl, CODE *code);
1.451 +/* parse literal set */
1.452 +
1.453 +#define indexing_expression _glp_mpl_indexing_expression
1.454 +DOMAIN *indexing_expression(MPL *mpl);
1.455 +/* parse indexing expression */
1.456 +
1.457 +#define close_scope _glp_mpl_close_scope
1.458 +void close_scope(MPL *mpl, DOMAIN *domain);
1.459 +/* close scope of indexing expression */
1.460 +
1.461 +#define iterated_expression _glp_mpl_iterated_expression
1.462 +CODE *iterated_expression(MPL *mpl);
1.463 +/* parse iterated expression */
1.464 +
1.465 +#define domain_arity _glp_mpl_domain_arity
1.466 +int domain_arity(MPL *mpl, DOMAIN *domain);
1.467 +/* determine arity of domain */
1.468 +
1.469 +#define set_expression _glp_mpl_set_expression
1.470 +CODE *set_expression(MPL *mpl);
1.471 +/* parse set expression */
1.472 +
1.473 +#define branched_expression _glp_mpl_branched_expression
1.474 +CODE *branched_expression(MPL *mpl);
1.475 +/* parse conditional expression */
1.476 +
1.477 +#define primary_expression _glp_mpl_primary_expression
1.478 +CODE *primary_expression(MPL *mpl);
1.479 +/* parse primary expression */
1.480 +
1.481 +#define error_preceding _glp_mpl_error_preceding
1.482 +void error_preceding(MPL *mpl, char *opstr);
1.483 +/* raise error if preceding operand has wrong type */
1.484 +
1.485 +#define error_following _glp_mpl_error_following
1.486 +void error_following(MPL *mpl, char *opstr);
1.487 +/* raise error if following operand has wrong type */
1.488 +
1.489 +#define error_dimension _glp_mpl_error_dimension
1.490 +void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2);
1.491 +/* raise error if operands have different dimension */
1.492 +
1.493 +#define expression_0 _glp_mpl_expression_0
1.494 +CODE *expression_0(MPL *mpl);
1.495 +/* parse expression of level 0 */
1.496 +
1.497 +#define expression_1 _glp_mpl_expression_1
1.498 +CODE *expression_1(MPL *mpl);
1.499 +/* parse expression of level 1 */
1.500 +
1.501 +#define expression_2 _glp_mpl_expression_2
1.502 +CODE *expression_2(MPL *mpl);
1.503 +/* parse expression of level 2 */
1.504 +
1.505 +#define expression_3 _glp_mpl_expression_3
1.506 +CODE *expression_3(MPL *mpl);
1.507 +/* parse expression of level 3 */
1.508 +
1.509 +#define expression_4 _glp_mpl_expression_4
1.510 +CODE *expression_4(MPL *mpl);
1.511 +/* parse expression of level 4 */
1.512 +
1.513 +#define expression_5 _glp_mpl_expression_5
1.514 +CODE *expression_5(MPL *mpl);
1.515 +/* parse expression of level 5 */
1.516 +
1.517 +#define expression_6 _glp_mpl_expression_6
1.518 +CODE *expression_6(MPL *mpl);
1.519 +/* parse expression of level 6 */
1.520 +
1.521 +#define expression_7 _glp_mpl_expression_7
1.522 +CODE *expression_7(MPL *mpl);
1.523 +/* parse expression of level 7 */
1.524 +
1.525 +#define expression_8 _glp_mpl_expression_8
1.526 +CODE *expression_8(MPL *mpl);
1.527 +/* parse expression of level 8 */
1.528 +
1.529 +#define expression_9 _glp_mpl_expression_9
1.530 +CODE *expression_9(MPL *mpl);
1.531 +/* parse expression of level 9 */
1.532 +
1.533 +#define expression_10 _glp_mpl_expression_10
1.534 +CODE *expression_10(MPL *mpl);
1.535 +/* parse expression of level 10 */
1.536 +
1.537 +#define expression_11 _glp_mpl_expression_11
1.538 +CODE *expression_11(MPL *mpl);
1.539 +/* parse expression of level 11 */
1.540 +
1.541 +#define expression_12 _glp_mpl_expression_12
1.542 +CODE *expression_12(MPL *mpl);
1.543 +/* parse expression of level 12 */
1.544 +
1.545 +#define expression_13 _glp_mpl_expression_13
1.546 +CODE *expression_13(MPL *mpl);
1.547 +/* parse expression of level 13 */
1.548 +
1.549 +#define set_statement _glp_mpl_set_statement
1.550 +SET *set_statement(MPL *mpl);
1.551 +/* parse set statement */
1.552 +
1.553 +#define parameter_statement _glp_mpl_parameter_statement
1.554 +PARAMETER *parameter_statement(MPL *mpl);
1.555 +/* parse parameter statement */
1.556 +
1.557 +#define variable_statement _glp_mpl_variable_statement
1.558 +VARIABLE *variable_statement(MPL *mpl);
1.559 +/* parse variable statement */
1.560 +
1.561 +#define constraint_statement _glp_mpl_constraint_statement
1.562 +CONSTRAINT *constraint_statement(MPL *mpl);
1.563 +/* parse constraint statement */
1.564 +
1.565 +#define objective_statement _glp_mpl_objective_statement
1.566 +CONSTRAINT *objective_statement(MPL *mpl);
1.567 +/* parse objective statement */
1.568 +
1.569 +#define table_statement _glp_mpl_table_statement
1.570 +TABLE *table_statement(MPL *mpl);
1.571 +/* parse table statement */
1.572 +
1.573 +#define solve_statement _glp_mpl_solve_statement
1.574 +void *solve_statement(MPL *mpl);
1.575 +/* parse solve statement */
1.576 +
1.577 +#define check_statement _glp_mpl_check_statement
1.578 +CHECK *check_statement(MPL *mpl);
1.579 +/* parse check statement */
1.580 +
1.581 +#define display_statement _glp_mpl_display_statement
1.582 +DISPLAY *display_statement(MPL *mpl);
1.583 +/* parse display statement */
1.584 +
1.585 +#define printf_statement _glp_mpl_printf_statement
1.586 +PRINTF *printf_statement(MPL *mpl);
1.587 +/* parse printf statement */
1.588 +
1.589 +#define for_statement _glp_mpl_for_statement
1.590 +FOR *for_statement(MPL *mpl);
1.591 +/* parse for statement */
1.592 +
1.593 +#define end_statement _glp_mpl_end_statement
1.594 +void end_statement(MPL *mpl);
1.595 +/* parse end statement */
1.596 +
1.597 +#define simple_statement _glp_mpl_simple_statement
1.598 +STATEMENT *simple_statement(MPL *mpl, int spec);
1.599 +/* parse simple statement */
1.600 +
1.601 +#define model_section _glp_mpl_model_section
1.602 +void model_section(MPL *mpl);
1.603 +/* parse model section */
1.604 +
1.605 +/**********************************************************************/
1.606 +/* * * PROCESSING DATA SECTION * * */
1.607 +/**********************************************************************/
1.608 +
1.609 +#if 2 + 2 == 5
1.610 +struct SLICE /* see TUPLE */
1.611 +{ /* component of slice; the slice itself is associated with its
1.612 + first component; slices are similar to n-tuples with exception
1.613 + that some slice components (which are indicated by asterisks)
1.614 + don't refer to any symbols */
1.615 + SYMBOL *sym;
1.616 + /* symbol, which this component refers to; can be NULL */
1.617 + SLICE *next;
1.618 + /* the next component of slice */
1.619 +};
1.620 +#endif
1.621 +
1.622 +#define create_slice _glp_mpl_create_slice
1.623 +SLICE *create_slice(MPL *mpl);
1.624 +/* create slice */
1.625 +
1.626 +#define expand_slice _glp_mpl_expand_slice
1.627 +SLICE *expand_slice
1.628 +( MPL *mpl,
1.629 + SLICE *slice, /* destroyed */
1.630 + SYMBOL *sym /* destroyed */
1.631 +);
1.632 +/* append new component to slice */
1.633 +
1.634 +#define slice_dimen _glp_mpl_slice_dimen
1.635 +int slice_dimen
1.636 +( MPL *mpl,
1.637 + SLICE *slice /* not changed */
1.638 +);
1.639 +/* determine dimension of slice */
1.640 +
1.641 +#define slice_arity _glp_mpl_slice_arity
1.642 +int slice_arity
1.643 +( MPL *mpl,
1.644 + SLICE *slice /* not changed */
1.645 +);
1.646 +/* determine arity of slice */
1.647 +
1.648 +#define fake_slice _glp_mpl_fake_slice
1.649 +SLICE *fake_slice(MPL *mpl, int dim);
1.650 +/* create fake slice of all asterisks */
1.651 +
1.652 +#define delete_slice _glp_mpl_delete_slice
1.653 +void delete_slice
1.654 +( MPL *mpl,
1.655 + SLICE *slice /* destroyed */
1.656 +);
1.657 +/* delete slice */
1.658 +
1.659 +#define is_number _glp_mpl_is_number
1.660 +int is_number(MPL *mpl);
1.661 +/* check if current token is number */
1.662 +
1.663 +#define is_symbol _glp_mpl_is_symbol
1.664 +int is_symbol(MPL *mpl);
1.665 +/* check if current token is symbol */
1.666 +
1.667 +#define is_literal _glp_mpl_is_literal
1.668 +int is_literal(MPL *mpl, char *literal);
1.669 +/* check if current token is given symbolic literal */
1.670 +
1.671 +#define read_number _glp_mpl_read_number
1.672 +double read_number(MPL *mpl);
1.673 +/* read number */
1.674 +
1.675 +#define read_symbol _glp_mpl_read_symbol
1.676 +SYMBOL *read_symbol(MPL *mpl);
1.677 +/* read symbol */
1.678 +
1.679 +#define read_slice _glp_mpl_read_slice
1.680 +SLICE *read_slice
1.681 +( MPL *mpl,
1.682 + char *name, /* not changed */
1.683 + int dim
1.684 +);
1.685 +/* read slice */
1.686 +
1.687 +#define select_set _glp_mpl_select_set
1.688 +SET *select_set
1.689 +( MPL *mpl,
1.690 + char *name /* not changed */
1.691 +);
1.692 +/* select set to saturate it with elemental sets */
1.693 +
1.694 +#define simple_format _glp_mpl_simple_format
1.695 +void simple_format
1.696 +( MPL *mpl,
1.697 + SET *set, /* not changed */
1.698 + MEMBER *memb, /* modified */
1.699 + SLICE *slice /* not changed */
1.700 +);
1.701 +/* read set data block in simple format */
1.702 +
1.703 +#define matrix_format _glp_mpl_matrix_format
1.704 +void matrix_format
1.705 +( MPL *mpl,
1.706 + SET *set, /* not changed */
1.707 + MEMBER *memb, /* modified */
1.708 + SLICE *slice, /* not changed */
1.709 + int tr
1.710 +);
1.711 +/* read set data block in matrix format */
1.712 +
1.713 +#define set_data _glp_mpl_set_data
1.714 +void set_data(MPL *mpl);
1.715 +/* read set data */
1.716 +
1.717 +#define select_parameter _glp_mpl_select_parameter
1.718 +PARAMETER *select_parameter
1.719 +( MPL *mpl,
1.720 + char *name /* not changed */
1.721 +);
1.722 +/* select parameter to saturate it with data */
1.723 +
1.724 +#define set_default _glp_mpl_set_default
1.725 +void set_default
1.726 +( MPL *mpl,
1.727 + PARAMETER *par, /* not changed */
1.728 + SYMBOL *altval /* destroyed */
1.729 +);
1.730 +/* set default parameter value */
1.731 +
1.732 +#define read_value _glp_mpl_read_value
1.733 +MEMBER *read_value
1.734 +( MPL *mpl,
1.735 + PARAMETER *par, /* not changed */
1.736 + TUPLE *tuple /* destroyed */
1.737 +);
1.738 +/* read value and assign it to parameter member */
1.739 +
1.740 +#define plain_format _glp_mpl_plain_format
1.741 +void plain_format
1.742 +( MPL *mpl,
1.743 + PARAMETER *par, /* not changed */
1.744 + SLICE *slice /* not changed */
1.745 +);
1.746 +/* read parameter data block in plain format */
1.747 +
1.748 +#define tabular_format _glp_mpl_tabular_format
1.749 +void tabular_format
1.750 +( MPL *mpl,
1.751 + PARAMETER *par, /* not changed */
1.752 + SLICE *slice, /* not changed */
1.753 + int tr
1.754 +);
1.755 +/* read parameter data block in tabular format */
1.756 +
1.757 +#define tabbing_format _glp_mpl_tabbing_format
1.758 +void tabbing_format
1.759 +( MPL *mpl,
1.760 + SYMBOL *altval /* not changed */
1.761 +);
1.762 +/* read parameter data block in tabbing format */
1.763 +
1.764 +#define parameter_data _glp_mpl_parameter_data
1.765 +void parameter_data(MPL *mpl);
1.766 +/* read parameter data */
1.767 +
1.768 +#define data_section _glp_mpl_data_section
1.769 +void data_section(MPL *mpl);
1.770 +/* read data section */
1.771 +
1.772 +/**********************************************************************/
1.773 +/* * * FLOATING-POINT NUMBERS * * */
1.774 +/**********************************************************************/
1.775 +
1.776 +#define fp_add _glp_mpl_fp_add
1.777 +double fp_add(MPL *mpl, double x, double y);
1.778 +/* floating-point addition */
1.779 +
1.780 +#define fp_sub _glp_mpl_fp_sub
1.781 +double fp_sub(MPL *mpl, double x, double y);
1.782 +/* floating-point subtraction */
1.783 +
1.784 +#define fp_less _glp_mpl_fp_less
1.785 +double fp_less(MPL *mpl, double x, double y);
1.786 +/* floating-point non-negative subtraction */
1.787 +
1.788 +#define fp_mul _glp_mpl_fp_mul
1.789 +double fp_mul(MPL *mpl, double x, double y);
1.790 +/* floating-point multiplication */
1.791 +
1.792 +#define fp_div _glp_mpl_fp_div
1.793 +double fp_div(MPL *mpl, double x, double y);
1.794 +/* floating-point division */
1.795 +
1.796 +#define fp_idiv _glp_mpl_fp_idiv
1.797 +double fp_idiv(MPL *mpl, double x, double y);
1.798 +/* floating-point quotient of exact division */
1.799 +
1.800 +#define fp_mod _glp_mpl_fp_mod
1.801 +double fp_mod(MPL *mpl, double x, double y);
1.802 +/* floating-point remainder of exact division */
1.803 +
1.804 +#define fp_power _glp_mpl_fp_power
1.805 +double fp_power(MPL *mpl, double x, double y);
1.806 +/* floating-point exponentiation (raise to power) */
1.807 +
1.808 +#define fp_exp _glp_mpl_fp_exp
1.809 +double fp_exp(MPL *mpl, double x);
1.810 +/* floating-point base-e exponential */
1.811 +
1.812 +#define fp_log _glp_mpl_fp_log
1.813 +double fp_log(MPL *mpl, double x);
1.814 +/* floating-point natural logarithm */
1.815 +
1.816 +#define fp_log10 _glp_mpl_fp_log10
1.817 +double fp_log10(MPL *mpl, double x);
1.818 +/* floating-point common (decimal) logarithm */
1.819 +
1.820 +#define fp_sqrt _glp_mpl_fp_sqrt
1.821 +double fp_sqrt(MPL *mpl, double x);
1.822 +/* floating-point square root */
1.823 +
1.824 +#define fp_sin _glp_mpl_fp_sin
1.825 +double fp_sin(MPL *mpl, double x);
1.826 +/* floating-point trigonometric sine */
1.827 +
1.828 +#define fp_cos _glp_mpl_fp_cos
1.829 +double fp_cos(MPL *mpl, double x);
1.830 +/* floating-point trigonometric cosine */
1.831 +
1.832 +#define fp_atan _glp_mpl_fp_atan
1.833 +double fp_atan(MPL *mpl, double x);
1.834 +/* floating-point trigonometric arctangent */
1.835 +
1.836 +#define fp_atan2 _glp_mpl_fp_atan2
1.837 +double fp_atan2(MPL *mpl, double y, double x);
1.838 +/* floating-point trigonometric arctangent */
1.839 +
1.840 +#define fp_round _glp_mpl_fp_round
1.841 +double fp_round(MPL *mpl, double x, double n);
1.842 +/* round floating-point value to n fractional digits */
1.843 +
1.844 +#define fp_trunc _glp_mpl_fp_trunc
1.845 +double fp_trunc(MPL *mpl, double x, double n);
1.846 +/* truncate floating-point value to n fractional digits */
1.847 +
1.848 +/**********************************************************************/
1.849 +/* * * PSEUDO-RANDOM NUMBER GENERATORS * * */
1.850 +/**********************************************************************/
1.851 +
1.852 +#define fp_irand224 _glp_mpl_fp_irand224
1.853 +double fp_irand224(MPL *mpl);
1.854 +/* pseudo-random integer in the range [0, 2^24) */
1.855 +
1.856 +#define fp_uniform01 _glp_mpl_fp_uniform01
1.857 +double fp_uniform01(MPL *mpl);
1.858 +/* pseudo-random number in the range [0, 1) */
1.859 +
1.860 +#define fp_uniform _glp_mpl_uniform
1.861 +double fp_uniform(MPL *mpl, double a, double b);
1.862 +/* pseudo-random number in the range [a, b) */
1.863 +
1.864 +#define fp_normal01 _glp_mpl_fp_normal01
1.865 +double fp_normal01(MPL *mpl);
1.866 +/* Gaussian random variate with mu = 0 and sigma = 1 */
1.867 +
1.868 +#define fp_normal _glp_mpl_fp_normal
1.869 +double fp_normal(MPL *mpl, double mu, double sigma);
1.870 +/* Gaussian random variate with specified mu and sigma */
1.871 +
1.872 +/**********************************************************************/
1.873 +/* * * DATE/TIME * * */
1.874 +/**********************************************************************/
1.875 +
1.876 +#define fn_gmtime _glp_mpl_fn_gmtime
1.877 +double fn_gmtime(MPL *mpl);
1.878 +/* obtain the current calendar time (UTC) */
1.879 +
1.880 +#define fn_str2time _glp_mpl_fn_str2time
1.881 +double fn_str2time(MPL *mpl, const char *str, const char *fmt);
1.882 +/* convert character string to the calendar time */
1.883 +
1.884 +#define fn_time2str _glp_mpl_fn_time2str
1.885 +void fn_time2str(MPL *mpl, char *str, double t, const char *fmt);
1.886 +/* convert the calendar time to character string */
1.887 +
1.888 +/**********************************************************************/
1.889 +/* * * CHARACTER STRINGS * * */
1.890 +/**********************************************************************/
1.891 +
1.892 +#define create_string _glp_mpl_create_string
1.893 +STRING *create_string
1.894 +( MPL *mpl,
1.895 + char buf[MAX_LENGTH+1] /* not changed */
1.896 +);
1.897 +/* create character string */
1.898 +
1.899 +#define copy_string _glp_mpl_copy_string
1.900 +STRING *copy_string
1.901 +( MPL *mpl,
1.902 + STRING *str /* not changed */
1.903 +);
1.904 +/* make copy of character string */
1.905 +
1.906 +#define compare_strings _glp_mpl_compare_strings
1.907 +int compare_strings
1.908 +( MPL *mpl,
1.909 + STRING *str1, /* not changed */
1.910 + STRING *str2 /* not changed */
1.911 +);
1.912 +/* compare one character string with another */
1.913 +
1.914 +#define fetch_string _glp_mpl_fetch_string
1.915 +char *fetch_string
1.916 +( MPL *mpl,
1.917 + STRING *str, /* not changed */
1.918 + char buf[MAX_LENGTH+1] /* modified */
1.919 +);
1.920 +/* extract content of character string */
1.921 +
1.922 +#define delete_string _glp_mpl_delete_string
1.923 +void delete_string
1.924 +( MPL *mpl,
1.925 + STRING *str /* destroyed */
1.926 +);
1.927 +/* delete character string */
1.928 +
1.929 +/**********************************************************************/
1.930 +/* * * SYMBOLS * * */
1.931 +/**********************************************************************/
1.932 +
1.933 +struct SYMBOL
1.934 +{ /* symbol (numeric or abstract quantity) */
1.935 + double num;
1.936 + /* numeric value of symbol (used only if str == NULL) */
1.937 + STRING *str;
1.938 + /* abstract value of symbol (used only if str != NULL) */
1.939 +};
1.940 +
1.941 +#define create_symbol_num _glp_mpl_create_symbol_num
1.942 +SYMBOL *create_symbol_num(MPL *mpl, double num);
1.943 +/* create symbol of numeric type */
1.944 +
1.945 +#define create_symbol_str _glp_mpl_create_symbol_str
1.946 +SYMBOL *create_symbol_str
1.947 +( MPL *mpl,
1.948 + STRING *str /* destroyed */
1.949 +);
1.950 +/* create symbol of abstract type */
1.951 +
1.952 +#define copy_symbol _glp_mpl_copy_symbol
1.953 +SYMBOL *copy_symbol
1.954 +( MPL *mpl,
1.955 + SYMBOL *sym /* not changed */
1.956 +);
1.957 +/* make copy of symbol */
1.958 +
1.959 +#define compare_symbols _glp_mpl_compare_symbols
1.960 +int compare_symbols
1.961 +( MPL *mpl,
1.962 + SYMBOL *sym1, /* not changed */
1.963 + SYMBOL *sym2 /* not changed */
1.964 +);
1.965 +/* compare one symbol with another */
1.966 +
1.967 +#define delete_symbol _glp_mpl_delete_symbol
1.968 +void delete_symbol
1.969 +( MPL *mpl,
1.970 + SYMBOL *sym /* destroyed */
1.971 +);
1.972 +/* delete symbol */
1.973 +
1.974 +#define format_symbol _glp_mpl_format_symbol
1.975 +char *format_symbol
1.976 +( MPL *mpl,
1.977 + SYMBOL *sym /* not changed */
1.978 +);
1.979 +/* format symbol for displaying or printing */
1.980 +
1.981 +#define concat_symbols _glp_mpl_concat_symbols
1.982 +SYMBOL *concat_symbols
1.983 +( MPL *mpl,
1.984 + SYMBOL *sym1, /* destroyed */
1.985 + SYMBOL *sym2 /* destroyed */
1.986 +);
1.987 +/* concatenate one symbol with another */
1.988 +
1.989 +/**********************************************************************/
1.990 +/* * * N-TUPLES * * */
1.991 +/**********************************************************************/
1.992 +
1.993 +struct TUPLE
1.994 +{ /* component of n-tuple; the n-tuple itself is associated with
1.995 + its first component; (note that 0-tuple has no components) */
1.996 + SYMBOL *sym;
1.997 + /* symbol, which the component refers to; cannot be NULL */
1.998 + TUPLE *next;
1.999 + /* the next component of n-tuple */
1.1000 +};
1.1001 +
1.1002 +#define create_tuple _glp_mpl_create_tuple
1.1003 +TUPLE *create_tuple(MPL *mpl);
1.1004 +/* create n-tuple */
1.1005 +
1.1006 +#define expand_tuple _glp_mpl_expand_tuple
1.1007 +TUPLE *expand_tuple
1.1008 +( MPL *mpl,
1.1009 + TUPLE *tuple, /* destroyed */
1.1010 + SYMBOL *sym /* destroyed */
1.1011 +);
1.1012 +/* append symbol to n-tuple */
1.1013 +
1.1014 +#define tuple_dimen _glp_mpl_tuple_dimen
1.1015 +int tuple_dimen
1.1016 +( MPL *mpl,
1.1017 + TUPLE *tuple /* not changed */
1.1018 +);
1.1019 +/* determine dimension of n-tuple */
1.1020 +
1.1021 +#define copy_tuple _glp_mpl_copy_tuple
1.1022 +TUPLE *copy_tuple
1.1023 +( MPL *mpl,
1.1024 + TUPLE *tuple /* not changed */
1.1025 +);
1.1026 +/* make copy of n-tuple */
1.1027 +
1.1028 +#define compare_tuples _glp_mpl_compare_tuples
1.1029 +int compare_tuples
1.1030 +( MPL *mpl,
1.1031 + TUPLE *tuple1, /* not changed */
1.1032 + TUPLE *tuple2 /* not changed */
1.1033 +);
1.1034 +/* compare one n-tuple with another */
1.1035 +
1.1036 +#define build_subtuple _glp_mpl_build_subtuple
1.1037 +TUPLE *build_subtuple
1.1038 +( MPL *mpl,
1.1039 + TUPLE *tuple, /* not changed */
1.1040 + int dim
1.1041 +);
1.1042 +/* build subtuple of given n-tuple */
1.1043 +
1.1044 +#define delete_tuple _glp_mpl_delete_tuple
1.1045 +void delete_tuple
1.1046 +( MPL *mpl,
1.1047 + TUPLE *tuple /* destroyed */
1.1048 +);
1.1049 +/* delete n-tuple */
1.1050 +
1.1051 +#define format_tuple _glp_mpl_format_tuple
1.1052 +char *format_tuple
1.1053 +( MPL *mpl,
1.1054 + int c,
1.1055 + TUPLE *tuple /* not changed */
1.1056 +);
1.1057 +/* format n-tuple for displaying or printing */
1.1058 +
1.1059 +/**********************************************************************/
1.1060 +/* * * ELEMENTAL SETS * * */
1.1061 +/**********************************************************************/
1.1062 +
1.1063 +#if 2 + 2 == 5
1.1064 +struct ELEMSET /* see ARRAY */
1.1065 +{ /* elemental set of n-tuples; formally it is a "value" assigned
1.1066 + to members of model sets (like numbers and symbols, which are
1.1067 + values assigned to members of model parameters); note that a
1.1068 + simple model set is not an elemental set, it is 0-dimensional
1.1069 + array, the only member of which (if it exists) is assigned an
1.1070 + elemental set */
1.1071 +#endif
1.1072 +
1.1073 +#define create_elemset _glp_mpl_create_elemset
1.1074 +ELEMSET *create_elemset(MPL *mpl, int dim);
1.1075 +/* create elemental set */
1.1076 +
1.1077 +#define find_tuple _glp_mpl_find_tuple
1.1078 +MEMBER *find_tuple
1.1079 +( MPL *mpl,
1.1080 + ELEMSET *set, /* not changed */
1.1081 + TUPLE *tuple /* not changed */
1.1082 +);
1.1083 +/* check if elemental set contains given n-tuple */
1.1084 +
1.1085 +#define add_tuple _glp_mpl_add_tuple
1.1086 +MEMBER *add_tuple
1.1087 +( MPL *mpl,
1.1088 + ELEMSET *set, /* modified */
1.1089 + TUPLE *tuple /* destroyed */
1.1090 +);
1.1091 +/* add new n-tuple to elemental set */
1.1092 +
1.1093 +#define check_then_add _glp_mpl_check_then_add
1.1094 +MEMBER *check_then_add
1.1095 +( MPL *mpl,
1.1096 + ELEMSET *set, /* modified */
1.1097 + TUPLE *tuple /* destroyed */
1.1098 +);
1.1099 +/* check and add new n-tuple to elemental set */
1.1100 +
1.1101 +#define copy_elemset _glp_mpl_copy_elemset
1.1102 +ELEMSET *copy_elemset
1.1103 +( MPL *mpl,
1.1104 + ELEMSET *set /* not changed */
1.1105 +);
1.1106 +/* make copy of elemental set */
1.1107 +
1.1108 +#define delete_elemset _glp_mpl_delete_elemset
1.1109 +void delete_elemset
1.1110 +( MPL *mpl,
1.1111 + ELEMSET *set /* destroyed */
1.1112 +);
1.1113 +/* delete elemental set */
1.1114 +
1.1115 +#define arelset_size _glp_mpl_arelset_size
1.1116 +int arelset_size(MPL *mpl, double t0, double tf, double dt);
1.1117 +/* compute size of "arithmetic" elemental set */
1.1118 +
1.1119 +#define arelset_member _glp_mpl_arelset_member
1.1120 +double arelset_member(MPL *mpl, double t0, double tf, double dt, int j);
1.1121 +/* compute member of "arithmetic" elemental set */
1.1122 +
1.1123 +#define create_arelset _glp_mpl_create_arelset
1.1124 +ELEMSET *create_arelset(MPL *mpl, double t0, double tf, double dt);
1.1125 +/* create "arithmetic" elemental set */
1.1126 +
1.1127 +#define set_union _glp_mpl_set_union
1.1128 +ELEMSET *set_union
1.1129 +( MPL *mpl,
1.1130 + ELEMSET *X, /* destroyed */
1.1131 + ELEMSET *Y /* destroyed */
1.1132 +);
1.1133 +/* union of two elemental sets */
1.1134 +
1.1135 +#define set_diff _glp_mpl_set_diff
1.1136 +ELEMSET *set_diff
1.1137 +( MPL *mpl,
1.1138 + ELEMSET *X, /* destroyed */
1.1139 + ELEMSET *Y /* destroyed */
1.1140 +);
1.1141 +/* difference between two elemental sets */
1.1142 +
1.1143 +#define set_symdiff _glp_mpl_set_symdiff
1.1144 +ELEMSET *set_symdiff
1.1145 +( MPL *mpl,
1.1146 + ELEMSET *X, /* destroyed */
1.1147 + ELEMSET *Y /* destroyed */
1.1148 +);
1.1149 +/* symmetric difference between two elemental sets */
1.1150 +
1.1151 +#define set_inter _glp_mpl_set_inter
1.1152 +ELEMSET *set_inter
1.1153 +( MPL *mpl,
1.1154 + ELEMSET *X, /* destroyed */
1.1155 + ELEMSET *Y /* destroyed */
1.1156 +);
1.1157 +/* intersection of two elemental sets */
1.1158 +
1.1159 +#define set_cross _glp_mpl_set_cross
1.1160 +ELEMSET *set_cross
1.1161 +( MPL *mpl,
1.1162 + ELEMSET *X, /* destroyed */
1.1163 + ELEMSET *Y /* destroyed */
1.1164 +);
1.1165 +/* cross (Cartesian) product of two elemental sets */
1.1166 +
1.1167 +/**********************************************************************/
1.1168 +/* * * ELEMENTAL VARIABLES * * */
1.1169 +/**********************************************************************/
1.1170 +
1.1171 +struct ELEMVAR
1.1172 +{ /* elemental variable; formally it is a "value" assigned to
1.1173 + members of model variables (like numbers and symbols, which
1.1174 + are values assigned to members of model parameters) */
1.1175 + int j;
1.1176 + /* LP column number assigned to this elemental variable */
1.1177 + VARIABLE *var;
1.1178 + /* model variable, which contains this elemental variable */
1.1179 + MEMBER *memb;
1.1180 + /* array member, which is assigned this elemental variable */
1.1181 + double lbnd;
1.1182 + /* lower bound */
1.1183 + double ubnd;
1.1184 + /* upper bound */
1.1185 + double temp;
1.1186 + /* working quantity used in operations on linear forms; normally
1.1187 + it contains floating-point zero */
1.1188 +#if 1 /* 15/V-2010 */
1.1189 + int stat;
1.1190 + double prim, dual;
1.1191 + /* solution components provided by the solver */
1.1192 +#endif
1.1193 +};
1.1194 +
1.1195 +/**********************************************************************/
1.1196 +/* * * LINEAR FORMS * * */
1.1197 +/**********************************************************************/
1.1198 +
1.1199 +struct FORMULA
1.1200 +{ /* term of linear form c * x, where c is a coefficient, x is an
1.1201 + elemental variable; the linear form itself is the sum of terms
1.1202 + and is associated with its first term; (note that the linear
1.1203 + form may be empty that means the sum is equal to zero) */
1.1204 + double coef;
1.1205 + /* coefficient at elemental variable or constant term */
1.1206 + ELEMVAR *var;
1.1207 + /* reference to elemental variable; NULL means constant term */
1.1208 + FORMULA *next;
1.1209 + /* the next term of linear form */
1.1210 +};
1.1211 +
1.1212 +#define constant_term _glp_mpl_constant_term
1.1213 +FORMULA *constant_term(MPL *mpl, double coef);
1.1214 +/* create constant term */
1.1215 +
1.1216 +#define single_variable _glp_mpl_single_variable
1.1217 +FORMULA *single_variable
1.1218 +( MPL *mpl,
1.1219 + ELEMVAR *var /* referenced */
1.1220 +);
1.1221 +/* create single variable */
1.1222 +
1.1223 +#define copy_formula _glp_mpl_copy_formula
1.1224 +FORMULA *copy_formula
1.1225 +( MPL *mpl,
1.1226 + FORMULA *form /* not changed */
1.1227 +);
1.1228 +/* make copy of linear form */
1.1229 +
1.1230 +#define delete_formula _glp_mpl_delete_formula
1.1231 +void delete_formula
1.1232 +( MPL *mpl,
1.1233 + FORMULA *form /* destroyed */
1.1234 +);
1.1235 +/* delete linear form */
1.1236 +
1.1237 +#define linear_comb _glp_mpl_linear_comb
1.1238 +FORMULA *linear_comb
1.1239 +( MPL *mpl,
1.1240 + double a, FORMULA *fx, /* destroyed */
1.1241 + double b, FORMULA *fy /* destroyed */
1.1242 +);
1.1243 +/* linear combination of two linear forms */
1.1244 +
1.1245 +#define remove_constant _glp_mpl_remove_constant
1.1246 +FORMULA *remove_constant
1.1247 +( MPL *mpl,
1.1248 + FORMULA *form, /* destroyed */
1.1249 + double *coef /* modified */
1.1250 +);
1.1251 +/* remove constant term from linear form */
1.1252 +
1.1253 +#define reduce_terms _glp_mpl_reduce_terms
1.1254 +FORMULA *reduce_terms
1.1255 +( MPL *mpl,
1.1256 + FORMULA *form /* destroyed */
1.1257 +);
1.1258 +/* reduce identical terms in linear form */
1.1259 +
1.1260 +/**********************************************************************/
1.1261 +/* * * ELEMENTAL CONSTRAINTS * * */
1.1262 +/**********************************************************************/
1.1263 +
1.1264 +struct ELEMCON
1.1265 +{ /* elemental constraint; formally it is a "value" assigned to
1.1266 + members of model constraints (like numbers or symbols, which
1.1267 + are values assigned to members of model parameters) */
1.1268 + int i;
1.1269 + /* LP row number assigned to this elemental constraint */
1.1270 + CONSTRAINT *con;
1.1271 + /* model constraint, which contains this elemental constraint */
1.1272 + MEMBER *memb;
1.1273 + /* array member, which is assigned this elemental constraint */
1.1274 + FORMULA *form;
1.1275 + /* linear form */
1.1276 + double lbnd;
1.1277 + /* lower bound */
1.1278 + double ubnd;
1.1279 + /* upper bound */
1.1280 +#if 1 /* 15/V-2010 */
1.1281 + int stat;
1.1282 + double prim, dual;
1.1283 + /* solution components provided by the solver */
1.1284 +#endif
1.1285 +};
1.1286 +
1.1287 +/**********************************************************************/
1.1288 +/* * * GENERIC VALUES * * */
1.1289 +/**********************************************************************/
1.1290 +
1.1291 +union VALUE
1.1292 +{ /* generic value, which can be assigned to object member or be a
1.1293 + result of evaluation of expression */
1.1294 + /* indicator that specifies the particular type of generic value
1.1295 + is stored in the corresponding array or pseudo-code descriptor
1.1296 + and can be one of the following:
1.1297 + A_NONE - no value
1.1298 + A_NUMERIC - floating-point number
1.1299 + A_SYMBOLIC - symbol
1.1300 + A_LOGICAL - logical value
1.1301 + A_TUPLE - n-tuple
1.1302 + A_ELEMSET - elemental set
1.1303 + A_ELEMVAR - elemental variable
1.1304 + A_FORMULA - linear form
1.1305 + A_ELEMCON - elemental constraint */
1.1306 + void *none; /* null */
1.1307 + double num; /* value */
1.1308 + SYMBOL *sym; /* value */
1.1309 + int bit; /* value */
1.1310 + TUPLE *tuple; /* value */
1.1311 + ELEMSET *set; /* value */
1.1312 + ELEMVAR *var; /* reference */
1.1313 + FORMULA *form; /* value */
1.1314 + ELEMCON *con; /* reference */
1.1315 +};
1.1316 +
1.1317 +#define delete_value _glp_mpl_delete_value
1.1318 +void delete_value
1.1319 +( MPL *mpl,
1.1320 + int type,
1.1321 + VALUE *value /* content destroyed */
1.1322 +);
1.1323 +/* delete generic value */
1.1324 +
1.1325 +/**********************************************************************/
1.1326 +/* * * SYMBOLICALLY INDEXED ARRAYS * * */
1.1327 +/**********************************************************************/
1.1328 +
1.1329 +struct ARRAY
1.1330 +{ /* multi-dimensional array, a set of members indexed over simple
1.1331 + or compound sets of symbols; arrays are used to represent the
1.1332 + contents of model objects (i.e. sets, parameters, variables,
1.1333 + constraints, and objectives); arrays also are used as "values"
1.1334 + that are assigned to members of set objects, in which case the
1.1335 + array itself represents an elemental set */
1.1336 + int type;
1.1337 + /* type of generic values assigned to the array members:
1.1338 + A_NONE - none (members have no assigned values)
1.1339 + A_NUMERIC - floating-point numbers
1.1340 + A_SYMBOLIC - symbols
1.1341 + A_ELEMSET - elemental sets
1.1342 + A_ELEMVAR - elemental variables
1.1343 + A_ELEMCON - elemental constraints */
1.1344 + int dim;
1.1345 + /* dimension of the array that determines number of components in
1.1346 + n-tuples for all members of the array, dim >= 0; dim = 0 means
1.1347 + the array is 0-dimensional */
1.1348 + int size;
1.1349 + /* size of the array, i.e. number of its members */
1.1350 + MEMBER *head;
1.1351 + /* the first array member; NULL means the array is empty */
1.1352 + MEMBER *tail;
1.1353 + /* the last array member; NULL means the array is empty */
1.1354 + AVL *tree;
1.1355 + /* the search tree intended to find array members for logarithmic
1.1356 + time; NULL means the search tree doesn't exist */
1.1357 + ARRAY *prev;
1.1358 + /* the previous array in the translator database */
1.1359 + ARRAY *next;
1.1360 + /* the next array in the translator database */
1.1361 +};
1.1362 +
1.1363 +struct MEMBER
1.1364 +{ /* array member */
1.1365 + TUPLE *tuple;
1.1366 + /* n-tuple, which identifies the member; number of its components
1.1367 + is the same for all members within the array and determined by
1.1368 + the array dimension; duplicate members are not allowed */
1.1369 + MEMBER *next;
1.1370 + /* the next array member */
1.1371 + VALUE value;
1.1372 + /* generic value assigned to the member */
1.1373 +};
1.1374 +
1.1375 +#define create_array _glp_mpl_create_array
1.1376 +ARRAY *create_array(MPL *mpl, int type, int dim);
1.1377 +/* create array */
1.1378 +
1.1379 +#define find_member _glp_mpl_find_member
1.1380 +MEMBER *find_member
1.1381 +( MPL *mpl,
1.1382 + ARRAY *array, /* not changed */
1.1383 + TUPLE *tuple /* not changed */
1.1384 +);
1.1385 +/* find array member with given n-tuple */
1.1386 +
1.1387 +#define add_member _glp_mpl_add_member
1.1388 +MEMBER *add_member
1.1389 +( MPL *mpl,
1.1390 + ARRAY *array, /* modified */
1.1391 + TUPLE *tuple /* destroyed */
1.1392 +);
1.1393 +/* add new member to array */
1.1394 +
1.1395 +#define delete_array _glp_mpl_delete_array
1.1396 +void delete_array
1.1397 +( MPL *mpl,
1.1398 + ARRAY *array /* destroyed */
1.1399 +);
1.1400 +/* delete array */
1.1401 +
1.1402 +/**********************************************************************/
1.1403 +/* * * DOMAINS AND DUMMY INDICES * * */
1.1404 +/**********************************************************************/
1.1405 +
1.1406 +struct DOMAIN
1.1407 +{ /* domain (a simple or compound set); syntactically domain looks
1.1408 + like '{ i in I, (j,k) in S, t in T : <predicate> }'; domains
1.1409 + are used to define sets, over which model objects are indexed,
1.1410 + and also as constituents of iterated operators */
1.1411 + DOMAIN_BLOCK *list;
1.1412 + /* linked list of domain blocks (in the example above such blocks
1.1413 + are 'i in I', '(j,k) in S', and 't in T'); this list cannot be
1.1414 + empty */
1.1415 + CODE *code;
1.1416 + /* pseudo-code for computing the logical predicate, which follows
1.1417 + the colon; NULL means no predicate is specified */
1.1418 +};
1.1419 +
1.1420 +struct DOMAIN_BLOCK
1.1421 +{ /* domain block; syntactically domain blocks look like 'i in I',
1.1422 + '(j,k) in S', and 't in T' in the example above (in the sequel
1.1423 + sets like I, S, and T are called basic sets) */
1.1424 + DOMAIN_SLOT *list;
1.1425 + /* linked list of domain slots (i.e. indexing positions); number
1.1426 + of slots in this list is the same as dimension of n-tuples in
1.1427 + the basic set; this list cannot be empty */
1.1428 + CODE *code;
1.1429 + /* pseudo-code for computing basic set; cannot be NULL */
1.1430 + TUPLE *backup;
1.1431 + /* if this n-tuple is not empty, current values of dummy indices
1.1432 + in the domain block are the same as components of this n-tuple
1.1433 + (note that this n-tuple may have larger dimension than number
1.1434 + of dummy indices in this block, in which case extra components
1.1435 + are ignored); this n-tuple is used to restore former values of
1.1436 + dummy indices, if they were changed due to recursive calls to
1.1437 + the domain block */
1.1438 + DOMAIN_BLOCK *next;
1.1439 + /* the next block in the same domain */
1.1440 +};
1.1441 +
1.1442 +struct DOMAIN_SLOT
1.1443 +{ /* domain slot; it specifies an individual indexing position and
1.1444 + defines the corresponding dummy index */
1.1445 + char *name;
1.1446 + /* symbolic name of the dummy index; null pointer means the dummy
1.1447 + index is not explicitly specified */
1.1448 + CODE *code;
1.1449 + /* pseudo-code for computing symbolic value, at which the dummy
1.1450 + index is bound; NULL means the dummy index is free within the
1.1451 + domain scope */
1.1452 + SYMBOL *value;
1.1453 + /* current value assigned to the dummy index; NULL means no value
1.1454 + is assigned at the moment */
1.1455 + CODE *list;
1.1456 + /* linked list of pseudo-codes with operation O_INDEX referring
1.1457 + to this slot; this linked list is used to invalidate resultant
1.1458 + values of the operation, which depend on this dummy index */
1.1459 + DOMAIN_SLOT *next;
1.1460 + /* the next slot in the same domain block */
1.1461 +};
1.1462 +
1.1463 +#define assign_dummy_index _glp_mpl_assign_dummy_index
1.1464 +void assign_dummy_index
1.1465 +( MPL *mpl,
1.1466 + DOMAIN_SLOT *slot, /* modified */
1.1467 + SYMBOL *value /* not changed */
1.1468 +);
1.1469 +/* assign new value to dummy index */
1.1470 +
1.1471 +#define update_dummy_indices _glp_mpl_update_dummy_indices
1.1472 +void update_dummy_indices
1.1473 +( MPL *mpl,
1.1474 + DOMAIN_BLOCK *block /* not changed */
1.1475 +);
1.1476 +/* update current values of dummy indices */
1.1477 +
1.1478 +#define enter_domain_block _glp_mpl_enter_domain_block
1.1479 +int enter_domain_block
1.1480 +( MPL *mpl,
1.1481 + DOMAIN_BLOCK *block, /* not changed */
1.1482 + TUPLE *tuple, /* not changed */
1.1483 + void *info, void (*func)(MPL *mpl, void *info)
1.1484 +);
1.1485 +/* enter domain block */
1.1486 +
1.1487 +#define eval_within_domain _glp_mpl_eval_within_domain
1.1488 +int eval_within_domain
1.1489 +( MPL *mpl,
1.1490 + DOMAIN *domain, /* not changed */
1.1491 + TUPLE *tuple, /* not changed */
1.1492 + void *info, void (*func)(MPL *mpl, void *info)
1.1493 +);
1.1494 +/* perform evaluation within domain scope */
1.1495 +
1.1496 +#define loop_within_domain _glp_mpl_loop_within_domain
1.1497 +void loop_within_domain
1.1498 +( MPL *mpl,
1.1499 + DOMAIN *domain, /* not changed */
1.1500 + void *info, int (*func)(MPL *mpl, void *info)
1.1501 +);
1.1502 +/* perform iterations within domain scope */
1.1503 +
1.1504 +#define out_of_domain _glp_mpl_out_of_domain
1.1505 +void out_of_domain
1.1506 +( MPL *mpl,
1.1507 + char *name, /* not changed */
1.1508 + TUPLE *tuple /* not changed */
1.1509 +);
1.1510 +/* raise domain exception */
1.1511 +
1.1512 +#define get_domain_tuple _glp_mpl_get_domain_tuple
1.1513 +TUPLE *get_domain_tuple
1.1514 +( MPL *mpl,
1.1515 + DOMAIN *domain /* not changed */
1.1516 +);
1.1517 +/* obtain current n-tuple from domain */
1.1518 +
1.1519 +#define clean_domain _glp_mpl_clean_domain
1.1520 +void clean_domain(MPL *mpl, DOMAIN *domain);
1.1521 +/* clean domain */
1.1522 +
1.1523 +/**********************************************************************/
1.1524 +/* * * MODEL SETS * * */
1.1525 +/**********************************************************************/
1.1526 +
1.1527 +struct SET
1.1528 +{ /* model set */
1.1529 + char *name;
1.1530 + /* symbolic name; cannot be NULL */
1.1531 + char *alias;
1.1532 + /* alias; NULL means alias is not specified */
1.1533 + int dim; /* aka arity */
1.1534 + /* dimension (number of subscripts); dim = 0 means 0-dimensional
1.1535 + (unsubscripted) set, dim > 0 means set of sets */
1.1536 + DOMAIN *domain;
1.1537 + /* subscript domain; NULL for 0-dimensional set */
1.1538 + int dimen;
1.1539 + /* dimension of n-tuples, which members of this set consist of
1.1540 + (note that the model set itself is an array of elemental sets,
1.1541 + which are its members; so, don't confuse this dimension with
1.1542 + dimension of the model set); always non-zero */
1.1543 + WITHIN *within;
1.1544 + /* list of supersets, which restrict each member of the set to be
1.1545 + in every superset from this list; this list can be empty */
1.1546 + CODE *assign;
1.1547 + /* pseudo-code for computing assigned value; can be NULL */
1.1548 + CODE *option;
1.1549 + /* pseudo-code for computing default value; can be NULL */
1.1550 + GADGET *gadget;
1.1551 + /* plain set used to initialize the array of sets; can be NULL */
1.1552 + int data;
1.1553 + /* data status flag:
1.1554 + 0 - no data are provided in the data section
1.1555 + 1 - data are provided, but not checked yet
1.1556 + 2 - data are provided and have been checked */
1.1557 + ARRAY *array;
1.1558 + /* array of members, which are assigned elemental sets */
1.1559 +};
1.1560 +
1.1561 +struct WITHIN
1.1562 +{ /* restricting superset list entry */
1.1563 + CODE *code;
1.1564 + /* pseudo-code for computing the superset; cannot be NULL */
1.1565 + WITHIN *next;
1.1566 + /* the next entry for the same set or parameter */
1.1567 +};
1.1568 +
1.1569 +struct GADGET
1.1570 +{ /* plain set used to initialize the array of sets with data */
1.1571 + SET *set;
1.1572 + /* pointer to plain set; cannot be NULL */
1.1573 + int ind[20]; /* ind[dim+dimen]; */
1.1574 + /* permutation of integers 1, 2, ..., dim+dimen */
1.1575 +};
1.1576 +
1.1577 +#define check_elem_set _glp_mpl_check_elem_set
1.1578 +void check_elem_set
1.1579 +( MPL *mpl,
1.1580 + SET *set, /* not changed */
1.1581 + TUPLE *tuple, /* not changed */
1.1582 + ELEMSET *refer /* not changed */
1.1583 +);
1.1584 +/* check elemental set assigned to set member */
1.1585 +
1.1586 +#define take_member_set _glp_mpl_take_member_set
1.1587 +ELEMSET *take_member_set /* returns reference, not value */
1.1588 +( MPL *mpl,
1.1589 + SET *set, /* not changed */
1.1590 + TUPLE *tuple /* not changed */
1.1591 +);
1.1592 +/* obtain elemental set assigned to set member */
1.1593 +
1.1594 +#define eval_member_set _glp_mpl_eval_member_set
1.1595 +ELEMSET *eval_member_set /* returns reference, not value */
1.1596 +( MPL *mpl,
1.1597 + SET *set, /* not changed */
1.1598 + TUPLE *tuple /* not changed */
1.1599 +);
1.1600 +/* evaluate elemental set assigned to set member */
1.1601 +
1.1602 +#define eval_whole_set _glp_mpl_eval_whole_set
1.1603 +void eval_whole_set(MPL *mpl, SET *set);
1.1604 +/* evaluate model set over entire domain */
1.1605 +
1.1606 +#define clean_set _glp_mpl_clean_set
1.1607 +void clean_set(MPL *mpl, SET *set);
1.1608 +/* clean model set */
1.1609 +
1.1610 +/**********************************************************************/
1.1611 +/* * * MODEL PARAMETERS * * */
1.1612 +/**********************************************************************/
1.1613 +
1.1614 +struct PARAMETER
1.1615 +{ /* model parameter */
1.1616 + char *name;
1.1617 + /* symbolic name; cannot be NULL */
1.1618 + char *alias;
1.1619 + /* alias; NULL means alias is not specified */
1.1620 + int dim; /* aka arity */
1.1621 + /* dimension (number of subscripts); dim = 0 means 0-dimensional
1.1622 + (unsubscripted) parameter */
1.1623 + DOMAIN *domain;
1.1624 + /* subscript domain; NULL for 0-dimensional parameter */
1.1625 + int type;
1.1626 + /* parameter type:
1.1627 + A_NUMERIC - numeric
1.1628 + A_INTEGER - integer
1.1629 + A_BINARY - binary
1.1630 + A_SYMBOLIC - symbolic */
1.1631 + CONDITION *cond;
1.1632 + /* list of conditions, which restrict each parameter member to
1.1633 + satisfy to every condition from this list; this list is used
1.1634 + only for numeric parameters and can be empty */
1.1635 + WITHIN *in;
1.1636 + /* list of supersets, which restrict each parameter member to be
1.1637 + in every superset from this list; this list is used only for
1.1638 + symbolic parameters and can be empty */
1.1639 + CODE *assign;
1.1640 + /* pseudo-code for computing assigned value; can be NULL */
1.1641 + CODE *option;
1.1642 + /* pseudo-code for computing default value; can be NULL */
1.1643 + int data;
1.1644 + /* data status flag:
1.1645 + 0 - no data are provided in the data section
1.1646 + 1 - data are provided, but not checked yet
1.1647 + 2 - data are provided and have been checked */
1.1648 + SYMBOL *defval;
1.1649 + /* default value provided in the data section; can be NULL */
1.1650 + ARRAY *array;
1.1651 + /* array of members, which are assigned numbers or symbols */
1.1652 +};
1.1653 +
1.1654 +struct CONDITION
1.1655 +{ /* restricting condition list entry */
1.1656 + int rho;
1.1657 + /* flag that specifies the form of the condition:
1.1658 + O_LT - less than
1.1659 + O_LE - less than or equal to
1.1660 + O_EQ - equal to
1.1661 + O_GE - greater than or equal to
1.1662 + O_GT - greater than
1.1663 + O_NE - not equal to */
1.1664 + CODE *code;
1.1665 + /* pseudo-code for computing the reference value */
1.1666 + CONDITION *next;
1.1667 + /* the next entry for the same parameter */
1.1668 +};
1.1669 +
1.1670 +#define check_value_num _glp_mpl_check_value_num
1.1671 +void check_value_num
1.1672 +( MPL *mpl,
1.1673 + PARAMETER *par, /* not changed */
1.1674 + TUPLE *tuple, /* not changed */
1.1675 + double value
1.1676 +);
1.1677 +/* check numeric value assigned to parameter member */
1.1678 +
1.1679 +#define take_member_num _glp_mpl_take_member_num
1.1680 +double take_member_num
1.1681 +( MPL *mpl,
1.1682 + PARAMETER *par, /* not changed */
1.1683 + TUPLE *tuple /* not changed */
1.1684 +);
1.1685 +/* obtain numeric value assigned to parameter member */
1.1686 +
1.1687 +#define eval_member_num _glp_mpl_eval_member_num
1.1688 +double eval_member_num
1.1689 +( MPL *mpl,
1.1690 + PARAMETER *par, /* not changed */
1.1691 + TUPLE *tuple /* not changed */
1.1692 +);
1.1693 +/* evaluate numeric value assigned to parameter member */
1.1694 +
1.1695 +#define check_value_sym _glp_mpl_check_value_sym
1.1696 +void check_value_sym
1.1697 +( MPL *mpl,
1.1698 + PARAMETER *par, /* not changed */
1.1699 + TUPLE *tuple, /* not changed */
1.1700 + SYMBOL *value /* not changed */
1.1701 +);
1.1702 +/* check symbolic value assigned to parameter member */
1.1703 +
1.1704 +#define take_member_sym _glp_mpl_take_member_sym
1.1705 +SYMBOL *take_member_sym /* returns value, not reference */
1.1706 +( MPL *mpl,
1.1707 + PARAMETER *par, /* not changed */
1.1708 + TUPLE *tuple /* not changed */
1.1709 +);
1.1710 +/* obtain symbolic value assigned to parameter member */
1.1711 +
1.1712 +#define eval_member_sym _glp_mpl_eval_member_sym
1.1713 +SYMBOL *eval_member_sym /* returns value, not reference */
1.1714 +( MPL *mpl,
1.1715 + PARAMETER *par, /* not changed */
1.1716 + TUPLE *tuple /* not changed */
1.1717 +);
1.1718 +/* evaluate symbolic value assigned to parameter member */
1.1719 +
1.1720 +#define eval_whole_par _glp_mpl_eval_whole_par
1.1721 +void eval_whole_par(MPL *mpl, PARAMETER *par);
1.1722 +/* evaluate model parameter over entire domain */
1.1723 +
1.1724 +#define clean_parameter _glp_mpl_clean_parameter
1.1725 +void clean_parameter(MPL *mpl, PARAMETER *par);
1.1726 +/* clean model parameter */
1.1727 +
1.1728 +/**********************************************************************/
1.1729 +/* * * MODEL VARIABLES * * */
1.1730 +/**********************************************************************/
1.1731 +
1.1732 +struct VARIABLE
1.1733 +{ /* model variable */
1.1734 + char *name;
1.1735 + /* symbolic name; cannot be NULL */
1.1736 + char *alias;
1.1737 + /* alias; NULL means alias is not specified */
1.1738 + int dim; /* aka arity */
1.1739 + /* dimension (number of subscripts); dim = 0 means 0-dimensional
1.1740 + (unsubscripted) variable */
1.1741 + DOMAIN *domain;
1.1742 + /* subscript domain; NULL for 0-dimensional variable */
1.1743 + int type;
1.1744 + /* variable type:
1.1745 + A_NUMERIC - continuous
1.1746 + A_INTEGER - integer
1.1747 + A_BINARY - binary */
1.1748 + CODE *lbnd;
1.1749 + /* pseudo-code for computing lower bound; NULL means lower bound
1.1750 + is not specified */
1.1751 + CODE *ubnd;
1.1752 + /* pseudo-code for computing upper bound; NULL means upper bound
1.1753 + is not specified */
1.1754 + /* if both the pointers lbnd and ubnd refer to the same code, the
1.1755 + variable is fixed at the corresponding value */
1.1756 + ARRAY *array;
1.1757 + /* array of members, which are assigned elemental variables */
1.1758 +};
1.1759 +
1.1760 +#define take_member_var _glp_mpl_take_member_var
1.1761 +ELEMVAR *take_member_var /* returns reference */
1.1762 +( MPL *mpl,
1.1763 + VARIABLE *var, /* not changed */
1.1764 + TUPLE *tuple /* not changed */
1.1765 +);
1.1766 +/* obtain reference to elemental variable */
1.1767 +
1.1768 +#define eval_member_var _glp_mpl_eval_member_var
1.1769 +ELEMVAR *eval_member_var /* returns reference */
1.1770 +( MPL *mpl,
1.1771 + VARIABLE *var, /* not changed */
1.1772 + TUPLE *tuple /* not changed */
1.1773 +);
1.1774 +/* evaluate reference to elemental variable */
1.1775 +
1.1776 +#define eval_whole_var _glp_mpl_eval_whole_var
1.1777 +void eval_whole_var(MPL *mpl, VARIABLE *var);
1.1778 +/* evaluate model variable over entire domain */
1.1779 +
1.1780 +#define clean_variable _glp_mpl_clean_variable
1.1781 +void clean_variable(MPL *mpl, VARIABLE *var);
1.1782 +/* clean model variable */
1.1783 +
1.1784 +/**********************************************************************/
1.1785 +/* * * MODEL CONSTRAINTS AND OBJECTIVES * * */
1.1786 +/**********************************************************************/
1.1787 +
1.1788 +struct CONSTRAINT
1.1789 +{ /* model constraint or objective */
1.1790 + char *name;
1.1791 + /* symbolic name; cannot be NULL */
1.1792 + char *alias;
1.1793 + /* alias; NULL means alias is not specified */
1.1794 + int dim; /* aka arity */
1.1795 + /* dimension (number of subscripts); dim = 0 means 0-dimensional
1.1796 + (unsubscripted) constraint */
1.1797 + DOMAIN *domain;
1.1798 + /* subscript domain; NULL for 0-dimensional constraint */
1.1799 + int type;
1.1800 + /* constraint type:
1.1801 + A_CONSTRAINT - constraint
1.1802 + A_MINIMIZE - objective (minimization)
1.1803 + A_MAXIMIZE - objective (maximization) */
1.1804 + CODE *code;
1.1805 + /* pseudo-code for computing main linear form; cannot be NULL */
1.1806 + CODE *lbnd;
1.1807 + /* pseudo-code for computing lower bound; NULL means lower bound
1.1808 + is not specified */
1.1809 + CODE *ubnd;
1.1810 + /* pseudo-code for computing upper bound; NULL means upper bound
1.1811 + is not specified */
1.1812 + /* if both the pointers lbnd and ubnd refer to the same code, the
1.1813 + constraint has the form of equation */
1.1814 + ARRAY *array;
1.1815 + /* array of members, which are assigned elemental constraints */
1.1816 +};
1.1817 +
1.1818 +#define take_member_con _glp_mpl_take_member_con
1.1819 +ELEMCON *take_member_con /* returns reference */
1.1820 +( MPL *mpl,
1.1821 + CONSTRAINT *con, /* not changed */
1.1822 + TUPLE *tuple /* not changed */
1.1823 +);
1.1824 +/* obtain reference to elemental constraint */
1.1825 +
1.1826 +#define eval_member_con _glp_mpl_eval_member_con
1.1827 +ELEMCON *eval_member_con /* returns reference */
1.1828 +( MPL *mpl,
1.1829 + CONSTRAINT *con, /* not changed */
1.1830 + TUPLE *tuple /* not changed */
1.1831 +);
1.1832 +/* evaluate reference to elemental constraint */
1.1833 +
1.1834 +#define eval_whole_con _glp_mpl_eval_whole_con
1.1835 +void eval_whole_con(MPL *mpl, CONSTRAINT *con);
1.1836 +/* evaluate model constraint over entire domain */
1.1837 +
1.1838 +#define clean_constraint _glp_mpl_clean_constraint
1.1839 +void clean_constraint(MPL *mpl, CONSTRAINT *con);
1.1840 +/* clean model constraint */
1.1841 +
1.1842 +/**********************************************************************/
1.1843 +/* * * DATA TABLES * * */
1.1844 +/**********************************************************************/
1.1845 +
1.1846 +struct TABLE
1.1847 +{ /* data table */
1.1848 + char *name;
1.1849 + /* symbolic name; cannot be NULL */
1.1850 + char *alias;
1.1851 + /* alias; NULL means alias is not specified */
1.1852 + int type;
1.1853 + /* table type:
1.1854 + A_INPUT - input table
1.1855 + A_OUTPUT - output table */
1.1856 + TABARG *arg;
1.1857 + /* argument list; cannot be empty */
1.1858 + union
1.1859 + { struct
1.1860 + { SET *set;
1.1861 + /* input set; NULL means the set is not specified */
1.1862 + TABFLD *fld;
1.1863 + /* field list; cannot be empty */
1.1864 + TABIN *list;
1.1865 + /* input list; can be empty */
1.1866 + } in;
1.1867 + struct
1.1868 + { DOMAIN *domain;
1.1869 + /* subscript domain; cannot be NULL */
1.1870 + TABOUT *list;
1.1871 + /* output list; cannot be empty */
1.1872 + } out;
1.1873 + } u;
1.1874 +};
1.1875 +
1.1876 +struct TABARG
1.1877 +{ /* table argument list entry */
1.1878 + CODE *code;
1.1879 + /* pseudo-code for computing the argument */
1.1880 + TABARG *next;
1.1881 + /* next entry for the same table */
1.1882 +};
1.1883 +
1.1884 +struct TABFLD
1.1885 +{ /* table field list entry */
1.1886 + char *name;
1.1887 + /* field name; cannot be NULL */
1.1888 + TABFLD *next;
1.1889 + /* next entry for the same table */
1.1890 +};
1.1891 +
1.1892 +struct TABIN
1.1893 +{ /* table input list entry */
1.1894 + PARAMETER *par;
1.1895 + /* parameter to be read; cannot be NULL */
1.1896 + char *name;
1.1897 + /* column name; cannot be NULL */
1.1898 + TABIN *next;
1.1899 + /* next entry for the same table */
1.1900 +};
1.1901 +
1.1902 +struct TABOUT
1.1903 +{ /* table output list entry */
1.1904 + CODE *code;
1.1905 + /* pseudo-code for computing the value to be written */
1.1906 + char *name;
1.1907 + /* column name; cannot be NULL */
1.1908 + TABOUT *next;
1.1909 + /* next entry for the same table */
1.1910 +};
1.1911 +
1.1912 +struct TABDCA
1.1913 +{ /* table driver communication area */
1.1914 + int id;
1.1915 + /* driver identifier (set by mpl_tab_drv_open) */
1.1916 + void *link;
1.1917 + /* driver link pointer (set by mpl_tab_drv_open) */
1.1918 + int na;
1.1919 + /* number of arguments */
1.1920 + char **arg; /* char *arg[1+ns]; */
1.1921 + /* arg[k], 1 <= k <= ns, is pointer to k-th argument */
1.1922 + int nf;
1.1923 + /* number of fields */
1.1924 + char **name; /* char *name[1+nc]; */
1.1925 + /* name[k], 1 <= k <= nc, is name of k-th field */
1.1926 + int *type; /* int type[1+nc]; */
1.1927 + /* type[k], 1 <= k <= nc, is type of k-th field:
1.1928 + '?' - value not assigned
1.1929 + 'N' - number
1.1930 + 'S' - character string */
1.1931 + double *num; /* double num[1+nc]; */
1.1932 + /* num[k], 1 <= k <= nc, is numeric value of k-th field */
1.1933 + char **str;
1.1934 + /* str[k], 1 <= k <= nc, is string value of k-th field */
1.1935 +};
1.1936 +
1.1937 +#define mpl_tab_num_args _glp_mpl_tab_num_args
1.1938 +int mpl_tab_num_args(TABDCA *dca);
1.1939 +
1.1940 +#define mpl_tab_get_arg _glp_mpl_tab_get_arg
1.1941 +const char *mpl_tab_get_arg(TABDCA *dca, int k);
1.1942 +
1.1943 +#define mpl_tab_num_flds _glp_mpl_tab_num_flds
1.1944 +int mpl_tab_num_flds(TABDCA *dca);
1.1945 +
1.1946 +#define mpl_tab_get_name _glp_mpl_tab_get_name
1.1947 +const char *mpl_tab_get_name(TABDCA *dca, int k);
1.1948 +
1.1949 +#define mpl_tab_get_type _glp_mpl_tab_get_type
1.1950 +int mpl_tab_get_type(TABDCA *dca, int k);
1.1951 +
1.1952 +#define mpl_tab_get_num _glp_mpl_tab_get_num
1.1953 +double mpl_tab_get_num(TABDCA *dca, int k);
1.1954 +
1.1955 +#define mpl_tab_get_str _glp_mpl_tab_get_str
1.1956 +const char *mpl_tab_get_str(TABDCA *dca, int k);
1.1957 +
1.1958 +#define mpl_tab_set_num _glp_mpl_tab_set_num
1.1959 +void mpl_tab_set_num(TABDCA *dca, int k, double num);
1.1960 +
1.1961 +#define mpl_tab_set_str _glp_mpl_tab_set_str
1.1962 +void mpl_tab_set_str(TABDCA *dca, int k, const char *str);
1.1963 +
1.1964 +#define mpl_tab_drv_open _glp_mpl_tab_drv_open
1.1965 +void mpl_tab_drv_open(MPL *mpl, int mode);
1.1966 +
1.1967 +#define mpl_tab_drv_read _glp_mpl_tab_drv_read
1.1968 +int mpl_tab_drv_read(MPL *mpl);
1.1969 +
1.1970 +#define mpl_tab_drv_write _glp_mpl_tab_drv_write
1.1971 +void mpl_tab_drv_write(MPL *mpl);
1.1972 +
1.1973 +#define mpl_tab_drv_close _glp_mpl_tab_drv_close
1.1974 +void mpl_tab_drv_close(MPL *mpl);
1.1975 +
1.1976 +/**********************************************************************/
1.1977 +/* * * PSEUDO-CODE * * */
1.1978 +/**********************************************************************/
1.1979 +
1.1980 +union OPERANDS
1.1981 +{ /* operands that participate in pseudo-code operation (choice of
1.1982 + particular operands depends on the operation code) */
1.1983 + /*--------------------------------------------------------------*/
1.1984 + double num; /* O_NUMBER */
1.1985 + /* floaing-point number to be taken */
1.1986 + /*--------------------------------------------------------------*/
1.1987 + char *str; /* O_STRING */
1.1988 + /* character string to be taken */
1.1989 + /*--------------------------------------------------------------*/
1.1990 + struct /* O_INDEX */
1.1991 + { DOMAIN_SLOT *slot;
1.1992 + /* domain slot, which contains dummy index to be taken */
1.1993 + CODE *next;
1.1994 + /* the next pseudo-code with op = O_INDEX, which refers to the
1.1995 + same slot as this one; pointer to the beginning of this list
1.1996 + is stored in the corresponding domain slot */
1.1997 + } index;
1.1998 + /*--------------------------------------------------------------*/
1.1999 + struct /* O_MEMNUM, O_MEMSYM */
1.2000 + { PARAMETER *par;
1.2001 + /* model parameter, which contains member to be taken */
1.2002 + ARG_LIST *list;
1.2003 + /* list of subscripts; NULL for 0-dimensional parameter */
1.2004 + } par;
1.2005 + /*--------------------------------------------------------------*/
1.2006 + struct /* O_MEMSET */
1.2007 + { SET *set;
1.2008 + /* model set, which contains member to be taken */
1.2009 + ARG_LIST *list;
1.2010 + /* list of subscripts; NULL for 0-dimensional set */
1.2011 + } set;
1.2012 + /*--------------------------------------------------------------*/
1.2013 + struct /* O_MEMVAR */
1.2014 + { VARIABLE *var;
1.2015 + /* model variable, which contains member to be taken */
1.2016 + ARG_LIST *list;
1.2017 + /* list of subscripts; NULL for 0-dimensional variable */
1.2018 +#if 1 /* 15/V-2010 */
1.2019 + int suff;
1.2020 + /* suffix specified: */
1.2021 +#define DOT_NONE 0x00 /* none (means variable itself) */
1.2022 +#define DOT_LB 0x01 /* .lb (lower bound) */
1.2023 +#define DOT_UB 0x02 /* .ub (upper bound) */
1.2024 +#define DOT_STATUS 0x03 /* .status (status) */
1.2025 +#define DOT_VAL 0x04 /* .val (primal value) */
1.2026 +#define DOT_DUAL 0x05 /* .dual (dual value) */
1.2027 +#endif
1.2028 + } var;
1.2029 +#if 1 /* 15/V-2010 */
1.2030 + /*--------------------------------------------------------------*/
1.2031 + struct /* O_MEMCON */
1.2032 + { CONSTRAINT *con;
1.2033 + /* model constraint, which contains member to be taken */
1.2034 + ARG_LIST *list;
1.2035 + /* list of subscripys; NULL for 0-dimensional constraint */
1.2036 + int suff;
1.2037 + /* suffix specified (see O_MEMVAR above) */
1.2038 + } con;
1.2039 +#endif
1.2040 + /*--------------------------------------------------------------*/
1.2041 + ARG_LIST *list; /* O_TUPLE, O_MAKE, n-ary operations */
1.2042 + /* list of operands */
1.2043 + /*--------------------------------------------------------------*/
1.2044 + DOMAIN_BLOCK *slice; /* O_SLICE */
1.2045 + /* domain block, which specifies slice (i.e. n-tuple that contains
1.2046 + free dummy indices); this operation is never evaluated */
1.2047 + /*--------------------------------------------------------------*/
1.2048 + struct /* unary, binary, ternary operations */
1.2049 + { CODE *x;
1.2050 + /* pseudo-code for computing first operand */
1.2051 + CODE *y;
1.2052 + /* pseudo-code for computing second operand */
1.2053 + CODE *z;
1.2054 + /* pseudo-code for computing third operand */
1.2055 + } arg;
1.2056 + /*--------------------------------------------------------------*/
1.2057 + struct /* iterated operations */
1.2058 + { DOMAIN *domain;
1.2059 + /* domain, over which the operation is performed */
1.2060 + CODE *x;
1.2061 + /* pseudo-code for computing "integrand" */
1.2062 + } loop;
1.2063 + /*--------------------------------------------------------------*/
1.2064 +};
1.2065 +
1.2066 +struct ARG_LIST
1.2067 +{ /* operands list entry */
1.2068 + CODE *x;
1.2069 + /* pseudo-code for computing operand */
1.2070 + ARG_LIST *next;
1.2071 + /* the next operand of the same operation */
1.2072 +};
1.2073 +
1.2074 +struct CODE
1.2075 +{ /* pseudo-code (internal form of expressions) */
1.2076 + int op;
1.2077 + /* operation code: */
1.2078 +#define O_NUMBER 301 /* take floating-point number */
1.2079 +#define O_STRING 302 /* take character string */
1.2080 +#define O_INDEX 303 /* take dummy index */
1.2081 +#define O_MEMNUM 304 /* take member of numeric parameter */
1.2082 +#define O_MEMSYM 305 /* take member of symbolic parameter */
1.2083 +#define O_MEMSET 306 /* take member of set */
1.2084 +#define O_MEMVAR 307 /* take member of variable */
1.2085 +#define O_MEMCON 308 /* take member of constraint */
1.2086 +#define O_TUPLE 309 /* make n-tuple */
1.2087 +#define O_MAKE 310 /* make elemental set of n-tuples */
1.2088 +#define O_SLICE 311 /* define domain block (dummy op) */
1.2089 + /* 0-ary operations --------------------*/
1.2090 +#define O_IRAND224 312 /* pseudo-random in [0, 2^24-1] */
1.2091 +#define O_UNIFORM01 313 /* pseudo-random in [0, 1) */
1.2092 +#define O_NORMAL01 314 /* gaussian random, mu = 0, sigma = 1 */
1.2093 +#define O_GMTIME 315 /* current calendar time (UTC) */
1.2094 + /* unary operations --------------------*/
1.2095 +#define O_CVTNUM 316 /* conversion to numeric */
1.2096 +#define O_CVTSYM 317 /* conversion to symbolic */
1.2097 +#define O_CVTLOG 318 /* conversion to logical */
1.2098 +#define O_CVTTUP 319 /* conversion to 1-tuple */
1.2099 +#define O_CVTLFM 320 /* conversion to linear form */
1.2100 +#define O_PLUS 321 /* unary plus */
1.2101 +#define O_MINUS 322 /* unary minus */
1.2102 +#define O_NOT 323 /* negation (logical "not") */
1.2103 +#define O_ABS 324 /* absolute value */
1.2104 +#define O_CEIL 325 /* round upward ("ceiling of x") */
1.2105 +#define O_FLOOR 326 /* round downward ("floor of x") */
1.2106 +#define O_EXP 327 /* base-e exponential */
1.2107 +#define O_LOG 328 /* natural logarithm */
1.2108 +#define O_LOG10 329 /* common (decimal) logarithm */
1.2109 +#define O_SQRT 330 /* square root */
1.2110 +#define O_SIN 331 /* trigonometric sine */
1.2111 +#define O_COS 332 /* trigonometric cosine */
1.2112 +#define O_ATAN 333 /* trigonometric arctangent */
1.2113 +#define O_ROUND 334 /* round to nearest integer */
1.2114 +#define O_TRUNC 335 /* truncate to nearest integer */
1.2115 +#define O_CARD 336 /* cardinality of set */
1.2116 +#define O_LENGTH 337 /* length of symbolic value */
1.2117 + /* binary operations -------------------*/
1.2118 +#define O_ADD 338 /* addition */
1.2119 +#define O_SUB 339 /* subtraction */
1.2120 +#define O_LESS 340 /* non-negative subtraction */
1.2121 +#define O_MUL 341 /* multiplication */
1.2122 +#define O_DIV 342 /* division */
1.2123 +#define O_IDIV 343 /* quotient of exact division */
1.2124 +#define O_MOD 344 /* remainder of exact division */
1.2125 +#define O_POWER 345 /* exponentiation (raise to power) */
1.2126 +#define O_ATAN2 346 /* trigonometric arctangent */
1.2127 +#define O_ROUND2 347 /* round to n fractional digits */
1.2128 +#define O_TRUNC2 348 /* truncate to n fractional digits */
1.2129 +#define O_UNIFORM 349 /* pseudo-random in [a, b) */
1.2130 +#define O_NORMAL 350 /* gaussian random, given mu and sigma */
1.2131 +#define O_CONCAT 351 /* concatenation */
1.2132 +#define O_LT 352 /* comparison on 'less than' */
1.2133 +#define O_LE 353 /* comparison on 'not greater than' */
1.2134 +#define O_EQ 354 /* comparison on 'equal to' */
1.2135 +#define O_GE 355 /* comparison on 'not less than' */
1.2136 +#define O_GT 356 /* comparison on 'greater than' */
1.2137 +#define O_NE 357 /* comparison on 'not equal to' */
1.2138 +#define O_AND 358 /* conjunction (logical "and") */
1.2139 +#define O_OR 359 /* disjunction (logical "or") */
1.2140 +#define O_UNION 360 /* union */
1.2141 +#define O_DIFF 361 /* difference */
1.2142 +#define O_SYMDIFF 362 /* symmetric difference */
1.2143 +#define O_INTER 363 /* intersection */
1.2144 +#define O_CROSS 364 /* cross (Cartesian) product */
1.2145 +#define O_IN 365 /* test on 'x in Y' */
1.2146 +#define O_NOTIN 366 /* test on 'x not in Y' */
1.2147 +#define O_WITHIN 367 /* test on 'X within Y' */
1.2148 +#define O_NOTWITHIN 368 /* test on 'X not within Y' */
1.2149 +#define O_SUBSTR 369 /* substring */
1.2150 +#define O_STR2TIME 370 /* convert string to time */
1.2151 +#define O_TIME2STR 371 /* convert time to string */
1.2152 + /* ternary operations ------------------*/
1.2153 +#define O_DOTS 372 /* build "arithmetic" set */
1.2154 +#define O_FORK 373 /* if-then-else */
1.2155 +#define O_SUBSTR3 374 /* substring */
1.2156 + /* n-ary operations --------------------*/
1.2157 +#define O_MIN 375 /* minimal value (n-ary) */
1.2158 +#define O_MAX 376 /* maximal value (n-ary) */
1.2159 + /* iterated operations -----------------*/
1.2160 +#define O_SUM 377 /* summation */
1.2161 +#define O_PROD 378 /* multiplication */
1.2162 +#define O_MINIMUM 379 /* minimum */
1.2163 +#define O_MAXIMUM 380 /* maximum */
1.2164 +#define O_FORALL 381 /* conjunction (A-quantification) */
1.2165 +#define O_EXISTS 382 /* disjunction (E-quantification) */
1.2166 +#define O_SETOF 383 /* compute elemental set */
1.2167 +#define O_BUILD 384 /* build elemental set */
1.2168 + OPERANDS arg;
1.2169 + /* operands that participate in the operation */
1.2170 + int type;
1.2171 + /* type of the resultant value:
1.2172 + A_NUMERIC - numeric
1.2173 + A_SYMBOLIC - symbolic
1.2174 + A_LOGICAL - logical
1.2175 + A_TUPLE - n-tuple
1.2176 + A_ELEMSET - elemental set
1.2177 + A_FORMULA - linear form */
1.2178 + int dim;
1.2179 + /* dimension of the resultant value; for A_TUPLE and A_ELEMSET it
1.2180 + is the dimension of the corresponding n-tuple(s) and cannot be
1.2181 + zero; for other resultant types it is always zero */
1.2182 + CODE *up;
1.2183 + /* parent pseudo-code, which refers to this pseudo-code as to its
1.2184 + operand; NULL means this pseudo-code has no parent and defines
1.2185 + an expression, which is not contained in another expression */
1.2186 + int vflag;
1.2187 + /* volatile flag; being set this flag means that this operation
1.2188 + has a side effect; for primary expressions this flag is set
1.2189 + directly by corresponding parsing routines (for example, if
1.2190 + primary expression is a reference to a function that generates
1.2191 + pseudo-random numbers); in other cases this flag is inherited
1.2192 + from operands */
1.2193 + int valid;
1.2194 + /* if this flag is set, the resultant value, which is a temporary
1.2195 + result of evaluating this operation on particular values of
1.2196 + operands, is valid; if this flag is clear, the resultant value
1.2197 + doesn't exist and therefore not valid; having been evaluated
1.2198 + the resultant value is stored here and not destroyed until the
1.2199 + dummy indices, which this value depends on, have been changed
1.2200 + (and if it doesn't depend on dummy indices at all, it is never
1.2201 + destroyed); thus, if the resultant value is valid, evaluating
1.2202 + routine can immediately take its copy not computing the result
1.2203 + from scratch; this mechanism is similar to moving invariants
1.2204 + out of loops and allows improving efficiency at the expense of
1.2205 + some extra memory needed to keep temporary results */
1.2206 + /* however, if the volatile flag (see above) is set, even if the
1.2207 + resultant value is valid, evaluating routine computes it as if
1.2208 + it were not valid, i.e. caching is not used in this case */
1.2209 + VALUE value;
1.2210 + /* resultant value in generic format */
1.2211 +};
1.2212 +
1.2213 +#define eval_numeric _glp_mpl_eval_numeric
1.2214 +double eval_numeric(MPL *mpl, CODE *code);
1.2215 +/* evaluate pseudo-code to determine numeric value */
1.2216 +
1.2217 +#define eval_symbolic _glp_mpl_eval_symbolic
1.2218 +SYMBOL *eval_symbolic(MPL *mpl, CODE *code);
1.2219 +/* evaluate pseudo-code to determine symbolic value */
1.2220 +
1.2221 +#define eval_logical _glp_mpl_eval_logical
1.2222 +int eval_logical(MPL *mpl, CODE *code);
1.2223 +/* evaluate pseudo-code to determine logical value */
1.2224 +
1.2225 +#define eval_tuple _glp_mpl_eval_tuple
1.2226 +TUPLE *eval_tuple(MPL *mpl, CODE *code);
1.2227 +/* evaluate pseudo-code to construct n-tuple */
1.2228 +
1.2229 +#define eval_elemset _glp_mpl_eval_elemset
1.2230 +ELEMSET *eval_elemset(MPL *mpl, CODE *code);
1.2231 +/* evaluate pseudo-code to construct elemental set */
1.2232 +
1.2233 +#define is_member _glp_mpl_is_member
1.2234 +int is_member(MPL *mpl, CODE *code, TUPLE *tuple);
1.2235 +/* check if n-tuple is in set specified by pseudo-code */
1.2236 +
1.2237 +#define eval_formula _glp_mpl_eval_formula
1.2238 +FORMULA *eval_formula(MPL *mpl, CODE *code);
1.2239 +/* evaluate pseudo-code to construct linear form */
1.2240 +
1.2241 +#define clean_code _glp_mpl_clean_code
1.2242 +void clean_code(MPL *mpl, CODE *code);
1.2243 +/* clean pseudo-code */
1.2244 +
1.2245 +/**********************************************************************/
1.2246 +/* * * MODEL STATEMENTS * * */
1.2247 +/**********************************************************************/
1.2248 +
1.2249 +struct CHECK
1.2250 +{ /* check statement */
1.2251 + DOMAIN *domain;
1.2252 + /* subscript domain; NULL means domain is not used */
1.2253 + CODE *code;
1.2254 + /* code for computing the predicate to be checked */
1.2255 +};
1.2256 +
1.2257 +struct DISPLAY
1.2258 +{ /* display statement */
1.2259 + DOMAIN *domain;
1.2260 + /* subscript domain; NULL means domain is not used */
1.2261 + DISPLAY1 *list;
1.2262 + /* display list; cannot be empty */
1.2263 +};
1.2264 +
1.2265 +struct DISPLAY1
1.2266 +{ /* display list entry */
1.2267 + int type;
1.2268 + /* item type:
1.2269 + A_INDEX - dummy index
1.2270 + A_SET - model set
1.2271 + A_PARAMETER - model parameter
1.2272 + A_VARIABLE - model variable
1.2273 + A_CONSTRAINT - model constraint/objective
1.2274 + A_EXPRESSION - expression */
1.2275 + union
1.2276 + { DOMAIN_SLOT *slot;
1.2277 + SET *set;
1.2278 + PARAMETER *par;
1.2279 + VARIABLE *var;
1.2280 + CONSTRAINT *con;
1.2281 + CODE *code;
1.2282 + } u;
1.2283 + /* item to be displayed */
1.2284 +#if 0 /* 15/V-2010 */
1.2285 + ARG_LIST *list;
1.2286 + /* optional subscript list (for constraint/objective only) */
1.2287 +#endif
1.2288 + DISPLAY1 *next;
1.2289 + /* the next entry for the same statement */
1.2290 +};
1.2291 +
1.2292 +struct PRINTF
1.2293 +{ /* printf statement */
1.2294 + DOMAIN *domain;
1.2295 + /* subscript domain; NULL means domain is not used */
1.2296 + CODE *fmt;
1.2297 + /* pseudo-code for computing format string */
1.2298 + PRINTF1 *list;
1.2299 + /* printf list; can be empty */
1.2300 + CODE *fname;
1.2301 + /* pseudo-code for computing filename to redirect the output;
1.2302 + NULL means the output goes to stdout */
1.2303 + int app;
1.2304 + /* if this flag is set, the output is appended */
1.2305 +};
1.2306 +
1.2307 +struct PRINTF1
1.2308 +{ /* printf list entry */
1.2309 + CODE *code;
1.2310 + /* pseudo-code for computing value to be printed */
1.2311 + PRINTF1 *next;
1.2312 + /* the next entry for the same statement */
1.2313 +};
1.2314 +
1.2315 +struct FOR
1.2316 +{ /* for statement */
1.2317 + DOMAIN *domain;
1.2318 + /* subscript domain; cannot be NULL */
1.2319 + STATEMENT *list;
1.2320 + /* linked list of model statements within this for statement in
1.2321 + the original order */
1.2322 +};
1.2323 +
1.2324 +struct STATEMENT
1.2325 +{ /* model statement */
1.2326 + int line;
1.2327 + /* number of source text line, where statement begins */
1.2328 + int type;
1.2329 + /* statement type:
1.2330 + A_SET - set statement
1.2331 + A_PARAMETER - parameter statement
1.2332 + A_VARIABLE - variable statement
1.2333 + A_CONSTRAINT - constraint/objective statement
1.2334 + A_TABLE - table statement
1.2335 + A_SOLVE - solve statement
1.2336 + A_CHECK - check statement
1.2337 + A_DISPLAY - display statement
1.2338 + A_PRINTF - printf statement
1.2339 + A_FOR - for statement */
1.2340 + union
1.2341 + { SET *set;
1.2342 + PARAMETER *par;
1.2343 + VARIABLE *var;
1.2344 + CONSTRAINT *con;
1.2345 + TABLE *tab;
1.2346 + void *slv; /* currently not used (set to NULL) */
1.2347 + CHECK *chk;
1.2348 + DISPLAY *dpy;
1.2349 + PRINTF *prt;
1.2350 + FOR *fur;
1.2351 + } u;
1.2352 + /* specific part of statement */
1.2353 + STATEMENT *next;
1.2354 + /* the next statement; in this list statements follow in the same
1.2355 + order as they appear in the model section */
1.2356 +};
1.2357 +
1.2358 +#define execute_table _glp_mpl_execute_table
1.2359 +void execute_table(MPL *mpl, TABLE *tab);
1.2360 +/* execute table statement */
1.2361 +
1.2362 +#define free_dca _glp_mpl_free_dca
1.2363 +void free_dca(MPL *mpl);
1.2364 +/* free table driver communucation area */
1.2365 +
1.2366 +#define clean_table _glp_mpl_clean_table
1.2367 +void clean_table(MPL *mpl, TABLE *tab);
1.2368 +/* clean table statement */
1.2369 +
1.2370 +#define execute_check _glp_mpl_execute_check
1.2371 +void execute_check(MPL *mpl, CHECK *chk);
1.2372 +/* execute check statement */
1.2373 +
1.2374 +#define clean_check _glp_mpl_clean_check
1.2375 +void clean_check(MPL *mpl, CHECK *chk);
1.2376 +/* clean check statement */
1.2377 +
1.2378 +#define execute_display _glp_mpl_execute_display
1.2379 +void execute_display(MPL *mpl, DISPLAY *dpy);
1.2380 +/* execute display statement */
1.2381 +
1.2382 +#define clean_display _glp_mpl_clean_display
1.2383 +void clean_display(MPL *mpl, DISPLAY *dpy);
1.2384 +/* clean display statement */
1.2385 +
1.2386 +#define execute_printf _glp_mpl_execute_printf
1.2387 +void execute_printf(MPL *mpl, PRINTF *prt);
1.2388 +/* execute printf statement */
1.2389 +
1.2390 +#define clean_printf _glp_mpl_clean_printf
1.2391 +void clean_printf(MPL *mpl, PRINTF *prt);
1.2392 +/* clean printf statement */
1.2393 +
1.2394 +#define execute_for _glp_mpl_execute_for
1.2395 +void execute_for(MPL *mpl, FOR *fur);
1.2396 +/* execute for statement */
1.2397 +
1.2398 +#define clean_for _glp_mpl_clean_for
1.2399 +void clean_for(MPL *mpl, FOR *fur);
1.2400 +/* clean for statement */
1.2401 +
1.2402 +#define execute_statement _glp_mpl_execute_statement
1.2403 +void execute_statement(MPL *mpl, STATEMENT *stmt);
1.2404 +/* execute specified model statement */
1.2405 +
1.2406 +#define clean_statement _glp_mpl_clean_statement
1.2407 +void clean_statement(MPL *mpl, STATEMENT *stmt);
1.2408 +/* clean specified model statement */
1.2409 +
1.2410 +/**********************************************************************/
1.2411 +/* * * GENERATING AND POSTSOLVING MODEL * * */
1.2412 +/**********************************************************************/
1.2413 +
1.2414 +#define alloc_content _glp_mpl_alloc_content
1.2415 +void alloc_content(MPL *mpl);
1.2416 +/* allocate content arrays for all model objects */
1.2417 +
1.2418 +#define generate_model _glp_mpl_generate_model
1.2419 +void generate_model(MPL *mpl);
1.2420 +/* generate model */
1.2421 +
1.2422 +#define build_problem _glp_mpl_build_problem
1.2423 +void build_problem(MPL *mpl);
1.2424 +/* build problem instance */
1.2425 +
1.2426 +#define postsolve_model _glp_mpl_postsolve_model
1.2427 +void postsolve_model(MPL *mpl);
1.2428 +/* postsolve model */
1.2429 +
1.2430 +#define clean_model _glp_mpl_clean_model
1.2431 +void clean_model(MPL *mpl);
1.2432 +/* clean model content */
1.2433 +
1.2434 +/**********************************************************************/
1.2435 +/* * * INPUT/OUTPUT * * */
1.2436 +/**********************************************************************/
1.2437 +
1.2438 +#define open_input _glp_mpl_open_input
1.2439 +void open_input(MPL *mpl, char *file);
1.2440 +/* open input text file */
1.2441 +
1.2442 +#define read_char _glp_mpl_read_char
1.2443 +int read_char(MPL *mpl);
1.2444 +/* read next character from input text file */
1.2445 +
1.2446 +#define close_input _glp_mpl_close_input
1.2447 +void close_input(MPL *mpl);
1.2448 +/* close input text file */
1.2449 +
1.2450 +#define open_output _glp_mpl_open_output
1.2451 +void open_output(MPL *mpl, char *file);
1.2452 +/* open output text file */
1.2453 +
1.2454 +#define write_char _glp_mpl_write_char
1.2455 +void write_char(MPL *mpl, int c);
1.2456 +/* write next character to output text file */
1.2457 +
1.2458 +#define write_text _glp_mpl_write_text
1.2459 +void write_text(MPL *mpl, char *fmt, ...);
1.2460 +/* format and write text to output text file */
1.2461 +
1.2462 +#define flush_output _glp_mpl_flush_output
1.2463 +void flush_output(MPL *mpl);
1.2464 +/* finalize writing data to output text file */
1.2465 +
1.2466 +/**********************************************************************/
1.2467 +/* * * SOLVER INTERFACE * * */
1.2468 +/**********************************************************************/
1.2469 +
1.2470 +#define MPL_FR 401 /* free (unbounded) */
1.2471 +#define MPL_LO 402 /* lower bound */
1.2472 +#define MPL_UP 403 /* upper bound */
1.2473 +#define MPL_DB 404 /* both lower and upper bounds */
1.2474 +#define MPL_FX 405 /* fixed */
1.2475 +
1.2476 +#define MPL_ST 411 /* constraint */
1.2477 +#define MPL_MIN 412 /* objective (minimization) */
1.2478 +#define MPL_MAX 413 /* objective (maximization) */
1.2479 +
1.2480 +#define MPL_NUM 421 /* continuous */
1.2481 +#define MPL_INT 422 /* integer */
1.2482 +#define MPL_BIN 423 /* binary */
1.2483 +
1.2484 +#define error _glp_mpl_error
1.2485 +void error(MPL *mpl, char *fmt, ...);
1.2486 +/* print error message and terminate model processing */
1.2487 +
1.2488 +#define warning _glp_mpl_warning
1.2489 +void warning(MPL *mpl, char *fmt, ...);
1.2490 +/* print warning message and continue model processing */
1.2491 +
1.2492 +#define mpl_initialize _glp_mpl_initialize
1.2493 +MPL *mpl_initialize(void);
1.2494 +/* create and initialize translator database */
1.2495 +
1.2496 +#define mpl_read_model _glp_mpl_read_model
1.2497 +int mpl_read_model(MPL *mpl, char *file, int skip_data);
1.2498 +/* read model section and optional data section */
1.2499 +
1.2500 +#define mpl_read_data _glp_mpl_read_data
1.2501 +int mpl_read_data(MPL *mpl, char *file);
1.2502 +/* read data section */
1.2503 +
1.2504 +#define mpl_generate _glp_mpl_generate
1.2505 +int mpl_generate(MPL *mpl, char *file);
1.2506 +/* generate model */
1.2507 +
1.2508 +#define mpl_get_prob_name _glp_mpl_get_prob_name
1.2509 +char *mpl_get_prob_name(MPL *mpl);
1.2510 +/* obtain problem (model) name */
1.2511 +
1.2512 +#define mpl_get_num_rows _glp_mpl_get_num_rows
1.2513 +int mpl_get_num_rows(MPL *mpl);
1.2514 +/* determine number of rows */
1.2515 +
1.2516 +#define mpl_get_num_cols _glp_mpl_get_num_cols
1.2517 +int mpl_get_num_cols(MPL *mpl);
1.2518 +/* determine number of columns */
1.2519 +
1.2520 +#define mpl_get_row_name _glp_mpl_get_row_name
1.2521 +char *mpl_get_row_name(MPL *mpl, int i);
1.2522 +/* obtain row name */
1.2523 +
1.2524 +#define mpl_get_row_kind _glp_mpl_get_row_kind
1.2525 +int mpl_get_row_kind(MPL *mpl, int i);
1.2526 +/* determine row kind */
1.2527 +
1.2528 +#define mpl_get_row_bnds _glp_mpl_get_row_bnds
1.2529 +int mpl_get_row_bnds(MPL *mpl, int i, double *lb, double *ub);
1.2530 +/* obtain row bounds */
1.2531 +
1.2532 +#define mpl_get_mat_row _glp_mpl_get_mat_row
1.2533 +int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[]);
1.2534 +/* obtain row of the constraint matrix */
1.2535 +
1.2536 +#define mpl_get_row_c0 _glp_mpl_get_row_c0
1.2537 +double mpl_get_row_c0(MPL *mpl, int i);
1.2538 +/* obtain constant term of free row */
1.2539 +
1.2540 +#define mpl_get_col_name _glp_mpl_get_col_name
1.2541 +char *mpl_get_col_name(MPL *mpl, int j);
1.2542 +/* obtain column name */
1.2543 +
1.2544 +#define mpl_get_col_kind _glp_mpl_get_col_kind
1.2545 +int mpl_get_col_kind(MPL *mpl, int j);
1.2546 +/* determine column kind */
1.2547 +
1.2548 +#define mpl_get_col_bnds _glp_mpl_get_col_bnds
1.2549 +int mpl_get_col_bnds(MPL *mpl, int j, double *lb, double *ub);
1.2550 +/* obtain column bounds */
1.2551 +
1.2552 +#define mpl_has_solve_stmt _glp_mpl_has_solve_stmt
1.2553 +int mpl_has_solve_stmt(MPL *mpl);
1.2554 +/* check if model has solve statement */
1.2555 +
1.2556 +#if 1 /* 15/V-2010 */
1.2557 +#define mpl_put_row_soln _glp_mpl_put_row_soln
1.2558 +void mpl_put_row_soln(MPL *mpl, int i, int stat, double prim,
1.2559 + double dual);
1.2560 +/* store row (constraint/objective) solution components */
1.2561 +#endif
1.2562 +
1.2563 +#if 1 /* 15/V-2010 */
1.2564 +#define mpl_put_col_soln _glp_mpl_put_col_soln
1.2565 +void mpl_put_col_soln(MPL *mpl, int j, int stat, double prim,
1.2566 + double dual);
1.2567 +/* store column (variable) solution components */
1.2568 +#endif
1.2569 +
1.2570 +#if 0 /* 15/V-2010 */
1.2571 +#define mpl_put_col_value _glp_mpl_put_col_value
1.2572 +void mpl_put_col_value(MPL *mpl, int j, double val);
1.2573 +/* store column value */
1.2574 +#endif
1.2575 +
1.2576 +#define mpl_postsolve _glp_mpl_postsolve
1.2577 +int mpl_postsolve(MPL *mpl);
1.2578 +/* postsolve model */
1.2579 +
1.2580 +#define mpl_terminate _glp_mpl_terminate
1.2581 +void mpl_terminate(MPL *mpl);
1.2582 +/* free all resources used by translator */
1.2583 +
1.2584 +#endif
1.2585 +
1.2586 +/* eof */