src/glpmpl.h
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

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