lemon-project-template-glpk

annotate deps/glpk/src/glpmpl.h @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
rev   line source
alpar@9 1 /* glpmpl.h (GNU MathProg translator) */
alpar@9 2
alpar@9 3 /***********************************************************************
alpar@9 4 * This code is part of GLPK (GNU Linear Programming Kit).
alpar@9 5 *
alpar@9 6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
alpar@9 7 * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
alpar@9 8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9 9 * E-mail: <mao@gnu.org>.
alpar@9 10 *
alpar@9 11 * GLPK is free software: you can redistribute it and/or modify it
alpar@9 12 * under the terms of the GNU General Public License as published by
alpar@9 13 * the Free Software Foundation, either version 3 of the License, or
alpar@9 14 * (at your option) any later version.
alpar@9 15 *
alpar@9 16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
alpar@9 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
alpar@9 18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
alpar@9 19 * License for more details.
alpar@9 20 *
alpar@9 21 * You should have received a copy of the GNU General Public License
alpar@9 22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
alpar@9 23 ***********************************************************************/
alpar@9 24
alpar@9 25 #ifndef GLPMPL_H
alpar@9 26 #define GLPMPL_H
alpar@9 27
alpar@9 28 #include "glpavl.h"
alpar@9 29 #include "glprng.h"
alpar@9 30
alpar@9 31 typedef struct MPL MPL;
alpar@9 32 typedef char STRING;
alpar@9 33 typedef struct SYMBOL SYMBOL;
alpar@9 34 typedef struct TUPLE TUPLE;
alpar@9 35 typedef struct ARRAY ELEMSET;
alpar@9 36 typedef struct ELEMVAR ELEMVAR;
alpar@9 37 typedef struct FORMULA FORMULA;
alpar@9 38 typedef struct ELEMCON ELEMCON;
alpar@9 39 typedef union VALUE VALUE;
alpar@9 40 typedef struct ARRAY ARRAY;
alpar@9 41 typedef struct MEMBER MEMBER;
alpar@9 42 #if 1
alpar@9 43 /* many C compilers have DOMAIN declared in <math.h> :( */
alpar@9 44 #undef DOMAIN
alpar@9 45 #define DOMAIN DOMAIN1
alpar@9 46 #endif
alpar@9 47 typedef struct DOMAIN DOMAIN;
alpar@9 48 typedef struct DOMAIN_BLOCK DOMAIN_BLOCK;
alpar@9 49 typedef struct DOMAIN_SLOT DOMAIN_SLOT;
alpar@9 50 typedef struct SET SET;
alpar@9 51 typedef struct WITHIN WITHIN;
alpar@9 52 typedef struct GADGET GADGET;
alpar@9 53 typedef struct PARAMETER PARAMETER;
alpar@9 54 typedef struct CONDITION CONDITION;
alpar@9 55 typedef struct VARIABLE VARIABLE;
alpar@9 56 typedef struct CONSTRAINT CONSTRAINT;
alpar@9 57 typedef struct TABLE TABLE;
alpar@9 58 typedef struct TABARG TABARG;
alpar@9 59 typedef struct TABFLD TABFLD;
alpar@9 60 typedef struct TABIN TABIN;
alpar@9 61 typedef struct TABOUT TABOUT;
alpar@9 62 typedef struct TABDCA TABDCA;
alpar@9 63 typedef union OPERANDS OPERANDS;
alpar@9 64 typedef struct ARG_LIST ARG_LIST;
alpar@9 65 typedef struct CODE CODE;
alpar@9 66 typedef struct CHECK CHECK;
alpar@9 67 typedef struct DISPLAY DISPLAY;
alpar@9 68 typedef struct DISPLAY1 DISPLAY1;
alpar@9 69 typedef struct PRINTF PRINTF;
alpar@9 70 typedef struct PRINTF1 PRINTF1;
alpar@9 71 typedef struct FOR FOR;
alpar@9 72 typedef struct STATEMENT STATEMENT;
alpar@9 73 typedef struct TUPLE SLICE;
alpar@9 74
alpar@9 75 /**********************************************************************/
alpar@9 76 /* * * TRANSLATOR DATABASE * * */
alpar@9 77 /**********************************************************************/
alpar@9 78
alpar@9 79 #define A_BINARY 101 /* something binary */
alpar@9 80 #define A_CHECK 102 /* check statement */
alpar@9 81 #define A_CONSTRAINT 103 /* model constraint */
alpar@9 82 #define A_DISPLAY 104 /* display statement */
alpar@9 83 #define A_ELEMCON 105 /* elemental constraint/objective */
alpar@9 84 #define A_ELEMSET 106 /* elemental set */
alpar@9 85 #define A_ELEMVAR 107 /* elemental variable */
alpar@9 86 #define A_EXPRESSION 108 /* expression */
alpar@9 87 #define A_FOR 109 /* for statement */
alpar@9 88 #define A_FORMULA 110 /* formula */
alpar@9 89 #define A_INDEX 111 /* dummy index */
alpar@9 90 #define A_INPUT 112 /* input table */
alpar@9 91 #define A_INTEGER 113 /* something integer */
alpar@9 92 #define A_LOGICAL 114 /* something logical */
alpar@9 93 #define A_MAXIMIZE 115 /* objective has to be maximized */
alpar@9 94 #define A_MINIMIZE 116 /* objective has to be minimized */
alpar@9 95 #define A_NONE 117 /* nothing */
alpar@9 96 #define A_NUMERIC 118 /* something numeric */
alpar@9 97 #define A_OUTPUT 119 /* output table */
alpar@9 98 #define A_PARAMETER 120 /* model parameter */
alpar@9 99 #define A_PRINTF 121 /* printf statement */
alpar@9 100 #define A_SET 122 /* model set */
alpar@9 101 #define A_SOLVE 123 /* solve statement */
alpar@9 102 #define A_SYMBOLIC 124 /* something symbolic */
alpar@9 103 #define A_TABLE 125 /* data table */
alpar@9 104 #define A_TUPLE 126 /* n-tuple */
alpar@9 105 #define A_VARIABLE 127 /* model variable */
alpar@9 106
alpar@9 107 #define MAX_LENGTH 100
alpar@9 108 /* maximal length of any symbolic value (this includes symbolic names,
alpar@9 109 numeric and string literals, and all symbolic values that may appear
alpar@9 110 during the evaluation phase) */
alpar@9 111
alpar@9 112 #define CONTEXT_SIZE 60
alpar@9 113 /* size of the context queue, in characters */
alpar@9 114
alpar@9 115 #define OUTBUF_SIZE 1024
alpar@9 116 /* size of the output buffer, in characters */
alpar@9 117
alpar@9 118 struct MPL
alpar@9 119 { /* translator database */
alpar@9 120 /*--------------------------------------------------------------*/
alpar@9 121 /* scanning segment */
alpar@9 122 int line;
alpar@9 123 /* number of the current text line */
alpar@9 124 int c;
alpar@9 125 /* the current character or EOF */
alpar@9 126 int token;
alpar@9 127 /* the current token: */
alpar@9 128 #define T_EOF 201 /* end of file */
alpar@9 129 #define T_NAME 202 /* symbolic name (model section only) */
alpar@9 130 #define T_SYMBOL 203 /* symbol (data section only) */
alpar@9 131 #define T_NUMBER 204 /* numeric literal */
alpar@9 132 #define T_STRING 205 /* string literal */
alpar@9 133 #define T_AND 206 /* and && */
alpar@9 134 #define T_BY 207 /* by */
alpar@9 135 #define T_CROSS 208 /* cross */
alpar@9 136 #define T_DIFF 209 /* diff */
alpar@9 137 #define T_DIV 210 /* div */
alpar@9 138 #define T_ELSE 211 /* else */
alpar@9 139 #define T_IF 212 /* if */
alpar@9 140 #define T_IN 213 /* in */
alpar@9 141 #define T_INFINITY 214 /* Infinity */
alpar@9 142 #define T_INTER 215 /* inter */
alpar@9 143 #define T_LESS 216 /* less */
alpar@9 144 #define T_MOD 217 /* mod */
alpar@9 145 #define T_NOT 218 /* not ! */
alpar@9 146 #define T_OR 219 /* or || */
alpar@9 147 #define T_SPTP 220 /* s.t. */
alpar@9 148 #define T_SYMDIFF 221 /* symdiff */
alpar@9 149 #define T_THEN 222 /* then */
alpar@9 150 #define T_UNION 223 /* union */
alpar@9 151 #define T_WITHIN 224 /* within */
alpar@9 152 #define T_PLUS 225 /* + */
alpar@9 153 #define T_MINUS 226 /* - */
alpar@9 154 #define T_ASTERISK 227 /* * */
alpar@9 155 #define T_SLASH 228 /* / */
alpar@9 156 #define T_POWER 229 /* ^ ** */
alpar@9 157 #define T_LT 230 /* < */
alpar@9 158 #define T_LE 231 /* <= */
alpar@9 159 #define T_EQ 232 /* = == */
alpar@9 160 #define T_GE 233 /* >= */
alpar@9 161 #define T_GT 234 /* > */
alpar@9 162 #define T_NE 235 /* <> != */
alpar@9 163 #define T_CONCAT 236 /* & */
alpar@9 164 #define T_BAR 237 /* | */
alpar@9 165 #define T_POINT 238 /* . */
alpar@9 166 #define T_COMMA 239 /* , */
alpar@9 167 #define T_COLON 240 /* : */
alpar@9 168 #define T_SEMICOLON 241 /* ; */
alpar@9 169 #define T_ASSIGN 242 /* := */
alpar@9 170 #define T_DOTS 243 /* .. */
alpar@9 171 #define T_LEFT 244 /* ( */
alpar@9 172 #define T_RIGHT 245 /* ) */
alpar@9 173 #define T_LBRACKET 246 /* [ */
alpar@9 174 #define T_RBRACKET 247 /* ] */
alpar@9 175 #define T_LBRACE 248 /* { */
alpar@9 176 #define T_RBRACE 249 /* } */
alpar@9 177 #define T_APPEND 250 /* >> */
alpar@9 178 #define T_TILDE 251 /* ~ */
alpar@9 179 #define T_INPUT 252 /* <- */
alpar@9 180 int imlen;
alpar@9 181 /* length of the current token */
alpar@9 182 char *image; /* char image[MAX_LENGTH+1]; */
alpar@9 183 /* image of the current token */
alpar@9 184 double value;
alpar@9 185 /* value of the current token (for T_NUMBER only) */
alpar@9 186 int b_token;
alpar@9 187 /* the previous token */
alpar@9 188 int b_imlen;
alpar@9 189 /* length of the previous token */
alpar@9 190 char *b_image; /* char b_image[MAX_LENGTH+1]; */
alpar@9 191 /* image of the previous token */
alpar@9 192 double b_value;
alpar@9 193 /* value of the previous token (if token is T_NUMBER) */
alpar@9 194 int f_dots;
alpar@9 195 /* if this flag is set, the next token should be recognized as
alpar@9 196 T_DOTS, not as T_POINT */
alpar@9 197 int f_scan;
alpar@9 198 /* if this flag is set, the next token is already scanned */
alpar@9 199 int f_token;
alpar@9 200 /* the next token */
alpar@9 201 int f_imlen;
alpar@9 202 /* length of the next token */
alpar@9 203 char *f_image; /* char f_image[MAX_LENGTH+1]; */
alpar@9 204 /* image of the next token */
alpar@9 205 double f_value;
alpar@9 206 /* value of the next token (if token is T_NUMBER) */
alpar@9 207 char *context; /* char context[CONTEXT_SIZE]; */
alpar@9 208 /* context circular queue (not null-terminated!) */
alpar@9 209 int c_ptr;
alpar@9 210 /* pointer to the current position in the context queue */
alpar@9 211 int flag_d;
alpar@9 212 /* if this flag is set, the data section is being processed */
alpar@9 213 /*--------------------------------------------------------------*/
alpar@9 214 /* translating segment */
alpar@9 215 DMP *pool;
alpar@9 216 /* memory pool used to allocate all data instances created during
alpar@9 217 the translation phase */
alpar@9 218 AVL *tree;
alpar@9 219 /* symbolic name table:
alpar@9 220 node.type = A_INDEX => node.link -> DOMAIN_SLOT
alpar@9 221 node.type = A_SET => node.link -> SET
alpar@9 222 node.type = A_PARAMETER => node.link -> PARAMETER
alpar@9 223 node.type = A_VARIABLE => node.link -> VARIABLE
alpar@9 224 node.type = A_CONSTRANT => node.link -> CONSTRAINT */
alpar@9 225 STATEMENT *model;
alpar@9 226 /* linked list of model statements in the original order */
alpar@9 227 int flag_x;
alpar@9 228 /* if this flag is set, the current token being left parenthesis
alpar@9 229 begins a slice that allows recognizing any undeclared symbolic
alpar@9 230 names as dummy indices; this flag is automatically reset once
alpar@9 231 the next token has been scanned */
alpar@9 232 int as_within;
alpar@9 233 /* the warning "in understood as within" has been issued */
alpar@9 234 int as_in;
alpar@9 235 /* the warning "within understood as in" has been issued */
alpar@9 236 int as_binary;
alpar@9 237 /* the warning "logical understood as binary" has been issued */
alpar@9 238 int flag_s;
alpar@9 239 /* if this flag is set, the solve statement has been parsed */
alpar@9 240 /*--------------------------------------------------------------*/
alpar@9 241 /* common segment */
alpar@9 242 DMP *strings;
alpar@9 243 /* memory pool to allocate STRING data structures */
alpar@9 244 DMP *symbols;
alpar@9 245 /* memory pool to allocate SYMBOL data structures */
alpar@9 246 DMP *tuples;
alpar@9 247 /* memory pool to allocate TUPLE data structures */
alpar@9 248 DMP *arrays;
alpar@9 249 /* memory pool to allocate ARRAY data structures */
alpar@9 250 DMP *members;
alpar@9 251 /* memory pool to allocate MEMBER data structures */
alpar@9 252 DMP *elemvars;
alpar@9 253 /* memory pool to allocate ELEMVAR data structures */
alpar@9 254 DMP *formulae;
alpar@9 255 /* memory pool to allocate FORMULA data structures */
alpar@9 256 DMP *elemcons;
alpar@9 257 /* memory pool to allocate ELEMCON data structures */
alpar@9 258 ARRAY *a_list;
alpar@9 259 /* linked list of all arrays in the database */
alpar@9 260 char *sym_buf; /* char sym_buf[255+1]; */
alpar@9 261 /* working buffer used by the routine format_symbol */
alpar@9 262 char *tup_buf; /* char tup_buf[255+1]; */
alpar@9 263 /* working buffer used by the routine format_tuple */
alpar@9 264 /*--------------------------------------------------------------*/
alpar@9 265 /* generating/postsolving segment */
alpar@9 266 RNG *rand;
alpar@9 267 /* pseudo-random number generator */
alpar@9 268 int flag_p;
alpar@9 269 /* if this flag is set, the postsolving phase is in effect */
alpar@9 270 STATEMENT *stmt;
alpar@9 271 /* model statement being currently executed */
alpar@9 272 TABDCA *dca;
alpar@9 273 /* pointer to table driver communication area for table statement
alpar@9 274 currently executed */
alpar@9 275 int m;
alpar@9 276 /* number of rows in the problem, m >= 0 */
alpar@9 277 int n;
alpar@9 278 /* number of columns in the problem, n >= 0 */
alpar@9 279 ELEMCON **row; /* ELEMCON *row[1+m]; */
alpar@9 280 /* row[0] is not used;
alpar@9 281 row[i] is elemental constraint or objective, which corresponds
alpar@9 282 to i-th row of the problem, 1 <= i <= m */
alpar@9 283 ELEMVAR **col; /* ELEMVAR *col[1+n]; */
alpar@9 284 /* col[0] is not used;
alpar@9 285 col[j] is elemental variable, which corresponds to j-th column
alpar@9 286 of the problem, 1 <= j <= n */
alpar@9 287 /*--------------------------------------------------------------*/
alpar@9 288 /* input/output segment */
alpar@9 289 XFILE *in_fp;
alpar@9 290 /* stream assigned to the input text file */
alpar@9 291 char *in_file;
alpar@9 292 /* name of the input text file */
alpar@9 293 XFILE *out_fp;
alpar@9 294 /* stream assigned to the output text file used to write all data
alpar@9 295 produced by display and printf statements; NULL means the data
alpar@9 296 should be sent to stdout via the routine xprintf */
alpar@9 297 char *out_file;
alpar@9 298 /* name of the output text file */
alpar@9 299 #if 0 /* 08/XI-2009 */
alpar@9 300 char *out_buf; /* char out_buf[OUTBUF_SIZE] */
alpar@9 301 /* buffer to accumulate output data */
alpar@9 302 int out_cnt;
alpar@9 303 /* count of data bytes stored in the output buffer */
alpar@9 304 #endif
alpar@9 305 XFILE *prt_fp;
alpar@9 306 /* stream assigned to the print text file; may be NULL */
alpar@9 307 char *prt_file;
alpar@9 308 /* name of the output print file */
alpar@9 309 /*--------------------------------------------------------------*/
alpar@9 310 /* solver interface segment */
alpar@9 311 jmp_buf jump;
alpar@9 312 /* jump address for non-local go to in case of error */
alpar@9 313 int phase;
alpar@9 314 /* phase of processing:
alpar@9 315 0 - database is being or has been initialized
alpar@9 316 1 - model section is being or has been read
alpar@9 317 2 - data section is being or has been read
alpar@9 318 3 - model is being or has been generated/postsolved
alpar@9 319 4 - model processing error has occurred */
alpar@9 320 char *mod_file;
alpar@9 321 /* name of the input text file, which contains model section */
alpar@9 322 char *mpl_buf; /* char mpl_buf[255+1]; */
alpar@9 323 /* working buffer used by some interface routines */
alpar@9 324 };
alpar@9 325
alpar@9 326 /**********************************************************************/
alpar@9 327 /* * * PROCESSING MODEL SECTION * * */
alpar@9 328 /**********************************************************************/
alpar@9 329
alpar@9 330 #define alloc(type) ((type *)dmp_get_atomv(mpl->pool, sizeof(type)))
alpar@9 331 /* allocate atom of given type */
alpar@9 332
alpar@9 333 #define enter_context _glp_mpl_enter_context
alpar@9 334 void enter_context(MPL *mpl);
alpar@9 335 /* enter current token into context queue */
alpar@9 336
alpar@9 337 #define print_context _glp_mpl_print_context
alpar@9 338 void print_context(MPL *mpl);
alpar@9 339 /* print current content of context queue */
alpar@9 340
alpar@9 341 #define get_char _glp_mpl_get_char
alpar@9 342 void get_char(MPL *mpl);
alpar@9 343 /* scan next character from input text file */
alpar@9 344
alpar@9 345 #define append_char _glp_mpl_append_char
alpar@9 346 void append_char(MPL *mpl);
alpar@9 347 /* append character to current token */
alpar@9 348
alpar@9 349 #define get_token _glp_mpl_get_token
alpar@9 350 void get_token(MPL *mpl);
alpar@9 351 /* scan next token from input text file */
alpar@9 352
alpar@9 353 #define unget_token _glp_mpl_unget_token
alpar@9 354 void unget_token(MPL *mpl);
alpar@9 355 /* return current token back to input stream */
alpar@9 356
alpar@9 357 #define is_keyword _glp_mpl_is_keyword
alpar@9 358 int is_keyword(MPL *mpl, char *keyword);
alpar@9 359 /* check if current token is given non-reserved keyword */
alpar@9 360
alpar@9 361 #define is_reserved _glp_mpl_is_reserved
alpar@9 362 int is_reserved(MPL *mpl);
alpar@9 363 /* check if current token is reserved keyword */
alpar@9 364
alpar@9 365 #define make_code _glp_mpl_make_code
alpar@9 366 CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim);
alpar@9 367 /* generate pseudo-code (basic routine) */
alpar@9 368
alpar@9 369 #define make_unary _glp_mpl_make_unary
alpar@9 370 CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim);
alpar@9 371 /* generate pseudo-code for unary operation */
alpar@9 372
alpar@9 373 #define make_binary _glp_mpl_make_binary
alpar@9 374 CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
alpar@9 375 int dim);
alpar@9 376 /* generate pseudo-code for binary operation */
alpar@9 377
alpar@9 378 #define make_ternary _glp_mpl_make_ternary
alpar@9 379 CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
alpar@9 380 int type, int dim);
alpar@9 381 /* generate pseudo-code for ternary operation */
alpar@9 382
alpar@9 383 #define numeric_literal _glp_mpl_numeric_literal
alpar@9 384 CODE *numeric_literal(MPL *mpl);
alpar@9 385 /* parse reference to numeric literal */
alpar@9 386
alpar@9 387 #define string_literal _glp_mpl_string_literal
alpar@9 388 CODE *string_literal(MPL *mpl);
alpar@9 389 /* parse reference to string literal */
alpar@9 390
alpar@9 391 #define create_arg_list _glp_mpl_create_arg_list
alpar@9 392 ARG_LIST *create_arg_list(MPL *mpl);
alpar@9 393 /* create empty operands list */
alpar@9 394
alpar@9 395 #define expand_arg_list _glp_mpl_expand_arg_list
alpar@9 396 ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x);
alpar@9 397 /* append operand to operands list */
alpar@9 398
alpar@9 399 #define arg_list_len _glp_mpl_arg_list_len
alpar@9 400 int arg_list_len(MPL *mpl, ARG_LIST *list);
alpar@9 401 /* determine length of operands list */
alpar@9 402
alpar@9 403 #define subscript_list _glp_mpl_subscript_list
alpar@9 404 ARG_LIST *subscript_list(MPL *mpl);
alpar@9 405 /* parse subscript list */
alpar@9 406
alpar@9 407 #define object_reference _glp_mpl_object_reference
alpar@9 408 CODE *object_reference(MPL *mpl);
alpar@9 409 /* parse reference to named object */
alpar@9 410
alpar@9 411 #define numeric_argument _glp_mpl_numeric_argument
alpar@9 412 CODE *numeric_argument(MPL *mpl, char *func);
alpar@9 413 /* parse argument passed to built-in function */
alpar@9 414
alpar@9 415 #define symbolic_argument _glp_mpl_symbolic_argument
alpar@9 416 CODE *symbolic_argument(MPL *mpl, char *func);
alpar@9 417
alpar@9 418 #define elemset_argument _glp_mpl_elemset_argument
alpar@9 419 CODE *elemset_argument(MPL *mpl, char *func);
alpar@9 420
alpar@9 421 #define function_reference _glp_mpl_function_reference
alpar@9 422 CODE *function_reference(MPL *mpl);
alpar@9 423 /* parse reference to built-in function */
alpar@9 424
alpar@9 425 #define create_domain _glp_mpl_create_domain
alpar@9 426 DOMAIN *create_domain(MPL *mpl);
alpar@9 427 /* create empty domain */
alpar@9 428
alpar@9 429 #define create_block _glp_mpl_create_block
alpar@9 430 DOMAIN_BLOCK *create_block(MPL *mpl);
alpar@9 431 /* create empty domain block */
alpar@9 432
alpar@9 433 #define append_block _glp_mpl_append_block
alpar@9 434 void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block);
alpar@9 435 /* append domain block to specified domain */
alpar@9 436
alpar@9 437 #define append_slot _glp_mpl_append_slot
alpar@9 438 DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
alpar@9 439 CODE *code);
alpar@9 440 /* create and append new slot to domain block */
alpar@9 441
alpar@9 442 #define expression_list _glp_mpl_expression_list
alpar@9 443 CODE *expression_list(MPL *mpl);
alpar@9 444 /* parse expression list */
alpar@9 445
alpar@9 446 #define literal_set _glp_mpl_literal_set
alpar@9 447 CODE *literal_set(MPL *mpl, CODE *code);
alpar@9 448 /* parse literal set */
alpar@9 449
alpar@9 450 #define indexing_expression _glp_mpl_indexing_expression
alpar@9 451 DOMAIN *indexing_expression(MPL *mpl);
alpar@9 452 /* parse indexing expression */
alpar@9 453
alpar@9 454 #define close_scope _glp_mpl_close_scope
alpar@9 455 void close_scope(MPL *mpl, DOMAIN *domain);
alpar@9 456 /* close scope of indexing expression */
alpar@9 457
alpar@9 458 #define iterated_expression _glp_mpl_iterated_expression
alpar@9 459 CODE *iterated_expression(MPL *mpl);
alpar@9 460 /* parse iterated expression */
alpar@9 461
alpar@9 462 #define domain_arity _glp_mpl_domain_arity
alpar@9 463 int domain_arity(MPL *mpl, DOMAIN *domain);
alpar@9 464 /* determine arity of domain */
alpar@9 465
alpar@9 466 #define set_expression _glp_mpl_set_expression
alpar@9 467 CODE *set_expression(MPL *mpl);
alpar@9 468 /* parse set expression */
alpar@9 469
alpar@9 470 #define branched_expression _glp_mpl_branched_expression
alpar@9 471 CODE *branched_expression(MPL *mpl);
alpar@9 472 /* parse conditional expression */
alpar@9 473
alpar@9 474 #define primary_expression _glp_mpl_primary_expression
alpar@9 475 CODE *primary_expression(MPL *mpl);
alpar@9 476 /* parse primary expression */
alpar@9 477
alpar@9 478 #define error_preceding _glp_mpl_error_preceding
alpar@9 479 void error_preceding(MPL *mpl, char *opstr);
alpar@9 480 /* raise error if preceding operand has wrong type */
alpar@9 481
alpar@9 482 #define error_following _glp_mpl_error_following
alpar@9 483 void error_following(MPL *mpl, char *opstr);
alpar@9 484 /* raise error if following operand has wrong type */
alpar@9 485
alpar@9 486 #define error_dimension _glp_mpl_error_dimension
alpar@9 487 void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2);
alpar@9 488 /* raise error if operands have different dimension */
alpar@9 489
alpar@9 490 #define expression_0 _glp_mpl_expression_0
alpar@9 491 CODE *expression_0(MPL *mpl);
alpar@9 492 /* parse expression of level 0 */
alpar@9 493
alpar@9 494 #define expression_1 _glp_mpl_expression_1
alpar@9 495 CODE *expression_1(MPL *mpl);
alpar@9 496 /* parse expression of level 1 */
alpar@9 497
alpar@9 498 #define expression_2 _glp_mpl_expression_2
alpar@9 499 CODE *expression_2(MPL *mpl);
alpar@9 500 /* parse expression of level 2 */
alpar@9 501
alpar@9 502 #define expression_3 _glp_mpl_expression_3
alpar@9 503 CODE *expression_3(MPL *mpl);
alpar@9 504 /* parse expression of level 3 */
alpar@9 505
alpar@9 506 #define expression_4 _glp_mpl_expression_4
alpar@9 507 CODE *expression_4(MPL *mpl);
alpar@9 508 /* parse expression of level 4 */
alpar@9 509
alpar@9 510 #define expression_5 _glp_mpl_expression_5
alpar@9 511 CODE *expression_5(MPL *mpl);
alpar@9 512 /* parse expression of level 5 */
alpar@9 513
alpar@9 514 #define expression_6 _glp_mpl_expression_6
alpar@9 515 CODE *expression_6(MPL *mpl);
alpar@9 516 /* parse expression of level 6 */
alpar@9 517
alpar@9 518 #define expression_7 _glp_mpl_expression_7
alpar@9 519 CODE *expression_7(MPL *mpl);
alpar@9 520 /* parse expression of level 7 */
alpar@9 521
alpar@9 522 #define expression_8 _glp_mpl_expression_8
alpar@9 523 CODE *expression_8(MPL *mpl);
alpar@9 524 /* parse expression of level 8 */
alpar@9 525
alpar@9 526 #define expression_9 _glp_mpl_expression_9
alpar@9 527 CODE *expression_9(MPL *mpl);
alpar@9 528 /* parse expression of level 9 */
alpar@9 529
alpar@9 530 #define expression_10 _glp_mpl_expression_10
alpar@9 531 CODE *expression_10(MPL *mpl);
alpar@9 532 /* parse expression of level 10 */
alpar@9 533
alpar@9 534 #define expression_11 _glp_mpl_expression_11
alpar@9 535 CODE *expression_11(MPL *mpl);
alpar@9 536 /* parse expression of level 11 */
alpar@9 537
alpar@9 538 #define expression_12 _glp_mpl_expression_12
alpar@9 539 CODE *expression_12(MPL *mpl);
alpar@9 540 /* parse expression of level 12 */
alpar@9 541
alpar@9 542 #define expression_13 _glp_mpl_expression_13
alpar@9 543 CODE *expression_13(MPL *mpl);
alpar@9 544 /* parse expression of level 13 */
alpar@9 545
alpar@9 546 #define set_statement _glp_mpl_set_statement
alpar@9 547 SET *set_statement(MPL *mpl);
alpar@9 548 /* parse set statement */
alpar@9 549
alpar@9 550 #define parameter_statement _glp_mpl_parameter_statement
alpar@9 551 PARAMETER *parameter_statement(MPL *mpl);
alpar@9 552 /* parse parameter statement */
alpar@9 553
alpar@9 554 #define variable_statement _glp_mpl_variable_statement
alpar@9 555 VARIABLE *variable_statement(MPL *mpl);
alpar@9 556 /* parse variable statement */
alpar@9 557
alpar@9 558 #define constraint_statement _glp_mpl_constraint_statement
alpar@9 559 CONSTRAINT *constraint_statement(MPL *mpl);
alpar@9 560 /* parse constraint statement */
alpar@9 561
alpar@9 562 #define objective_statement _glp_mpl_objective_statement
alpar@9 563 CONSTRAINT *objective_statement(MPL *mpl);
alpar@9 564 /* parse objective statement */
alpar@9 565
alpar@9 566 #define table_statement _glp_mpl_table_statement
alpar@9 567 TABLE *table_statement(MPL *mpl);
alpar@9 568 /* parse table statement */
alpar@9 569
alpar@9 570 #define solve_statement _glp_mpl_solve_statement
alpar@9 571 void *solve_statement(MPL *mpl);
alpar@9 572 /* parse solve statement */
alpar@9 573
alpar@9 574 #define check_statement _glp_mpl_check_statement
alpar@9 575 CHECK *check_statement(MPL *mpl);
alpar@9 576 /* parse check statement */
alpar@9 577
alpar@9 578 #define display_statement _glp_mpl_display_statement
alpar@9 579 DISPLAY *display_statement(MPL *mpl);
alpar@9 580 /* parse display statement */
alpar@9 581
alpar@9 582 #define printf_statement _glp_mpl_printf_statement
alpar@9 583 PRINTF *printf_statement(MPL *mpl);
alpar@9 584 /* parse printf statement */
alpar@9 585
alpar@9 586 #define for_statement _glp_mpl_for_statement
alpar@9 587 FOR *for_statement(MPL *mpl);
alpar@9 588 /* parse for statement */
alpar@9 589
alpar@9 590 #define end_statement _glp_mpl_end_statement
alpar@9 591 void end_statement(MPL *mpl);
alpar@9 592 /* parse end statement */
alpar@9 593
alpar@9 594 #define simple_statement _glp_mpl_simple_statement
alpar@9 595 STATEMENT *simple_statement(MPL *mpl, int spec);
alpar@9 596 /* parse simple statement */
alpar@9 597
alpar@9 598 #define model_section _glp_mpl_model_section
alpar@9 599 void model_section(MPL *mpl);
alpar@9 600 /* parse model section */
alpar@9 601
alpar@9 602 /**********************************************************************/
alpar@9 603 /* * * PROCESSING DATA SECTION * * */
alpar@9 604 /**********************************************************************/
alpar@9 605
alpar@9 606 #if 2 + 2 == 5
alpar@9 607 struct SLICE /* see TUPLE */
alpar@9 608 { /* component of slice; the slice itself is associated with its
alpar@9 609 first component; slices are similar to n-tuples with exception
alpar@9 610 that some slice components (which are indicated by asterisks)
alpar@9 611 don't refer to any symbols */
alpar@9 612 SYMBOL *sym;
alpar@9 613 /* symbol, which this component refers to; can be NULL */
alpar@9 614 SLICE *next;
alpar@9 615 /* the next component of slice */
alpar@9 616 };
alpar@9 617 #endif
alpar@9 618
alpar@9 619 #define create_slice _glp_mpl_create_slice
alpar@9 620 SLICE *create_slice(MPL *mpl);
alpar@9 621 /* create slice */
alpar@9 622
alpar@9 623 #define expand_slice _glp_mpl_expand_slice
alpar@9 624 SLICE *expand_slice
alpar@9 625 ( MPL *mpl,
alpar@9 626 SLICE *slice, /* destroyed */
alpar@9 627 SYMBOL *sym /* destroyed */
alpar@9 628 );
alpar@9 629 /* append new component to slice */
alpar@9 630
alpar@9 631 #define slice_dimen _glp_mpl_slice_dimen
alpar@9 632 int slice_dimen
alpar@9 633 ( MPL *mpl,
alpar@9 634 SLICE *slice /* not changed */
alpar@9 635 );
alpar@9 636 /* determine dimension of slice */
alpar@9 637
alpar@9 638 #define slice_arity _glp_mpl_slice_arity
alpar@9 639 int slice_arity
alpar@9 640 ( MPL *mpl,
alpar@9 641 SLICE *slice /* not changed */
alpar@9 642 );
alpar@9 643 /* determine arity of slice */
alpar@9 644
alpar@9 645 #define fake_slice _glp_mpl_fake_slice
alpar@9 646 SLICE *fake_slice(MPL *mpl, int dim);
alpar@9 647 /* create fake slice of all asterisks */
alpar@9 648
alpar@9 649 #define delete_slice _glp_mpl_delete_slice
alpar@9 650 void delete_slice
alpar@9 651 ( MPL *mpl,
alpar@9 652 SLICE *slice /* destroyed */
alpar@9 653 );
alpar@9 654 /* delete slice */
alpar@9 655
alpar@9 656 #define is_number _glp_mpl_is_number
alpar@9 657 int is_number(MPL *mpl);
alpar@9 658 /* check if current token is number */
alpar@9 659
alpar@9 660 #define is_symbol _glp_mpl_is_symbol
alpar@9 661 int is_symbol(MPL *mpl);
alpar@9 662 /* check if current token is symbol */
alpar@9 663
alpar@9 664 #define is_literal _glp_mpl_is_literal
alpar@9 665 int is_literal(MPL *mpl, char *literal);
alpar@9 666 /* check if current token is given symbolic literal */
alpar@9 667
alpar@9 668 #define read_number _glp_mpl_read_number
alpar@9 669 double read_number(MPL *mpl);
alpar@9 670 /* read number */
alpar@9 671
alpar@9 672 #define read_symbol _glp_mpl_read_symbol
alpar@9 673 SYMBOL *read_symbol(MPL *mpl);
alpar@9 674 /* read symbol */
alpar@9 675
alpar@9 676 #define read_slice _glp_mpl_read_slice
alpar@9 677 SLICE *read_slice
alpar@9 678 ( MPL *mpl,
alpar@9 679 char *name, /* not changed */
alpar@9 680 int dim
alpar@9 681 );
alpar@9 682 /* read slice */
alpar@9 683
alpar@9 684 #define select_set _glp_mpl_select_set
alpar@9 685 SET *select_set
alpar@9 686 ( MPL *mpl,
alpar@9 687 char *name /* not changed */
alpar@9 688 );
alpar@9 689 /* select set to saturate it with elemental sets */
alpar@9 690
alpar@9 691 #define simple_format _glp_mpl_simple_format
alpar@9 692 void simple_format
alpar@9 693 ( MPL *mpl,
alpar@9 694 SET *set, /* not changed */
alpar@9 695 MEMBER *memb, /* modified */
alpar@9 696 SLICE *slice /* not changed */
alpar@9 697 );
alpar@9 698 /* read set data block in simple format */
alpar@9 699
alpar@9 700 #define matrix_format _glp_mpl_matrix_format
alpar@9 701 void matrix_format
alpar@9 702 ( MPL *mpl,
alpar@9 703 SET *set, /* not changed */
alpar@9 704 MEMBER *memb, /* modified */
alpar@9 705 SLICE *slice, /* not changed */
alpar@9 706 int tr
alpar@9 707 );
alpar@9 708 /* read set data block in matrix format */
alpar@9 709
alpar@9 710 #define set_data _glp_mpl_set_data
alpar@9 711 void set_data(MPL *mpl);
alpar@9 712 /* read set data */
alpar@9 713
alpar@9 714 #define select_parameter _glp_mpl_select_parameter
alpar@9 715 PARAMETER *select_parameter
alpar@9 716 ( MPL *mpl,
alpar@9 717 char *name /* not changed */
alpar@9 718 );
alpar@9 719 /* select parameter to saturate it with data */
alpar@9 720
alpar@9 721 #define set_default _glp_mpl_set_default
alpar@9 722 void set_default
alpar@9 723 ( MPL *mpl,
alpar@9 724 PARAMETER *par, /* not changed */
alpar@9 725 SYMBOL *altval /* destroyed */
alpar@9 726 );
alpar@9 727 /* set default parameter value */
alpar@9 728
alpar@9 729 #define read_value _glp_mpl_read_value
alpar@9 730 MEMBER *read_value
alpar@9 731 ( MPL *mpl,
alpar@9 732 PARAMETER *par, /* not changed */
alpar@9 733 TUPLE *tuple /* destroyed */
alpar@9 734 );
alpar@9 735 /* read value and assign it to parameter member */
alpar@9 736
alpar@9 737 #define plain_format _glp_mpl_plain_format
alpar@9 738 void plain_format
alpar@9 739 ( MPL *mpl,
alpar@9 740 PARAMETER *par, /* not changed */
alpar@9 741 SLICE *slice /* not changed */
alpar@9 742 );
alpar@9 743 /* read parameter data block in plain format */
alpar@9 744
alpar@9 745 #define tabular_format _glp_mpl_tabular_format
alpar@9 746 void tabular_format
alpar@9 747 ( MPL *mpl,
alpar@9 748 PARAMETER *par, /* not changed */
alpar@9 749 SLICE *slice, /* not changed */
alpar@9 750 int tr
alpar@9 751 );
alpar@9 752 /* read parameter data block in tabular format */
alpar@9 753
alpar@9 754 #define tabbing_format _glp_mpl_tabbing_format
alpar@9 755 void tabbing_format
alpar@9 756 ( MPL *mpl,
alpar@9 757 SYMBOL *altval /* not changed */
alpar@9 758 );
alpar@9 759 /* read parameter data block in tabbing format */
alpar@9 760
alpar@9 761 #define parameter_data _glp_mpl_parameter_data
alpar@9 762 void parameter_data(MPL *mpl);
alpar@9 763 /* read parameter data */
alpar@9 764
alpar@9 765 #define data_section _glp_mpl_data_section
alpar@9 766 void data_section(MPL *mpl);
alpar@9 767 /* read data section */
alpar@9 768
alpar@9 769 /**********************************************************************/
alpar@9 770 /* * * FLOATING-POINT NUMBERS * * */
alpar@9 771 /**********************************************************************/
alpar@9 772
alpar@9 773 #define fp_add _glp_mpl_fp_add
alpar@9 774 double fp_add(MPL *mpl, double x, double y);
alpar@9 775 /* floating-point addition */
alpar@9 776
alpar@9 777 #define fp_sub _glp_mpl_fp_sub
alpar@9 778 double fp_sub(MPL *mpl, double x, double y);
alpar@9 779 /* floating-point subtraction */
alpar@9 780
alpar@9 781 #define fp_less _glp_mpl_fp_less
alpar@9 782 double fp_less(MPL *mpl, double x, double y);
alpar@9 783 /* floating-point non-negative subtraction */
alpar@9 784
alpar@9 785 #define fp_mul _glp_mpl_fp_mul
alpar@9 786 double fp_mul(MPL *mpl, double x, double y);
alpar@9 787 /* floating-point multiplication */
alpar@9 788
alpar@9 789 #define fp_div _glp_mpl_fp_div
alpar@9 790 double fp_div(MPL *mpl, double x, double y);
alpar@9 791 /* floating-point division */
alpar@9 792
alpar@9 793 #define fp_idiv _glp_mpl_fp_idiv
alpar@9 794 double fp_idiv(MPL *mpl, double x, double y);
alpar@9 795 /* floating-point quotient of exact division */
alpar@9 796
alpar@9 797 #define fp_mod _glp_mpl_fp_mod
alpar@9 798 double fp_mod(MPL *mpl, double x, double y);
alpar@9 799 /* floating-point remainder of exact division */
alpar@9 800
alpar@9 801 #define fp_power _glp_mpl_fp_power
alpar@9 802 double fp_power(MPL *mpl, double x, double y);
alpar@9 803 /* floating-point exponentiation (raise to power) */
alpar@9 804
alpar@9 805 #define fp_exp _glp_mpl_fp_exp
alpar@9 806 double fp_exp(MPL *mpl, double x);
alpar@9 807 /* floating-point base-e exponential */
alpar@9 808
alpar@9 809 #define fp_log _glp_mpl_fp_log
alpar@9 810 double fp_log(MPL *mpl, double x);
alpar@9 811 /* floating-point natural logarithm */
alpar@9 812
alpar@9 813 #define fp_log10 _glp_mpl_fp_log10
alpar@9 814 double fp_log10(MPL *mpl, double x);
alpar@9 815 /* floating-point common (decimal) logarithm */
alpar@9 816
alpar@9 817 #define fp_sqrt _glp_mpl_fp_sqrt
alpar@9 818 double fp_sqrt(MPL *mpl, double x);
alpar@9 819 /* floating-point square root */
alpar@9 820
alpar@9 821 #define fp_sin _glp_mpl_fp_sin
alpar@9 822 double fp_sin(MPL *mpl, double x);
alpar@9 823 /* floating-point trigonometric sine */
alpar@9 824
alpar@9 825 #define fp_cos _glp_mpl_fp_cos
alpar@9 826 double fp_cos(MPL *mpl, double x);
alpar@9 827 /* floating-point trigonometric cosine */
alpar@9 828
alpar@9 829 #define fp_atan _glp_mpl_fp_atan
alpar@9 830 double fp_atan(MPL *mpl, double x);
alpar@9 831 /* floating-point trigonometric arctangent */
alpar@9 832
alpar@9 833 #define fp_atan2 _glp_mpl_fp_atan2
alpar@9 834 double fp_atan2(MPL *mpl, double y, double x);
alpar@9 835 /* floating-point trigonometric arctangent */
alpar@9 836
alpar@9 837 #define fp_round _glp_mpl_fp_round
alpar@9 838 double fp_round(MPL *mpl, double x, double n);
alpar@9 839 /* round floating-point value to n fractional digits */
alpar@9 840
alpar@9 841 #define fp_trunc _glp_mpl_fp_trunc
alpar@9 842 double fp_trunc(MPL *mpl, double x, double n);
alpar@9 843 /* truncate floating-point value to n fractional digits */
alpar@9 844
alpar@9 845 /**********************************************************************/
alpar@9 846 /* * * PSEUDO-RANDOM NUMBER GENERATORS * * */
alpar@9 847 /**********************************************************************/
alpar@9 848
alpar@9 849 #define fp_irand224 _glp_mpl_fp_irand224
alpar@9 850 double fp_irand224(MPL *mpl);
alpar@9 851 /* pseudo-random integer in the range [0, 2^24) */
alpar@9 852
alpar@9 853 #define fp_uniform01 _glp_mpl_fp_uniform01
alpar@9 854 double fp_uniform01(MPL *mpl);
alpar@9 855 /* pseudo-random number in the range [0, 1) */
alpar@9 856
alpar@9 857 #define fp_uniform _glp_mpl_uniform
alpar@9 858 double fp_uniform(MPL *mpl, double a, double b);
alpar@9 859 /* pseudo-random number in the range [a, b) */
alpar@9 860
alpar@9 861 #define fp_normal01 _glp_mpl_fp_normal01
alpar@9 862 double fp_normal01(MPL *mpl);
alpar@9 863 /* Gaussian random variate with mu = 0 and sigma = 1 */
alpar@9 864
alpar@9 865 #define fp_normal _glp_mpl_fp_normal
alpar@9 866 double fp_normal(MPL *mpl, double mu, double sigma);
alpar@9 867 /* Gaussian random variate with specified mu and sigma */
alpar@9 868
alpar@9 869 /**********************************************************************/
alpar@9 870 /* * * DATE/TIME * * */
alpar@9 871 /**********************************************************************/
alpar@9 872
alpar@9 873 #define fn_gmtime _glp_mpl_fn_gmtime
alpar@9 874 double fn_gmtime(MPL *mpl);
alpar@9 875 /* obtain the current calendar time (UTC) */
alpar@9 876
alpar@9 877 #define fn_str2time _glp_mpl_fn_str2time
alpar@9 878 double fn_str2time(MPL *mpl, const char *str, const char *fmt);
alpar@9 879 /* convert character string to the calendar time */
alpar@9 880
alpar@9 881 #define fn_time2str _glp_mpl_fn_time2str
alpar@9 882 void fn_time2str(MPL *mpl, char *str, double t, const char *fmt);
alpar@9 883 /* convert the calendar time to character string */
alpar@9 884
alpar@9 885 /**********************************************************************/
alpar@9 886 /* * * CHARACTER STRINGS * * */
alpar@9 887 /**********************************************************************/
alpar@9 888
alpar@9 889 #define create_string _glp_mpl_create_string
alpar@9 890 STRING *create_string
alpar@9 891 ( MPL *mpl,
alpar@9 892 char buf[MAX_LENGTH+1] /* not changed */
alpar@9 893 );
alpar@9 894 /* create character string */
alpar@9 895
alpar@9 896 #define copy_string _glp_mpl_copy_string
alpar@9 897 STRING *copy_string
alpar@9 898 ( MPL *mpl,
alpar@9 899 STRING *str /* not changed */
alpar@9 900 );
alpar@9 901 /* make copy of character string */
alpar@9 902
alpar@9 903 #define compare_strings _glp_mpl_compare_strings
alpar@9 904 int compare_strings
alpar@9 905 ( MPL *mpl,
alpar@9 906 STRING *str1, /* not changed */
alpar@9 907 STRING *str2 /* not changed */
alpar@9 908 );
alpar@9 909 /* compare one character string with another */
alpar@9 910
alpar@9 911 #define fetch_string _glp_mpl_fetch_string
alpar@9 912 char *fetch_string
alpar@9 913 ( MPL *mpl,
alpar@9 914 STRING *str, /* not changed */
alpar@9 915 char buf[MAX_LENGTH+1] /* modified */
alpar@9 916 );
alpar@9 917 /* extract content of character string */
alpar@9 918
alpar@9 919 #define delete_string _glp_mpl_delete_string
alpar@9 920 void delete_string
alpar@9 921 ( MPL *mpl,
alpar@9 922 STRING *str /* destroyed */
alpar@9 923 );
alpar@9 924 /* delete character string */
alpar@9 925
alpar@9 926 /**********************************************************************/
alpar@9 927 /* * * SYMBOLS * * */
alpar@9 928 /**********************************************************************/
alpar@9 929
alpar@9 930 struct SYMBOL
alpar@9 931 { /* symbol (numeric or abstract quantity) */
alpar@9 932 double num;
alpar@9 933 /* numeric value of symbol (used only if str == NULL) */
alpar@9 934 STRING *str;
alpar@9 935 /* abstract value of symbol (used only if str != NULL) */
alpar@9 936 };
alpar@9 937
alpar@9 938 #define create_symbol_num _glp_mpl_create_symbol_num
alpar@9 939 SYMBOL *create_symbol_num(MPL *mpl, double num);
alpar@9 940 /* create symbol of numeric type */
alpar@9 941
alpar@9 942 #define create_symbol_str _glp_mpl_create_symbol_str
alpar@9 943 SYMBOL *create_symbol_str
alpar@9 944 ( MPL *mpl,
alpar@9 945 STRING *str /* destroyed */
alpar@9 946 );
alpar@9 947 /* create symbol of abstract type */
alpar@9 948
alpar@9 949 #define copy_symbol _glp_mpl_copy_symbol
alpar@9 950 SYMBOL *copy_symbol
alpar@9 951 ( MPL *mpl,
alpar@9 952 SYMBOL *sym /* not changed */
alpar@9 953 );
alpar@9 954 /* make copy of symbol */
alpar@9 955
alpar@9 956 #define compare_symbols _glp_mpl_compare_symbols
alpar@9 957 int compare_symbols
alpar@9 958 ( MPL *mpl,
alpar@9 959 SYMBOL *sym1, /* not changed */
alpar@9 960 SYMBOL *sym2 /* not changed */
alpar@9 961 );
alpar@9 962 /* compare one symbol with another */
alpar@9 963
alpar@9 964 #define delete_symbol _glp_mpl_delete_symbol
alpar@9 965 void delete_symbol
alpar@9 966 ( MPL *mpl,
alpar@9 967 SYMBOL *sym /* destroyed */
alpar@9 968 );
alpar@9 969 /* delete symbol */
alpar@9 970
alpar@9 971 #define format_symbol _glp_mpl_format_symbol
alpar@9 972 char *format_symbol
alpar@9 973 ( MPL *mpl,
alpar@9 974 SYMBOL *sym /* not changed */
alpar@9 975 );
alpar@9 976 /* format symbol for displaying or printing */
alpar@9 977
alpar@9 978 #define concat_symbols _glp_mpl_concat_symbols
alpar@9 979 SYMBOL *concat_symbols
alpar@9 980 ( MPL *mpl,
alpar@9 981 SYMBOL *sym1, /* destroyed */
alpar@9 982 SYMBOL *sym2 /* destroyed */
alpar@9 983 );
alpar@9 984 /* concatenate one symbol with another */
alpar@9 985
alpar@9 986 /**********************************************************************/
alpar@9 987 /* * * N-TUPLES * * */
alpar@9 988 /**********************************************************************/
alpar@9 989
alpar@9 990 struct TUPLE
alpar@9 991 { /* component of n-tuple; the n-tuple itself is associated with
alpar@9 992 its first component; (note that 0-tuple has no components) */
alpar@9 993 SYMBOL *sym;
alpar@9 994 /* symbol, which the component refers to; cannot be NULL */
alpar@9 995 TUPLE *next;
alpar@9 996 /* the next component of n-tuple */
alpar@9 997 };
alpar@9 998
alpar@9 999 #define create_tuple _glp_mpl_create_tuple
alpar@9 1000 TUPLE *create_tuple(MPL *mpl);
alpar@9 1001 /* create n-tuple */
alpar@9 1002
alpar@9 1003 #define expand_tuple _glp_mpl_expand_tuple
alpar@9 1004 TUPLE *expand_tuple
alpar@9 1005 ( MPL *mpl,
alpar@9 1006 TUPLE *tuple, /* destroyed */
alpar@9 1007 SYMBOL *sym /* destroyed */
alpar@9 1008 );
alpar@9 1009 /* append symbol to n-tuple */
alpar@9 1010
alpar@9 1011 #define tuple_dimen _glp_mpl_tuple_dimen
alpar@9 1012 int tuple_dimen
alpar@9 1013 ( MPL *mpl,
alpar@9 1014 TUPLE *tuple /* not changed */
alpar@9 1015 );
alpar@9 1016 /* determine dimension of n-tuple */
alpar@9 1017
alpar@9 1018 #define copy_tuple _glp_mpl_copy_tuple
alpar@9 1019 TUPLE *copy_tuple
alpar@9 1020 ( MPL *mpl,
alpar@9 1021 TUPLE *tuple /* not changed */
alpar@9 1022 );
alpar@9 1023 /* make copy of n-tuple */
alpar@9 1024
alpar@9 1025 #define compare_tuples _glp_mpl_compare_tuples
alpar@9 1026 int compare_tuples
alpar@9 1027 ( MPL *mpl,
alpar@9 1028 TUPLE *tuple1, /* not changed */
alpar@9 1029 TUPLE *tuple2 /* not changed */
alpar@9 1030 );
alpar@9 1031 /* compare one n-tuple with another */
alpar@9 1032
alpar@9 1033 #define build_subtuple _glp_mpl_build_subtuple
alpar@9 1034 TUPLE *build_subtuple
alpar@9 1035 ( MPL *mpl,
alpar@9 1036 TUPLE *tuple, /* not changed */
alpar@9 1037 int dim
alpar@9 1038 );
alpar@9 1039 /* build subtuple of given n-tuple */
alpar@9 1040
alpar@9 1041 #define delete_tuple _glp_mpl_delete_tuple
alpar@9 1042 void delete_tuple
alpar@9 1043 ( MPL *mpl,
alpar@9 1044 TUPLE *tuple /* destroyed */
alpar@9 1045 );
alpar@9 1046 /* delete n-tuple */
alpar@9 1047
alpar@9 1048 #define format_tuple _glp_mpl_format_tuple
alpar@9 1049 char *format_tuple
alpar@9 1050 ( MPL *mpl,
alpar@9 1051 int c,
alpar@9 1052 TUPLE *tuple /* not changed */
alpar@9 1053 );
alpar@9 1054 /* format n-tuple for displaying or printing */
alpar@9 1055
alpar@9 1056 /**********************************************************************/
alpar@9 1057 /* * * ELEMENTAL SETS * * */
alpar@9 1058 /**********************************************************************/
alpar@9 1059
alpar@9 1060 #if 2 + 2 == 5
alpar@9 1061 struct ELEMSET /* see ARRAY */
alpar@9 1062 { /* elemental set of n-tuples; formally it is a "value" assigned
alpar@9 1063 to members of model sets (like numbers and symbols, which are
alpar@9 1064 values assigned to members of model parameters); note that a
alpar@9 1065 simple model set is not an elemental set, it is 0-dimensional
alpar@9 1066 array, the only member of which (if it exists) is assigned an
alpar@9 1067 elemental set */
alpar@9 1068 #endif
alpar@9 1069
alpar@9 1070 #define create_elemset _glp_mpl_create_elemset
alpar@9 1071 ELEMSET *create_elemset(MPL *mpl, int dim);
alpar@9 1072 /* create elemental set */
alpar@9 1073
alpar@9 1074 #define find_tuple _glp_mpl_find_tuple
alpar@9 1075 MEMBER *find_tuple
alpar@9 1076 ( MPL *mpl,
alpar@9 1077 ELEMSET *set, /* not changed */
alpar@9 1078 TUPLE *tuple /* not changed */
alpar@9 1079 );
alpar@9 1080 /* check if elemental set contains given n-tuple */
alpar@9 1081
alpar@9 1082 #define add_tuple _glp_mpl_add_tuple
alpar@9 1083 MEMBER *add_tuple
alpar@9 1084 ( MPL *mpl,
alpar@9 1085 ELEMSET *set, /* modified */
alpar@9 1086 TUPLE *tuple /* destroyed */
alpar@9 1087 );
alpar@9 1088 /* add new n-tuple to elemental set */
alpar@9 1089
alpar@9 1090 #define check_then_add _glp_mpl_check_then_add
alpar@9 1091 MEMBER *check_then_add
alpar@9 1092 ( MPL *mpl,
alpar@9 1093 ELEMSET *set, /* modified */
alpar@9 1094 TUPLE *tuple /* destroyed */
alpar@9 1095 );
alpar@9 1096 /* check and add new n-tuple to elemental set */
alpar@9 1097
alpar@9 1098 #define copy_elemset _glp_mpl_copy_elemset
alpar@9 1099 ELEMSET *copy_elemset
alpar@9 1100 ( MPL *mpl,
alpar@9 1101 ELEMSET *set /* not changed */
alpar@9 1102 );
alpar@9 1103 /* make copy of elemental set */
alpar@9 1104
alpar@9 1105 #define delete_elemset _glp_mpl_delete_elemset
alpar@9 1106 void delete_elemset
alpar@9 1107 ( MPL *mpl,
alpar@9 1108 ELEMSET *set /* destroyed */
alpar@9 1109 );
alpar@9 1110 /* delete elemental set */
alpar@9 1111
alpar@9 1112 #define arelset_size _glp_mpl_arelset_size
alpar@9 1113 int arelset_size(MPL *mpl, double t0, double tf, double dt);
alpar@9 1114 /* compute size of "arithmetic" elemental set */
alpar@9 1115
alpar@9 1116 #define arelset_member _glp_mpl_arelset_member
alpar@9 1117 double arelset_member(MPL *mpl, double t0, double tf, double dt, int j);
alpar@9 1118 /* compute member of "arithmetic" elemental set */
alpar@9 1119
alpar@9 1120 #define create_arelset _glp_mpl_create_arelset
alpar@9 1121 ELEMSET *create_arelset(MPL *mpl, double t0, double tf, double dt);
alpar@9 1122 /* create "arithmetic" elemental set */
alpar@9 1123
alpar@9 1124 #define set_union _glp_mpl_set_union
alpar@9 1125 ELEMSET *set_union
alpar@9 1126 ( MPL *mpl,
alpar@9 1127 ELEMSET *X, /* destroyed */
alpar@9 1128 ELEMSET *Y /* destroyed */
alpar@9 1129 );
alpar@9 1130 /* union of two elemental sets */
alpar@9 1131
alpar@9 1132 #define set_diff _glp_mpl_set_diff
alpar@9 1133 ELEMSET *set_diff
alpar@9 1134 ( MPL *mpl,
alpar@9 1135 ELEMSET *X, /* destroyed */
alpar@9 1136 ELEMSET *Y /* destroyed */
alpar@9 1137 );
alpar@9 1138 /* difference between two elemental sets */
alpar@9 1139
alpar@9 1140 #define set_symdiff _glp_mpl_set_symdiff
alpar@9 1141 ELEMSET *set_symdiff
alpar@9 1142 ( MPL *mpl,
alpar@9 1143 ELEMSET *X, /* destroyed */
alpar@9 1144 ELEMSET *Y /* destroyed */
alpar@9 1145 );
alpar@9 1146 /* symmetric difference between two elemental sets */
alpar@9 1147
alpar@9 1148 #define set_inter _glp_mpl_set_inter
alpar@9 1149 ELEMSET *set_inter
alpar@9 1150 ( MPL *mpl,
alpar@9 1151 ELEMSET *X, /* destroyed */
alpar@9 1152 ELEMSET *Y /* destroyed */
alpar@9 1153 );
alpar@9 1154 /* intersection of two elemental sets */
alpar@9 1155
alpar@9 1156 #define set_cross _glp_mpl_set_cross
alpar@9 1157 ELEMSET *set_cross
alpar@9 1158 ( MPL *mpl,
alpar@9 1159 ELEMSET *X, /* destroyed */
alpar@9 1160 ELEMSET *Y /* destroyed */
alpar@9 1161 );
alpar@9 1162 /* cross (Cartesian) product of two elemental sets */
alpar@9 1163
alpar@9 1164 /**********************************************************************/
alpar@9 1165 /* * * ELEMENTAL VARIABLES * * */
alpar@9 1166 /**********************************************************************/
alpar@9 1167
alpar@9 1168 struct ELEMVAR
alpar@9 1169 { /* elemental variable; formally it is a "value" assigned to
alpar@9 1170 members of model variables (like numbers and symbols, which
alpar@9 1171 are values assigned to members of model parameters) */
alpar@9 1172 int j;
alpar@9 1173 /* LP column number assigned to this elemental variable */
alpar@9 1174 VARIABLE *var;
alpar@9 1175 /* model variable, which contains this elemental variable */
alpar@9 1176 MEMBER *memb;
alpar@9 1177 /* array member, which is assigned this elemental variable */
alpar@9 1178 double lbnd;
alpar@9 1179 /* lower bound */
alpar@9 1180 double ubnd;
alpar@9 1181 /* upper bound */
alpar@9 1182 double temp;
alpar@9 1183 /* working quantity used in operations on linear forms; normally
alpar@9 1184 it contains floating-point zero */
alpar@9 1185 #if 1 /* 15/V-2010 */
alpar@9 1186 int stat;
alpar@9 1187 double prim, dual;
alpar@9 1188 /* solution components provided by the solver */
alpar@9 1189 #endif
alpar@9 1190 };
alpar@9 1191
alpar@9 1192 /**********************************************************************/
alpar@9 1193 /* * * LINEAR FORMS * * */
alpar@9 1194 /**********************************************************************/
alpar@9 1195
alpar@9 1196 struct FORMULA
alpar@9 1197 { /* term of linear form c * x, where c is a coefficient, x is an
alpar@9 1198 elemental variable; the linear form itself is the sum of terms
alpar@9 1199 and is associated with its first term; (note that the linear
alpar@9 1200 form may be empty that means the sum is equal to zero) */
alpar@9 1201 double coef;
alpar@9 1202 /* coefficient at elemental variable or constant term */
alpar@9 1203 ELEMVAR *var;
alpar@9 1204 /* reference to elemental variable; NULL means constant term */
alpar@9 1205 FORMULA *next;
alpar@9 1206 /* the next term of linear form */
alpar@9 1207 };
alpar@9 1208
alpar@9 1209 #define constant_term _glp_mpl_constant_term
alpar@9 1210 FORMULA *constant_term(MPL *mpl, double coef);
alpar@9 1211 /* create constant term */
alpar@9 1212
alpar@9 1213 #define single_variable _glp_mpl_single_variable
alpar@9 1214 FORMULA *single_variable
alpar@9 1215 ( MPL *mpl,
alpar@9 1216 ELEMVAR *var /* referenced */
alpar@9 1217 );
alpar@9 1218 /* create single variable */
alpar@9 1219
alpar@9 1220 #define copy_formula _glp_mpl_copy_formula
alpar@9 1221 FORMULA *copy_formula
alpar@9 1222 ( MPL *mpl,
alpar@9 1223 FORMULA *form /* not changed */
alpar@9 1224 );
alpar@9 1225 /* make copy of linear form */
alpar@9 1226
alpar@9 1227 #define delete_formula _glp_mpl_delete_formula
alpar@9 1228 void delete_formula
alpar@9 1229 ( MPL *mpl,
alpar@9 1230 FORMULA *form /* destroyed */
alpar@9 1231 );
alpar@9 1232 /* delete linear form */
alpar@9 1233
alpar@9 1234 #define linear_comb _glp_mpl_linear_comb
alpar@9 1235 FORMULA *linear_comb
alpar@9 1236 ( MPL *mpl,
alpar@9 1237 double a, FORMULA *fx, /* destroyed */
alpar@9 1238 double b, FORMULA *fy /* destroyed */
alpar@9 1239 );
alpar@9 1240 /* linear combination of two linear forms */
alpar@9 1241
alpar@9 1242 #define remove_constant _glp_mpl_remove_constant
alpar@9 1243 FORMULA *remove_constant
alpar@9 1244 ( MPL *mpl,
alpar@9 1245 FORMULA *form, /* destroyed */
alpar@9 1246 double *coef /* modified */
alpar@9 1247 );
alpar@9 1248 /* remove constant term from linear form */
alpar@9 1249
alpar@9 1250 #define reduce_terms _glp_mpl_reduce_terms
alpar@9 1251 FORMULA *reduce_terms
alpar@9 1252 ( MPL *mpl,
alpar@9 1253 FORMULA *form /* destroyed */
alpar@9 1254 );
alpar@9 1255 /* reduce identical terms in linear form */
alpar@9 1256
alpar@9 1257 /**********************************************************************/
alpar@9 1258 /* * * ELEMENTAL CONSTRAINTS * * */
alpar@9 1259 /**********************************************************************/
alpar@9 1260
alpar@9 1261 struct ELEMCON
alpar@9 1262 { /* elemental constraint; formally it is a "value" assigned to
alpar@9 1263 members of model constraints (like numbers or symbols, which
alpar@9 1264 are values assigned to members of model parameters) */
alpar@9 1265 int i;
alpar@9 1266 /* LP row number assigned to this elemental constraint */
alpar@9 1267 CONSTRAINT *con;
alpar@9 1268 /* model constraint, which contains this elemental constraint */
alpar@9 1269 MEMBER *memb;
alpar@9 1270 /* array member, which is assigned this elemental constraint */
alpar@9 1271 FORMULA *form;
alpar@9 1272 /* linear form */
alpar@9 1273 double lbnd;
alpar@9 1274 /* lower bound */
alpar@9 1275 double ubnd;
alpar@9 1276 /* upper bound */
alpar@9 1277 #if 1 /* 15/V-2010 */
alpar@9 1278 int stat;
alpar@9 1279 double prim, dual;
alpar@9 1280 /* solution components provided by the solver */
alpar@9 1281 #endif
alpar@9 1282 };
alpar@9 1283
alpar@9 1284 /**********************************************************************/
alpar@9 1285 /* * * GENERIC VALUES * * */
alpar@9 1286 /**********************************************************************/
alpar@9 1287
alpar@9 1288 union VALUE
alpar@9 1289 { /* generic value, which can be assigned to object member or be a
alpar@9 1290 result of evaluation of expression */
alpar@9 1291 /* indicator that specifies the particular type of generic value
alpar@9 1292 is stored in the corresponding array or pseudo-code descriptor
alpar@9 1293 and can be one of the following:
alpar@9 1294 A_NONE - no value
alpar@9 1295 A_NUMERIC - floating-point number
alpar@9 1296 A_SYMBOLIC - symbol
alpar@9 1297 A_LOGICAL - logical value
alpar@9 1298 A_TUPLE - n-tuple
alpar@9 1299 A_ELEMSET - elemental set
alpar@9 1300 A_ELEMVAR - elemental variable
alpar@9 1301 A_FORMULA - linear form
alpar@9 1302 A_ELEMCON - elemental constraint */
alpar@9 1303 void *none; /* null */
alpar@9 1304 double num; /* value */
alpar@9 1305 SYMBOL *sym; /* value */
alpar@9 1306 int bit; /* value */
alpar@9 1307 TUPLE *tuple; /* value */
alpar@9 1308 ELEMSET *set; /* value */
alpar@9 1309 ELEMVAR *var; /* reference */
alpar@9 1310 FORMULA *form; /* value */
alpar@9 1311 ELEMCON *con; /* reference */
alpar@9 1312 };
alpar@9 1313
alpar@9 1314 #define delete_value _glp_mpl_delete_value
alpar@9 1315 void delete_value
alpar@9 1316 ( MPL *mpl,
alpar@9 1317 int type,
alpar@9 1318 VALUE *value /* content destroyed */
alpar@9 1319 );
alpar@9 1320 /* delete generic value */
alpar@9 1321
alpar@9 1322 /**********************************************************************/
alpar@9 1323 /* * * SYMBOLICALLY INDEXED ARRAYS * * */
alpar@9 1324 /**********************************************************************/
alpar@9 1325
alpar@9 1326 struct ARRAY
alpar@9 1327 { /* multi-dimensional array, a set of members indexed over simple
alpar@9 1328 or compound sets of symbols; arrays are used to represent the
alpar@9 1329 contents of model objects (i.e. sets, parameters, variables,
alpar@9 1330 constraints, and objectives); arrays also are used as "values"
alpar@9 1331 that are assigned to members of set objects, in which case the
alpar@9 1332 array itself represents an elemental set */
alpar@9 1333 int type;
alpar@9 1334 /* type of generic values assigned to the array members:
alpar@9 1335 A_NONE - none (members have no assigned values)
alpar@9 1336 A_NUMERIC - floating-point numbers
alpar@9 1337 A_SYMBOLIC - symbols
alpar@9 1338 A_ELEMSET - elemental sets
alpar@9 1339 A_ELEMVAR - elemental variables
alpar@9 1340 A_ELEMCON - elemental constraints */
alpar@9 1341 int dim;
alpar@9 1342 /* dimension of the array that determines number of components in
alpar@9 1343 n-tuples for all members of the array, dim >= 0; dim = 0 means
alpar@9 1344 the array is 0-dimensional */
alpar@9 1345 int size;
alpar@9 1346 /* size of the array, i.e. number of its members */
alpar@9 1347 MEMBER *head;
alpar@9 1348 /* the first array member; NULL means the array is empty */
alpar@9 1349 MEMBER *tail;
alpar@9 1350 /* the last array member; NULL means the array is empty */
alpar@9 1351 AVL *tree;
alpar@9 1352 /* the search tree intended to find array members for logarithmic
alpar@9 1353 time; NULL means the search tree doesn't exist */
alpar@9 1354 ARRAY *prev;
alpar@9 1355 /* the previous array in the translator database */
alpar@9 1356 ARRAY *next;
alpar@9 1357 /* the next array in the translator database */
alpar@9 1358 };
alpar@9 1359
alpar@9 1360 struct MEMBER
alpar@9 1361 { /* array member */
alpar@9 1362 TUPLE *tuple;
alpar@9 1363 /* n-tuple, which identifies the member; number of its components
alpar@9 1364 is the same for all members within the array and determined by
alpar@9 1365 the array dimension; duplicate members are not allowed */
alpar@9 1366 MEMBER *next;
alpar@9 1367 /* the next array member */
alpar@9 1368 VALUE value;
alpar@9 1369 /* generic value assigned to the member */
alpar@9 1370 };
alpar@9 1371
alpar@9 1372 #define create_array _glp_mpl_create_array
alpar@9 1373 ARRAY *create_array(MPL *mpl, int type, int dim);
alpar@9 1374 /* create array */
alpar@9 1375
alpar@9 1376 #define find_member _glp_mpl_find_member
alpar@9 1377 MEMBER *find_member
alpar@9 1378 ( MPL *mpl,
alpar@9 1379 ARRAY *array, /* not changed */
alpar@9 1380 TUPLE *tuple /* not changed */
alpar@9 1381 );
alpar@9 1382 /* find array member with given n-tuple */
alpar@9 1383
alpar@9 1384 #define add_member _glp_mpl_add_member
alpar@9 1385 MEMBER *add_member
alpar@9 1386 ( MPL *mpl,
alpar@9 1387 ARRAY *array, /* modified */
alpar@9 1388 TUPLE *tuple /* destroyed */
alpar@9 1389 );
alpar@9 1390 /* add new member to array */
alpar@9 1391
alpar@9 1392 #define delete_array _glp_mpl_delete_array
alpar@9 1393 void delete_array
alpar@9 1394 ( MPL *mpl,
alpar@9 1395 ARRAY *array /* destroyed */
alpar@9 1396 );
alpar@9 1397 /* delete array */
alpar@9 1398
alpar@9 1399 /**********************************************************************/
alpar@9 1400 /* * * DOMAINS AND DUMMY INDICES * * */
alpar@9 1401 /**********************************************************************/
alpar@9 1402
alpar@9 1403 struct DOMAIN
alpar@9 1404 { /* domain (a simple or compound set); syntactically domain looks
alpar@9 1405 like '{ i in I, (j,k) in S, t in T : <predicate> }'; domains
alpar@9 1406 are used to define sets, over which model objects are indexed,
alpar@9 1407 and also as constituents of iterated operators */
alpar@9 1408 DOMAIN_BLOCK *list;
alpar@9 1409 /* linked list of domain blocks (in the example above such blocks
alpar@9 1410 are 'i in I', '(j,k) in S', and 't in T'); this list cannot be
alpar@9 1411 empty */
alpar@9 1412 CODE *code;
alpar@9 1413 /* pseudo-code for computing the logical predicate, which follows
alpar@9 1414 the colon; NULL means no predicate is specified */
alpar@9 1415 };
alpar@9 1416
alpar@9 1417 struct DOMAIN_BLOCK
alpar@9 1418 { /* domain block; syntactically domain blocks look like 'i in I',
alpar@9 1419 '(j,k) in S', and 't in T' in the example above (in the sequel
alpar@9 1420 sets like I, S, and T are called basic sets) */
alpar@9 1421 DOMAIN_SLOT *list;
alpar@9 1422 /* linked list of domain slots (i.e. indexing positions); number
alpar@9 1423 of slots in this list is the same as dimension of n-tuples in
alpar@9 1424 the basic set; this list cannot be empty */
alpar@9 1425 CODE *code;
alpar@9 1426 /* pseudo-code for computing basic set; cannot be NULL */
alpar@9 1427 TUPLE *backup;
alpar@9 1428 /* if this n-tuple is not empty, current values of dummy indices
alpar@9 1429 in the domain block are the same as components of this n-tuple
alpar@9 1430 (note that this n-tuple may have larger dimension than number
alpar@9 1431 of dummy indices in this block, in which case extra components
alpar@9 1432 are ignored); this n-tuple is used to restore former values of
alpar@9 1433 dummy indices, if they were changed due to recursive calls to
alpar@9 1434 the domain block */
alpar@9 1435 DOMAIN_BLOCK *next;
alpar@9 1436 /* the next block in the same domain */
alpar@9 1437 };
alpar@9 1438
alpar@9 1439 struct DOMAIN_SLOT
alpar@9 1440 { /* domain slot; it specifies an individual indexing position and
alpar@9 1441 defines the corresponding dummy index */
alpar@9 1442 char *name;
alpar@9 1443 /* symbolic name of the dummy index; null pointer means the dummy
alpar@9 1444 index is not explicitly specified */
alpar@9 1445 CODE *code;
alpar@9 1446 /* pseudo-code for computing symbolic value, at which the dummy
alpar@9 1447 index is bound; NULL means the dummy index is free within the
alpar@9 1448 domain scope */
alpar@9 1449 SYMBOL *value;
alpar@9 1450 /* current value assigned to the dummy index; NULL means no value
alpar@9 1451 is assigned at the moment */
alpar@9 1452 CODE *list;
alpar@9 1453 /* linked list of pseudo-codes with operation O_INDEX referring
alpar@9 1454 to this slot; this linked list is used to invalidate resultant
alpar@9 1455 values of the operation, which depend on this dummy index */
alpar@9 1456 DOMAIN_SLOT *next;
alpar@9 1457 /* the next slot in the same domain block */
alpar@9 1458 };
alpar@9 1459
alpar@9 1460 #define assign_dummy_index _glp_mpl_assign_dummy_index
alpar@9 1461 void assign_dummy_index
alpar@9 1462 ( MPL *mpl,
alpar@9 1463 DOMAIN_SLOT *slot, /* modified */
alpar@9 1464 SYMBOL *value /* not changed */
alpar@9 1465 );
alpar@9 1466 /* assign new value to dummy index */
alpar@9 1467
alpar@9 1468 #define update_dummy_indices _glp_mpl_update_dummy_indices
alpar@9 1469 void update_dummy_indices
alpar@9 1470 ( MPL *mpl,
alpar@9 1471 DOMAIN_BLOCK *block /* not changed */
alpar@9 1472 );
alpar@9 1473 /* update current values of dummy indices */
alpar@9 1474
alpar@9 1475 #define enter_domain_block _glp_mpl_enter_domain_block
alpar@9 1476 int enter_domain_block
alpar@9 1477 ( MPL *mpl,
alpar@9 1478 DOMAIN_BLOCK *block, /* not changed */
alpar@9 1479 TUPLE *tuple, /* not changed */
alpar@9 1480 void *info, void (*func)(MPL *mpl, void *info)
alpar@9 1481 );
alpar@9 1482 /* enter domain block */
alpar@9 1483
alpar@9 1484 #define eval_within_domain _glp_mpl_eval_within_domain
alpar@9 1485 int eval_within_domain
alpar@9 1486 ( MPL *mpl,
alpar@9 1487 DOMAIN *domain, /* not changed */
alpar@9 1488 TUPLE *tuple, /* not changed */
alpar@9 1489 void *info, void (*func)(MPL *mpl, void *info)
alpar@9 1490 );
alpar@9 1491 /* perform evaluation within domain scope */
alpar@9 1492
alpar@9 1493 #define loop_within_domain _glp_mpl_loop_within_domain
alpar@9 1494 void loop_within_domain
alpar@9 1495 ( MPL *mpl,
alpar@9 1496 DOMAIN *domain, /* not changed */
alpar@9 1497 void *info, int (*func)(MPL *mpl, void *info)
alpar@9 1498 );
alpar@9 1499 /* perform iterations within domain scope */
alpar@9 1500
alpar@9 1501 #define out_of_domain _glp_mpl_out_of_domain
alpar@9 1502 void out_of_domain
alpar@9 1503 ( MPL *mpl,
alpar@9 1504 char *name, /* not changed */
alpar@9 1505 TUPLE *tuple /* not changed */
alpar@9 1506 );
alpar@9 1507 /* raise domain exception */
alpar@9 1508
alpar@9 1509 #define get_domain_tuple _glp_mpl_get_domain_tuple
alpar@9 1510 TUPLE *get_domain_tuple
alpar@9 1511 ( MPL *mpl,
alpar@9 1512 DOMAIN *domain /* not changed */
alpar@9 1513 );
alpar@9 1514 /* obtain current n-tuple from domain */
alpar@9 1515
alpar@9 1516 #define clean_domain _glp_mpl_clean_domain
alpar@9 1517 void clean_domain(MPL *mpl, DOMAIN *domain);
alpar@9 1518 /* clean domain */
alpar@9 1519
alpar@9 1520 /**********************************************************************/
alpar@9 1521 /* * * MODEL SETS * * */
alpar@9 1522 /**********************************************************************/
alpar@9 1523
alpar@9 1524 struct SET
alpar@9 1525 { /* model set */
alpar@9 1526 char *name;
alpar@9 1527 /* symbolic name; cannot be NULL */
alpar@9 1528 char *alias;
alpar@9 1529 /* alias; NULL means alias is not specified */
alpar@9 1530 int dim; /* aka arity */
alpar@9 1531 /* dimension (number of subscripts); dim = 0 means 0-dimensional
alpar@9 1532 (unsubscripted) set, dim > 0 means set of sets */
alpar@9 1533 DOMAIN *domain;
alpar@9 1534 /* subscript domain; NULL for 0-dimensional set */
alpar@9 1535 int dimen;
alpar@9 1536 /* dimension of n-tuples, which members of this set consist of
alpar@9 1537 (note that the model set itself is an array of elemental sets,
alpar@9 1538 which are its members; so, don't confuse this dimension with
alpar@9 1539 dimension of the model set); always non-zero */
alpar@9 1540 WITHIN *within;
alpar@9 1541 /* list of supersets, which restrict each member of the set to be
alpar@9 1542 in every superset from this list; this list can be empty */
alpar@9 1543 CODE *assign;
alpar@9 1544 /* pseudo-code for computing assigned value; can be NULL */
alpar@9 1545 CODE *option;
alpar@9 1546 /* pseudo-code for computing default value; can be NULL */
alpar@9 1547 GADGET *gadget;
alpar@9 1548 /* plain set used to initialize the array of sets; can be NULL */
alpar@9 1549 int data;
alpar@9 1550 /* data status flag:
alpar@9 1551 0 - no data are provided in the data section
alpar@9 1552 1 - data are provided, but not checked yet
alpar@9 1553 2 - data are provided and have been checked */
alpar@9 1554 ARRAY *array;
alpar@9 1555 /* array of members, which are assigned elemental sets */
alpar@9 1556 };
alpar@9 1557
alpar@9 1558 struct WITHIN
alpar@9 1559 { /* restricting superset list entry */
alpar@9 1560 CODE *code;
alpar@9 1561 /* pseudo-code for computing the superset; cannot be NULL */
alpar@9 1562 WITHIN *next;
alpar@9 1563 /* the next entry for the same set or parameter */
alpar@9 1564 };
alpar@9 1565
alpar@9 1566 struct GADGET
alpar@9 1567 { /* plain set used to initialize the array of sets with data */
alpar@9 1568 SET *set;
alpar@9 1569 /* pointer to plain set; cannot be NULL */
alpar@9 1570 int ind[20]; /* ind[dim+dimen]; */
alpar@9 1571 /* permutation of integers 1, 2, ..., dim+dimen */
alpar@9 1572 };
alpar@9 1573
alpar@9 1574 #define check_elem_set _glp_mpl_check_elem_set
alpar@9 1575 void check_elem_set
alpar@9 1576 ( MPL *mpl,
alpar@9 1577 SET *set, /* not changed */
alpar@9 1578 TUPLE *tuple, /* not changed */
alpar@9 1579 ELEMSET *refer /* not changed */
alpar@9 1580 );
alpar@9 1581 /* check elemental set assigned to set member */
alpar@9 1582
alpar@9 1583 #define take_member_set _glp_mpl_take_member_set
alpar@9 1584 ELEMSET *take_member_set /* returns reference, not value */
alpar@9 1585 ( MPL *mpl,
alpar@9 1586 SET *set, /* not changed */
alpar@9 1587 TUPLE *tuple /* not changed */
alpar@9 1588 );
alpar@9 1589 /* obtain elemental set assigned to set member */
alpar@9 1590
alpar@9 1591 #define eval_member_set _glp_mpl_eval_member_set
alpar@9 1592 ELEMSET *eval_member_set /* returns reference, not value */
alpar@9 1593 ( MPL *mpl,
alpar@9 1594 SET *set, /* not changed */
alpar@9 1595 TUPLE *tuple /* not changed */
alpar@9 1596 );
alpar@9 1597 /* evaluate elemental set assigned to set member */
alpar@9 1598
alpar@9 1599 #define eval_whole_set _glp_mpl_eval_whole_set
alpar@9 1600 void eval_whole_set(MPL *mpl, SET *set);
alpar@9 1601 /* evaluate model set over entire domain */
alpar@9 1602
alpar@9 1603 #define clean_set _glp_mpl_clean_set
alpar@9 1604 void clean_set(MPL *mpl, SET *set);
alpar@9 1605 /* clean model set */
alpar@9 1606
alpar@9 1607 /**********************************************************************/
alpar@9 1608 /* * * MODEL PARAMETERS * * */
alpar@9 1609 /**********************************************************************/
alpar@9 1610
alpar@9 1611 struct PARAMETER
alpar@9 1612 { /* model parameter */
alpar@9 1613 char *name;
alpar@9 1614 /* symbolic name; cannot be NULL */
alpar@9 1615 char *alias;
alpar@9 1616 /* alias; NULL means alias is not specified */
alpar@9 1617 int dim; /* aka arity */
alpar@9 1618 /* dimension (number of subscripts); dim = 0 means 0-dimensional
alpar@9 1619 (unsubscripted) parameter */
alpar@9 1620 DOMAIN *domain;
alpar@9 1621 /* subscript domain; NULL for 0-dimensional parameter */
alpar@9 1622 int type;
alpar@9 1623 /* parameter type:
alpar@9 1624 A_NUMERIC - numeric
alpar@9 1625 A_INTEGER - integer
alpar@9 1626 A_BINARY - binary
alpar@9 1627 A_SYMBOLIC - symbolic */
alpar@9 1628 CONDITION *cond;
alpar@9 1629 /* list of conditions, which restrict each parameter member to
alpar@9 1630 satisfy to every condition from this list; this list is used
alpar@9 1631 only for numeric parameters and can be empty */
alpar@9 1632 WITHIN *in;
alpar@9 1633 /* list of supersets, which restrict each parameter member to be
alpar@9 1634 in every superset from this list; this list is used only for
alpar@9 1635 symbolic parameters and can be empty */
alpar@9 1636 CODE *assign;
alpar@9 1637 /* pseudo-code for computing assigned value; can be NULL */
alpar@9 1638 CODE *option;
alpar@9 1639 /* pseudo-code for computing default value; can be NULL */
alpar@9 1640 int data;
alpar@9 1641 /* data status flag:
alpar@9 1642 0 - no data are provided in the data section
alpar@9 1643 1 - data are provided, but not checked yet
alpar@9 1644 2 - data are provided and have been checked */
alpar@9 1645 SYMBOL *defval;
alpar@9 1646 /* default value provided in the data section; can be NULL */
alpar@9 1647 ARRAY *array;
alpar@9 1648 /* array of members, which are assigned numbers or symbols */
alpar@9 1649 };
alpar@9 1650
alpar@9 1651 struct CONDITION
alpar@9 1652 { /* restricting condition list entry */
alpar@9 1653 int rho;
alpar@9 1654 /* flag that specifies the form of the condition:
alpar@9 1655 O_LT - less than
alpar@9 1656 O_LE - less than or equal to
alpar@9 1657 O_EQ - equal to
alpar@9 1658 O_GE - greater than or equal to
alpar@9 1659 O_GT - greater than
alpar@9 1660 O_NE - not equal to */
alpar@9 1661 CODE *code;
alpar@9 1662 /* pseudo-code for computing the reference value */
alpar@9 1663 CONDITION *next;
alpar@9 1664 /* the next entry for the same parameter */
alpar@9 1665 };
alpar@9 1666
alpar@9 1667 #define check_value_num _glp_mpl_check_value_num
alpar@9 1668 void check_value_num
alpar@9 1669 ( MPL *mpl,
alpar@9 1670 PARAMETER *par, /* not changed */
alpar@9 1671 TUPLE *tuple, /* not changed */
alpar@9 1672 double value
alpar@9 1673 );
alpar@9 1674 /* check numeric value assigned to parameter member */
alpar@9 1675
alpar@9 1676 #define take_member_num _glp_mpl_take_member_num
alpar@9 1677 double take_member_num
alpar@9 1678 ( MPL *mpl,
alpar@9 1679 PARAMETER *par, /* not changed */
alpar@9 1680 TUPLE *tuple /* not changed */
alpar@9 1681 );
alpar@9 1682 /* obtain numeric value assigned to parameter member */
alpar@9 1683
alpar@9 1684 #define eval_member_num _glp_mpl_eval_member_num
alpar@9 1685 double eval_member_num
alpar@9 1686 ( MPL *mpl,
alpar@9 1687 PARAMETER *par, /* not changed */
alpar@9 1688 TUPLE *tuple /* not changed */
alpar@9 1689 );
alpar@9 1690 /* evaluate numeric value assigned to parameter member */
alpar@9 1691
alpar@9 1692 #define check_value_sym _glp_mpl_check_value_sym
alpar@9 1693 void check_value_sym
alpar@9 1694 ( MPL *mpl,
alpar@9 1695 PARAMETER *par, /* not changed */
alpar@9 1696 TUPLE *tuple, /* not changed */
alpar@9 1697 SYMBOL *value /* not changed */
alpar@9 1698 );
alpar@9 1699 /* check symbolic value assigned to parameter member */
alpar@9 1700
alpar@9 1701 #define take_member_sym _glp_mpl_take_member_sym
alpar@9 1702 SYMBOL *take_member_sym /* returns value, not reference */
alpar@9 1703 ( MPL *mpl,
alpar@9 1704 PARAMETER *par, /* not changed */
alpar@9 1705 TUPLE *tuple /* not changed */
alpar@9 1706 );
alpar@9 1707 /* obtain symbolic value assigned to parameter member */
alpar@9 1708
alpar@9 1709 #define eval_member_sym _glp_mpl_eval_member_sym
alpar@9 1710 SYMBOL *eval_member_sym /* returns value, not reference */
alpar@9 1711 ( MPL *mpl,
alpar@9 1712 PARAMETER *par, /* not changed */
alpar@9 1713 TUPLE *tuple /* not changed */
alpar@9 1714 );
alpar@9 1715 /* evaluate symbolic value assigned to parameter member */
alpar@9 1716
alpar@9 1717 #define eval_whole_par _glp_mpl_eval_whole_par
alpar@9 1718 void eval_whole_par(MPL *mpl, PARAMETER *par);
alpar@9 1719 /* evaluate model parameter over entire domain */
alpar@9 1720
alpar@9 1721 #define clean_parameter _glp_mpl_clean_parameter
alpar@9 1722 void clean_parameter(MPL *mpl, PARAMETER *par);
alpar@9 1723 /* clean model parameter */
alpar@9 1724
alpar@9 1725 /**********************************************************************/
alpar@9 1726 /* * * MODEL VARIABLES * * */
alpar@9 1727 /**********************************************************************/
alpar@9 1728
alpar@9 1729 struct VARIABLE
alpar@9 1730 { /* model variable */
alpar@9 1731 char *name;
alpar@9 1732 /* symbolic name; cannot be NULL */
alpar@9 1733 char *alias;
alpar@9 1734 /* alias; NULL means alias is not specified */
alpar@9 1735 int dim; /* aka arity */
alpar@9 1736 /* dimension (number of subscripts); dim = 0 means 0-dimensional
alpar@9 1737 (unsubscripted) variable */
alpar@9 1738 DOMAIN *domain;
alpar@9 1739 /* subscript domain; NULL for 0-dimensional variable */
alpar@9 1740 int type;
alpar@9 1741 /* variable type:
alpar@9 1742 A_NUMERIC - continuous
alpar@9 1743 A_INTEGER - integer
alpar@9 1744 A_BINARY - binary */
alpar@9 1745 CODE *lbnd;
alpar@9 1746 /* pseudo-code for computing lower bound; NULL means lower bound
alpar@9 1747 is not specified */
alpar@9 1748 CODE *ubnd;
alpar@9 1749 /* pseudo-code for computing upper bound; NULL means upper bound
alpar@9 1750 is not specified */
alpar@9 1751 /* if both the pointers lbnd and ubnd refer to the same code, the
alpar@9 1752 variable is fixed at the corresponding value */
alpar@9 1753 ARRAY *array;
alpar@9 1754 /* array of members, which are assigned elemental variables */
alpar@9 1755 };
alpar@9 1756
alpar@9 1757 #define take_member_var _glp_mpl_take_member_var
alpar@9 1758 ELEMVAR *take_member_var /* returns reference */
alpar@9 1759 ( MPL *mpl,
alpar@9 1760 VARIABLE *var, /* not changed */
alpar@9 1761 TUPLE *tuple /* not changed */
alpar@9 1762 );
alpar@9 1763 /* obtain reference to elemental variable */
alpar@9 1764
alpar@9 1765 #define eval_member_var _glp_mpl_eval_member_var
alpar@9 1766 ELEMVAR *eval_member_var /* returns reference */
alpar@9 1767 ( MPL *mpl,
alpar@9 1768 VARIABLE *var, /* not changed */
alpar@9 1769 TUPLE *tuple /* not changed */
alpar@9 1770 );
alpar@9 1771 /* evaluate reference to elemental variable */
alpar@9 1772
alpar@9 1773 #define eval_whole_var _glp_mpl_eval_whole_var
alpar@9 1774 void eval_whole_var(MPL *mpl, VARIABLE *var);
alpar@9 1775 /* evaluate model variable over entire domain */
alpar@9 1776
alpar@9 1777 #define clean_variable _glp_mpl_clean_variable
alpar@9 1778 void clean_variable(MPL *mpl, VARIABLE *var);
alpar@9 1779 /* clean model variable */
alpar@9 1780
alpar@9 1781 /**********************************************************************/
alpar@9 1782 /* * * MODEL CONSTRAINTS AND OBJECTIVES * * */
alpar@9 1783 /**********************************************************************/
alpar@9 1784
alpar@9 1785 struct CONSTRAINT
alpar@9 1786 { /* model constraint or objective */
alpar@9 1787 char *name;
alpar@9 1788 /* symbolic name; cannot be NULL */
alpar@9 1789 char *alias;
alpar@9 1790 /* alias; NULL means alias is not specified */
alpar@9 1791 int dim; /* aka arity */
alpar@9 1792 /* dimension (number of subscripts); dim = 0 means 0-dimensional
alpar@9 1793 (unsubscripted) constraint */
alpar@9 1794 DOMAIN *domain;
alpar@9 1795 /* subscript domain; NULL for 0-dimensional constraint */
alpar@9 1796 int type;
alpar@9 1797 /* constraint type:
alpar@9 1798 A_CONSTRAINT - constraint
alpar@9 1799 A_MINIMIZE - objective (minimization)
alpar@9 1800 A_MAXIMIZE - objective (maximization) */
alpar@9 1801 CODE *code;
alpar@9 1802 /* pseudo-code for computing main linear form; cannot be NULL */
alpar@9 1803 CODE *lbnd;
alpar@9 1804 /* pseudo-code for computing lower bound; NULL means lower bound
alpar@9 1805 is not specified */
alpar@9 1806 CODE *ubnd;
alpar@9 1807 /* pseudo-code for computing upper bound; NULL means upper bound
alpar@9 1808 is not specified */
alpar@9 1809 /* if both the pointers lbnd and ubnd refer to the same code, the
alpar@9 1810 constraint has the form of equation */
alpar@9 1811 ARRAY *array;
alpar@9 1812 /* array of members, which are assigned elemental constraints */
alpar@9 1813 };
alpar@9 1814
alpar@9 1815 #define take_member_con _glp_mpl_take_member_con
alpar@9 1816 ELEMCON *take_member_con /* returns reference */
alpar@9 1817 ( MPL *mpl,
alpar@9 1818 CONSTRAINT *con, /* not changed */
alpar@9 1819 TUPLE *tuple /* not changed */
alpar@9 1820 );
alpar@9 1821 /* obtain reference to elemental constraint */
alpar@9 1822
alpar@9 1823 #define eval_member_con _glp_mpl_eval_member_con
alpar@9 1824 ELEMCON *eval_member_con /* returns reference */
alpar@9 1825 ( MPL *mpl,
alpar@9 1826 CONSTRAINT *con, /* not changed */
alpar@9 1827 TUPLE *tuple /* not changed */
alpar@9 1828 );
alpar@9 1829 /* evaluate reference to elemental constraint */
alpar@9 1830
alpar@9 1831 #define eval_whole_con _glp_mpl_eval_whole_con
alpar@9 1832 void eval_whole_con(MPL *mpl, CONSTRAINT *con);
alpar@9 1833 /* evaluate model constraint over entire domain */
alpar@9 1834
alpar@9 1835 #define clean_constraint _glp_mpl_clean_constraint
alpar@9 1836 void clean_constraint(MPL *mpl, CONSTRAINT *con);
alpar@9 1837 /* clean model constraint */
alpar@9 1838
alpar@9 1839 /**********************************************************************/
alpar@9 1840 /* * * DATA TABLES * * */
alpar@9 1841 /**********************************************************************/
alpar@9 1842
alpar@9 1843 struct TABLE
alpar@9 1844 { /* data table */
alpar@9 1845 char *name;
alpar@9 1846 /* symbolic name; cannot be NULL */
alpar@9 1847 char *alias;
alpar@9 1848 /* alias; NULL means alias is not specified */
alpar@9 1849 int type;
alpar@9 1850 /* table type:
alpar@9 1851 A_INPUT - input table
alpar@9 1852 A_OUTPUT - output table */
alpar@9 1853 TABARG *arg;
alpar@9 1854 /* argument list; cannot be empty */
alpar@9 1855 union
alpar@9 1856 { struct
alpar@9 1857 { SET *set;
alpar@9 1858 /* input set; NULL means the set is not specified */
alpar@9 1859 TABFLD *fld;
alpar@9 1860 /* field list; cannot be empty */
alpar@9 1861 TABIN *list;
alpar@9 1862 /* input list; can be empty */
alpar@9 1863 } in;
alpar@9 1864 struct
alpar@9 1865 { DOMAIN *domain;
alpar@9 1866 /* subscript domain; cannot be NULL */
alpar@9 1867 TABOUT *list;
alpar@9 1868 /* output list; cannot be empty */
alpar@9 1869 } out;
alpar@9 1870 } u;
alpar@9 1871 };
alpar@9 1872
alpar@9 1873 struct TABARG
alpar@9 1874 { /* table argument list entry */
alpar@9 1875 CODE *code;
alpar@9 1876 /* pseudo-code for computing the argument */
alpar@9 1877 TABARG *next;
alpar@9 1878 /* next entry for the same table */
alpar@9 1879 };
alpar@9 1880
alpar@9 1881 struct TABFLD
alpar@9 1882 { /* table field list entry */
alpar@9 1883 char *name;
alpar@9 1884 /* field name; cannot be NULL */
alpar@9 1885 TABFLD *next;
alpar@9 1886 /* next entry for the same table */
alpar@9 1887 };
alpar@9 1888
alpar@9 1889 struct TABIN
alpar@9 1890 { /* table input list entry */
alpar@9 1891 PARAMETER *par;
alpar@9 1892 /* parameter to be read; cannot be NULL */
alpar@9 1893 char *name;
alpar@9 1894 /* column name; cannot be NULL */
alpar@9 1895 TABIN *next;
alpar@9 1896 /* next entry for the same table */
alpar@9 1897 };
alpar@9 1898
alpar@9 1899 struct TABOUT
alpar@9 1900 { /* table output list entry */
alpar@9 1901 CODE *code;
alpar@9 1902 /* pseudo-code for computing the value to be written */
alpar@9 1903 char *name;
alpar@9 1904 /* column name; cannot be NULL */
alpar@9 1905 TABOUT *next;
alpar@9 1906 /* next entry for the same table */
alpar@9 1907 };
alpar@9 1908
alpar@9 1909 struct TABDCA
alpar@9 1910 { /* table driver communication area */
alpar@9 1911 int id;
alpar@9 1912 /* driver identifier (set by mpl_tab_drv_open) */
alpar@9 1913 void *link;
alpar@9 1914 /* driver link pointer (set by mpl_tab_drv_open) */
alpar@9 1915 int na;
alpar@9 1916 /* number of arguments */
alpar@9 1917 char **arg; /* char *arg[1+ns]; */
alpar@9 1918 /* arg[k], 1 <= k <= ns, is pointer to k-th argument */
alpar@9 1919 int nf;
alpar@9 1920 /* number of fields */
alpar@9 1921 char **name; /* char *name[1+nc]; */
alpar@9 1922 /* name[k], 1 <= k <= nc, is name of k-th field */
alpar@9 1923 int *type; /* int type[1+nc]; */
alpar@9 1924 /* type[k], 1 <= k <= nc, is type of k-th field:
alpar@9 1925 '?' - value not assigned
alpar@9 1926 'N' - number
alpar@9 1927 'S' - character string */
alpar@9 1928 double *num; /* double num[1+nc]; */
alpar@9 1929 /* num[k], 1 <= k <= nc, is numeric value of k-th field */
alpar@9 1930 char **str;
alpar@9 1931 /* str[k], 1 <= k <= nc, is string value of k-th field */
alpar@9 1932 };
alpar@9 1933
alpar@9 1934 #define mpl_tab_num_args _glp_mpl_tab_num_args
alpar@9 1935 int mpl_tab_num_args(TABDCA *dca);
alpar@9 1936
alpar@9 1937 #define mpl_tab_get_arg _glp_mpl_tab_get_arg
alpar@9 1938 const char *mpl_tab_get_arg(TABDCA *dca, int k);
alpar@9 1939
alpar@9 1940 #define mpl_tab_num_flds _glp_mpl_tab_num_flds
alpar@9 1941 int mpl_tab_num_flds(TABDCA *dca);
alpar@9 1942
alpar@9 1943 #define mpl_tab_get_name _glp_mpl_tab_get_name
alpar@9 1944 const char *mpl_tab_get_name(TABDCA *dca, int k);
alpar@9 1945
alpar@9 1946 #define mpl_tab_get_type _glp_mpl_tab_get_type
alpar@9 1947 int mpl_tab_get_type(TABDCA *dca, int k);
alpar@9 1948
alpar@9 1949 #define mpl_tab_get_num _glp_mpl_tab_get_num
alpar@9 1950 double mpl_tab_get_num(TABDCA *dca, int k);
alpar@9 1951
alpar@9 1952 #define mpl_tab_get_str _glp_mpl_tab_get_str
alpar@9 1953 const char *mpl_tab_get_str(TABDCA *dca, int k);
alpar@9 1954
alpar@9 1955 #define mpl_tab_set_num _glp_mpl_tab_set_num
alpar@9 1956 void mpl_tab_set_num(TABDCA *dca, int k, double num);
alpar@9 1957
alpar@9 1958 #define mpl_tab_set_str _glp_mpl_tab_set_str
alpar@9 1959 void mpl_tab_set_str(TABDCA *dca, int k, const char *str);
alpar@9 1960
alpar@9 1961 #define mpl_tab_drv_open _glp_mpl_tab_drv_open
alpar@9 1962 void mpl_tab_drv_open(MPL *mpl, int mode);
alpar@9 1963
alpar@9 1964 #define mpl_tab_drv_read _glp_mpl_tab_drv_read
alpar@9 1965 int mpl_tab_drv_read(MPL *mpl);
alpar@9 1966
alpar@9 1967 #define mpl_tab_drv_write _glp_mpl_tab_drv_write
alpar@9 1968 void mpl_tab_drv_write(MPL *mpl);
alpar@9 1969
alpar@9 1970 #define mpl_tab_drv_close _glp_mpl_tab_drv_close
alpar@9 1971 void mpl_tab_drv_close(MPL *mpl);
alpar@9 1972
alpar@9 1973 /**********************************************************************/
alpar@9 1974 /* * * PSEUDO-CODE * * */
alpar@9 1975 /**********************************************************************/
alpar@9 1976
alpar@9 1977 union OPERANDS
alpar@9 1978 { /* operands that participate in pseudo-code operation (choice of
alpar@9 1979 particular operands depends on the operation code) */
alpar@9 1980 /*--------------------------------------------------------------*/
alpar@9 1981 double num; /* O_NUMBER */
alpar@9 1982 /* floaing-point number to be taken */
alpar@9 1983 /*--------------------------------------------------------------*/
alpar@9 1984 char *str; /* O_STRING */
alpar@9 1985 /* character string to be taken */
alpar@9 1986 /*--------------------------------------------------------------*/
alpar@9 1987 struct /* O_INDEX */
alpar@9 1988 { DOMAIN_SLOT *slot;
alpar@9 1989 /* domain slot, which contains dummy index to be taken */
alpar@9 1990 CODE *next;
alpar@9 1991 /* the next pseudo-code with op = O_INDEX, which refers to the
alpar@9 1992 same slot as this one; pointer to the beginning of this list
alpar@9 1993 is stored in the corresponding domain slot */
alpar@9 1994 } index;
alpar@9 1995 /*--------------------------------------------------------------*/
alpar@9 1996 struct /* O_MEMNUM, O_MEMSYM */
alpar@9 1997 { PARAMETER *par;
alpar@9 1998 /* model parameter, which contains member to be taken */
alpar@9 1999 ARG_LIST *list;
alpar@9 2000 /* list of subscripts; NULL for 0-dimensional parameter */
alpar@9 2001 } par;
alpar@9 2002 /*--------------------------------------------------------------*/
alpar@9 2003 struct /* O_MEMSET */
alpar@9 2004 { SET *set;
alpar@9 2005 /* model set, which contains member to be taken */
alpar@9 2006 ARG_LIST *list;
alpar@9 2007 /* list of subscripts; NULL for 0-dimensional set */
alpar@9 2008 } set;
alpar@9 2009 /*--------------------------------------------------------------*/
alpar@9 2010 struct /* O_MEMVAR */
alpar@9 2011 { VARIABLE *var;
alpar@9 2012 /* model variable, which contains member to be taken */
alpar@9 2013 ARG_LIST *list;
alpar@9 2014 /* list of subscripts; NULL for 0-dimensional variable */
alpar@9 2015 #if 1 /* 15/V-2010 */
alpar@9 2016 int suff;
alpar@9 2017 /* suffix specified: */
alpar@9 2018 #define DOT_NONE 0x00 /* none (means variable itself) */
alpar@9 2019 #define DOT_LB 0x01 /* .lb (lower bound) */
alpar@9 2020 #define DOT_UB 0x02 /* .ub (upper bound) */
alpar@9 2021 #define DOT_STATUS 0x03 /* .status (status) */
alpar@9 2022 #define DOT_VAL 0x04 /* .val (primal value) */
alpar@9 2023 #define DOT_DUAL 0x05 /* .dual (dual value) */
alpar@9 2024 #endif
alpar@9 2025 } var;
alpar@9 2026 #if 1 /* 15/V-2010 */
alpar@9 2027 /*--------------------------------------------------------------*/
alpar@9 2028 struct /* O_MEMCON */
alpar@9 2029 { CONSTRAINT *con;
alpar@9 2030 /* model constraint, which contains member to be taken */
alpar@9 2031 ARG_LIST *list;
alpar@9 2032 /* list of subscripys; NULL for 0-dimensional constraint */
alpar@9 2033 int suff;
alpar@9 2034 /* suffix specified (see O_MEMVAR above) */
alpar@9 2035 } con;
alpar@9 2036 #endif
alpar@9 2037 /*--------------------------------------------------------------*/
alpar@9 2038 ARG_LIST *list; /* O_TUPLE, O_MAKE, n-ary operations */
alpar@9 2039 /* list of operands */
alpar@9 2040 /*--------------------------------------------------------------*/
alpar@9 2041 DOMAIN_BLOCK *slice; /* O_SLICE */
alpar@9 2042 /* domain block, which specifies slice (i.e. n-tuple that contains
alpar@9 2043 free dummy indices); this operation is never evaluated */
alpar@9 2044 /*--------------------------------------------------------------*/
alpar@9 2045 struct /* unary, binary, ternary operations */
alpar@9 2046 { CODE *x;
alpar@9 2047 /* pseudo-code for computing first operand */
alpar@9 2048 CODE *y;
alpar@9 2049 /* pseudo-code for computing second operand */
alpar@9 2050 CODE *z;
alpar@9 2051 /* pseudo-code for computing third operand */
alpar@9 2052 } arg;
alpar@9 2053 /*--------------------------------------------------------------*/
alpar@9 2054 struct /* iterated operations */
alpar@9 2055 { DOMAIN *domain;
alpar@9 2056 /* domain, over which the operation is performed */
alpar@9 2057 CODE *x;
alpar@9 2058 /* pseudo-code for computing "integrand" */
alpar@9 2059 } loop;
alpar@9 2060 /*--------------------------------------------------------------*/
alpar@9 2061 };
alpar@9 2062
alpar@9 2063 struct ARG_LIST
alpar@9 2064 { /* operands list entry */
alpar@9 2065 CODE *x;
alpar@9 2066 /* pseudo-code for computing operand */
alpar@9 2067 ARG_LIST *next;
alpar@9 2068 /* the next operand of the same operation */
alpar@9 2069 };
alpar@9 2070
alpar@9 2071 struct CODE
alpar@9 2072 { /* pseudo-code (internal form of expressions) */
alpar@9 2073 int op;
alpar@9 2074 /* operation code: */
alpar@9 2075 #define O_NUMBER 301 /* take floating-point number */
alpar@9 2076 #define O_STRING 302 /* take character string */
alpar@9 2077 #define O_INDEX 303 /* take dummy index */
alpar@9 2078 #define O_MEMNUM 304 /* take member of numeric parameter */
alpar@9 2079 #define O_MEMSYM 305 /* take member of symbolic parameter */
alpar@9 2080 #define O_MEMSET 306 /* take member of set */
alpar@9 2081 #define O_MEMVAR 307 /* take member of variable */
alpar@9 2082 #define O_MEMCON 308 /* take member of constraint */
alpar@9 2083 #define O_TUPLE 309 /* make n-tuple */
alpar@9 2084 #define O_MAKE 310 /* make elemental set of n-tuples */
alpar@9 2085 #define O_SLICE 311 /* define domain block (dummy op) */
alpar@9 2086 /* 0-ary operations --------------------*/
alpar@9 2087 #define O_IRAND224 312 /* pseudo-random in [0, 2^24-1] */
alpar@9 2088 #define O_UNIFORM01 313 /* pseudo-random in [0, 1) */
alpar@9 2089 #define O_NORMAL01 314 /* gaussian random, mu = 0, sigma = 1 */
alpar@9 2090 #define O_GMTIME 315 /* current calendar time (UTC) */
alpar@9 2091 /* unary operations --------------------*/
alpar@9 2092 #define O_CVTNUM 316 /* conversion to numeric */
alpar@9 2093 #define O_CVTSYM 317 /* conversion to symbolic */
alpar@9 2094 #define O_CVTLOG 318 /* conversion to logical */
alpar@9 2095 #define O_CVTTUP 319 /* conversion to 1-tuple */
alpar@9 2096 #define O_CVTLFM 320 /* conversion to linear form */
alpar@9 2097 #define O_PLUS 321 /* unary plus */
alpar@9 2098 #define O_MINUS 322 /* unary minus */
alpar@9 2099 #define O_NOT 323 /* negation (logical "not") */
alpar@9 2100 #define O_ABS 324 /* absolute value */
alpar@9 2101 #define O_CEIL 325 /* round upward ("ceiling of x") */
alpar@9 2102 #define O_FLOOR 326 /* round downward ("floor of x") */
alpar@9 2103 #define O_EXP 327 /* base-e exponential */
alpar@9 2104 #define O_LOG 328 /* natural logarithm */
alpar@9 2105 #define O_LOG10 329 /* common (decimal) logarithm */
alpar@9 2106 #define O_SQRT 330 /* square root */
alpar@9 2107 #define O_SIN 331 /* trigonometric sine */
alpar@9 2108 #define O_COS 332 /* trigonometric cosine */
alpar@9 2109 #define O_ATAN 333 /* trigonometric arctangent */
alpar@9 2110 #define O_ROUND 334 /* round to nearest integer */
alpar@9 2111 #define O_TRUNC 335 /* truncate to nearest integer */
alpar@9 2112 #define O_CARD 336 /* cardinality of set */
alpar@9 2113 #define O_LENGTH 337 /* length of symbolic value */
alpar@9 2114 /* binary operations -------------------*/
alpar@9 2115 #define O_ADD 338 /* addition */
alpar@9 2116 #define O_SUB 339 /* subtraction */
alpar@9 2117 #define O_LESS 340 /* non-negative subtraction */
alpar@9 2118 #define O_MUL 341 /* multiplication */
alpar@9 2119 #define O_DIV 342 /* division */
alpar@9 2120 #define O_IDIV 343 /* quotient of exact division */
alpar@9 2121 #define O_MOD 344 /* remainder of exact division */
alpar@9 2122 #define O_POWER 345 /* exponentiation (raise to power) */
alpar@9 2123 #define O_ATAN2 346 /* trigonometric arctangent */
alpar@9 2124 #define O_ROUND2 347 /* round to n fractional digits */
alpar@9 2125 #define O_TRUNC2 348 /* truncate to n fractional digits */
alpar@9 2126 #define O_UNIFORM 349 /* pseudo-random in [a, b) */
alpar@9 2127 #define O_NORMAL 350 /* gaussian random, given mu and sigma */
alpar@9 2128 #define O_CONCAT 351 /* concatenation */
alpar@9 2129 #define O_LT 352 /* comparison on 'less than' */
alpar@9 2130 #define O_LE 353 /* comparison on 'not greater than' */
alpar@9 2131 #define O_EQ 354 /* comparison on 'equal to' */
alpar@9 2132 #define O_GE 355 /* comparison on 'not less than' */
alpar@9 2133 #define O_GT 356 /* comparison on 'greater than' */
alpar@9 2134 #define O_NE 357 /* comparison on 'not equal to' */
alpar@9 2135 #define O_AND 358 /* conjunction (logical "and") */
alpar@9 2136 #define O_OR 359 /* disjunction (logical "or") */
alpar@9 2137 #define O_UNION 360 /* union */
alpar@9 2138 #define O_DIFF 361 /* difference */
alpar@9 2139 #define O_SYMDIFF 362 /* symmetric difference */
alpar@9 2140 #define O_INTER 363 /* intersection */
alpar@9 2141 #define O_CROSS 364 /* cross (Cartesian) product */
alpar@9 2142 #define O_IN 365 /* test on 'x in Y' */
alpar@9 2143 #define O_NOTIN 366 /* test on 'x not in Y' */
alpar@9 2144 #define O_WITHIN 367 /* test on 'X within Y' */
alpar@9 2145 #define O_NOTWITHIN 368 /* test on 'X not within Y' */
alpar@9 2146 #define O_SUBSTR 369 /* substring */
alpar@9 2147 #define O_STR2TIME 370 /* convert string to time */
alpar@9 2148 #define O_TIME2STR 371 /* convert time to string */
alpar@9 2149 /* ternary operations ------------------*/
alpar@9 2150 #define O_DOTS 372 /* build "arithmetic" set */
alpar@9 2151 #define O_FORK 373 /* if-then-else */
alpar@9 2152 #define O_SUBSTR3 374 /* substring */
alpar@9 2153 /* n-ary operations --------------------*/
alpar@9 2154 #define O_MIN 375 /* minimal value (n-ary) */
alpar@9 2155 #define O_MAX 376 /* maximal value (n-ary) */
alpar@9 2156 /* iterated operations -----------------*/
alpar@9 2157 #define O_SUM 377 /* summation */
alpar@9 2158 #define O_PROD 378 /* multiplication */
alpar@9 2159 #define O_MINIMUM 379 /* minimum */
alpar@9 2160 #define O_MAXIMUM 380 /* maximum */
alpar@9 2161 #define O_FORALL 381 /* conjunction (A-quantification) */
alpar@9 2162 #define O_EXISTS 382 /* disjunction (E-quantification) */
alpar@9 2163 #define O_SETOF 383 /* compute elemental set */
alpar@9 2164 #define O_BUILD 384 /* build elemental set */
alpar@9 2165 OPERANDS arg;
alpar@9 2166 /* operands that participate in the operation */
alpar@9 2167 int type;
alpar@9 2168 /* type of the resultant value:
alpar@9 2169 A_NUMERIC - numeric
alpar@9 2170 A_SYMBOLIC - symbolic
alpar@9 2171 A_LOGICAL - logical
alpar@9 2172 A_TUPLE - n-tuple
alpar@9 2173 A_ELEMSET - elemental set
alpar@9 2174 A_FORMULA - linear form */
alpar@9 2175 int dim;
alpar@9 2176 /* dimension of the resultant value; for A_TUPLE and A_ELEMSET it
alpar@9 2177 is the dimension of the corresponding n-tuple(s) and cannot be
alpar@9 2178 zero; for other resultant types it is always zero */
alpar@9 2179 CODE *up;
alpar@9 2180 /* parent pseudo-code, which refers to this pseudo-code as to its
alpar@9 2181 operand; NULL means this pseudo-code has no parent and defines
alpar@9 2182 an expression, which is not contained in another expression */
alpar@9 2183 int vflag;
alpar@9 2184 /* volatile flag; being set this flag means that this operation
alpar@9 2185 has a side effect; for primary expressions this flag is set
alpar@9 2186 directly by corresponding parsing routines (for example, if
alpar@9 2187 primary expression is a reference to a function that generates
alpar@9 2188 pseudo-random numbers); in other cases this flag is inherited
alpar@9 2189 from operands */
alpar@9 2190 int valid;
alpar@9 2191 /* if this flag is set, the resultant value, which is a temporary
alpar@9 2192 result of evaluating this operation on particular values of
alpar@9 2193 operands, is valid; if this flag is clear, the resultant value
alpar@9 2194 doesn't exist and therefore not valid; having been evaluated
alpar@9 2195 the resultant value is stored here and not destroyed until the
alpar@9 2196 dummy indices, which this value depends on, have been changed
alpar@9 2197 (and if it doesn't depend on dummy indices at all, it is never
alpar@9 2198 destroyed); thus, if the resultant value is valid, evaluating
alpar@9 2199 routine can immediately take its copy not computing the result
alpar@9 2200 from scratch; this mechanism is similar to moving invariants
alpar@9 2201 out of loops and allows improving efficiency at the expense of
alpar@9 2202 some extra memory needed to keep temporary results */
alpar@9 2203 /* however, if the volatile flag (see above) is set, even if the
alpar@9 2204 resultant value is valid, evaluating routine computes it as if
alpar@9 2205 it were not valid, i.e. caching is not used in this case */
alpar@9 2206 VALUE value;
alpar@9 2207 /* resultant value in generic format */
alpar@9 2208 };
alpar@9 2209
alpar@9 2210 #define eval_numeric _glp_mpl_eval_numeric
alpar@9 2211 double eval_numeric(MPL *mpl, CODE *code);
alpar@9 2212 /* evaluate pseudo-code to determine numeric value */
alpar@9 2213
alpar@9 2214 #define eval_symbolic _glp_mpl_eval_symbolic
alpar@9 2215 SYMBOL *eval_symbolic(MPL *mpl, CODE *code);
alpar@9 2216 /* evaluate pseudo-code to determine symbolic value */
alpar@9 2217
alpar@9 2218 #define eval_logical _glp_mpl_eval_logical
alpar@9 2219 int eval_logical(MPL *mpl, CODE *code);
alpar@9 2220 /* evaluate pseudo-code to determine logical value */
alpar@9 2221
alpar@9 2222 #define eval_tuple _glp_mpl_eval_tuple
alpar@9 2223 TUPLE *eval_tuple(MPL *mpl, CODE *code);
alpar@9 2224 /* evaluate pseudo-code to construct n-tuple */
alpar@9 2225
alpar@9 2226 #define eval_elemset _glp_mpl_eval_elemset
alpar@9 2227 ELEMSET *eval_elemset(MPL *mpl, CODE *code);
alpar@9 2228 /* evaluate pseudo-code to construct elemental set */
alpar@9 2229
alpar@9 2230 #define is_member _glp_mpl_is_member
alpar@9 2231 int is_member(MPL *mpl, CODE *code, TUPLE *tuple);
alpar@9 2232 /* check if n-tuple is in set specified by pseudo-code */
alpar@9 2233
alpar@9 2234 #define eval_formula _glp_mpl_eval_formula
alpar@9 2235 FORMULA *eval_formula(MPL *mpl, CODE *code);
alpar@9 2236 /* evaluate pseudo-code to construct linear form */
alpar@9 2237
alpar@9 2238 #define clean_code _glp_mpl_clean_code
alpar@9 2239 void clean_code(MPL *mpl, CODE *code);
alpar@9 2240 /* clean pseudo-code */
alpar@9 2241
alpar@9 2242 /**********************************************************************/
alpar@9 2243 /* * * MODEL STATEMENTS * * */
alpar@9 2244 /**********************************************************************/
alpar@9 2245
alpar@9 2246 struct CHECK
alpar@9 2247 { /* check statement */
alpar@9 2248 DOMAIN *domain;
alpar@9 2249 /* subscript domain; NULL means domain is not used */
alpar@9 2250 CODE *code;
alpar@9 2251 /* code for computing the predicate to be checked */
alpar@9 2252 };
alpar@9 2253
alpar@9 2254 struct DISPLAY
alpar@9 2255 { /* display statement */
alpar@9 2256 DOMAIN *domain;
alpar@9 2257 /* subscript domain; NULL means domain is not used */
alpar@9 2258 DISPLAY1 *list;
alpar@9 2259 /* display list; cannot be empty */
alpar@9 2260 };
alpar@9 2261
alpar@9 2262 struct DISPLAY1
alpar@9 2263 { /* display list entry */
alpar@9 2264 int type;
alpar@9 2265 /* item type:
alpar@9 2266 A_INDEX - dummy index
alpar@9 2267 A_SET - model set
alpar@9 2268 A_PARAMETER - model parameter
alpar@9 2269 A_VARIABLE - model variable
alpar@9 2270 A_CONSTRAINT - model constraint/objective
alpar@9 2271 A_EXPRESSION - expression */
alpar@9 2272 union
alpar@9 2273 { DOMAIN_SLOT *slot;
alpar@9 2274 SET *set;
alpar@9 2275 PARAMETER *par;
alpar@9 2276 VARIABLE *var;
alpar@9 2277 CONSTRAINT *con;
alpar@9 2278 CODE *code;
alpar@9 2279 } u;
alpar@9 2280 /* item to be displayed */
alpar@9 2281 #if 0 /* 15/V-2010 */
alpar@9 2282 ARG_LIST *list;
alpar@9 2283 /* optional subscript list (for constraint/objective only) */
alpar@9 2284 #endif
alpar@9 2285 DISPLAY1 *next;
alpar@9 2286 /* the next entry for the same statement */
alpar@9 2287 };
alpar@9 2288
alpar@9 2289 struct PRINTF
alpar@9 2290 { /* printf statement */
alpar@9 2291 DOMAIN *domain;
alpar@9 2292 /* subscript domain; NULL means domain is not used */
alpar@9 2293 CODE *fmt;
alpar@9 2294 /* pseudo-code for computing format string */
alpar@9 2295 PRINTF1 *list;
alpar@9 2296 /* printf list; can be empty */
alpar@9 2297 CODE *fname;
alpar@9 2298 /* pseudo-code for computing filename to redirect the output;
alpar@9 2299 NULL means the output goes to stdout */
alpar@9 2300 int app;
alpar@9 2301 /* if this flag is set, the output is appended */
alpar@9 2302 };
alpar@9 2303
alpar@9 2304 struct PRINTF1
alpar@9 2305 { /* printf list entry */
alpar@9 2306 CODE *code;
alpar@9 2307 /* pseudo-code for computing value to be printed */
alpar@9 2308 PRINTF1 *next;
alpar@9 2309 /* the next entry for the same statement */
alpar@9 2310 };
alpar@9 2311
alpar@9 2312 struct FOR
alpar@9 2313 { /* for statement */
alpar@9 2314 DOMAIN *domain;
alpar@9 2315 /* subscript domain; cannot be NULL */
alpar@9 2316 STATEMENT *list;
alpar@9 2317 /* linked list of model statements within this for statement in
alpar@9 2318 the original order */
alpar@9 2319 };
alpar@9 2320
alpar@9 2321 struct STATEMENT
alpar@9 2322 { /* model statement */
alpar@9 2323 int line;
alpar@9 2324 /* number of source text line, where statement begins */
alpar@9 2325 int type;
alpar@9 2326 /* statement type:
alpar@9 2327 A_SET - set statement
alpar@9 2328 A_PARAMETER - parameter statement
alpar@9 2329 A_VARIABLE - variable statement
alpar@9 2330 A_CONSTRAINT - constraint/objective statement
alpar@9 2331 A_TABLE - table statement
alpar@9 2332 A_SOLVE - solve statement
alpar@9 2333 A_CHECK - check statement
alpar@9 2334 A_DISPLAY - display statement
alpar@9 2335 A_PRINTF - printf statement
alpar@9 2336 A_FOR - for statement */
alpar@9 2337 union
alpar@9 2338 { SET *set;
alpar@9 2339 PARAMETER *par;
alpar@9 2340 VARIABLE *var;
alpar@9 2341 CONSTRAINT *con;
alpar@9 2342 TABLE *tab;
alpar@9 2343 void *slv; /* currently not used (set to NULL) */
alpar@9 2344 CHECK *chk;
alpar@9 2345 DISPLAY *dpy;
alpar@9 2346 PRINTF *prt;
alpar@9 2347 FOR *fur;
alpar@9 2348 } u;
alpar@9 2349 /* specific part of statement */
alpar@9 2350 STATEMENT *next;
alpar@9 2351 /* the next statement; in this list statements follow in the same
alpar@9 2352 order as they appear in the model section */
alpar@9 2353 };
alpar@9 2354
alpar@9 2355 #define execute_table _glp_mpl_execute_table
alpar@9 2356 void execute_table(MPL *mpl, TABLE *tab);
alpar@9 2357 /* execute table statement */
alpar@9 2358
alpar@9 2359 #define free_dca _glp_mpl_free_dca
alpar@9 2360 void free_dca(MPL *mpl);
alpar@9 2361 /* free table driver communucation area */
alpar@9 2362
alpar@9 2363 #define clean_table _glp_mpl_clean_table
alpar@9 2364 void clean_table(MPL *mpl, TABLE *tab);
alpar@9 2365 /* clean table statement */
alpar@9 2366
alpar@9 2367 #define execute_check _glp_mpl_execute_check
alpar@9 2368 void execute_check(MPL *mpl, CHECK *chk);
alpar@9 2369 /* execute check statement */
alpar@9 2370
alpar@9 2371 #define clean_check _glp_mpl_clean_check
alpar@9 2372 void clean_check(MPL *mpl, CHECK *chk);
alpar@9 2373 /* clean check statement */
alpar@9 2374
alpar@9 2375 #define execute_display _glp_mpl_execute_display
alpar@9 2376 void execute_display(MPL *mpl, DISPLAY *dpy);
alpar@9 2377 /* execute display statement */
alpar@9 2378
alpar@9 2379 #define clean_display _glp_mpl_clean_display
alpar@9 2380 void clean_display(MPL *mpl, DISPLAY *dpy);
alpar@9 2381 /* clean display statement */
alpar@9 2382
alpar@9 2383 #define execute_printf _glp_mpl_execute_printf
alpar@9 2384 void execute_printf(MPL *mpl, PRINTF *prt);
alpar@9 2385 /* execute printf statement */
alpar@9 2386
alpar@9 2387 #define clean_printf _glp_mpl_clean_printf
alpar@9 2388 void clean_printf(MPL *mpl, PRINTF *prt);
alpar@9 2389 /* clean printf statement */
alpar@9 2390
alpar@9 2391 #define execute_for _glp_mpl_execute_for
alpar@9 2392 void execute_for(MPL *mpl, FOR *fur);
alpar@9 2393 /* execute for statement */
alpar@9 2394
alpar@9 2395 #define clean_for _glp_mpl_clean_for
alpar@9 2396 void clean_for(MPL *mpl, FOR *fur);
alpar@9 2397 /* clean for statement */
alpar@9 2398
alpar@9 2399 #define execute_statement _glp_mpl_execute_statement
alpar@9 2400 void execute_statement(MPL *mpl, STATEMENT *stmt);
alpar@9 2401 /* execute specified model statement */
alpar@9 2402
alpar@9 2403 #define clean_statement _glp_mpl_clean_statement
alpar@9 2404 void clean_statement(MPL *mpl, STATEMENT *stmt);
alpar@9 2405 /* clean specified model statement */
alpar@9 2406
alpar@9 2407 /**********************************************************************/
alpar@9 2408 /* * * GENERATING AND POSTSOLVING MODEL * * */
alpar@9 2409 /**********************************************************************/
alpar@9 2410
alpar@9 2411 #define alloc_content _glp_mpl_alloc_content
alpar@9 2412 void alloc_content(MPL *mpl);
alpar@9 2413 /* allocate content arrays for all model objects */
alpar@9 2414
alpar@9 2415 #define generate_model _glp_mpl_generate_model
alpar@9 2416 void generate_model(MPL *mpl);
alpar@9 2417 /* generate model */
alpar@9 2418
alpar@9 2419 #define build_problem _glp_mpl_build_problem
alpar@9 2420 void build_problem(MPL *mpl);
alpar@9 2421 /* build problem instance */
alpar@9 2422
alpar@9 2423 #define postsolve_model _glp_mpl_postsolve_model
alpar@9 2424 void postsolve_model(MPL *mpl);
alpar@9 2425 /* postsolve model */
alpar@9 2426
alpar@9 2427 #define clean_model _glp_mpl_clean_model
alpar@9 2428 void clean_model(MPL *mpl);
alpar@9 2429 /* clean model content */
alpar@9 2430
alpar@9 2431 /**********************************************************************/
alpar@9 2432 /* * * INPUT/OUTPUT * * */
alpar@9 2433 /**********************************************************************/
alpar@9 2434
alpar@9 2435 #define open_input _glp_mpl_open_input
alpar@9 2436 void open_input(MPL *mpl, char *file);
alpar@9 2437 /* open input text file */
alpar@9 2438
alpar@9 2439 #define read_char _glp_mpl_read_char
alpar@9 2440 int read_char(MPL *mpl);
alpar@9 2441 /* read next character from input text file */
alpar@9 2442
alpar@9 2443 #define close_input _glp_mpl_close_input
alpar@9 2444 void close_input(MPL *mpl);
alpar@9 2445 /* close input text file */
alpar@9 2446
alpar@9 2447 #define open_output _glp_mpl_open_output
alpar@9 2448 void open_output(MPL *mpl, char *file);
alpar@9 2449 /* open output text file */
alpar@9 2450
alpar@9 2451 #define write_char _glp_mpl_write_char
alpar@9 2452 void write_char(MPL *mpl, int c);
alpar@9 2453 /* write next character to output text file */
alpar@9 2454
alpar@9 2455 #define write_text _glp_mpl_write_text
alpar@9 2456 void write_text(MPL *mpl, char *fmt, ...);
alpar@9 2457 /* format and write text to output text file */
alpar@9 2458
alpar@9 2459 #define flush_output _glp_mpl_flush_output
alpar@9 2460 void flush_output(MPL *mpl);
alpar@9 2461 /* finalize writing data to output text file */
alpar@9 2462
alpar@9 2463 /**********************************************************************/
alpar@9 2464 /* * * SOLVER INTERFACE * * */
alpar@9 2465 /**********************************************************************/
alpar@9 2466
alpar@9 2467 #define MPL_FR 401 /* free (unbounded) */
alpar@9 2468 #define MPL_LO 402 /* lower bound */
alpar@9 2469 #define MPL_UP 403 /* upper bound */
alpar@9 2470 #define MPL_DB 404 /* both lower and upper bounds */
alpar@9 2471 #define MPL_FX 405 /* fixed */
alpar@9 2472
alpar@9 2473 #define MPL_ST 411 /* constraint */
alpar@9 2474 #define MPL_MIN 412 /* objective (minimization) */
alpar@9 2475 #define MPL_MAX 413 /* objective (maximization) */
alpar@9 2476
alpar@9 2477 #define MPL_NUM 421 /* continuous */
alpar@9 2478 #define MPL_INT 422 /* integer */
alpar@9 2479 #define MPL_BIN 423 /* binary */
alpar@9 2480
alpar@9 2481 #define error _glp_mpl_error
alpar@9 2482 void error(MPL *mpl, char *fmt, ...);
alpar@9 2483 /* print error message and terminate model processing */
alpar@9 2484
alpar@9 2485 #define warning _glp_mpl_warning
alpar@9 2486 void warning(MPL *mpl, char *fmt, ...);
alpar@9 2487 /* print warning message and continue model processing */
alpar@9 2488
alpar@9 2489 #define mpl_initialize _glp_mpl_initialize
alpar@9 2490 MPL *mpl_initialize(void);
alpar@9 2491 /* create and initialize translator database */
alpar@9 2492
alpar@9 2493 #define mpl_read_model _glp_mpl_read_model
alpar@9 2494 int mpl_read_model(MPL *mpl, char *file, int skip_data);
alpar@9 2495 /* read model section and optional data section */
alpar@9 2496
alpar@9 2497 #define mpl_read_data _glp_mpl_read_data
alpar@9 2498 int mpl_read_data(MPL *mpl, char *file);
alpar@9 2499 /* read data section */
alpar@9 2500
alpar@9 2501 #define mpl_generate _glp_mpl_generate
alpar@9 2502 int mpl_generate(MPL *mpl, char *file);
alpar@9 2503 /* generate model */
alpar@9 2504
alpar@9 2505 #define mpl_get_prob_name _glp_mpl_get_prob_name
alpar@9 2506 char *mpl_get_prob_name(MPL *mpl);
alpar@9 2507 /* obtain problem (model) name */
alpar@9 2508
alpar@9 2509 #define mpl_get_num_rows _glp_mpl_get_num_rows
alpar@9 2510 int mpl_get_num_rows(MPL *mpl);
alpar@9 2511 /* determine number of rows */
alpar@9 2512
alpar@9 2513 #define mpl_get_num_cols _glp_mpl_get_num_cols
alpar@9 2514 int mpl_get_num_cols(MPL *mpl);
alpar@9 2515 /* determine number of columns */
alpar@9 2516
alpar@9 2517 #define mpl_get_row_name _glp_mpl_get_row_name
alpar@9 2518 char *mpl_get_row_name(MPL *mpl, int i);
alpar@9 2519 /* obtain row name */
alpar@9 2520
alpar@9 2521 #define mpl_get_row_kind _glp_mpl_get_row_kind
alpar@9 2522 int mpl_get_row_kind(MPL *mpl, int i);
alpar@9 2523 /* determine row kind */
alpar@9 2524
alpar@9 2525 #define mpl_get_row_bnds _glp_mpl_get_row_bnds
alpar@9 2526 int mpl_get_row_bnds(MPL *mpl, int i, double *lb, double *ub);
alpar@9 2527 /* obtain row bounds */
alpar@9 2528
alpar@9 2529 #define mpl_get_mat_row _glp_mpl_get_mat_row
alpar@9 2530 int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[]);
alpar@9 2531 /* obtain row of the constraint matrix */
alpar@9 2532
alpar@9 2533 #define mpl_get_row_c0 _glp_mpl_get_row_c0
alpar@9 2534 double mpl_get_row_c0(MPL *mpl, int i);
alpar@9 2535 /* obtain constant term of free row */
alpar@9 2536
alpar@9 2537 #define mpl_get_col_name _glp_mpl_get_col_name
alpar@9 2538 char *mpl_get_col_name(MPL *mpl, int j);
alpar@9 2539 /* obtain column name */
alpar@9 2540
alpar@9 2541 #define mpl_get_col_kind _glp_mpl_get_col_kind
alpar@9 2542 int mpl_get_col_kind(MPL *mpl, int j);
alpar@9 2543 /* determine column kind */
alpar@9 2544
alpar@9 2545 #define mpl_get_col_bnds _glp_mpl_get_col_bnds
alpar@9 2546 int mpl_get_col_bnds(MPL *mpl, int j, double *lb, double *ub);
alpar@9 2547 /* obtain column bounds */
alpar@9 2548
alpar@9 2549 #define mpl_has_solve_stmt _glp_mpl_has_solve_stmt
alpar@9 2550 int mpl_has_solve_stmt(MPL *mpl);
alpar@9 2551 /* check if model has solve statement */
alpar@9 2552
alpar@9 2553 #if 1 /* 15/V-2010 */
alpar@9 2554 #define mpl_put_row_soln _glp_mpl_put_row_soln
alpar@9 2555 void mpl_put_row_soln(MPL *mpl, int i, int stat, double prim,
alpar@9 2556 double dual);
alpar@9 2557 /* store row (constraint/objective) solution components */
alpar@9 2558 #endif
alpar@9 2559
alpar@9 2560 #if 1 /* 15/V-2010 */
alpar@9 2561 #define mpl_put_col_soln _glp_mpl_put_col_soln
alpar@9 2562 void mpl_put_col_soln(MPL *mpl, int j, int stat, double prim,
alpar@9 2563 double dual);
alpar@9 2564 /* store column (variable) solution components */
alpar@9 2565 #endif
alpar@9 2566
alpar@9 2567 #if 0 /* 15/V-2010 */
alpar@9 2568 #define mpl_put_col_value _glp_mpl_put_col_value
alpar@9 2569 void mpl_put_col_value(MPL *mpl, int j, double val);
alpar@9 2570 /* store column value */
alpar@9 2571 #endif
alpar@9 2572
alpar@9 2573 #define mpl_postsolve _glp_mpl_postsolve
alpar@9 2574 int mpl_postsolve(MPL *mpl);
alpar@9 2575 /* postsolve model */
alpar@9 2576
alpar@9 2577 #define mpl_terminate _glp_mpl_terminate
alpar@9 2578 void mpl_terminate(MPL *mpl);
alpar@9 2579 /* free all resources used by translator */
alpar@9 2580
alpar@9 2581 #endif
alpar@9 2582
alpar@9 2583 /* eof */