1 /* glpmpl.h (GNU MathProg translator) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
31 typedef struct MPL MPL;
33 typedef struct SYMBOL SYMBOL;
34 typedef struct TUPLE TUPLE;
35 typedef struct ARRAY ELEMSET;
36 typedef struct ELEMVAR ELEMVAR;
37 typedef struct FORMULA FORMULA;
38 typedef struct ELEMCON ELEMCON;
39 typedef union VALUE VALUE;
40 typedef struct ARRAY ARRAY;
41 typedef struct MEMBER MEMBER;
43 /* many C compilers have DOMAIN declared in <math.h> :( */
45 #define DOMAIN DOMAIN1
47 typedef struct DOMAIN DOMAIN;
48 typedef struct DOMAIN_BLOCK DOMAIN_BLOCK;
49 typedef struct DOMAIN_SLOT DOMAIN_SLOT;
50 typedef struct SET SET;
51 typedef struct WITHIN WITHIN;
52 typedef struct GADGET GADGET;
53 typedef struct PARAMETER PARAMETER;
54 typedef struct CONDITION CONDITION;
55 typedef struct VARIABLE VARIABLE;
56 typedef struct CONSTRAINT CONSTRAINT;
57 typedef struct TABLE TABLE;
58 typedef struct TABARG TABARG;
59 typedef struct TABFLD TABFLD;
60 typedef struct TABIN TABIN;
61 typedef struct TABOUT TABOUT;
62 typedef struct TABDCA TABDCA;
63 typedef union OPERANDS OPERANDS;
64 typedef struct ARG_LIST ARG_LIST;
65 typedef struct CODE CODE;
66 typedef struct CHECK CHECK;
67 typedef struct DISPLAY DISPLAY;
68 typedef struct DISPLAY1 DISPLAY1;
69 typedef struct PRINTF PRINTF;
70 typedef struct PRINTF1 PRINTF1;
71 typedef struct FOR FOR;
72 typedef struct STATEMENT STATEMENT;
73 typedef struct TUPLE SLICE;
75 /**********************************************************************/
76 /* * * TRANSLATOR DATABASE * * */
77 /**********************************************************************/
79 #define A_BINARY 101 /* something binary */
80 #define A_CHECK 102 /* check statement */
81 #define A_CONSTRAINT 103 /* model constraint */
82 #define A_DISPLAY 104 /* display statement */
83 #define A_ELEMCON 105 /* elemental constraint/objective */
84 #define A_ELEMSET 106 /* elemental set */
85 #define A_ELEMVAR 107 /* elemental variable */
86 #define A_EXPRESSION 108 /* expression */
87 #define A_FOR 109 /* for statement */
88 #define A_FORMULA 110 /* formula */
89 #define A_INDEX 111 /* dummy index */
90 #define A_INPUT 112 /* input table */
91 #define A_INTEGER 113 /* something integer */
92 #define A_LOGICAL 114 /* something logical */
93 #define A_MAXIMIZE 115 /* objective has to be maximized */
94 #define A_MINIMIZE 116 /* objective has to be minimized */
95 #define A_NONE 117 /* nothing */
96 #define A_NUMERIC 118 /* something numeric */
97 #define A_OUTPUT 119 /* output table */
98 #define A_PARAMETER 120 /* model parameter */
99 #define A_PRINTF 121 /* printf statement */
100 #define A_SET 122 /* model set */
101 #define A_SOLVE 123 /* solve statement */
102 #define A_SYMBOLIC 124 /* something symbolic */
103 #define A_TABLE 125 /* data table */
104 #define A_TUPLE 126 /* n-tuple */
105 #define A_VARIABLE 127 /* model variable */
107 #define MAX_LENGTH 100
108 /* maximal length of any symbolic value (this includes symbolic names,
109 numeric and string literals, and all symbolic values that may appear
110 during the evaluation phase) */
112 #define CONTEXT_SIZE 60
113 /* size of the context queue, in characters */
115 #define OUTBUF_SIZE 1024
116 /* size of the output buffer, in characters */
119 { /* translator database */
120 /*--------------------------------------------------------------*/
121 /* scanning segment */
123 /* number of the current text line */
125 /* the current character or EOF */
127 /* the current token: */
128 #define T_EOF 201 /* end of file */
129 #define T_NAME 202 /* symbolic name (model section only) */
130 #define T_SYMBOL 203 /* symbol (data section only) */
131 #define T_NUMBER 204 /* numeric literal */
132 #define T_STRING 205 /* string literal */
133 #define T_AND 206 /* and && */
134 #define T_BY 207 /* by */
135 #define T_CROSS 208 /* cross */
136 #define T_DIFF 209 /* diff */
137 #define T_DIV 210 /* div */
138 #define T_ELSE 211 /* else */
139 #define T_IF 212 /* if */
140 #define T_IN 213 /* in */
141 #define T_INFINITY 214 /* Infinity */
142 #define T_INTER 215 /* inter */
143 #define T_LESS 216 /* less */
144 #define T_MOD 217 /* mod */
145 #define T_NOT 218 /* not ! */
146 #define T_OR 219 /* or || */
147 #define T_SPTP 220 /* s.t. */
148 #define T_SYMDIFF 221 /* symdiff */
149 #define T_THEN 222 /* then */
150 #define T_UNION 223 /* union */
151 #define T_WITHIN 224 /* within */
152 #define T_PLUS 225 /* + */
153 #define T_MINUS 226 /* - */
154 #define T_ASTERISK 227 /* * */
155 #define T_SLASH 228 /* / */
156 #define T_POWER 229 /* ^ ** */
157 #define T_LT 230 /* < */
158 #define T_LE 231 /* <= */
159 #define T_EQ 232 /* = == */
160 #define T_GE 233 /* >= */
161 #define T_GT 234 /* > */
162 #define T_NE 235 /* <> != */
163 #define T_CONCAT 236 /* & */
164 #define T_BAR 237 /* | */
165 #define T_POINT 238 /* . */
166 #define T_COMMA 239 /* , */
167 #define T_COLON 240 /* : */
168 #define T_SEMICOLON 241 /* ; */
169 #define T_ASSIGN 242 /* := */
170 #define T_DOTS 243 /* .. */
171 #define T_LEFT 244 /* ( */
172 #define T_RIGHT 245 /* ) */
173 #define T_LBRACKET 246 /* [ */
174 #define T_RBRACKET 247 /* ] */
175 #define T_LBRACE 248 /* { */
176 #define T_RBRACE 249 /* } */
177 #define T_APPEND 250 /* >> */
178 #define T_TILDE 251 /* ~ */
179 #define T_INPUT 252 /* <- */
181 /* length of the current token */
182 char *image; /* char image[MAX_LENGTH+1]; */
183 /* image of the current token */
185 /* value of the current token (for T_NUMBER only) */
187 /* the previous token */
189 /* length of the previous token */
190 char *b_image; /* char b_image[MAX_LENGTH+1]; */
191 /* image of the previous token */
193 /* value of the previous token (if token is T_NUMBER) */
195 /* if this flag is set, the next token should be recognized as
196 T_DOTS, not as T_POINT */
198 /* if this flag is set, the next token is already scanned */
202 /* length of the next token */
203 char *f_image; /* char f_image[MAX_LENGTH+1]; */
204 /* image of the next token */
206 /* value of the next token (if token is T_NUMBER) */
207 char *context; /* char context[CONTEXT_SIZE]; */
208 /* context circular queue (not null-terminated!) */
210 /* pointer to the current position in the context queue */
212 /* if this flag is set, the data section is being processed */
213 /*--------------------------------------------------------------*/
214 /* translating segment */
216 /* memory pool used to allocate all data instances created during
217 the translation phase */
219 /* symbolic name table:
220 node.type = A_INDEX => node.link -> DOMAIN_SLOT
221 node.type = A_SET => node.link -> SET
222 node.type = A_PARAMETER => node.link -> PARAMETER
223 node.type = A_VARIABLE => node.link -> VARIABLE
224 node.type = A_CONSTRANT => node.link -> CONSTRAINT */
226 /* linked list of model statements in the original order */
228 /* if this flag is set, the current token being left parenthesis
229 begins a slice that allows recognizing any undeclared symbolic
230 names as dummy indices; this flag is automatically reset once
231 the next token has been scanned */
233 /* the warning "in understood as within" has been issued */
235 /* the warning "within understood as in" has been issued */
237 /* the warning "logical understood as binary" has been issued */
239 /* if this flag is set, the solve statement has been parsed */
240 /*--------------------------------------------------------------*/
243 /* memory pool to allocate STRING data structures */
245 /* memory pool to allocate SYMBOL data structures */
247 /* memory pool to allocate TUPLE data structures */
249 /* memory pool to allocate ARRAY data structures */
251 /* memory pool to allocate MEMBER data structures */
253 /* memory pool to allocate ELEMVAR data structures */
255 /* memory pool to allocate FORMULA data structures */
257 /* memory pool to allocate ELEMCON data structures */
259 /* linked list of all arrays in the database */
260 char *sym_buf; /* char sym_buf[255+1]; */
261 /* working buffer used by the routine format_symbol */
262 char *tup_buf; /* char tup_buf[255+1]; */
263 /* working buffer used by the routine format_tuple */
264 /*--------------------------------------------------------------*/
265 /* generating/postsolving segment */
267 /* pseudo-random number generator */
269 /* if this flag is set, the postsolving phase is in effect */
271 /* model statement being currently executed */
273 /* pointer to table driver communication area for table statement
274 currently executed */
276 /* number of rows in the problem, m >= 0 */
278 /* number of columns in the problem, n >= 0 */
279 ELEMCON **row; /* ELEMCON *row[1+m]; */
280 /* row[0] is not used;
281 row[i] is elemental constraint or objective, which corresponds
282 to i-th row of the problem, 1 <= i <= m */
283 ELEMVAR **col; /* ELEMVAR *col[1+n]; */
284 /* col[0] is not used;
285 col[j] is elemental variable, which corresponds to j-th column
286 of the problem, 1 <= j <= n */
287 /*--------------------------------------------------------------*/
288 /* input/output segment */
290 /* stream assigned to the input text file */
292 /* name of the input text file */
294 /* stream assigned to the output text file used to write all data
295 produced by display and printf statements; NULL means the data
296 should be sent to stdout via the routine xprintf */
298 /* name of the output text file */
299 #if 0 /* 08/XI-2009 */
300 char *out_buf; /* char out_buf[OUTBUF_SIZE] */
301 /* buffer to accumulate output data */
303 /* count of data bytes stored in the output buffer */
306 /* stream assigned to the print text file; may be NULL */
308 /* name of the output print file */
309 /*--------------------------------------------------------------*/
310 /* solver interface segment */
312 /* jump address for non-local go to in case of error */
314 /* phase of processing:
315 0 - database is being or has been initialized
316 1 - model section is being or has been read
317 2 - data section is being or has been read
318 3 - model is being or has been generated/postsolved
319 4 - model processing error has occurred */
321 /* name of the input text file, which contains model section */
322 char *mpl_buf; /* char mpl_buf[255+1]; */
323 /* working buffer used by some interface routines */
326 /**********************************************************************/
327 /* * * PROCESSING MODEL SECTION * * */
328 /**********************************************************************/
330 #define alloc(type) ((type *)dmp_get_atomv(mpl->pool, sizeof(type)))
331 /* allocate atom of given type */
333 #define enter_context _glp_mpl_enter_context
334 void enter_context(MPL *mpl);
335 /* enter current token into context queue */
337 #define print_context _glp_mpl_print_context
338 void print_context(MPL *mpl);
339 /* print current content of context queue */
341 #define get_char _glp_mpl_get_char
342 void get_char(MPL *mpl);
343 /* scan next character from input text file */
345 #define append_char _glp_mpl_append_char
346 void append_char(MPL *mpl);
347 /* append character to current token */
349 #define get_token _glp_mpl_get_token
350 void get_token(MPL *mpl);
351 /* scan next token from input text file */
353 #define unget_token _glp_mpl_unget_token
354 void unget_token(MPL *mpl);
355 /* return current token back to input stream */
357 #define is_keyword _glp_mpl_is_keyword
358 int is_keyword(MPL *mpl, char *keyword);
359 /* check if current token is given non-reserved keyword */
361 #define is_reserved _glp_mpl_is_reserved
362 int is_reserved(MPL *mpl);
363 /* check if current token is reserved keyword */
365 #define make_code _glp_mpl_make_code
366 CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim);
367 /* generate pseudo-code (basic routine) */
369 #define make_unary _glp_mpl_make_unary
370 CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim);
371 /* generate pseudo-code for unary operation */
373 #define make_binary _glp_mpl_make_binary
374 CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
376 /* generate pseudo-code for binary operation */
378 #define make_ternary _glp_mpl_make_ternary
379 CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
381 /* generate pseudo-code for ternary operation */
383 #define numeric_literal _glp_mpl_numeric_literal
384 CODE *numeric_literal(MPL *mpl);
385 /* parse reference to numeric literal */
387 #define string_literal _glp_mpl_string_literal
388 CODE *string_literal(MPL *mpl);
389 /* parse reference to string literal */
391 #define create_arg_list _glp_mpl_create_arg_list
392 ARG_LIST *create_arg_list(MPL *mpl);
393 /* create empty operands list */
395 #define expand_arg_list _glp_mpl_expand_arg_list
396 ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x);
397 /* append operand to operands list */
399 #define arg_list_len _glp_mpl_arg_list_len
400 int arg_list_len(MPL *mpl, ARG_LIST *list);
401 /* determine length of operands list */
403 #define subscript_list _glp_mpl_subscript_list
404 ARG_LIST *subscript_list(MPL *mpl);
405 /* parse subscript list */
407 #define object_reference _glp_mpl_object_reference
408 CODE *object_reference(MPL *mpl);
409 /* parse reference to named object */
411 #define numeric_argument _glp_mpl_numeric_argument
412 CODE *numeric_argument(MPL *mpl, char *func);
413 /* parse argument passed to built-in function */
415 #define symbolic_argument _glp_mpl_symbolic_argument
416 CODE *symbolic_argument(MPL *mpl, char *func);
418 #define elemset_argument _glp_mpl_elemset_argument
419 CODE *elemset_argument(MPL *mpl, char *func);
421 #define function_reference _glp_mpl_function_reference
422 CODE *function_reference(MPL *mpl);
423 /* parse reference to built-in function */
425 #define create_domain _glp_mpl_create_domain
426 DOMAIN *create_domain(MPL *mpl);
427 /* create empty domain */
429 #define create_block _glp_mpl_create_block
430 DOMAIN_BLOCK *create_block(MPL *mpl);
431 /* create empty domain block */
433 #define append_block _glp_mpl_append_block
434 void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block);
435 /* append domain block to specified domain */
437 #define append_slot _glp_mpl_append_slot
438 DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
440 /* create and append new slot to domain block */
442 #define expression_list _glp_mpl_expression_list
443 CODE *expression_list(MPL *mpl);
444 /* parse expression list */
446 #define literal_set _glp_mpl_literal_set
447 CODE *literal_set(MPL *mpl, CODE *code);
448 /* parse literal set */
450 #define indexing_expression _glp_mpl_indexing_expression
451 DOMAIN *indexing_expression(MPL *mpl);
452 /* parse indexing expression */
454 #define close_scope _glp_mpl_close_scope
455 void close_scope(MPL *mpl, DOMAIN *domain);
456 /* close scope of indexing expression */
458 #define iterated_expression _glp_mpl_iterated_expression
459 CODE *iterated_expression(MPL *mpl);
460 /* parse iterated expression */
462 #define domain_arity _glp_mpl_domain_arity
463 int domain_arity(MPL *mpl, DOMAIN *domain);
464 /* determine arity of domain */
466 #define set_expression _glp_mpl_set_expression
467 CODE *set_expression(MPL *mpl);
468 /* parse set expression */
470 #define branched_expression _glp_mpl_branched_expression
471 CODE *branched_expression(MPL *mpl);
472 /* parse conditional expression */
474 #define primary_expression _glp_mpl_primary_expression
475 CODE *primary_expression(MPL *mpl);
476 /* parse primary expression */
478 #define error_preceding _glp_mpl_error_preceding
479 void error_preceding(MPL *mpl, char *opstr);
480 /* raise error if preceding operand has wrong type */
482 #define error_following _glp_mpl_error_following
483 void error_following(MPL *mpl, char *opstr);
484 /* raise error if following operand has wrong type */
486 #define error_dimension _glp_mpl_error_dimension
487 void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2);
488 /* raise error if operands have different dimension */
490 #define expression_0 _glp_mpl_expression_0
491 CODE *expression_0(MPL *mpl);
492 /* parse expression of level 0 */
494 #define expression_1 _glp_mpl_expression_1
495 CODE *expression_1(MPL *mpl);
496 /* parse expression of level 1 */
498 #define expression_2 _glp_mpl_expression_2
499 CODE *expression_2(MPL *mpl);
500 /* parse expression of level 2 */
502 #define expression_3 _glp_mpl_expression_3
503 CODE *expression_3(MPL *mpl);
504 /* parse expression of level 3 */
506 #define expression_4 _glp_mpl_expression_4
507 CODE *expression_4(MPL *mpl);
508 /* parse expression of level 4 */
510 #define expression_5 _glp_mpl_expression_5
511 CODE *expression_5(MPL *mpl);
512 /* parse expression of level 5 */
514 #define expression_6 _glp_mpl_expression_6
515 CODE *expression_6(MPL *mpl);
516 /* parse expression of level 6 */
518 #define expression_7 _glp_mpl_expression_7
519 CODE *expression_7(MPL *mpl);
520 /* parse expression of level 7 */
522 #define expression_8 _glp_mpl_expression_8
523 CODE *expression_8(MPL *mpl);
524 /* parse expression of level 8 */
526 #define expression_9 _glp_mpl_expression_9
527 CODE *expression_9(MPL *mpl);
528 /* parse expression of level 9 */
530 #define expression_10 _glp_mpl_expression_10
531 CODE *expression_10(MPL *mpl);
532 /* parse expression of level 10 */
534 #define expression_11 _glp_mpl_expression_11
535 CODE *expression_11(MPL *mpl);
536 /* parse expression of level 11 */
538 #define expression_12 _glp_mpl_expression_12
539 CODE *expression_12(MPL *mpl);
540 /* parse expression of level 12 */
542 #define expression_13 _glp_mpl_expression_13
543 CODE *expression_13(MPL *mpl);
544 /* parse expression of level 13 */
546 #define set_statement _glp_mpl_set_statement
547 SET *set_statement(MPL *mpl);
548 /* parse set statement */
550 #define parameter_statement _glp_mpl_parameter_statement
551 PARAMETER *parameter_statement(MPL *mpl);
552 /* parse parameter statement */
554 #define variable_statement _glp_mpl_variable_statement
555 VARIABLE *variable_statement(MPL *mpl);
556 /* parse variable statement */
558 #define constraint_statement _glp_mpl_constraint_statement
559 CONSTRAINT *constraint_statement(MPL *mpl);
560 /* parse constraint statement */
562 #define objective_statement _glp_mpl_objective_statement
563 CONSTRAINT *objective_statement(MPL *mpl);
564 /* parse objective statement */
566 #define table_statement _glp_mpl_table_statement
567 TABLE *table_statement(MPL *mpl);
568 /* parse table statement */
570 #define solve_statement _glp_mpl_solve_statement
571 void *solve_statement(MPL *mpl);
572 /* parse solve statement */
574 #define check_statement _glp_mpl_check_statement
575 CHECK *check_statement(MPL *mpl);
576 /* parse check statement */
578 #define display_statement _glp_mpl_display_statement
579 DISPLAY *display_statement(MPL *mpl);
580 /* parse display statement */
582 #define printf_statement _glp_mpl_printf_statement
583 PRINTF *printf_statement(MPL *mpl);
584 /* parse printf statement */
586 #define for_statement _glp_mpl_for_statement
587 FOR *for_statement(MPL *mpl);
588 /* parse for statement */
590 #define end_statement _glp_mpl_end_statement
591 void end_statement(MPL *mpl);
592 /* parse end statement */
594 #define simple_statement _glp_mpl_simple_statement
595 STATEMENT *simple_statement(MPL *mpl, int spec);
596 /* parse simple statement */
598 #define model_section _glp_mpl_model_section
599 void model_section(MPL *mpl);
600 /* parse model section */
602 /**********************************************************************/
603 /* * * PROCESSING DATA SECTION * * */
604 /**********************************************************************/
607 struct SLICE /* see TUPLE */
608 { /* component of slice; the slice itself is associated with its
609 first component; slices are similar to n-tuples with exception
610 that some slice components (which are indicated by asterisks)
611 don't refer to any symbols */
613 /* symbol, which this component refers to; can be NULL */
615 /* the next component of slice */
619 #define create_slice _glp_mpl_create_slice
620 SLICE *create_slice(MPL *mpl);
623 #define expand_slice _glp_mpl_expand_slice
626 SLICE *slice, /* destroyed */
627 SYMBOL *sym /* destroyed */
629 /* append new component to slice */
631 #define slice_dimen _glp_mpl_slice_dimen
634 SLICE *slice /* not changed */
636 /* determine dimension of slice */
638 #define slice_arity _glp_mpl_slice_arity
641 SLICE *slice /* not changed */
643 /* determine arity of slice */
645 #define fake_slice _glp_mpl_fake_slice
646 SLICE *fake_slice(MPL *mpl, int dim);
647 /* create fake slice of all asterisks */
649 #define delete_slice _glp_mpl_delete_slice
652 SLICE *slice /* destroyed */
656 #define is_number _glp_mpl_is_number
657 int is_number(MPL *mpl);
658 /* check if current token is number */
660 #define is_symbol _glp_mpl_is_symbol
661 int is_symbol(MPL *mpl);
662 /* check if current token is symbol */
664 #define is_literal _glp_mpl_is_literal
665 int is_literal(MPL *mpl, char *literal);
666 /* check if current token is given symbolic literal */
668 #define read_number _glp_mpl_read_number
669 double read_number(MPL *mpl);
672 #define read_symbol _glp_mpl_read_symbol
673 SYMBOL *read_symbol(MPL *mpl);
676 #define read_slice _glp_mpl_read_slice
679 char *name, /* not changed */
684 #define select_set _glp_mpl_select_set
687 char *name /* not changed */
689 /* select set to saturate it with elemental sets */
691 #define simple_format _glp_mpl_simple_format
694 SET *set, /* not changed */
695 MEMBER *memb, /* modified */
696 SLICE *slice /* not changed */
698 /* read set data block in simple format */
700 #define matrix_format _glp_mpl_matrix_format
703 SET *set, /* not changed */
704 MEMBER *memb, /* modified */
705 SLICE *slice, /* not changed */
708 /* read set data block in matrix format */
710 #define set_data _glp_mpl_set_data
711 void set_data(MPL *mpl);
714 #define select_parameter _glp_mpl_select_parameter
715 PARAMETER *select_parameter
717 char *name /* not changed */
719 /* select parameter to saturate it with data */
721 #define set_default _glp_mpl_set_default
724 PARAMETER *par, /* not changed */
725 SYMBOL *altval /* destroyed */
727 /* set default parameter value */
729 #define read_value _glp_mpl_read_value
732 PARAMETER *par, /* not changed */
733 TUPLE *tuple /* destroyed */
735 /* read value and assign it to parameter member */
737 #define plain_format _glp_mpl_plain_format
740 PARAMETER *par, /* not changed */
741 SLICE *slice /* not changed */
743 /* read parameter data block in plain format */
745 #define tabular_format _glp_mpl_tabular_format
748 PARAMETER *par, /* not changed */
749 SLICE *slice, /* not changed */
752 /* read parameter data block in tabular format */
754 #define tabbing_format _glp_mpl_tabbing_format
757 SYMBOL *altval /* not changed */
759 /* read parameter data block in tabbing format */
761 #define parameter_data _glp_mpl_parameter_data
762 void parameter_data(MPL *mpl);
763 /* read parameter data */
765 #define data_section _glp_mpl_data_section
766 void data_section(MPL *mpl);
767 /* read data section */
769 /**********************************************************************/
770 /* * * FLOATING-POINT NUMBERS * * */
771 /**********************************************************************/
773 #define fp_add _glp_mpl_fp_add
774 double fp_add(MPL *mpl, double x, double y);
775 /* floating-point addition */
777 #define fp_sub _glp_mpl_fp_sub
778 double fp_sub(MPL *mpl, double x, double y);
779 /* floating-point subtraction */
781 #define fp_less _glp_mpl_fp_less
782 double fp_less(MPL *mpl, double x, double y);
783 /* floating-point non-negative subtraction */
785 #define fp_mul _glp_mpl_fp_mul
786 double fp_mul(MPL *mpl, double x, double y);
787 /* floating-point multiplication */
789 #define fp_div _glp_mpl_fp_div
790 double fp_div(MPL *mpl, double x, double y);
791 /* floating-point division */
793 #define fp_idiv _glp_mpl_fp_idiv
794 double fp_idiv(MPL *mpl, double x, double y);
795 /* floating-point quotient of exact division */
797 #define fp_mod _glp_mpl_fp_mod
798 double fp_mod(MPL *mpl, double x, double y);
799 /* floating-point remainder of exact division */
801 #define fp_power _glp_mpl_fp_power
802 double fp_power(MPL *mpl, double x, double y);
803 /* floating-point exponentiation (raise to power) */
805 #define fp_exp _glp_mpl_fp_exp
806 double fp_exp(MPL *mpl, double x);
807 /* floating-point base-e exponential */
809 #define fp_log _glp_mpl_fp_log
810 double fp_log(MPL *mpl, double x);
811 /* floating-point natural logarithm */
813 #define fp_log10 _glp_mpl_fp_log10
814 double fp_log10(MPL *mpl, double x);
815 /* floating-point common (decimal) logarithm */
817 #define fp_sqrt _glp_mpl_fp_sqrt
818 double fp_sqrt(MPL *mpl, double x);
819 /* floating-point square root */
821 #define fp_sin _glp_mpl_fp_sin
822 double fp_sin(MPL *mpl, double x);
823 /* floating-point trigonometric sine */
825 #define fp_cos _glp_mpl_fp_cos
826 double fp_cos(MPL *mpl, double x);
827 /* floating-point trigonometric cosine */
829 #define fp_atan _glp_mpl_fp_atan
830 double fp_atan(MPL *mpl, double x);
831 /* floating-point trigonometric arctangent */
833 #define fp_atan2 _glp_mpl_fp_atan2
834 double fp_atan2(MPL *mpl, double y, double x);
835 /* floating-point trigonometric arctangent */
837 #define fp_round _glp_mpl_fp_round
838 double fp_round(MPL *mpl, double x, double n);
839 /* round floating-point value to n fractional digits */
841 #define fp_trunc _glp_mpl_fp_trunc
842 double fp_trunc(MPL *mpl, double x, double n);
843 /* truncate floating-point value to n fractional digits */
845 /**********************************************************************/
846 /* * * PSEUDO-RANDOM NUMBER GENERATORS * * */
847 /**********************************************************************/
849 #define fp_irand224 _glp_mpl_fp_irand224
850 double fp_irand224(MPL *mpl);
851 /* pseudo-random integer in the range [0, 2^24) */
853 #define fp_uniform01 _glp_mpl_fp_uniform01
854 double fp_uniform01(MPL *mpl);
855 /* pseudo-random number in the range [0, 1) */
857 #define fp_uniform _glp_mpl_uniform
858 double fp_uniform(MPL *mpl, double a, double b);
859 /* pseudo-random number in the range [a, b) */
861 #define fp_normal01 _glp_mpl_fp_normal01
862 double fp_normal01(MPL *mpl);
863 /* Gaussian random variate with mu = 0 and sigma = 1 */
865 #define fp_normal _glp_mpl_fp_normal
866 double fp_normal(MPL *mpl, double mu, double sigma);
867 /* Gaussian random variate with specified mu and sigma */
869 /**********************************************************************/
870 /* * * DATE/TIME * * */
871 /**********************************************************************/
873 #define fn_gmtime _glp_mpl_fn_gmtime
874 double fn_gmtime(MPL *mpl);
875 /* obtain the current calendar time (UTC) */
877 #define fn_str2time _glp_mpl_fn_str2time
878 double fn_str2time(MPL *mpl, const char *str, const char *fmt);
879 /* convert character string to the calendar time */
881 #define fn_time2str _glp_mpl_fn_time2str
882 void fn_time2str(MPL *mpl, char *str, double t, const char *fmt);
883 /* convert the calendar time to character string */
885 /**********************************************************************/
886 /* * * CHARACTER STRINGS * * */
887 /**********************************************************************/
889 #define create_string _glp_mpl_create_string
890 STRING *create_string
892 char buf[MAX_LENGTH+1] /* not changed */
894 /* create character string */
896 #define copy_string _glp_mpl_copy_string
899 STRING *str /* not changed */
901 /* make copy of character string */
903 #define compare_strings _glp_mpl_compare_strings
906 STRING *str1, /* not changed */
907 STRING *str2 /* not changed */
909 /* compare one character string with another */
911 #define fetch_string _glp_mpl_fetch_string
914 STRING *str, /* not changed */
915 char buf[MAX_LENGTH+1] /* modified */
917 /* extract content of character string */
919 #define delete_string _glp_mpl_delete_string
922 STRING *str /* destroyed */
924 /* delete character string */
926 /**********************************************************************/
927 /* * * SYMBOLS * * */
928 /**********************************************************************/
931 { /* symbol (numeric or abstract quantity) */
933 /* numeric value of symbol (used only if str == NULL) */
935 /* abstract value of symbol (used only if str != NULL) */
938 #define create_symbol_num _glp_mpl_create_symbol_num
939 SYMBOL *create_symbol_num(MPL *mpl, double num);
940 /* create symbol of numeric type */
942 #define create_symbol_str _glp_mpl_create_symbol_str
943 SYMBOL *create_symbol_str
945 STRING *str /* destroyed */
947 /* create symbol of abstract type */
949 #define copy_symbol _glp_mpl_copy_symbol
952 SYMBOL *sym /* not changed */
954 /* make copy of symbol */
956 #define compare_symbols _glp_mpl_compare_symbols
959 SYMBOL *sym1, /* not changed */
960 SYMBOL *sym2 /* not changed */
962 /* compare one symbol with another */
964 #define delete_symbol _glp_mpl_delete_symbol
967 SYMBOL *sym /* destroyed */
971 #define format_symbol _glp_mpl_format_symbol
974 SYMBOL *sym /* not changed */
976 /* format symbol for displaying or printing */
978 #define concat_symbols _glp_mpl_concat_symbols
979 SYMBOL *concat_symbols
981 SYMBOL *sym1, /* destroyed */
982 SYMBOL *sym2 /* destroyed */
984 /* concatenate one symbol with another */
986 /**********************************************************************/
987 /* * * N-TUPLES * * */
988 /**********************************************************************/
991 { /* component of n-tuple; the n-tuple itself is associated with
992 its first component; (note that 0-tuple has no components) */
994 /* symbol, which the component refers to; cannot be NULL */
996 /* the next component of n-tuple */
999 #define create_tuple _glp_mpl_create_tuple
1000 TUPLE *create_tuple(MPL *mpl);
1001 /* create n-tuple */
1003 #define expand_tuple _glp_mpl_expand_tuple
1006 TUPLE *tuple, /* destroyed */
1007 SYMBOL *sym /* destroyed */
1009 /* append symbol to n-tuple */
1011 #define tuple_dimen _glp_mpl_tuple_dimen
1014 TUPLE *tuple /* not changed */
1016 /* determine dimension of n-tuple */
1018 #define copy_tuple _glp_mpl_copy_tuple
1021 TUPLE *tuple /* not changed */
1023 /* make copy of n-tuple */
1025 #define compare_tuples _glp_mpl_compare_tuples
1028 TUPLE *tuple1, /* not changed */
1029 TUPLE *tuple2 /* not changed */
1031 /* compare one n-tuple with another */
1033 #define build_subtuple _glp_mpl_build_subtuple
1034 TUPLE *build_subtuple
1036 TUPLE *tuple, /* not changed */
1039 /* build subtuple of given n-tuple */
1041 #define delete_tuple _glp_mpl_delete_tuple
1044 TUPLE *tuple /* destroyed */
1046 /* delete n-tuple */
1048 #define format_tuple _glp_mpl_format_tuple
1052 TUPLE *tuple /* not changed */
1054 /* format n-tuple for displaying or printing */
1056 /**********************************************************************/
1057 /* * * ELEMENTAL SETS * * */
1058 /**********************************************************************/
1061 struct ELEMSET /* see ARRAY */
1062 { /* elemental set of n-tuples; formally it is a "value" assigned
1063 to members of model sets (like numbers and symbols, which are
1064 values assigned to members of model parameters); note that a
1065 simple model set is not an elemental set, it is 0-dimensional
1066 array, the only member of which (if it exists) is assigned an
1070 #define create_elemset _glp_mpl_create_elemset
1071 ELEMSET *create_elemset(MPL *mpl, int dim);
1072 /* create elemental set */
1074 #define find_tuple _glp_mpl_find_tuple
1077 ELEMSET *set, /* not changed */
1078 TUPLE *tuple /* not changed */
1080 /* check if elemental set contains given n-tuple */
1082 #define add_tuple _glp_mpl_add_tuple
1085 ELEMSET *set, /* modified */
1086 TUPLE *tuple /* destroyed */
1088 /* add new n-tuple to elemental set */
1090 #define check_then_add _glp_mpl_check_then_add
1091 MEMBER *check_then_add
1093 ELEMSET *set, /* modified */
1094 TUPLE *tuple /* destroyed */
1096 /* check and add new n-tuple to elemental set */
1098 #define copy_elemset _glp_mpl_copy_elemset
1099 ELEMSET *copy_elemset
1101 ELEMSET *set /* not changed */
1103 /* make copy of elemental set */
1105 #define delete_elemset _glp_mpl_delete_elemset
1108 ELEMSET *set /* destroyed */
1110 /* delete elemental set */
1112 #define arelset_size _glp_mpl_arelset_size
1113 int arelset_size(MPL *mpl, double t0, double tf, double dt);
1114 /* compute size of "arithmetic" elemental set */
1116 #define arelset_member _glp_mpl_arelset_member
1117 double arelset_member(MPL *mpl, double t0, double tf, double dt, int j);
1118 /* compute member of "arithmetic" elemental set */
1120 #define create_arelset _glp_mpl_create_arelset
1121 ELEMSET *create_arelset(MPL *mpl, double t0, double tf, double dt);
1122 /* create "arithmetic" elemental set */
1124 #define set_union _glp_mpl_set_union
1127 ELEMSET *X, /* destroyed */
1128 ELEMSET *Y /* destroyed */
1130 /* union of two elemental sets */
1132 #define set_diff _glp_mpl_set_diff
1135 ELEMSET *X, /* destroyed */
1136 ELEMSET *Y /* destroyed */
1138 /* difference between two elemental sets */
1140 #define set_symdiff _glp_mpl_set_symdiff
1141 ELEMSET *set_symdiff
1143 ELEMSET *X, /* destroyed */
1144 ELEMSET *Y /* destroyed */
1146 /* symmetric difference between two elemental sets */
1148 #define set_inter _glp_mpl_set_inter
1151 ELEMSET *X, /* destroyed */
1152 ELEMSET *Y /* destroyed */
1154 /* intersection of two elemental sets */
1156 #define set_cross _glp_mpl_set_cross
1159 ELEMSET *X, /* destroyed */
1160 ELEMSET *Y /* destroyed */
1162 /* cross (Cartesian) product of two elemental sets */
1164 /**********************************************************************/
1165 /* * * ELEMENTAL VARIABLES * * */
1166 /**********************************************************************/
1169 { /* elemental variable; formally it is a "value" assigned to
1170 members of model variables (like numbers and symbols, which
1171 are values assigned to members of model parameters) */
1173 /* LP column number assigned to this elemental variable */
1175 /* model variable, which contains this elemental variable */
1177 /* array member, which is assigned this elemental variable */
1183 /* working quantity used in operations on linear forms; normally
1184 it contains floating-point zero */
1185 #if 1 /* 15/V-2010 */
1188 /* solution components provided by the solver */
1192 /**********************************************************************/
1193 /* * * LINEAR FORMS * * */
1194 /**********************************************************************/
1197 { /* term of linear form c * x, where c is a coefficient, x is an
1198 elemental variable; the linear form itself is the sum of terms
1199 and is associated with its first term; (note that the linear
1200 form may be empty that means the sum is equal to zero) */
1202 /* coefficient at elemental variable or constant term */
1204 /* reference to elemental variable; NULL means constant term */
1206 /* the next term of linear form */
1209 #define constant_term _glp_mpl_constant_term
1210 FORMULA *constant_term(MPL *mpl, double coef);
1211 /* create constant term */
1213 #define single_variable _glp_mpl_single_variable
1214 FORMULA *single_variable
1216 ELEMVAR *var /* referenced */
1218 /* create single variable */
1220 #define copy_formula _glp_mpl_copy_formula
1221 FORMULA *copy_formula
1223 FORMULA *form /* not changed */
1225 /* make copy of linear form */
1227 #define delete_formula _glp_mpl_delete_formula
1230 FORMULA *form /* destroyed */
1232 /* delete linear form */
1234 #define linear_comb _glp_mpl_linear_comb
1235 FORMULA *linear_comb
1237 double a, FORMULA *fx, /* destroyed */
1238 double b, FORMULA *fy /* destroyed */
1240 /* linear combination of two linear forms */
1242 #define remove_constant _glp_mpl_remove_constant
1243 FORMULA *remove_constant
1245 FORMULA *form, /* destroyed */
1246 double *coef /* modified */
1248 /* remove constant term from linear form */
1250 #define reduce_terms _glp_mpl_reduce_terms
1251 FORMULA *reduce_terms
1253 FORMULA *form /* destroyed */
1255 /* reduce identical terms in linear form */
1257 /**********************************************************************/
1258 /* * * ELEMENTAL CONSTRAINTS * * */
1259 /**********************************************************************/
1262 { /* elemental constraint; formally it is a "value" assigned to
1263 members of model constraints (like numbers or symbols, which
1264 are values assigned to members of model parameters) */
1266 /* LP row number assigned to this elemental constraint */
1268 /* model constraint, which contains this elemental constraint */
1270 /* array member, which is assigned this elemental constraint */
1277 #if 1 /* 15/V-2010 */
1280 /* solution components provided by the solver */
1284 /**********************************************************************/
1285 /* * * GENERIC VALUES * * */
1286 /**********************************************************************/
1289 { /* generic value, which can be assigned to object member or be a
1290 result of evaluation of expression */
1291 /* indicator that specifies the particular type of generic value
1292 is stored in the corresponding array or pseudo-code descriptor
1293 and can be one of the following:
1295 A_NUMERIC - floating-point number
1297 A_LOGICAL - logical value
1299 A_ELEMSET - elemental set
1300 A_ELEMVAR - elemental variable
1301 A_FORMULA - linear form
1302 A_ELEMCON - elemental constraint */
1303 void *none; /* null */
1304 double num; /* value */
1305 SYMBOL *sym; /* value */
1306 int bit; /* value */
1307 TUPLE *tuple; /* value */
1308 ELEMSET *set; /* value */
1309 ELEMVAR *var; /* reference */
1310 FORMULA *form; /* value */
1311 ELEMCON *con; /* reference */
1314 #define delete_value _glp_mpl_delete_value
1318 VALUE *value /* content destroyed */
1320 /* delete generic value */
1322 /**********************************************************************/
1323 /* * * SYMBOLICALLY INDEXED ARRAYS * * */
1324 /**********************************************************************/
1327 { /* multi-dimensional array, a set of members indexed over simple
1328 or compound sets of symbols; arrays are used to represent the
1329 contents of model objects (i.e. sets, parameters, variables,
1330 constraints, and objectives); arrays also are used as "values"
1331 that are assigned to members of set objects, in which case the
1332 array itself represents an elemental set */
1334 /* type of generic values assigned to the array members:
1335 A_NONE - none (members have no assigned values)
1336 A_NUMERIC - floating-point numbers
1337 A_SYMBOLIC - symbols
1338 A_ELEMSET - elemental sets
1339 A_ELEMVAR - elemental variables
1340 A_ELEMCON - elemental constraints */
1342 /* dimension of the array that determines number of components in
1343 n-tuples for all members of the array, dim >= 0; dim = 0 means
1344 the array is 0-dimensional */
1346 /* size of the array, i.e. number of its members */
1348 /* the first array member; NULL means the array is empty */
1350 /* the last array member; NULL means the array is empty */
1352 /* the search tree intended to find array members for logarithmic
1353 time; NULL means the search tree doesn't exist */
1355 /* the previous array in the translator database */
1357 /* the next array in the translator database */
1361 { /* array member */
1363 /* n-tuple, which identifies the member; number of its components
1364 is the same for all members within the array and determined by
1365 the array dimension; duplicate members are not allowed */
1367 /* the next array member */
1369 /* generic value assigned to the member */
1372 #define create_array _glp_mpl_create_array
1373 ARRAY *create_array(MPL *mpl, int type, int dim);
1376 #define find_member _glp_mpl_find_member
1379 ARRAY *array, /* not changed */
1380 TUPLE *tuple /* not changed */
1382 /* find array member with given n-tuple */
1384 #define add_member _glp_mpl_add_member
1387 ARRAY *array, /* modified */
1388 TUPLE *tuple /* destroyed */
1390 /* add new member to array */
1392 #define delete_array _glp_mpl_delete_array
1395 ARRAY *array /* destroyed */
1399 /**********************************************************************/
1400 /* * * DOMAINS AND DUMMY INDICES * * */
1401 /**********************************************************************/
1404 { /* domain (a simple or compound set); syntactically domain looks
1405 like '{ i in I, (j,k) in S, t in T : <predicate> }'; domains
1406 are used to define sets, over which model objects are indexed,
1407 and also as constituents of iterated operators */
1409 /* linked list of domain blocks (in the example above such blocks
1410 are 'i in I', '(j,k) in S', and 't in T'); this list cannot be
1413 /* pseudo-code for computing the logical predicate, which follows
1414 the colon; NULL means no predicate is specified */
1418 { /* domain block; syntactically domain blocks look like 'i in I',
1419 '(j,k) in S', and 't in T' in the example above (in the sequel
1420 sets like I, S, and T are called basic sets) */
1422 /* linked list of domain slots (i.e. indexing positions); number
1423 of slots in this list is the same as dimension of n-tuples in
1424 the basic set; this list cannot be empty */
1426 /* pseudo-code for computing basic set; cannot be NULL */
1428 /* if this n-tuple is not empty, current values of dummy indices
1429 in the domain block are the same as components of this n-tuple
1430 (note that this n-tuple may have larger dimension than number
1431 of dummy indices in this block, in which case extra components
1432 are ignored); this n-tuple is used to restore former values of
1433 dummy indices, if they were changed due to recursive calls to
1436 /* the next block in the same domain */
1440 { /* domain slot; it specifies an individual indexing position and
1441 defines the corresponding dummy index */
1443 /* symbolic name of the dummy index; null pointer means the dummy
1444 index is not explicitly specified */
1446 /* pseudo-code for computing symbolic value, at which the dummy
1447 index is bound; NULL means the dummy index is free within the
1450 /* current value assigned to the dummy index; NULL means no value
1451 is assigned at the moment */
1453 /* linked list of pseudo-codes with operation O_INDEX referring
1454 to this slot; this linked list is used to invalidate resultant
1455 values of the operation, which depend on this dummy index */
1457 /* the next slot in the same domain block */
1460 #define assign_dummy_index _glp_mpl_assign_dummy_index
1461 void assign_dummy_index
1463 DOMAIN_SLOT *slot, /* modified */
1464 SYMBOL *value /* not changed */
1466 /* assign new value to dummy index */
1468 #define update_dummy_indices _glp_mpl_update_dummy_indices
1469 void update_dummy_indices
1471 DOMAIN_BLOCK *block /* not changed */
1473 /* update current values of dummy indices */
1475 #define enter_domain_block _glp_mpl_enter_domain_block
1476 int enter_domain_block
1478 DOMAIN_BLOCK *block, /* not changed */
1479 TUPLE *tuple, /* not changed */
1480 void *info, void (*func)(MPL *mpl, void *info)
1482 /* enter domain block */
1484 #define eval_within_domain _glp_mpl_eval_within_domain
1485 int eval_within_domain
1487 DOMAIN *domain, /* not changed */
1488 TUPLE *tuple, /* not changed */
1489 void *info, void (*func)(MPL *mpl, void *info)
1491 /* perform evaluation within domain scope */
1493 #define loop_within_domain _glp_mpl_loop_within_domain
1494 void loop_within_domain
1496 DOMAIN *domain, /* not changed */
1497 void *info, int (*func)(MPL *mpl, void *info)
1499 /* perform iterations within domain scope */
1501 #define out_of_domain _glp_mpl_out_of_domain
1504 char *name, /* not changed */
1505 TUPLE *tuple /* not changed */
1507 /* raise domain exception */
1509 #define get_domain_tuple _glp_mpl_get_domain_tuple
1510 TUPLE *get_domain_tuple
1512 DOMAIN *domain /* not changed */
1514 /* obtain current n-tuple from domain */
1516 #define clean_domain _glp_mpl_clean_domain
1517 void clean_domain(MPL *mpl, DOMAIN *domain);
1520 /**********************************************************************/
1521 /* * * MODEL SETS * * */
1522 /**********************************************************************/
1527 /* symbolic name; cannot be NULL */
1529 /* alias; NULL means alias is not specified */
1530 int dim; /* aka arity */
1531 /* dimension (number of subscripts); dim = 0 means 0-dimensional
1532 (unsubscripted) set, dim > 0 means set of sets */
1534 /* subscript domain; NULL for 0-dimensional set */
1536 /* dimension of n-tuples, which members of this set consist of
1537 (note that the model set itself is an array of elemental sets,
1538 which are its members; so, don't confuse this dimension with
1539 dimension of the model set); always non-zero */
1541 /* list of supersets, which restrict each member of the set to be
1542 in every superset from this list; this list can be empty */
1544 /* pseudo-code for computing assigned value; can be NULL */
1546 /* pseudo-code for computing default value; can be NULL */
1548 /* plain set used to initialize the array of sets; can be NULL */
1550 /* data status flag:
1551 0 - no data are provided in the data section
1552 1 - data are provided, but not checked yet
1553 2 - data are provided and have been checked */
1555 /* array of members, which are assigned elemental sets */
1559 { /* restricting superset list entry */
1561 /* pseudo-code for computing the superset; cannot be NULL */
1563 /* the next entry for the same set or parameter */
1567 { /* plain set used to initialize the array of sets with data */
1569 /* pointer to plain set; cannot be NULL */
1570 int ind[20]; /* ind[dim+dimen]; */
1571 /* permutation of integers 1, 2, ..., dim+dimen */
1574 #define check_elem_set _glp_mpl_check_elem_set
1577 SET *set, /* not changed */
1578 TUPLE *tuple, /* not changed */
1579 ELEMSET *refer /* not changed */
1581 /* check elemental set assigned to set member */
1583 #define take_member_set _glp_mpl_take_member_set
1584 ELEMSET *take_member_set /* returns reference, not value */
1586 SET *set, /* not changed */
1587 TUPLE *tuple /* not changed */
1589 /* obtain elemental set assigned to set member */
1591 #define eval_member_set _glp_mpl_eval_member_set
1592 ELEMSET *eval_member_set /* returns reference, not value */
1594 SET *set, /* not changed */
1595 TUPLE *tuple /* not changed */
1597 /* evaluate elemental set assigned to set member */
1599 #define eval_whole_set _glp_mpl_eval_whole_set
1600 void eval_whole_set(MPL *mpl, SET *set);
1601 /* evaluate model set over entire domain */
1603 #define clean_set _glp_mpl_clean_set
1604 void clean_set(MPL *mpl, SET *set);
1605 /* clean model set */
1607 /**********************************************************************/
1608 /* * * MODEL PARAMETERS * * */
1609 /**********************************************************************/
1612 { /* model parameter */
1614 /* symbolic name; cannot be NULL */
1616 /* alias; NULL means alias is not specified */
1617 int dim; /* aka arity */
1618 /* dimension (number of subscripts); dim = 0 means 0-dimensional
1619 (unsubscripted) parameter */
1621 /* subscript domain; NULL for 0-dimensional parameter */
1627 A_SYMBOLIC - symbolic */
1629 /* list of conditions, which restrict each parameter member to
1630 satisfy to every condition from this list; this list is used
1631 only for numeric parameters and can be empty */
1633 /* list of supersets, which restrict each parameter member to be
1634 in every superset from this list; this list is used only for
1635 symbolic parameters and can be empty */
1637 /* pseudo-code for computing assigned value; can be NULL */
1639 /* pseudo-code for computing default value; can be NULL */
1641 /* data status flag:
1642 0 - no data are provided in the data section
1643 1 - data are provided, but not checked yet
1644 2 - data are provided and have been checked */
1646 /* default value provided in the data section; can be NULL */
1648 /* array of members, which are assigned numbers or symbols */
1652 { /* restricting condition list entry */
1654 /* flag that specifies the form of the condition:
1656 O_LE - less than or equal to
1658 O_GE - greater than or equal to
1660 O_NE - not equal to */
1662 /* pseudo-code for computing the reference value */
1664 /* the next entry for the same parameter */
1667 #define check_value_num _glp_mpl_check_value_num
1668 void check_value_num
1670 PARAMETER *par, /* not changed */
1671 TUPLE *tuple, /* not changed */
1674 /* check numeric value assigned to parameter member */
1676 #define take_member_num _glp_mpl_take_member_num
1677 double take_member_num
1679 PARAMETER *par, /* not changed */
1680 TUPLE *tuple /* not changed */
1682 /* obtain numeric value assigned to parameter member */
1684 #define eval_member_num _glp_mpl_eval_member_num
1685 double eval_member_num
1687 PARAMETER *par, /* not changed */
1688 TUPLE *tuple /* not changed */
1690 /* evaluate numeric value assigned to parameter member */
1692 #define check_value_sym _glp_mpl_check_value_sym
1693 void check_value_sym
1695 PARAMETER *par, /* not changed */
1696 TUPLE *tuple, /* not changed */
1697 SYMBOL *value /* not changed */
1699 /* check symbolic value assigned to parameter member */
1701 #define take_member_sym _glp_mpl_take_member_sym
1702 SYMBOL *take_member_sym /* returns value, not reference */
1704 PARAMETER *par, /* not changed */
1705 TUPLE *tuple /* not changed */
1707 /* obtain symbolic value assigned to parameter member */
1709 #define eval_member_sym _glp_mpl_eval_member_sym
1710 SYMBOL *eval_member_sym /* returns value, not reference */
1712 PARAMETER *par, /* not changed */
1713 TUPLE *tuple /* not changed */
1715 /* evaluate symbolic value assigned to parameter member */
1717 #define eval_whole_par _glp_mpl_eval_whole_par
1718 void eval_whole_par(MPL *mpl, PARAMETER *par);
1719 /* evaluate model parameter over entire domain */
1721 #define clean_parameter _glp_mpl_clean_parameter
1722 void clean_parameter(MPL *mpl, PARAMETER *par);
1723 /* clean model parameter */
1725 /**********************************************************************/
1726 /* * * MODEL VARIABLES * * */
1727 /**********************************************************************/
1730 { /* model variable */
1732 /* symbolic name; cannot be NULL */
1734 /* alias; NULL means alias is not specified */
1735 int dim; /* aka arity */
1736 /* dimension (number of subscripts); dim = 0 means 0-dimensional
1737 (unsubscripted) variable */
1739 /* subscript domain; NULL for 0-dimensional variable */
1742 A_NUMERIC - continuous
1744 A_BINARY - binary */
1746 /* pseudo-code for computing lower bound; NULL means lower bound
1749 /* pseudo-code for computing upper bound; NULL means upper bound
1751 /* if both the pointers lbnd and ubnd refer to the same code, the
1752 variable is fixed at the corresponding value */
1754 /* array of members, which are assigned elemental variables */
1757 #define take_member_var _glp_mpl_take_member_var
1758 ELEMVAR *take_member_var /* returns reference */
1760 VARIABLE *var, /* not changed */
1761 TUPLE *tuple /* not changed */
1763 /* obtain reference to elemental variable */
1765 #define eval_member_var _glp_mpl_eval_member_var
1766 ELEMVAR *eval_member_var /* returns reference */
1768 VARIABLE *var, /* not changed */
1769 TUPLE *tuple /* not changed */
1771 /* evaluate reference to elemental variable */
1773 #define eval_whole_var _glp_mpl_eval_whole_var
1774 void eval_whole_var(MPL *mpl, VARIABLE *var);
1775 /* evaluate model variable over entire domain */
1777 #define clean_variable _glp_mpl_clean_variable
1778 void clean_variable(MPL *mpl, VARIABLE *var);
1779 /* clean model variable */
1781 /**********************************************************************/
1782 /* * * MODEL CONSTRAINTS AND OBJECTIVES * * */
1783 /**********************************************************************/
1786 { /* model constraint or objective */
1788 /* symbolic name; cannot be NULL */
1790 /* alias; NULL means alias is not specified */
1791 int dim; /* aka arity */
1792 /* dimension (number of subscripts); dim = 0 means 0-dimensional
1793 (unsubscripted) constraint */
1795 /* subscript domain; NULL for 0-dimensional constraint */
1798 A_CONSTRAINT - constraint
1799 A_MINIMIZE - objective (minimization)
1800 A_MAXIMIZE - objective (maximization) */
1802 /* pseudo-code for computing main linear form; cannot be NULL */
1804 /* pseudo-code for computing lower bound; NULL means lower bound
1807 /* pseudo-code for computing upper bound; NULL means upper bound
1809 /* if both the pointers lbnd and ubnd refer to the same code, the
1810 constraint has the form of equation */
1812 /* array of members, which are assigned elemental constraints */
1815 #define take_member_con _glp_mpl_take_member_con
1816 ELEMCON *take_member_con /* returns reference */
1818 CONSTRAINT *con, /* not changed */
1819 TUPLE *tuple /* not changed */
1821 /* obtain reference to elemental constraint */
1823 #define eval_member_con _glp_mpl_eval_member_con
1824 ELEMCON *eval_member_con /* returns reference */
1826 CONSTRAINT *con, /* not changed */
1827 TUPLE *tuple /* not changed */
1829 /* evaluate reference to elemental constraint */
1831 #define eval_whole_con _glp_mpl_eval_whole_con
1832 void eval_whole_con(MPL *mpl, CONSTRAINT *con);
1833 /* evaluate model constraint over entire domain */
1835 #define clean_constraint _glp_mpl_clean_constraint
1836 void clean_constraint(MPL *mpl, CONSTRAINT *con);
1837 /* clean model constraint */
1839 /**********************************************************************/
1840 /* * * DATA TABLES * * */
1841 /**********************************************************************/
1846 /* symbolic name; cannot be NULL */
1848 /* alias; NULL means alias is not specified */
1851 A_INPUT - input table
1852 A_OUTPUT - output table */
1854 /* argument list; cannot be empty */
1858 /* input set; NULL means the set is not specified */
1860 /* field list; cannot be empty */
1862 /* input list; can be empty */
1866 /* subscript domain; cannot be NULL */
1868 /* output list; cannot be empty */
1874 { /* table argument list entry */
1876 /* pseudo-code for computing the argument */
1878 /* next entry for the same table */
1882 { /* table field list entry */
1884 /* field name; cannot be NULL */
1886 /* next entry for the same table */
1890 { /* table input list entry */
1892 /* parameter to be read; cannot be NULL */
1894 /* column name; cannot be NULL */
1896 /* next entry for the same table */
1900 { /* table output list entry */
1902 /* pseudo-code for computing the value to be written */
1904 /* column name; cannot be NULL */
1906 /* next entry for the same table */
1910 { /* table driver communication area */
1912 /* driver identifier (set by mpl_tab_drv_open) */
1914 /* driver link pointer (set by mpl_tab_drv_open) */
1916 /* number of arguments */
1917 char **arg; /* char *arg[1+ns]; */
1918 /* arg[k], 1 <= k <= ns, is pointer to k-th argument */
1920 /* number of fields */
1921 char **name; /* char *name[1+nc]; */
1922 /* name[k], 1 <= k <= nc, is name of k-th field */
1923 int *type; /* int type[1+nc]; */
1924 /* type[k], 1 <= k <= nc, is type of k-th field:
1925 '?' - value not assigned
1927 'S' - character string */
1928 double *num; /* double num[1+nc]; */
1929 /* num[k], 1 <= k <= nc, is numeric value of k-th field */
1931 /* str[k], 1 <= k <= nc, is string value of k-th field */
1934 #define mpl_tab_num_args _glp_mpl_tab_num_args
1935 int mpl_tab_num_args(TABDCA *dca);
1937 #define mpl_tab_get_arg _glp_mpl_tab_get_arg
1938 const char *mpl_tab_get_arg(TABDCA *dca, int k);
1940 #define mpl_tab_num_flds _glp_mpl_tab_num_flds
1941 int mpl_tab_num_flds(TABDCA *dca);
1943 #define mpl_tab_get_name _glp_mpl_tab_get_name
1944 const char *mpl_tab_get_name(TABDCA *dca, int k);
1946 #define mpl_tab_get_type _glp_mpl_tab_get_type
1947 int mpl_tab_get_type(TABDCA *dca, int k);
1949 #define mpl_tab_get_num _glp_mpl_tab_get_num
1950 double mpl_tab_get_num(TABDCA *dca, int k);
1952 #define mpl_tab_get_str _glp_mpl_tab_get_str
1953 const char *mpl_tab_get_str(TABDCA *dca, int k);
1955 #define mpl_tab_set_num _glp_mpl_tab_set_num
1956 void mpl_tab_set_num(TABDCA *dca, int k, double num);
1958 #define mpl_tab_set_str _glp_mpl_tab_set_str
1959 void mpl_tab_set_str(TABDCA *dca, int k, const char *str);
1961 #define mpl_tab_drv_open _glp_mpl_tab_drv_open
1962 void mpl_tab_drv_open(MPL *mpl, int mode);
1964 #define mpl_tab_drv_read _glp_mpl_tab_drv_read
1965 int mpl_tab_drv_read(MPL *mpl);
1967 #define mpl_tab_drv_write _glp_mpl_tab_drv_write
1968 void mpl_tab_drv_write(MPL *mpl);
1970 #define mpl_tab_drv_close _glp_mpl_tab_drv_close
1971 void mpl_tab_drv_close(MPL *mpl);
1973 /**********************************************************************/
1974 /* * * PSEUDO-CODE * * */
1975 /**********************************************************************/
1978 { /* operands that participate in pseudo-code operation (choice of
1979 particular operands depends on the operation code) */
1980 /*--------------------------------------------------------------*/
1981 double num; /* O_NUMBER */
1982 /* floaing-point number to be taken */
1983 /*--------------------------------------------------------------*/
1984 char *str; /* O_STRING */
1985 /* character string to be taken */
1986 /*--------------------------------------------------------------*/
1987 struct /* O_INDEX */
1988 { DOMAIN_SLOT *slot;
1989 /* domain slot, which contains dummy index to be taken */
1991 /* the next pseudo-code with op = O_INDEX, which refers to the
1992 same slot as this one; pointer to the beginning of this list
1993 is stored in the corresponding domain slot */
1995 /*--------------------------------------------------------------*/
1996 struct /* O_MEMNUM, O_MEMSYM */
1998 /* model parameter, which contains member to be taken */
2000 /* list of subscripts; NULL for 0-dimensional parameter */
2002 /*--------------------------------------------------------------*/
2003 struct /* O_MEMSET */
2005 /* model set, which contains member to be taken */
2007 /* list of subscripts; NULL for 0-dimensional set */
2009 /*--------------------------------------------------------------*/
2010 struct /* O_MEMVAR */
2012 /* model variable, which contains member to be taken */
2014 /* list of subscripts; NULL for 0-dimensional variable */
2015 #if 1 /* 15/V-2010 */
2017 /* suffix specified: */
2018 #define DOT_NONE 0x00 /* none (means variable itself) */
2019 #define DOT_LB 0x01 /* .lb (lower bound) */
2020 #define DOT_UB 0x02 /* .ub (upper bound) */
2021 #define DOT_STATUS 0x03 /* .status (status) */
2022 #define DOT_VAL 0x04 /* .val (primal value) */
2023 #define DOT_DUAL 0x05 /* .dual (dual value) */
2026 #if 1 /* 15/V-2010 */
2027 /*--------------------------------------------------------------*/
2028 struct /* O_MEMCON */
2030 /* model constraint, which contains member to be taken */
2032 /* list of subscripys; NULL for 0-dimensional constraint */
2034 /* suffix specified (see O_MEMVAR above) */
2037 /*--------------------------------------------------------------*/
2038 ARG_LIST *list; /* O_TUPLE, O_MAKE, n-ary operations */
2039 /* list of operands */
2040 /*--------------------------------------------------------------*/
2041 DOMAIN_BLOCK *slice; /* O_SLICE */
2042 /* domain block, which specifies slice (i.e. n-tuple that contains
2043 free dummy indices); this operation is never evaluated */
2044 /*--------------------------------------------------------------*/
2045 struct /* unary, binary, ternary operations */
2047 /* pseudo-code for computing first operand */
2049 /* pseudo-code for computing second operand */
2051 /* pseudo-code for computing third operand */
2053 /*--------------------------------------------------------------*/
2054 struct /* iterated operations */
2056 /* domain, over which the operation is performed */
2058 /* pseudo-code for computing "integrand" */
2060 /*--------------------------------------------------------------*/
2064 { /* operands list entry */
2066 /* pseudo-code for computing operand */
2068 /* the next operand of the same operation */
2072 { /* pseudo-code (internal form of expressions) */
2074 /* operation code: */
2075 #define O_NUMBER 301 /* take floating-point number */
2076 #define O_STRING 302 /* take character string */
2077 #define O_INDEX 303 /* take dummy index */
2078 #define O_MEMNUM 304 /* take member of numeric parameter */
2079 #define O_MEMSYM 305 /* take member of symbolic parameter */
2080 #define O_MEMSET 306 /* take member of set */
2081 #define O_MEMVAR 307 /* take member of variable */
2082 #define O_MEMCON 308 /* take member of constraint */
2083 #define O_TUPLE 309 /* make n-tuple */
2084 #define O_MAKE 310 /* make elemental set of n-tuples */
2085 #define O_SLICE 311 /* define domain block (dummy op) */
2086 /* 0-ary operations --------------------*/
2087 #define O_IRAND224 312 /* pseudo-random in [0, 2^24-1] */
2088 #define O_UNIFORM01 313 /* pseudo-random in [0, 1) */
2089 #define O_NORMAL01 314 /* gaussian random, mu = 0, sigma = 1 */
2090 #define O_GMTIME 315 /* current calendar time (UTC) */
2091 /* unary operations --------------------*/
2092 #define O_CVTNUM 316 /* conversion to numeric */
2093 #define O_CVTSYM 317 /* conversion to symbolic */
2094 #define O_CVTLOG 318 /* conversion to logical */
2095 #define O_CVTTUP 319 /* conversion to 1-tuple */
2096 #define O_CVTLFM 320 /* conversion to linear form */
2097 #define O_PLUS 321 /* unary plus */
2098 #define O_MINUS 322 /* unary minus */
2099 #define O_NOT 323 /* negation (logical "not") */
2100 #define O_ABS 324 /* absolute value */
2101 #define O_CEIL 325 /* round upward ("ceiling of x") */
2102 #define O_FLOOR 326 /* round downward ("floor of x") */
2103 #define O_EXP 327 /* base-e exponential */
2104 #define O_LOG 328 /* natural logarithm */
2105 #define O_LOG10 329 /* common (decimal) logarithm */
2106 #define O_SQRT 330 /* square root */
2107 #define O_SIN 331 /* trigonometric sine */
2108 #define O_COS 332 /* trigonometric cosine */
2109 #define O_ATAN 333 /* trigonometric arctangent */
2110 #define O_ROUND 334 /* round to nearest integer */
2111 #define O_TRUNC 335 /* truncate to nearest integer */
2112 #define O_CARD 336 /* cardinality of set */
2113 #define O_LENGTH 337 /* length of symbolic value */
2114 /* binary operations -------------------*/
2115 #define O_ADD 338 /* addition */
2116 #define O_SUB 339 /* subtraction */
2117 #define O_LESS 340 /* non-negative subtraction */
2118 #define O_MUL 341 /* multiplication */
2119 #define O_DIV 342 /* division */
2120 #define O_IDIV 343 /* quotient of exact division */
2121 #define O_MOD 344 /* remainder of exact division */
2122 #define O_POWER 345 /* exponentiation (raise to power) */
2123 #define O_ATAN2 346 /* trigonometric arctangent */
2124 #define O_ROUND2 347 /* round to n fractional digits */
2125 #define O_TRUNC2 348 /* truncate to n fractional digits */
2126 #define O_UNIFORM 349 /* pseudo-random in [a, b) */
2127 #define O_NORMAL 350 /* gaussian random, given mu and sigma */
2128 #define O_CONCAT 351 /* concatenation */
2129 #define O_LT 352 /* comparison on 'less than' */
2130 #define O_LE 353 /* comparison on 'not greater than' */
2131 #define O_EQ 354 /* comparison on 'equal to' */
2132 #define O_GE 355 /* comparison on 'not less than' */
2133 #define O_GT 356 /* comparison on 'greater than' */
2134 #define O_NE 357 /* comparison on 'not equal to' */
2135 #define O_AND 358 /* conjunction (logical "and") */
2136 #define O_OR 359 /* disjunction (logical "or") */
2137 #define O_UNION 360 /* union */
2138 #define O_DIFF 361 /* difference */
2139 #define O_SYMDIFF 362 /* symmetric difference */
2140 #define O_INTER 363 /* intersection */
2141 #define O_CROSS 364 /* cross (Cartesian) product */
2142 #define O_IN 365 /* test on 'x in Y' */
2143 #define O_NOTIN 366 /* test on 'x not in Y' */
2144 #define O_WITHIN 367 /* test on 'X within Y' */
2145 #define O_NOTWITHIN 368 /* test on 'X not within Y' */
2146 #define O_SUBSTR 369 /* substring */
2147 #define O_STR2TIME 370 /* convert string to time */
2148 #define O_TIME2STR 371 /* convert time to string */
2149 /* ternary operations ------------------*/
2150 #define O_DOTS 372 /* build "arithmetic" set */
2151 #define O_FORK 373 /* if-then-else */
2152 #define O_SUBSTR3 374 /* substring */
2153 /* n-ary operations --------------------*/
2154 #define O_MIN 375 /* minimal value (n-ary) */
2155 #define O_MAX 376 /* maximal value (n-ary) */
2156 /* iterated operations -----------------*/
2157 #define O_SUM 377 /* summation */
2158 #define O_PROD 378 /* multiplication */
2159 #define O_MINIMUM 379 /* minimum */
2160 #define O_MAXIMUM 380 /* maximum */
2161 #define O_FORALL 381 /* conjunction (A-quantification) */
2162 #define O_EXISTS 382 /* disjunction (E-quantification) */
2163 #define O_SETOF 383 /* compute elemental set */
2164 #define O_BUILD 384 /* build elemental set */
2166 /* operands that participate in the operation */
2168 /* type of the resultant value:
2170 A_SYMBOLIC - symbolic
2173 A_ELEMSET - elemental set
2174 A_FORMULA - linear form */
2176 /* dimension of the resultant value; for A_TUPLE and A_ELEMSET it
2177 is the dimension of the corresponding n-tuple(s) and cannot be
2178 zero; for other resultant types it is always zero */
2180 /* parent pseudo-code, which refers to this pseudo-code as to its
2181 operand; NULL means this pseudo-code has no parent and defines
2182 an expression, which is not contained in another expression */
2184 /* volatile flag; being set this flag means that this operation
2185 has a side effect; for primary expressions this flag is set
2186 directly by corresponding parsing routines (for example, if
2187 primary expression is a reference to a function that generates
2188 pseudo-random numbers); in other cases this flag is inherited
2191 /* if this flag is set, the resultant value, which is a temporary
2192 result of evaluating this operation on particular values of
2193 operands, is valid; if this flag is clear, the resultant value
2194 doesn't exist and therefore not valid; having been evaluated
2195 the resultant value is stored here and not destroyed until the
2196 dummy indices, which this value depends on, have been changed
2197 (and if it doesn't depend on dummy indices at all, it is never
2198 destroyed); thus, if the resultant value is valid, evaluating
2199 routine can immediately take its copy not computing the result
2200 from scratch; this mechanism is similar to moving invariants
2201 out of loops and allows improving efficiency at the expense of
2202 some extra memory needed to keep temporary results */
2203 /* however, if the volatile flag (see above) is set, even if the
2204 resultant value is valid, evaluating routine computes it as if
2205 it were not valid, i.e. caching is not used in this case */
2207 /* resultant value in generic format */
2210 #define eval_numeric _glp_mpl_eval_numeric
2211 double eval_numeric(MPL *mpl, CODE *code);
2212 /* evaluate pseudo-code to determine numeric value */
2214 #define eval_symbolic _glp_mpl_eval_symbolic
2215 SYMBOL *eval_symbolic(MPL *mpl, CODE *code);
2216 /* evaluate pseudo-code to determine symbolic value */
2218 #define eval_logical _glp_mpl_eval_logical
2219 int eval_logical(MPL *mpl, CODE *code);
2220 /* evaluate pseudo-code to determine logical value */
2222 #define eval_tuple _glp_mpl_eval_tuple
2223 TUPLE *eval_tuple(MPL *mpl, CODE *code);
2224 /* evaluate pseudo-code to construct n-tuple */
2226 #define eval_elemset _glp_mpl_eval_elemset
2227 ELEMSET *eval_elemset(MPL *mpl, CODE *code);
2228 /* evaluate pseudo-code to construct elemental set */
2230 #define is_member _glp_mpl_is_member
2231 int is_member(MPL *mpl, CODE *code, TUPLE *tuple);
2232 /* check if n-tuple is in set specified by pseudo-code */
2234 #define eval_formula _glp_mpl_eval_formula
2235 FORMULA *eval_formula(MPL *mpl, CODE *code);
2236 /* evaluate pseudo-code to construct linear form */
2238 #define clean_code _glp_mpl_clean_code
2239 void clean_code(MPL *mpl, CODE *code);
2240 /* clean pseudo-code */
2242 /**********************************************************************/
2243 /* * * MODEL STATEMENTS * * */
2244 /**********************************************************************/
2247 { /* check statement */
2249 /* subscript domain; NULL means domain is not used */
2251 /* code for computing the predicate to be checked */
2255 { /* display statement */
2257 /* subscript domain; NULL means domain is not used */
2259 /* display list; cannot be empty */
2263 { /* display list entry */
2266 A_INDEX - dummy index
2268 A_PARAMETER - model parameter
2269 A_VARIABLE - model variable
2270 A_CONSTRAINT - model constraint/objective
2271 A_EXPRESSION - expression */
2273 { DOMAIN_SLOT *slot;
2280 /* item to be displayed */
2281 #if 0 /* 15/V-2010 */
2283 /* optional subscript list (for constraint/objective only) */
2286 /* the next entry for the same statement */
2290 { /* printf statement */
2292 /* subscript domain; NULL means domain is not used */
2294 /* pseudo-code for computing format string */
2296 /* printf list; can be empty */
2298 /* pseudo-code for computing filename to redirect the output;
2299 NULL means the output goes to stdout */
2301 /* if this flag is set, the output is appended */
2305 { /* printf list entry */
2307 /* pseudo-code for computing value to be printed */
2309 /* the next entry for the same statement */
2313 { /* for statement */
2315 /* subscript domain; cannot be NULL */
2317 /* linked list of model statements within this for statement in
2318 the original order */
2322 { /* model statement */
2324 /* number of source text line, where statement begins */
2327 A_SET - set statement
2328 A_PARAMETER - parameter statement
2329 A_VARIABLE - variable statement
2330 A_CONSTRAINT - constraint/objective statement
2331 A_TABLE - table statement
2332 A_SOLVE - solve statement
2333 A_CHECK - check statement
2334 A_DISPLAY - display statement
2335 A_PRINTF - printf statement
2336 A_FOR - for statement */
2343 void *slv; /* currently not used (set to NULL) */
2349 /* specific part of statement */
2351 /* the next statement; in this list statements follow in the same
2352 order as they appear in the model section */
2355 #define execute_table _glp_mpl_execute_table
2356 void execute_table(MPL *mpl, TABLE *tab);
2357 /* execute table statement */
2359 #define free_dca _glp_mpl_free_dca
2360 void free_dca(MPL *mpl);
2361 /* free table driver communucation area */
2363 #define clean_table _glp_mpl_clean_table
2364 void clean_table(MPL *mpl, TABLE *tab);
2365 /* clean table statement */
2367 #define execute_check _glp_mpl_execute_check
2368 void execute_check(MPL *mpl, CHECK *chk);
2369 /* execute check statement */
2371 #define clean_check _glp_mpl_clean_check
2372 void clean_check(MPL *mpl, CHECK *chk);
2373 /* clean check statement */
2375 #define execute_display _glp_mpl_execute_display
2376 void execute_display(MPL *mpl, DISPLAY *dpy);
2377 /* execute display statement */
2379 #define clean_display _glp_mpl_clean_display
2380 void clean_display(MPL *mpl, DISPLAY *dpy);
2381 /* clean display statement */
2383 #define execute_printf _glp_mpl_execute_printf
2384 void execute_printf(MPL *mpl, PRINTF *prt);
2385 /* execute printf statement */
2387 #define clean_printf _glp_mpl_clean_printf
2388 void clean_printf(MPL *mpl, PRINTF *prt);
2389 /* clean printf statement */
2391 #define execute_for _glp_mpl_execute_for
2392 void execute_for(MPL *mpl, FOR *fur);
2393 /* execute for statement */
2395 #define clean_for _glp_mpl_clean_for
2396 void clean_for(MPL *mpl, FOR *fur);
2397 /* clean for statement */
2399 #define execute_statement _glp_mpl_execute_statement
2400 void execute_statement(MPL *mpl, STATEMENT *stmt);
2401 /* execute specified model statement */
2403 #define clean_statement _glp_mpl_clean_statement
2404 void clean_statement(MPL *mpl, STATEMENT *stmt);
2405 /* clean specified model statement */
2407 /**********************************************************************/
2408 /* * * GENERATING AND POSTSOLVING MODEL * * */
2409 /**********************************************************************/
2411 #define alloc_content _glp_mpl_alloc_content
2412 void alloc_content(MPL *mpl);
2413 /* allocate content arrays for all model objects */
2415 #define generate_model _glp_mpl_generate_model
2416 void generate_model(MPL *mpl);
2417 /* generate model */
2419 #define build_problem _glp_mpl_build_problem
2420 void build_problem(MPL *mpl);
2421 /* build problem instance */
2423 #define postsolve_model _glp_mpl_postsolve_model
2424 void postsolve_model(MPL *mpl);
2425 /* postsolve model */
2427 #define clean_model _glp_mpl_clean_model
2428 void clean_model(MPL *mpl);
2429 /* clean model content */
2431 /**********************************************************************/
2432 /* * * INPUT/OUTPUT * * */
2433 /**********************************************************************/
2435 #define open_input _glp_mpl_open_input
2436 void open_input(MPL *mpl, char *file);
2437 /* open input text file */
2439 #define read_char _glp_mpl_read_char
2440 int read_char(MPL *mpl);
2441 /* read next character from input text file */
2443 #define close_input _glp_mpl_close_input
2444 void close_input(MPL *mpl);
2445 /* close input text file */
2447 #define open_output _glp_mpl_open_output
2448 void open_output(MPL *mpl, char *file);
2449 /* open output text file */
2451 #define write_char _glp_mpl_write_char
2452 void write_char(MPL *mpl, int c);
2453 /* write next character to output text file */
2455 #define write_text _glp_mpl_write_text
2456 void write_text(MPL *mpl, char *fmt, ...);
2457 /* format and write text to output text file */
2459 #define flush_output _glp_mpl_flush_output
2460 void flush_output(MPL *mpl);
2461 /* finalize writing data to output text file */
2463 /**********************************************************************/
2464 /* * * SOLVER INTERFACE * * */
2465 /**********************************************************************/
2467 #define MPL_FR 401 /* free (unbounded) */
2468 #define MPL_LO 402 /* lower bound */
2469 #define MPL_UP 403 /* upper bound */
2470 #define MPL_DB 404 /* both lower and upper bounds */
2471 #define MPL_FX 405 /* fixed */
2473 #define MPL_ST 411 /* constraint */
2474 #define MPL_MIN 412 /* objective (minimization) */
2475 #define MPL_MAX 413 /* objective (maximization) */
2477 #define MPL_NUM 421 /* continuous */
2478 #define MPL_INT 422 /* integer */
2479 #define MPL_BIN 423 /* binary */
2481 #define error _glp_mpl_error
2482 void error(MPL *mpl, char *fmt, ...);
2483 /* print error message and terminate model processing */
2485 #define warning _glp_mpl_warning
2486 void warning(MPL *mpl, char *fmt, ...);
2487 /* print warning message and continue model processing */
2489 #define mpl_initialize _glp_mpl_initialize
2490 MPL *mpl_initialize(void);
2491 /* create and initialize translator database */
2493 #define mpl_read_model _glp_mpl_read_model
2494 int mpl_read_model(MPL *mpl, char *file, int skip_data);
2495 /* read model section and optional data section */
2497 #define mpl_read_data _glp_mpl_read_data
2498 int mpl_read_data(MPL *mpl, char *file);
2499 /* read data section */
2501 #define mpl_generate _glp_mpl_generate
2502 int mpl_generate(MPL *mpl, char *file);
2503 /* generate model */
2505 #define mpl_get_prob_name _glp_mpl_get_prob_name
2506 char *mpl_get_prob_name(MPL *mpl);
2507 /* obtain problem (model) name */
2509 #define mpl_get_num_rows _glp_mpl_get_num_rows
2510 int mpl_get_num_rows(MPL *mpl);
2511 /* determine number of rows */
2513 #define mpl_get_num_cols _glp_mpl_get_num_cols
2514 int mpl_get_num_cols(MPL *mpl);
2515 /* determine number of columns */
2517 #define mpl_get_row_name _glp_mpl_get_row_name
2518 char *mpl_get_row_name(MPL *mpl, int i);
2519 /* obtain row name */
2521 #define mpl_get_row_kind _glp_mpl_get_row_kind
2522 int mpl_get_row_kind(MPL *mpl, int i);
2523 /* determine row kind */
2525 #define mpl_get_row_bnds _glp_mpl_get_row_bnds
2526 int mpl_get_row_bnds(MPL *mpl, int i, double *lb, double *ub);
2527 /* obtain row bounds */
2529 #define mpl_get_mat_row _glp_mpl_get_mat_row
2530 int mpl_get_mat_row(MPL *mpl, int i, int ndx[], double val[]);
2531 /* obtain row of the constraint matrix */
2533 #define mpl_get_row_c0 _glp_mpl_get_row_c0
2534 double mpl_get_row_c0(MPL *mpl, int i);
2535 /* obtain constant term of free row */
2537 #define mpl_get_col_name _glp_mpl_get_col_name
2538 char *mpl_get_col_name(MPL *mpl, int j);
2539 /* obtain column name */
2541 #define mpl_get_col_kind _glp_mpl_get_col_kind
2542 int mpl_get_col_kind(MPL *mpl, int j);
2543 /* determine column kind */
2545 #define mpl_get_col_bnds _glp_mpl_get_col_bnds
2546 int mpl_get_col_bnds(MPL *mpl, int j, double *lb, double *ub);
2547 /* obtain column bounds */
2549 #define mpl_has_solve_stmt _glp_mpl_has_solve_stmt
2550 int mpl_has_solve_stmt(MPL *mpl);
2551 /* check if model has solve statement */
2553 #if 1 /* 15/V-2010 */
2554 #define mpl_put_row_soln _glp_mpl_put_row_soln
2555 void mpl_put_row_soln(MPL *mpl, int i, int stat, double prim,
2557 /* store row (constraint/objective) solution components */
2560 #if 1 /* 15/V-2010 */
2561 #define mpl_put_col_soln _glp_mpl_put_col_soln
2562 void mpl_put_col_soln(MPL *mpl, int j, int stat, double prim,
2564 /* store column (variable) solution components */
2567 #if 0 /* 15/V-2010 */
2568 #define mpl_put_col_value _glp_mpl_put_col_value
2569 void mpl_put_col_value(MPL *mpl, int j, double val);
2570 /* store column value */
2573 #define mpl_postsolve _glp_mpl_postsolve
2574 int mpl_postsolve(MPL *mpl);
2575 /* postsolve model */
2577 #define mpl_terminate _glp_mpl_terminate
2578 void mpl_terminate(MPL *mpl);
2579 /* free all resources used by translator */