-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglpmpl.h
2591 lines (2253 loc) · 87.7 KB
/
glpmpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* glpmpl.h (GNU MathProg translator) */
/***********************************************************************
* This code is part of GLPK (GNU Linear Programming Kit).
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
* 2009, 2010, 2011, 2013 Andrew Makhorin, Department for Applied
* Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
* reserved. E-mail: <[email protected]>.
*
* GLPK is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GLPK is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#ifndef GLPMPL_H
#define GLPMPL_H
#include "glpavl.h"
#include "glprng.h"
#if 0 /* 22/I-2013 */
typedef struct MPL MPL;
#else
typedef struct glp_tran MPL;
#endif
typedef char STRING;
typedef struct SYMBOL SYMBOL;
typedef struct TUPLE TUPLE;
typedef struct ARRAY ELEMSET;
typedef struct ELEMVAR ELEMVAR;
typedef struct FORMULA FORMULA;
typedef struct ELEMCON ELEMCON;
typedef union VALUE VALUE;
typedef struct ARRAY ARRAY;
typedef struct MEMBER MEMBER;
#if 1
/* many C compilers have DOMAIN declared in <math.h> :( */
#undef DOMAIN
#define DOMAIN DOMAIN1
#endif
typedef struct DOMAIN DOMAIN;
typedef struct DOMAIN_BLOCK DOMAIN_BLOCK;
typedef struct DOMAIN_SLOT DOMAIN_SLOT;
typedef struct SET SET;
typedef struct WITHIN WITHIN;
typedef struct GADGET GADGET;
typedef struct PARAMETER PARAMETER;
typedef struct CONDITION CONDITION;
typedef struct VARIABLE VARIABLE;
typedef struct CONSTRAINT CONSTRAINT;
typedef struct TABLE TABLE;
typedef struct TABARG TABARG;
typedef struct TABFLD TABFLD;
typedef struct TABIN TABIN;
typedef struct TABOUT TABOUT;
typedef struct TABDCA TABDCA;
typedef union OPERANDS OPERANDS;
typedef struct ARG_LIST ARG_LIST;
typedef struct CODE CODE;
typedef struct CHECK CHECK;
typedef struct DISPLAY DISPLAY;
typedef struct DISPLAY1 DISPLAY1;
typedef struct PRINTF PRINTF;
typedef struct PRINTF1 PRINTF1;
typedef struct FOR FOR;
typedef struct STATEMENT STATEMENT;
typedef struct TUPLE SLICE;
/**********************************************************************/
/* * * TRANSLATOR DATABASE * * */
/**********************************************************************/
#define A_BINARY 101 /* something binary */
#define A_CHECK 102 /* check statement */
#define A_CONSTRAINT 103 /* model constraint */
#define A_DISPLAY 104 /* display statement */
#define A_ELEMCON 105 /* elemental constraint/objective */
#define A_ELEMSET 106 /* elemental set */
#define A_ELEMVAR 107 /* elemental variable */
#define A_EXPRESSION 108 /* expression */
#define A_FOR 109 /* for statement */
#define A_FORMULA 110 /* formula */
#define A_INDEX 111 /* dummy index */
#define A_INPUT 112 /* input table */
#define A_INTEGER 113 /* something integer */
#define A_LOGICAL 114 /* something logical */
#define A_MAXIMIZE 115 /* objective has to be maximized */
#define A_MINIMIZE 116 /* objective has to be minimized */
#define A_NONE 117 /* nothing */
#define A_NUMERIC 118 /* something numeric */
#define A_OUTPUT 119 /* output table */
#define A_PARAMETER 120 /* model parameter */
#define A_PRINTF 121 /* printf statement */
#define A_SET 122 /* model set */
#define A_SOLVE 123 /* solve statement */
#define A_SYMBOLIC 124 /* something symbolic */
#define A_TABLE 125 /* data table */
#define A_TUPLE 126 /* n-tuple */
#define A_VARIABLE 127 /* model variable */
#define MAX_LENGTH 100
/* maximal length of any symbolic value (this includes symbolic names,
numeric and string literals, and all symbolic values that may appear
during the evaluation phase) */
#define CONTEXT_SIZE 60
/* size of the context queue, in characters */
#define OUTBUF_SIZE 1024
/* size of the output buffer, in characters */
#if 0 /* 22/I-2013 */
struct MPL
#else
struct glp_tran
#endif
{ /* translator database */
/*--------------------------------------------------------------*/
/* scanning segment */
int line;
/* number of the current text line */
int c;
/* the current character or EOF */
int token;
/* the current token: */
#define T_EOF 201 /* end of file */
#define T_NAME 202 /* symbolic name (model section only) */
#define T_SYMBOL 203 /* symbol (data section only) */
#define T_NUMBER 204 /* numeric literal */
#define T_STRING 205 /* string literal */
#define T_AND 206 /* and && */
#define T_BY 207 /* by */
#define T_CROSS 208 /* cross */
#define T_DIFF 209 /* diff */
#define T_DIV 210 /* div */
#define T_ELSE 211 /* else */
#define T_IF 212 /* if */
#define T_IN 213 /* in */
#define T_INFINITY 214 /* Infinity */
#define T_INTER 215 /* inter */
#define T_LESS 216 /* less */
#define T_MOD 217 /* mod */
#define T_NOT 218 /* not ! */
#define T_OR 219 /* or || */
#define T_SPTP 220 /* s.t. */
#define T_SYMDIFF 221 /* symdiff */
#define T_THEN 222 /* then */
#define T_UNION 223 /* union */
#define T_WITHIN 224 /* within */
#define T_PLUS 225 /* + */
#define T_MINUS 226 /* - */
#define T_ASTERISK 227 /* * */
#define T_SLASH 228 /* / */
#define T_POWER 229 /* ^ ** */
#define T_LT 230 /* < */
#define T_LE 231 /* <= */
#define T_EQ 232 /* = == */
#define T_GE 233 /* >= */
#define T_GT 234 /* > */
#define T_NE 235 /* <> != */
#define T_CONCAT 236 /* & */
#define T_BAR 237 /* | */
#define T_POINT 238 /* . */
#define T_COMMA 239 /* , */
#define T_COLON 240 /* : */
#define T_SEMICOLON 241 /* ; */
#define T_ASSIGN 242 /* := */
#define T_DOTS 243 /* .. */
#define T_LEFT 244 /* ( */
#define T_RIGHT 245 /* ) */
#define T_LBRACKET 246 /* [ */
#define T_RBRACKET 247 /* ] */
#define T_LBRACE 248 /* { */
#define T_RBRACE 249 /* } */
#define T_APPEND 250 /* >> */
#define T_TILDE 251 /* ~ */
#define T_INPUT 252 /* <- */
int imlen;
/* length of the current token */
char *image; /* char image[MAX_LENGTH+1]; */
/* image of the current token */
double value;
/* value of the current token (for T_NUMBER only) */
int b_token;
/* the previous token */
int b_imlen;
/* length of the previous token */
char *b_image; /* char b_image[MAX_LENGTH+1]; */
/* image of the previous token */
double b_value;
/* value of the previous token (if token is T_NUMBER) */
int f_dots;
/* if this flag is set, the next token should be recognized as
T_DOTS, not as T_POINT */
int f_scan;
/* if this flag is set, the next token is already scanned */
int f_token;
/* the next token */
int f_imlen;
/* length of the next token */
char *f_image; /* char f_image[MAX_LENGTH+1]; */
/* image of the next token */
double f_value;
/* value of the next token (if token is T_NUMBER) */
char *context; /* char context[CONTEXT_SIZE]; */
/* context circular queue (not null-terminated!) */
int c_ptr;
/* pointer to the current position in the context queue */
int flag_d;
/* if this flag is set, the data section is being processed */
/*--------------------------------------------------------------*/
/* translating segment */
DMP *pool;
/* memory pool used to allocate all data instances created during
the translation phase */
AVL *tree;
/* symbolic name table:
node.type = A_INDEX => node.link -> DOMAIN_SLOT
node.type = A_SET => node.link -> SET
node.type = A_PARAMETER => node.link -> PARAMETER
node.type = A_VARIABLE => node.link -> VARIABLE
node.type = A_CONSTRANT => node.link -> CONSTRAINT */
STATEMENT *model;
/* linked list of model statements in the original order */
int flag_x;
/* if this flag is set, the current token being left parenthesis
begins a slice that allows recognizing any undeclared symbolic
names as dummy indices; this flag is automatically reset once
the next token has been scanned */
int as_within;
/* the warning "in understood as within" has been issued */
int as_in;
/* the warning "within understood as in" has been issued */
int as_binary;
/* the warning "logical understood as binary" has been issued */
int flag_s;
/* if this flag is set, the solve statement has been parsed */
/*--------------------------------------------------------------*/
/* common segment */
DMP *strings;
/* memory pool to allocate STRING data structures */
DMP *symbols;
/* memory pool to allocate SYMBOL data structures */
DMP *tuples;
/* memory pool to allocate TUPLE data structures */
DMP *arrays;
/* memory pool to allocate ARRAY data structures */
DMP *members;
/* memory pool to allocate MEMBER data structures */
DMP *elemvars;
/* memory pool to allocate ELEMVAR data structures */
DMP *formulae;
/* memory pool to allocate FORMULA data structures */
DMP *elemcons;
/* memory pool to allocate ELEMCON data structures */
ARRAY *a_list;
/* linked list of all arrays in the database */
char *sym_buf; /* char sym_buf[255+1]; */
/* working buffer used by the routine format_symbol */
char *tup_buf; /* char tup_buf[255+1]; */
/* working buffer used by the routine format_tuple */
/*--------------------------------------------------------------*/
/* generating/postsolving segment */
RNG *rand;
/* pseudo-random number generator */
int flag_p;
/* if this flag is set, the postsolving phase is in effect */
STATEMENT *stmt;
/* model statement being currently executed */
TABDCA *dca;
/* pointer to table driver communication area for table statement
currently executed */
int m;
/* number of rows in the problem, m >= 0 */
int n;
/* number of columns in the problem, n >= 0 */
ELEMCON **row; /* ELEMCON *row[1+m]; */
/* row[0] is not used;
row[i] is elemental constraint or objective, which corresponds
to i-th row of the problem, 1 <= i <= m */
ELEMVAR **col; /* ELEMVAR *col[1+n]; */
/* col[0] is not used;
col[j] is elemental variable, which corresponds to j-th column
of the problem, 1 <= j <= n */
/*--------------------------------------------------------------*/
/* input/output segment */
XFILE *in_fp;
/* stream assigned to the input text file */
char *in_file;
/* name of the input text file */
XFILE *out_fp;
/* stream assigned to the output text file used to write all data
produced by display and printf statements; NULL means the data
should be sent to stdout via the routine xprintf */
char *out_file;
/* name of the output text file */
#if 0 /* 08/XI-2009 */
char *out_buf; /* char out_buf[OUTBUF_SIZE] */
/* buffer to accumulate output data */
int out_cnt;
/* count of data bytes stored in the output buffer */
#endif
XFILE *prt_fp;
/* stream assigned to the print text file; may be NULL */
char *prt_file;
/* name of the output print file */
/*--------------------------------------------------------------*/
/* solver interface segment */
jmp_buf jump;
/* jump address for non-local go to in case of error */
int phase;
/* phase of processing:
0 - database is being or has been initialized
1 - model section is being or has been read
2 - data section is being or has been read
3 - model is being or has been generated/postsolved
4 - model processing error has occurred */
char *mod_file;
/* name of the input text file, which contains model section */
char *mpl_buf; /* char mpl_buf[255+1]; */
/* working buffer used by some interface routines */
};
/**********************************************************************/
/* * * PROCESSING MODEL SECTION * * */
/**********************************************************************/
#define alloc(type) ((type *)dmp_get_atomv(mpl->pool, sizeof(type)))
/* allocate atom of given type */
#define enter_context _glp_mpl_enter_context
void enter_context(MPL *mpl);
/* enter current token into context queue */
#define print_context _glp_mpl_print_context
void print_context(MPL *mpl);
/* print current content of context queue */
#define get_char _glp_mpl_get_char
void get_char(MPL *mpl);
/* scan next character from input text file */
#define append_char _glp_mpl_append_char
void append_char(MPL *mpl);
/* append character to current token */
#define get_token _glp_mpl_get_token
void get_token(MPL *mpl);
/* scan next token from input text file */
#define unget_token _glp_mpl_unget_token
void unget_token(MPL *mpl);
/* return current token back to input stream */
#define is_keyword _glp_mpl_is_keyword
int is_keyword(MPL *mpl, char *keyword);
/* check if current token is given non-reserved keyword */
#define is_reserved _glp_mpl_is_reserved
int is_reserved(MPL *mpl);
/* check if current token is reserved keyword */
#define make_code _glp_mpl_make_code
CODE *make_code(MPL *mpl, int op, OPERANDS *arg, int type, int dim);
/* generate pseudo-code (basic routine) */
#define make_unary _glp_mpl_make_unary
CODE *make_unary(MPL *mpl, int op, CODE *x, int type, int dim);
/* generate pseudo-code for unary operation */
#define make_binary _glp_mpl_make_binary
CODE *make_binary(MPL *mpl, int op, CODE *x, CODE *y, int type,
int dim);
/* generate pseudo-code for binary operation */
#define make_ternary _glp_mpl_make_ternary
CODE *make_ternary(MPL *mpl, int op, CODE *x, CODE *y, CODE *z,
int type, int dim);
/* generate pseudo-code for ternary operation */
#define numeric_literal _glp_mpl_numeric_literal
CODE *numeric_literal(MPL *mpl);
/* parse reference to numeric literal */
#define string_literal _glp_mpl_string_literal
CODE *string_literal(MPL *mpl);
/* parse reference to string literal */
#define create_arg_list _glp_mpl_create_arg_list
ARG_LIST *create_arg_list(MPL *mpl);
/* create empty operands list */
#define expand_arg_list _glp_mpl_expand_arg_list
ARG_LIST *expand_arg_list(MPL *mpl, ARG_LIST *list, CODE *x);
/* append operand to operands list */
#define arg_list_len _glp_mpl_arg_list_len
int arg_list_len(MPL *mpl, ARG_LIST *list);
/* determine length of operands list */
#define subscript_list _glp_mpl_subscript_list
ARG_LIST *subscript_list(MPL *mpl);
/* parse subscript list */
#define object_reference _glp_mpl_object_reference
CODE *object_reference(MPL *mpl);
/* parse reference to named object */
#define numeric_argument _glp_mpl_numeric_argument
CODE *numeric_argument(MPL *mpl, char *func);
/* parse argument passed to built-in function */
#define symbolic_argument _glp_mpl_symbolic_argument
CODE *symbolic_argument(MPL *mpl, char *func);
#define elemset_argument _glp_mpl_elemset_argument
CODE *elemset_argument(MPL *mpl, char *func);
#define function_reference _glp_mpl_function_reference
CODE *function_reference(MPL *mpl);
/* parse reference to built-in function */
#define create_domain _glp_mpl_create_domain
DOMAIN *create_domain(MPL *mpl);
/* create empty domain */
#define create_block _glp_mpl_create_block
DOMAIN_BLOCK *create_block(MPL *mpl);
/* create empty domain block */
#define append_block _glp_mpl_append_block
void append_block(MPL *mpl, DOMAIN *domain, DOMAIN_BLOCK *block);
/* append domain block to specified domain */
#define append_slot _glp_mpl_append_slot
DOMAIN_SLOT *append_slot(MPL *mpl, DOMAIN_BLOCK *block, char *name,
CODE *code);
/* create and append new slot to domain block */
#define expression_list _glp_mpl_expression_list
CODE *expression_list(MPL *mpl);
/* parse expression list */
#define literal_set _glp_mpl_literal_set
CODE *literal_set(MPL *mpl, CODE *code);
/* parse literal set */
#define indexing_expression _glp_mpl_indexing_expression
DOMAIN *indexing_expression(MPL *mpl);
/* parse indexing expression */
#define close_scope _glp_mpl_close_scope
void close_scope(MPL *mpl, DOMAIN *domain);
/* close scope of indexing expression */
#define iterated_expression _glp_mpl_iterated_expression
CODE *iterated_expression(MPL *mpl);
/* parse iterated expression */
#define domain_arity _glp_mpl_domain_arity
int domain_arity(MPL *mpl, DOMAIN *domain);
/* determine arity of domain */
#define set_expression _glp_mpl_set_expression
CODE *set_expression(MPL *mpl);
/* parse set expression */
#define branched_expression _glp_mpl_branched_expression
CODE *branched_expression(MPL *mpl);
/* parse conditional expression */
#define primary_expression _glp_mpl_primary_expression
CODE *primary_expression(MPL *mpl);
/* parse primary expression */
#define error_preceding _glp_mpl_error_preceding
void error_preceding(MPL *mpl, char *opstr);
/* raise error if preceding operand has wrong type */
#define error_following _glp_mpl_error_following
void error_following(MPL *mpl, char *opstr);
/* raise error if following operand has wrong type */
#define error_dimension _glp_mpl_error_dimension
void error_dimension(MPL *mpl, char *opstr, int dim1, int dim2);
/* raise error if operands have different dimension */
#define expression_0 _glp_mpl_expression_0
CODE *expression_0(MPL *mpl);
/* parse expression of level 0 */
#define expression_1 _glp_mpl_expression_1
CODE *expression_1(MPL *mpl);
/* parse expression of level 1 */
#define expression_2 _glp_mpl_expression_2
CODE *expression_2(MPL *mpl);
/* parse expression of level 2 */
#define expression_3 _glp_mpl_expression_3
CODE *expression_3(MPL *mpl);
/* parse expression of level 3 */
#define expression_4 _glp_mpl_expression_4
CODE *expression_4(MPL *mpl);
/* parse expression of level 4 */
#define expression_5 _glp_mpl_expression_5
CODE *expression_5(MPL *mpl);
/* parse expression of level 5 */
#define expression_6 _glp_mpl_expression_6
CODE *expression_6(MPL *mpl);
/* parse expression of level 6 */
#define expression_7 _glp_mpl_expression_7
CODE *expression_7(MPL *mpl);
/* parse expression of level 7 */
#define expression_8 _glp_mpl_expression_8
CODE *expression_8(MPL *mpl);
/* parse expression of level 8 */
#define expression_9 _glp_mpl_expression_9
CODE *expression_9(MPL *mpl);
/* parse expression of level 9 */
#define expression_10 _glp_mpl_expression_10
CODE *expression_10(MPL *mpl);
/* parse expression of level 10 */
#define expression_11 _glp_mpl_expression_11
CODE *expression_11(MPL *mpl);
/* parse expression of level 11 */
#define expression_12 _glp_mpl_expression_12
CODE *expression_12(MPL *mpl);
/* parse expression of level 12 */
#define expression_13 _glp_mpl_expression_13
CODE *expression_13(MPL *mpl);
/* parse expression of level 13 */
#define set_statement _glp_mpl_set_statement
SET *set_statement(MPL *mpl);
/* parse set statement */
#define parameter_statement _glp_mpl_parameter_statement
PARAMETER *parameter_statement(MPL *mpl);
/* parse parameter statement */
#define variable_statement _glp_mpl_variable_statement
VARIABLE *variable_statement(MPL *mpl);
/* parse variable statement */
#define constraint_statement _glp_mpl_constraint_statement
CONSTRAINT *constraint_statement(MPL *mpl);
/* parse constraint statement */
#define objective_statement _glp_mpl_objective_statement
CONSTRAINT *objective_statement(MPL *mpl);
/* parse objective statement */
#define table_statement _glp_mpl_table_statement
TABLE *table_statement(MPL *mpl);
/* parse table statement */
#define solve_statement _glp_mpl_solve_statement
void *solve_statement(MPL *mpl);
/* parse solve statement */
#define check_statement _glp_mpl_check_statement
CHECK *check_statement(MPL *mpl);
/* parse check statement */
#define display_statement _glp_mpl_display_statement
DISPLAY *display_statement(MPL *mpl);
/* parse display statement */
#define printf_statement _glp_mpl_printf_statement
PRINTF *printf_statement(MPL *mpl);
/* parse printf statement */
#define for_statement _glp_mpl_for_statement
FOR *for_statement(MPL *mpl);
/* parse for statement */
#define end_statement _glp_mpl_end_statement
void end_statement(MPL *mpl);
/* parse end statement */
#define simple_statement _glp_mpl_simple_statement
STATEMENT *simple_statement(MPL *mpl, int spec);
/* parse simple statement */
#define model_section _glp_mpl_model_section
void model_section(MPL *mpl);
/* parse model section */
/**********************************************************************/
/* * * PROCESSING DATA SECTION * * */
/**********************************************************************/
#if 2 + 2 == 5
struct SLICE /* see TUPLE */
{ /* component of slice; the slice itself is associated with its
first component; slices are similar to n-tuples with exception
that some slice components (which are indicated by asterisks)
don't refer to any symbols */
SYMBOL *sym;
/* symbol, which this component refers to; can be NULL */
SLICE *next;
/* the next component of slice */
};
#endif
#define create_slice _glp_mpl_create_slice
SLICE *create_slice(MPL *mpl);
/* create slice */
#define expand_slice _glp_mpl_expand_slice
SLICE *expand_slice
( MPL *mpl,
SLICE *slice, /* destroyed */
SYMBOL *sym /* destroyed */
);
/* append new component to slice */
#define slice_dimen _glp_mpl_slice_dimen
int slice_dimen
( MPL *mpl,
SLICE *slice /* not changed */
);
/* determine dimension of slice */
#define slice_arity _glp_mpl_slice_arity
int slice_arity
( MPL *mpl,
SLICE *slice /* not changed */
);
/* determine arity of slice */
#define fake_slice _glp_mpl_fake_slice
SLICE *fake_slice(MPL *mpl, int dim);
/* create fake slice of all asterisks */
#define delete_slice _glp_mpl_delete_slice
void delete_slice
( MPL *mpl,
SLICE *slice /* destroyed */
);
/* delete slice */
#define is_number _glp_mpl_is_number
int is_number(MPL *mpl);
/* check if current token is number */
#define is_symbol _glp_mpl_is_symbol
int is_symbol(MPL *mpl);
/* check if current token is symbol */
#define is_literal _glp_mpl_is_literal
int is_literal(MPL *mpl, char *literal);
/* check if current token is given symbolic literal */
#define read_number _glp_mpl_read_number
double read_number(MPL *mpl);
/* read number */
#define read_symbol _glp_mpl_read_symbol
SYMBOL *read_symbol(MPL *mpl);
/* read symbol */
#define read_slice _glp_mpl_read_slice
SLICE *read_slice
( MPL *mpl,
char *name, /* not changed */
int dim
);
/* read slice */
#define select_set _glp_mpl_select_set
SET *select_set
( MPL *mpl,
char *name /* not changed */
);
/* select set to saturate it with elemental sets */
#define simple_format _glp_mpl_simple_format
void simple_format
( MPL *mpl,
SET *set, /* not changed */
MEMBER *memb, /* modified */
SLICE *slice /* not changed */
);
/* read set data block in simple format */
#define matrix_format _glp_mpl_matrix_format
void matrix_format
( MPL *mpl,
SET *set, /* not changed */
MEMBER *memb, /* modified */
SLICE *slice, /* not changed */
int tr
);
/* read set data block in matrix format */
#define set_data _glp_mpl_set_data
void set_data(MPL *mpl);
/* read set data */
#define select_parameter _glp_mpl_select_parameter
PARAMETER *select_parameter
( MPL *mpl,
char *name /* not changed */
);
/* select parameter to saturate it with data */
#define set_default _glp_mpl_set_default
void set_default
( MPL *mpl,
PARAMETER *par, /* not changed */
SYMBOL *altval /* destroyed */
);
/* set default parameter value */
#define read_value _glp_mpl_read_value
MEMBER *read_value
( MPL *mpl,
PARAMETER *par, /* not changed */
TUPLE *tuple /* destroyed */
);
/* read value and assign it to parameter member */
#define plain_format _glp_mpl_plain_format
void plain_format
( MPL *mpl,
PARAMETER *par, /* not changed */
SLICE *slice /* not changed */
);
/* read parameter data block in plain format */
#define tabular_format _glp_mpl_tabular_format
void tabular_format
( MPL *mpl,
PARAMETER *par, /* not changed */
SLICE *slice, /* not changed */
int tr
);
/* read parameter data block in tabular format */
#define tabbing_format _glp_mpl_tabbing_format
void tabbing_format
( MPL *mpl,
SYMBOL *altval /* not changed */
);
/* read parameter data block in tabbing format */
#define parameter_data _glp_mpl_parameter_data
void parameter_data(MPL *mpl);
/* read parameter data */
#define data_section _glp_mpl_data_section
void data_section(MPL *mpl);
/* read data section */
/**********************************************************************/
/* * * FLOATING-POINT NUMBERS * * */
/**********************************************************************/
#define fp_add _glp_mpl_fp_add
double fp_add(MPL *mpl, double x, double y);
/* floating-point addition */
#define fp_sub _glp_mpl_fp_sub
double fp_sub(MPL *mpl, double x, double y);
/* floating-point subtraction */
#define fp_less _glp_mpl_fp_less
double fp_less(MPL *mpl, double x, double y);
/* floating-point non-negative subtraction */
#define fp_mul _glp_mpl_fp_mul
double fp_mul(MPL *mpl, double x, double y);
/* floating-point multiplication */
#define fp_div _glp_mpl_fp_div
double fp_div(MPL *mpl, double x, double y);
/* floating-point division */
#define fp_idiv _glp_mpl_fp_idiv
double fp_idiv(MPL *mpl, double x, double y);
/* floating-point quotient of exact division */
#define fp_mod _glp_mpl_fp_mod
double fp_mod(MPL *mpl, double x, double y);
/* floating-point remainder of exact division */
#define fp_power _glp_mpl_fp_power
double fp_power(MPL *mpl, double x, double y);
/* floating-point exponentiation (raise to power) */
#define fp_exp _glp_mpl_fp_exp
double fp_exp(MPL *mpl, double x);
/* floating-point base-e exponential */
#define fp_log _glp_mpl_fp_log
double fp_log(MPL *mpl, double x);
/* floating-point natural logarithm */
#define fp_log10 _glp_mpl_fp_log10
double fp_log10(MPL *mpl, double x);
/* floating-point common (decimal) logarithm */
#define fp_sqrt _glp_mpl_fp_sqrt
double fp_sqrt(MPL *mpl, double x);
/* floating-point square root */
#define fp_sin _glp_mpl_fp_sin
double fp_sin(MPL *mpl, double x);
/* floating-point trigonometric sine */
#define fp_cos _glp_mpl_fp_cos
double fp_cos(MPL *mpl, double x);
/* floating-point trigonometric cosine */
#define fp_atan _glp_mpl_fp_atan
double fp_atan(MPL *mpl, double x);
/* floating-point trigonometric arctangent */
#define fp_atan2 _glp_mpl_fp_atan2
double fp_atan2(MPL *mpl, double y, double x);
/* floating-point trigonometric arctangent */
#define fp_round _glp_mpl_fp_round
double fp_round(MPL *mpl, double x, double n);
/* round floating-point value to n fractional digits */
#define fp_trunc _glp_mpl_fp_trunc
double fp_trunc(MPL *mpl, double x, double n);
/* truncate floating-point value to n fractional digits */
/**********************************************************************/
/* * * PSEUDO-RANDOM NUMBER GENERATORS * * */
/**********************************************************************/
#define fp_irand224 _glp_mpl_fp_irand224
double fp_irand224(MPL *mpl);
/* pseudo-random integer in the range [0, 2^24) */
#define fp_uniform01 _glp_mpl_fp_uniform01
double fp_uniform01(MPL *mpl);
/* pseudo-random number in the range [0, 1) */
#define fp_uniform _glp_mpl_uniform
double fp_uniform(MPL *mpl, double a, double b);
/* pseudo-random number in the range [a, b) */
#define fp_normal01 _glp_mpl_fp_normal01
double fp_normal01(MPL *mpl);
/* Gaussian random variate with mu = 0 and sigma = 1 */
#define fp_normal _glp_mpl_fp_normal
double fp_normal(MPL *mpl, double mu, double sigma);
/* Gaussian random variate with specified mu and sigma */
/**********************************************************************/
/* * * DATE/TIME * * */
/**********************************************************************/
#define fn_gmtime _glp_mpl_fn_gmtime
double fn_gmtime(MPL *mpl);
/* obtain the current calendar time (UTC) */
#define fn_str2time _glp_mpl_fn_str2time
double fn_str2time(MPL *mpl, const char *str, const char *fmt);
/* convert character string to the calendar time */
#define fn_time2str _glp_mpl_fn_time2str
void fn_time2str(MPL *mpl, char *str, double t, const char *fmt);
/* convert the calendar time to character string */
/**********************************************************************/
/* * * CHARACTER STRINGS * * */
/**********************************************************************/
#define create_string _glp_mpl_create_string
STRING *create_string
( MPL *mpl,
char buf[MAX_LENGTH+1] /* not changed */
);
/* create character string */
#define copy_string _glp_mpl_copy_string
STRING *copy_string
( MPL *mpl,
STRING *str /* not changed */
);
/* make copy of character string */
#define compare_strings _glp_mpl_compare_strings
int compare_strings
( MPL *mpl,
STRING *str1, /* not changed */
STRING *str2 /* not changed */
);
/* compare one character string with another */
#define fetch_string _glp_mpl_fetch_string
char *fetch_string
( MPL *mpl,
STRING *str, /* not changed */
char buf[MAX_LENGTH+1] /* modified */
);
/* extract content of character string */
#define delete_string _glp_mpl_delete_string
void delete_string
( MPL *mpl,
STRING *str /* destroyed */
);
/* delete character string */
/**********************************************************************/
/* * * SYMBOLS * * */
/**********************************************************************/
struct SYMBOL
{ /* symbol (numeric or abstract quantity) */
double num;
/* numeric value of symbol (used only if str == NULL) */
STRING *str;
/* abstract value of symbol (used only if str != NULL) */
};
#define create_symbol_num _glp_mpl_create_symbol_num
SYMBOL *create_symbol_num(MPL *mpl, double num);
/* create symbol of numeric type */
#define create_symbol_str _glp_mpl_create_symbol_str
SYMBOL *create_symbol_str
( MPL *mpl,
STRING *str /* destroyed */
);
/* create symbol of abstract type */
#define copy_symbol _glp_mpl_copy_symbol
SYMBOL *copy_symbol
( MPL *mpl,
SYMBOL *sym /* not changed */
);
/* make copy of symbol */
#define compare_symbols _glp_mpl_compare_symbols
int compare_symbols
( MPL *mpl,
SYMBOL *sym1, /* not changed */
SYMBOL *sym2 /* not changed */
);
/* compare one symbol with another */
#define delete_symbol _glp_mpl_delete_symbol
void delete_symbol
( MPL *mpl,
SYMBOL *sym /* destroyed */
);
/* delete symbol */
#define format_symbol _glp_mpl_format_symbol
char *format_symbol
( MPL *mpl,
SYMBOL *sym /* not changed */
);
/* format symbol for displaying or printing */
#define concat_symbols _glp_mpl_concat_symbols
SYMBOL *concat_symbols
( MPL *mpl,
SYMBOL *sym1, /* destroyed */
SYMBOL *sym2 /* destroyed */
);
/* concatenate one symbol with another */
/**********************************************************************/
/* * * N-TUPLES * * */
/**********************************************************************/
struct TUPLE
{ /* component of n-tuple; the n-tuple itself is associated with
its first component; (note that 0-tuple has no components) */