GAMS file writer.
Definition in file reader_gms.c.
#include "blockmemshell/memory.h"#include "scip/cons_and.h"#include "scip/cons_nonlinear.h"#include "scip/cons_indicator.h"#include "scip/cons_knapsack.h"#include "scip/cons_linear.h"#include "scip/cons_logicor.h"#include "scip/cons_setppc.h"#include "scip/cons_sos1.h"#include "scip/cons_sos2.h"#include "scip/cons_varbound.h"#include "scip/pub_cons.h"#include "scip/pub_message.h"#include "scip/pub_misc.h"#include "scip/pub_reader.h"#include "scip/pub_var.h"#include "scip/reader_gms.h"#include "scip/scip_cons.h"#include "scip/scip_general.h"#include "scip/scip_mem.h"#include "scip/scip_message.h"#include "scip/scip_numerics.h"#include "scip/scip_param.h"#include "scip/scip_reader.h"#include "scip/scip_var.h"#include "scip/expr_abs.h"Go to the source code of this file.
Macros | |
| #define | READER_NAME "gmsreader" |
| #define | READER_DESC "file writer for (MI)(N)LPs in GAMS file format" |
| #define | READER_EXTENSION "gms" |
| #define | GMS_MAX_LINELEN 256 |
| #define | GMS_MAX_PRINTLEN 256 |
| #define | GMS_MAX_NAMELEN 64 |
| #define | GMS_PRINTLEN 100 |
| #define | GMS_DEFAULT_BIGM 1e+6 |
| #define | GMS_DEFAULT_INDICATORREFORM 's' |
Functions | |
| static SCIP_RETCODE | getActiveVariables (SCIP *scip, SCIP_VAR ***vars, SCIP_Real **scalars, int *nvars, int *varssize, SCIP_Real *constant, SCIP_Bool transformed) |
| static void | clearLine (char *linebuffer, int *linecnt) |
| static void | endLine (SCIP *scip, FILE *file, char *linebuffer, int *linecnt) |
| static void | endLineNoNewline (SCIP *scip, FILE *file, char *linebuffer, int *linecnt) |
| static void | appendLine (SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *extension) |
| static void | conformName (char *name) |
| static SCIP_RETCODE | printConformName (SCIP *scip, char *t, int len, const char *name) |
| static SCIP_RETCODE | printActiveVariables (SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *prefix, const char *suffix, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Bool transformed) |
| static SCIP_RETCODE | printLinearRow (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real rhs) |
| static SCIP_RETCODE | printLinearCons (SCIP *scip, FILE *file, const char *rowname, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed) |
| static SCIP_RETCODE | printIndicatorCons (SCIP *scip, FILE *file, const char *rowname, SCIP_VAR *z, SCIP_VAR *s, SCIP_Bool *sossetdeclr, SCIP_Bool transformed) |
| static SCIP_RETCODE | printSOSCons (SCIP *scip, FILE *file, const char *rowname, int nvars, SCIP_VAR **vars, int sostype, SCIP_Bool transformed) |
| static SCIP_RETCODE | printAndCons (SCIP *scip, FILE *file, const char *rowname, int nvars, SCIP_VAR **vars, SCIP_VAR *resultant, SCIP_Bool transformed) |
| static SCIP_RETCODE | printExpr (SCIP *scip, FILE *file, char *linebuffer, int *linecnt, SCIP_Bool *nsmooth, SCIP_Bool *nqcons, SCIP_Bool transformed, SCIP_EXPR *expr) |
| static SCIP_RETCODE | printNonlinearRow (SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_EXPR *expr, SCIP_Real rhs, SCIP_Bool transformed, SCIP_Bool *nsmooth, SCIP_Bool *nqcons) |
| static SCIP_RETCODE | printNonlinearCons (SCIP *scip, FILE *file, const char *rowname, SCIP_EXPR *expr, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed, SCIP_Bool *nsmooth, SCIP_Bool *nqcons) |
| static SCIP_RETCODE | checkVarnames (SCIP *scip, SCIP_VAR **vars, int nvars) |
| static SCIP_RETCODE | checkConsnames (SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_Bool transformed) |
| static | SCIP_DECL_READERCOPY (readerCopyGms) |
| static | SCIP_DECL_READERWRITE (readerWriteGms) |
| SCIP_RETCODE | SCIPincludeReaderGms (SCIP *scip) |
| SCIP_RETCODE | SCIPwriteGms (SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result) |
Variables | |
| static const char | badchars [] = "#*+/-@$[](){}" |
| #define READER_NAME "gmsreader" |
Definition at line 64 of file reader_gms.c.
| #define READER_DESC "file writer for (MI)(N)LPs in GAMS file format" |
Definition at line 65 of file reader_gms.c.
| #define READER_EXTENSION "gms" |
Definition at line 66 of file reader_gms.c.
| #define GMS_MAX_LINELEN 256 |
Definition at line 69 of file reader_gms.c.
Referenced by endLine(), endLineNoNewline(), and SCIPwriteGms().
| #define GMS_MAX_PRINTLEN 256 |
the maximum length of any line is 255 + '\0' = 256
Definition at line 70 of file reader_gms.c.
Referenced by appendLine(), printActiveVariables(), printAndCons(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printSOSCons(), and SCIPwriteGms().
| #define GMS_MAX_NAMELEN 64 |
the maximum length for any name is 63 + '\0' = 64
Definition at line 71 of file reader_gms.c.
Referenced by checkConsnames(), checkVarnames(), printActiveVariables(), printAndCons(), printExpr(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printSOSCons(), and SCIPwriteGms().
| #define GMS_PRINTLEN 100 |
Definition at line 72 of file reader_gms.c.
Referenced by appendLine(), and printExpr().
| #define GMS_DEFAULT_BIGM 1e+6 |
Definition at line 73 of file reader_gms.c.
Referenced by SCIPincludeReaderGms().
| #define GMS_DEFAULT_INDICATORREFORM 's' |
Definition at line 74 of file reader_gms.c.
Referenced by SCIPincludeReaderGms().
|
static |
transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant
| scip | SCIP data structure |
| vars | pointer to vars array to get active variables for |
| scalars | pointer to scalars a_1, ..., a_n in linear sum a_1*x_1 + ... + a_n*x_n + c |
| nvars | pointer to number of variables and values in vars and vals array |
| varssize | pointer to length of vars and scalars array |
| constant | pointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c |
| transformed | transformed constraint? |
Definition at line 84 of file reader_gms.c.
References assert(), getActiveVariables(), NULL, nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPcalcMemGrowSize(), SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, SCIPvarGetOrigvarSum(), and vars.
|
static |
clears the given line buffer
| linebuffer | line |
| linecnt | number of characters in line |
Definition at line 135 of file reader_gms.c.
References assert(), clearLine(), and NULL.
Referenced by clearLine(), clearLine(), clearLine(), clearLine(), clearLine(), endLine(), endLine(), endLine(), endLine(), endLineNoNewline(), printAndCons(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printRow(), printRow(), printRow(), printRowAnd(), printRowExact(), printRowNl(), printSOSCons(), printSosCons(), SCIPwriteGms(), SCIPwriteLp(), SCIPwritePbm(), SCIPwritePip(), and SCIPwritePpm().
|
static |
ends the given line with '\0' and prints it to the given file stream, with a newline at the end
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line |
| linecnt | number of characters in line |
Definition at line 149 of file reader_gms.c.
References assert(), clearLine(), endLine(), GMS_MAX_LINELEN, NULL, and SCIPinfoMessage().
Referenced by appendLine(), appendLine(), appendLine(), appendLine(), endLine(), endLine(), endLine(), endLine(), printAndCons(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printRow(), printRow(), printRow(), printRowAnd(), printRowExact(), printRowNl(), printSOSCons(), printSosCons(), SCIPwriteGms(), SCIPwriteLp(), and SCIPwritePip().
|
static |
ends the given line with '\0' and prints it to the given file stream, without a newline at the end
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line |
| linecnt | number of characters in line |
Definition at line 171 of file reader_gms.c.
References assert(), clearLine(), endLineNoNewline(), GMS_MAX_LINELEN, NULL, and SCIPinfoMessage().
Referenced by endLineNoNewline(), and printExpr().
|
static |
appends extension to line and prints it to the give file stream if the line exceeded the length given in the define GMS_PRINTLEN
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line |
| linecnt | number of characters in line |
| extension | string to extend the line |
Definition at line 194 of file reader_gms.c.
References appendLine(), assert(), endLine(), GMS_MAX_PRINTLEN, GMS_PRINTLEN, NULL, and SCIPdebugMsg.
Referenced by appendLine(), appendLine(), appendLine(), appendLine(), printActiveVariables(), printAndCons(), printExpr(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printRow(), printRow(), printRow(), printRowAnd(), printRowExact(), printRowNl(), printSignomial(), printSOSCons(), printSosCons(), SCIPwriteGms(), SCIPwriteLp(), and SCIPwritePip().
|
static |
checks string for occurences of bad symbols and replace those by '_'
| name | string to adjust |
Definition at line 226 of file reader_gms.c.
References assert(), badchars, c, conformName(), and NULL.
Referenced by conformName(), and printConformName().
|
static |
| scip | SCIP data structure |
| t | target string |
| len | length of t |
| name | source string or format string |
Definition at line 250 of file reader_gms.c.
References assert(), conformName(), NULL, printConformName(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPgetBoolParam(), and SCIPsnprintf().
Referenced by printActiveVariables(), printAndCons(), printConformName(), printExpr(), printIndicatorCons(), printLinearRow(), printNonlinearRow(), printSOSCons(), and SCIPwriteGms().
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line |
| linecnt | number of characters in line |
| prefix | prefix (maybe NULL) |
| suffix | suffix (maybe NULL) |
| nvars | number of variables |
| vars | array of variables |
| vals | array of values (or NULL if all ones) |
| transformed | transformed constraint? |
Definition at line 275 of file reader_gms.c.
References appendLine(), assert(), getActiveVariables(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, NULL, nvars, printActiveVariables(), printConformName(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), SCIPisZero(), SCIPsnprintf(), SCIPvarGetName(), var, and vars.
Referenced by printActiveVariables(), printIndicatorCons(), printSOSCons(), and SCIPwriteGms().
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| rownameextension | row name extension |
| type | row type ("=e=", "=l=", or "=g=") |
| nvars | number of variables |
| vars | array of variables |
| vals | array of values |
| rhs | right hand side |
Definition at line 431 of file reader_gms.c.
References appendLine(), assert(), clearLine(), endLine(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, NULL, nvars, printConformName(), printLinearRow(), SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPisZero(), SCIPsnprintf(), SCIPvarGetName(), var, and vars.
Referenced by printLinearCons(), and printLinearRow().
|
static |
prints given linear constraint information in GAMS format to file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | name of the row |
| nvars | number of variables |
| vars | array of variables |
| vals | array of coefficients values (or NULL if all coefficient values are 1) |
| lhs | left hand side |
| rhs | right hand side |
| transformed | transformed constraint? |
Definition at line 518 of file reader_gms.c.
References assert(), getActiveVariables(), NULL, nvars, printLinearCons(), printLinearRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisEQ(), SCIPisInfinity(), and vars.
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| z | indicating variable (binary) |
| s | slack variable |
| sossetdeclr | buffer to store whether we declared the SOS set for indicator reform |
| transformed | transformed constraint? |
Definition at line 613 of file reader_gms.c.
References appendLine(), assert(), clearLine(), endLine(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, NULL, printActiveVariables(), printConformName(), printIndicatorCons(), SCIP_Bool, SCIP_CALL, SCIP_ERROR, SCIP_OKAY, SCIP_Real, SCIPerrorMessage, SCIPgetCharParam(), SCIPgetNegatedVar(), SCIPgetRealParam(), SCIPinfoMessage(), SCIPisInfinity(), SCIPsnprintf(), SCIPvarGetName(), SCIPvarGetUbGlobal(), SCIPvarIsBinary(), SCIPvarIsNegated(), SCIPwarningMessage(), and TRUE.
Referenced by printIndicatorCons(), and SCIPwriteGms().
|
static |
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| nvars | number of variables in SOS |
| vars | variables in SOS |
| sostype | type of SOS: 1 or 2 |
| transformed | transformed constraint? |
Definition at line 741 of file reader_gms.c.
References appendLine(), assert(), clearLine(), endLine(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, NULL, nvars, printActiveVariables(), printConformName(), printSOSCons(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPsnprintf(), and vars.
Referenced by printSOSCons(), and SCIPwriteGms().
|
static |
print "and" constraint using a product of binary variables (performing retransformation to active variables)
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| nvars | number of variables in and |
| vars | variables in and |
| resultant | resultant variable |
| transformed | transformed constraint? |
Definition at line 798 of file reader_gms.c.
References appendLine(), assert(), clearLine(), endLine(), FALSE, getActiveVariables(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, i, NULL, nvars, printAndCons(), printConformName(), REALABS, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsnprintf(), SCIPvarGetName(), TRUE, and vars.
Referenced by printAndCons(), printAndCons(), SCIPwriteGms(), and SCIPwriteLp().
|
static |
prints expression in GAMS format to file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| linebuffer | line buffer of length GMS_MAX_PRINTLEN |
| linecnt | number of characters in line so far |
| nsmooth | buffer to store whether we printed a nonsmooth function |
| nqcons | buffer to update whether we are still quadratic |
| transformed | expression belongs to transformed constraint? |
| expr | expression to print |
Definition at line 953 of file reader_gms.c.
References appendLine(), assert(), endLineNoNewline(), EPSISINT, FALSE, getActiveVariables(), GMS_MAX_NAMELEN, GMS_PRINTLEN, i, NULL, printConformName(), printExpr(), REALABS, SCIP_Bool, SCIP_CALL, SCIP_EXPRITER_ALLSTAGES, SCIP_EXPRITER_DFS, SCIP_EXPRITER_ENTEREXPR, SCIP_EXPRITER_LEAVEEXPR, SCIP_EXPRITER_VISITEDCHILD, SCIP_EXPRITER_VISITINGCHILD, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcreateExpriter(), SCIPexprGetHdlr(), SCIPexprhdlrGetPrecedence(), SCIPexpriterGetChildIdxDFS(), SCIPexpriterGetNext(), SCIPexpriterGetParentDFS(), SCIPexpriterGetStageDFS(), SCIPexpriterInit(), SCIPexpriterIsEnd(), SCIPexpriterSetStagesDFS(), SCIPfreeBufferArray, SCIPfreeExpriter(), SCIPgetExponentExprPow(), SCIPgetExprhdlrSum(), SCIPgetVarExprVar(), SCIPinfoMessage(), SCIPisExprAbs(), SCIPisExprPower(), SCIPisExprProduct(), SCIPisExprSum(), SCIPisExprValue(), SCIPisExprVar(), SCIPvarGetName(), and TRUE.
Referenced by printExpr(), and printNonlinearRow().
|
static |
print nonlinear row in GAMS format to file stream
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| rownameextension | row name extension |
| type | row type ("=e=", "=l=", or "=g=") |
| expr | expression |
| rhs | right hand side |
| transformed | transformed constraint? |
| nsmooth | buffer to store whether we printed a nonsmooth function |
| nqcons | buffer to update whether we are still quadratic |
Definition at line 1170 of file reader_gms.c.
References appendLine(), assert(), clearLine(), endLine(), GMS_MAX_NAMELEN, GMS_MAX_PRINTLEN, NULL, printConformName(), printExpr(), printNonlinearRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPsnprintf().
Referenced by printNonlinearCons(), and printNonlinearRow().
|
static |
print nonlinear row in GAMS format to file stream (performing retransformation to active linear variables)
| scip | SCIP data structure |
| file | output file (or NULL for standard output) |
| rowname | row name |
| expr | expression |
| lhs | left hand side |
| rhs | right hand side |
| transformed | transformed constraint? |
| nsmooth | buffer to store whether we printed a nonsmooth function |
| nqcons | buffer to update whether we are still quadratic |
Definition at line 1215 of file reader_gms.c.
References assert(), NULL, printNonlinearCons(), printNonlinearRow(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPcheckExprQuadratic(), SCIPexprAreQuadraticExprsVariables(), SCIPisEQ(), and SCIPisInfinity().
Referenced by printNonlinearCons(), printNonlinearCons(), SCIPwriteGms(), and SCIPwritePip().
|
static |
method check if the variable names are not longer than GMS_MAX_NAMELEN
| scip | SCIP data structure |
| vars | array of variables |
| nvars | number of variables |
Definition at line 1265 of file reader_gms.c.
References assert(), badchars, checkVarnames(), GMS_MAX_NAMELEN, NULL, nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPgetBoolParam(), SCIPinfoMessage(), SCIPvarGetName(), SCIPwarningMessage(), var, and vars.
Referenced by checkVarnames(), checkVarnames(), checkVarnames(), checkVarnames(), SCIPwriteGms(), SCIPwriteLp(), SCIPwriteMps(), and SCIPwritePip().
|
static |
method check if the constraint names are not longer than GMS_MAX_NAMELEN
| scip | SCIP data structure |
| conss | array of constraints |
| nconss | number of constraints |
| transformed | TRUE iff problem is the transformed problem |
Definition at line 1324 of file reader_gms.c.
References assert(), badchars, c, checkConsnames(), GMS_MAX_NAMELEN, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetName(), SCIPconsIsEnabled(), SCIPconsIsTransformed(), SCIPgetBoolParam(), SCIPgetLhsLinear(), SCIPgetLhsNonlinear(), SCIPgetRhsNonlinear(), SCIPinfoMessage(), SCIPisEQ(), and SCIPwarningMessage().
Referenced by checkConsnames(), checkConsnames(), checkConsnames(), checkConsnames(), SCIPwriteGms(), SCIPwriteLp(), SCIPwriteMps(), and SCIPwritePip().
|
static |
copy method for reader plugins (called when SCIP copies plugins)
Definition at line 1417 of file reader_gms.c.
References assert(), NULL, READER_NAME, SCIP_CALL, SCIP_DECL_READERCOPY, SCIP_INVALIDCALL, SCIP_OKAY, SCIP_STRINGEQ, SCIPincludeReaderGms(), and SCIPreaderGetName().
|
static |
problem writing method of reader
Definition at line 1433 of file reader_gms.c.
References nvars, objscale, result, SCIP_CALL, SCIP_DECL_READERWRITE, SCIP_OKAY, SCIPwriteGms(), and vars.
|
static |
Definition at line 80 of file reader_gms.c.
Referenced by checkConsnames(), checkVarnames(), and conformName().