Exemple #1
0
/** reads parameters */
static
SCIP_RETCODE readParams(
   SCIP*                      scip,               /**< SCIP data structure */
   const char*                filename            /**< parameter file name, or NULL */
   )
{
   if( filename != NULL )
   {
      if( SCIPfileExists(filename) )
      {
         std::cout << "reading parameter file <" << filename << ">" << std::endl;
         SCIP_CALL( SCIPreadParams(scip, filename) );
      }
      else
         std::cout << "parameter file <" << filename << "> not found - using default parameters" << std::endl;
   }
   else if( SCIPfileExists("scipmip.set") )
   {
      std::cout << "reading parameter file <scipmip.set>" << std::endl;
      SCIP_CALL( SCIPreadParams(scip, "scipmip.set") );
   }

   return SCIP_OKAY;
}
Exemple #2
0
/** read in parameter file */
static
SCIP_RETCODE readParams(
   SCIP*                 scip,               /**< SCIP data structure */
   const char*           filename            /**< parameter file name */
   )
{
   if( SCIPfileExists(filename) )
   {
      SCIPinfoMessage(scip, NULL, "reading user parameter file <%s>\n", filename);
      SCIP_CALL( SCIPreadParams(scip, filename) );
   }
   else
      SCIPinfoMessage(scip, NULL, "user parameter file <%s> not found - using default parameters\n", filename);

   return SCIP_OKAY;
}
Exemple #3
0
static
SCIP_RETCODE run(
   const char*                nlfile,        /**< name of AMPL .nl file */
   const char*                setfile,       /**< SCIP settings file, or NULL to try default scip.set */
   SCIP_Bool                  interactive    /**< whether to start SCIP interactive shell instead of solving command */
)
{
   SCIP* scip;
   char buffer[SCIP_MAXSTRLEN];
   SCIP_Bool printstat;

   assert(nlfile != NULL);

   /* setup SCIP and print version information */
   SCIP_CALL( SCIPcreate(&scip) );

   SCIPprintVersion(scip, NULL);
   SCIPinfoMessage(scip, NULL, "\n");

   SCIP_CALL( SCIPincludeDefaultPlugins(scip) );
   SCIP_CALL( SCIPincludeReaderNl(scip) );

   SCIP_CALL( SCIPaddBoolParam(scip, "display/statistics",
      "whether to print statistics on a solve",
      NULL, FALSE, FALSE, NULL, NULL) );

   SCIPprintExternalCodes(scip, NULL);
   SCIPinfoMessage(scip, NULL, "\n");

   /* read setting file */
   if( setfile != NULL )
   {
      SCIP_CALL( SCIPreadParams(scip, setfile) );
   }

   SCIP_CALL( SCIPgetBoolParam(scip, "display/statistics", &printstat) );

   /* setup commands to be executed by SCIP */

   SCIP_CALL( SCIPaddDialogInputLine(scip, "display param") );

   /* add .nl extension, if not given */
   (void) SCIPsnprintf(buffer, SCIP_MAXSTRLEN, "read %s%s", nlfile, (strlen(nlfile) < 3 || strcmp(nlfile+(strlen(nlfile)-3), ".nl") != 0) ? ".nl" : "");
   SCIP_CALL( SCIPaddDialogInputLine(scip, buffer) );

   if( !interactive )
   {
      /* SCIP_CALL( SCIPaddDialogInputLine(scip, "display problem") ); */

      SCIP_CALL( SCIPaddDialogInputLine(scip, "optimize") );

      SCIP_CALL( SCIPaddDialogInputLine(scip, "write amplsol") );

      if( printstat )
      {
         SCIP_CALL( SCIPaddDialogInputLine(scip, "display statistics") );
      }

      SCIP_CALL( SCIPaddDialogInputLine(scip, "quit") );
   }

   /* run SCIP */
   SCIP_CALL( SCIPstartInteraction(scip) );

   SCIP_CALL( SCIPfree(&scip) );

   return SCIP_OKAY;
}