| 1 | /* $Id: CoinMessage.cpp 1448 2011-06-19 15:34:41Z stefan $ */ |
| 2 | // Copyright (C) 2002, International Business Machines |
| 3 | // Corporation and others. All Rights Reserved. |
| 4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
| 5 | |
| 6 | #if defined(_MSC_VER) |
| 7 | // Turn off compiler warning about long names |
| 8 | # pragma warning(disable:4786) |
| 9 | #endif |
| 10 | |
| 11 | #include "CoinPragma.hpp" |
| 12 | #include "CoinMessage.hpp" |
| 13 | #include "CoinError.hpp" |
| 14 | |
| 15 | typedef struct { |
| 16 | COIN_Message internalNumber; |
| 17 | int externalNumber; // or continuation |
| 18 | char detail; |
| 19 | const char * message; |
| 20 | } Coin_message; |
| 21 | static Coin_message us_english[]= |
| 22 | { |
| 23 | {COIN_MPS_LINE,1,1,"At line %d %s" }, |
| 24 | {COIN_MPS_STATS,2,1,"Problem %s has %d rows, %d columns and %d elements" }, |
| 25 | {COIN_MPS_ILLEGAL,3001,0,"Illegal value for %s of %g" }, |
| 26 | {COIN_MPS_BADIMAGE,3002,0,"Bad image at line %d < %s >" }, |
| 27 | {COIN_MPS_DUPOBJ,3003,0,"Duplicate objective at line %d < %s >" }, |
| 28 | {COIN_MPS_DUPROW,3004,0,"Duplicate row %s at line %d < %s >" }, |
| 29 | {COIN_MPS_NOMATCHROW,3005,0,"No match for row %s at line %d < %s >" }, |
| 30 | {COIN_MPS_NOMATCHCOL,3006,0,"No match for column %s at line %d < %s >" }, |
| 31 | {COIN_MPS_FILE,6001,0,"Unable to open mps input file %s" }, |
| 32 | {COIN_MPS_BADFILE1,6002,0,"Unknown image %s at line %d of file %s" }, |
| 33 | {COIN_MPS_BADFILE2,6003,0,"Consider the possibility of a compressed file\ |
| 34 | which %s is unable to read" }, |
| 35 | {COIN_MPS_EOF,6004,0,"EOF on file %s" }, |
| 36 | {COIN_MPS_RETURNING,6005,0,"Returning as too many errors" }, |
| 37 | {COIN_MPS_CHANGED,3007,1,"Generated %s names had duplicates - %d changed" }, |
| 38 | {COIN_SOLVER_MPS,8,1,"%s read with %d errors" }, |
| 39 | {COIN_PRESOLVE_COLINFEAS,501,2,"Problem is infeasible due to column %d, %g %g" }, |
| 40 | {COIN_PRESOLVE_ROWINFEAS,502,2,"Problem is infeasible due to row %d, %g %g" }, |
| 41 | {COIN_PRESOLVE_COLUMNBOUNDA,503,2,"Problem looks unbounded above due to column %d, %g %g" }, |
| 42 | {COIN_PRESOLVE_COLUMNBOUNDB,504,2,"Problem looks unbounded below due to column %d, %g %g" }, |
| 43 | {COIN_PRESOLVE_NONOPTIMAL,505,1,"Presolved problem not optimal, resolve after postsolve" }, |
| 44 | {COIN_PRESOLVE_STATS,506,1,"Presolve %d (%d) rows, %d (%d) columns and %d (%d) elements" }, |
| 45 | {COIN_PRESOLVE_INFEAS,507,1,"Presolve determined that the problem was infeasible with tolerance of %g" }, |
| 46 | {COIN_PRESOLVE_UNBOUND,508,1,"Presolve thinks problem is unbounded" }, |
| 47 | {COIN_PRESOLVE_INFEASUNBOUND,509,1,"Presolve thinks problem is infeasible AND unbounded???" }, |
| 48 | {COIN_PRESOLVE_INTEGERMODS,510,1,"Presolve is modifying %d integer bounds and re-presolving" }, |
| 49 | {COIN_PRESOLVE_POSTSOLVE,511,1,"After Postsolve, objective %g, infeasibilities - dual %g (%d), primal %g (%d)" }, |
| 50 | {COIN_PRESOLVE_NEEDS_CLEANING,512,1,"Presolved model was optimal, full model needs cleaning up" }, |
| 51 | {COIN_PRESOLVE_PASS,513,3,"%d rows dropped after presolve pass %d" }, |
| 52 | # if PRESOLVE_DEBUG |
| 53 | { COIN_PRESOLDBG_FIRSTCHECK,514,3,"First occurrence of %s checks." }, |
| 54 | { COIN_PRESOLDBG_RCOSTACC,515,3, |
| 55 | "rcost[%d] = %g should be %g |diff| = %g." }, |
| 56 | { COIN_PRESOLDBG_RCOSTSTAT,516,3, |
| 57 | "rcost[%d] = %g inconsistent with status %s (%s)." }, |
| 58 | { COIN_PRESOLDBG_STATSB,517,3, |
| 59 | "status[%d] = %s rcost = %g lb = %g val = %g ub = %g." }, |
| 60 | { COIN_PRESOLDBG_DUALSTAT,518,3, |
| 61 | "dual[%d] = %g inconsistent with status %s (%s)." }, |
| 62 | # endif |
| 63 | {COIN_GENERAL_INFO,9,1,"%s" }, |
| 64 | {COIN_GENERAL_WARNING,3007,1,"%s" }, |
| 65 | {COIN_DUMMY_END,999999,0,"" } |
| 66 | }; |
| 67 | // **** aiutami! |
| 68 | static Coin_message italian[]= |
| 69 | { |
| 70 | {COIN_MPS_LINE,1,1,"al numero %d %s" }, |
| 71 | {COIN_MPS_STATS,2,1,"matrice %s ha %d file, %d colonne and %d elementi (diverso da zero)" }, |
| 72 | {COIN_DUMMY_END,999999,0,"" } |
| 73 | }; |
| 74 | /* Constructor */ |
| 75 | CoinMessage::CoinMessage(Language language) : |
| 76 | CoinMessages(sizeof(us_english)/sizeof(Coin_message)) |
| 77 | { |
| 78 | language_=language; |
| 79 | strcpy(source_,"Coin" ); |
| 80 | class_= 2; // Coin |
| 81 | Coin_message * message = us_english; |
| 82 | |
| 83 | while (message->internalNumber!=COIN_DUMMY_END) { |
| 84 | CoinOneMessage oneMessage(message->externalNumber,message->detail, |
| 85 | message->message); |
| 86 | addMessage(message->internalNumber,oneMessage); |
| 87 | message ++; |
| 88 | } |
| 89 | // Put into compact form |
| 90 | toCompact(); |
| 91 | // now override any language ones |
| 92 | |
| 93 | switch (language) { |
| 94 | case it: |
| 95 | message = italian; |
| 96 | break; |
| 97 | |
| 98 | default: |
| 99 | message=NULL; |
| 100 | break; |
| 101 | } |
| 102 | |
| 103 | // replace if any found |
| 104 | if (message) { |
| 105 | while (message->internalNumber!=COIN_DUMMY_END) { |
| 106 | replaceMessage(message->internalNumber,message->message); |
| 107 | message ++; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |