예제 #1
0
int GamsScip::readyAPI(
   struct gmoRec*     gmo_,               /**< GAMS modeling object */
   struct optRec*     opt_                /**< GAMS options object */
)
{
   char buffer[512];

   gmo = gmo_;
   assert(gmo != NULL);

   if( getGmoReady() || getGevReady() )
      return 1;

   gev = (gevRec*)gmoEnvironment(gmo);
   assert(gev != NULL);

   ipoptlicensed = false;
#ifdef GAMS_BUILD
   if( pal == NULL && !palCreate(&pal, buffer, sizeof(buffer)) )
      return 1;

#define PALPTR pal
#include "coinlibdCL5svn.h" 
   palGetAuditLine(pal, buffer);
   gevLogStat(gev, "");
   gevLogStat(gev, buffer);
   gevStatAudit(gev, buffer);

   initLicensing(gmo, pal);

#ifdef COIN_HAS_OSIXPR
   /* Xpress license setup - don't say anything if failing, since Xpress is not used by default */
   XPlicenseInit_t initType;
   gevxpresslice(gev, pal, gmoM(gmo), gmoN(gmo), gmoNZ(gmo), gmoNLNZ(gmo), gmoNDisc(gmo), 0, &initType, buffer, sizeof(buffer));
#endif
#endif

   // check for academic license, or if we run in demo mode
   if( !checkScipLicense(gmo, pal) )
   {
      gevLogStat(gev, "*** Use of SCIP is limited to academic users.");
      gevLogStat(gev, "*** Please contact [email protected] to arrange for a license.");
      gmoSolveStatSet(gmo, gmoSolveStat_License);
      gmoModelStatSet(gmo, gmoModelStat_LicenseError);
      return 1;
   }

   ipoptlicensed = HSLInit(gmo, pal);

   // print version info and copyright
   if( SCIPsubversion() > 0 )
      sprintf(buffer, "SCIP version %d.%d.%d.%d (" SCIP_GITHASH ")\n", SCIPmajorVersion(), SCIPminorVersion(), SCIPtechVersion(), SCIPsubversion());
   else
      sprintf(buffer, "SCIP version %d.%d.%d (" SCIP_GITHASH ")\n", SCIPmajorVersion(), SCIPminorVersion(), SCIPtechVersion());
   gevLogStatPChar(gev, buffer);
   gevLogStatPChar(gev, SCIP_COPYRIGHT"\n\n");

   // install or update error printing callback in SCIP to use current gev
   SCIPmessageSetErrorPrinting(printErrorGev, (void*)gev);

   // setup (or reset) SCIP instance
   SCIP_RETCODE scipret;
   scipret = setupSCIP();

   if( scipret != SCIP_OKAY )
   {
      snprintf(buffer, sizeof(buffer), "Error %d in call of SCIP function\n", scipret);
      gevLogStatPChar(gev, buffer);
      gmoSolveStatSet(gmo, gmoSolveStat_SystemErr);
      gmoModelStatSet(gmo, gmoModelStat_ErrorNoSolution);
      return 1;
   }

   assert(scip != NULL);

   // print info on used external codes
   SCIPprintExternalCodes(scip, NULL);

   return 0;
}
예제 #2
0
파일: GAMS.cpp 프로젝트: ERGO-Code/HiGHS
static
int setupProblem(
   gamshighs_t* gh
)
{
   int numCol;
   int numRow;
   int numNz;
   int i;
   int rc = 1;

   assert(gh != NULL);
   assert(gh->options != NULL);
   assert(gh->highs == NULL);
   assert(gh->lp == NULL);

   gh->highs = new Highs(*gh->options);

   numCol = gmoN(gh->gmo);
   numRow = gmoM(gh->gmo);
   numNz = gmoNZ(gh->gmo);

   gh->lp = new HighsLp();

   gh->lp->numRow_ = numRow;
   gh->lp->numCol_ = numCol;
   gh->lp->nnz_ = numNz;

   /* columns */
   gh->lp->colUpper_.resize(numCol);
   gh->lp->colLower_.resize(numCol);
   gmoGetVarLower(gh->gmo, &gh->lp->colLower_[0]);
   gmoGetVarUpper(gh->gmo, &gh->lp->colUpper_[0]);

   /* objective */
   gh->lp->colCost_.resize(numCol);
   gmoGetObjVector(gh->gmo, &gh->lp->colCost_[0], NULL);
   if( gmoSense(gh->gmo) == gmoObj_Min )
      gh->lp->sense_ = 1;
   else
      gh->lp->sense_ = -1;

   /* row left- and right-hand-side */
   gh->lp->rowLower_.resize(numRow);
   gh->lp->rowUpper_.resize(numRow);
   for( i = 0; i < numRow; ++i )
   {
      switch( gmoGetEquTypeOne(gh->gmo, i) )
      {
         case gmoequ_E :
            gh->lp->rowLower_[i] = gh->lp->rowUpper_[i] = gmoGetRhsOne(gh->gmo, i);
            break;

         case gmoequ_G :
            gh->lp->rowLower_[i] = gmoGetRhsOne(gh->gmo, i);
            gh->lp->rowUpper_[i] = HIGHS_CONST_INF;
            break;

         case gmoequ_L :
            gh->lp->rowLower_[i] = -HIGHS_CONST_INF;
            gh->lp->rowUpper_[i] = gmoGetRhsOne(gh->gmo, i);
            break;

         case gmoequ_N:
         case gmoequ_X:
         case gmoequ_C:
         case gmoequ_B:
            /* these should not occur */
            goto TERMINATE;
      }
   }

   /* coefficients matrix */
   gh->lp->Astart_.resize(numCol + 1);
   gh->lp->Aindex_.resize(numNz);
   gh->lp->Avalue_.resize(numNz);
   gmoGetMatrixCol(gh->gmo, &gh->lp->Astart_[0], &gh->lp->Aindex_[0], &gh->lp->Avalue_[0], NULL);

   gh->highs->initializeLp(*gh->lp);

   //FilereaderLp().writeModelToFile("highs.lp", *gh->lp);
   //FilereaderMps().writeModelToFile("highs.mps", *gh->lp);

   rc = 0;
TERMINATE:

   return rc;
}