Opened 11 years ago

Closed 20 months ago

#86 closed enhancement (migrated)

improve license handling for Xpress

Reported by: mkaut Owned by: mjs
Priority: trivial Milestone:
Component: OsiXpr Version: 0.100.0
Keywords: Cc:

Description

In OsiXprSolverInterface::incrementInstanceCounter(), I propose to replace the current

    if ( numInstances_ == 0 ) {          
	XPRS_CHECKED( XPRSinit, (NULL) );
    }

by

    if ( numInstances_ == 0 ) {          
	int xprInitCode = XPRSinit(NULL);
	int xprLicErr;
	char xprMsg[1024];
	switch (xprInitCode) {
	    case  0: // license OK
	        break;
	    case 32: // student license
	        xprLicErr = XPRSgetlicerrmsg(xprMsg, 1024);
	        if (strlen(xprMsg) > 0) {
	            fprintf( stderr, "%s\n", xprMsg );
	        } else {
	            // print some warning about student license?
	        }
	        break;
	    default: // this means license problems
	        xprLicErr = XPRSgetlicerrmsg(xprMsg, 1024);
	        if (strlen(xprMsg) > 0) {
	            fprintf( stderr, "%s\n", xprMsg );
	        } else {
	            fprintf( stderr, "Xpress licensing error %d (no details)\n",
	                     xprLicErr );
	        }
	        return; // should we do XPRSfree() and exit(1) or exit(xprInitCode) instead?
	}
	// get and print the solver info - only if Osi set to verbose?
	XPRSgetbanner(xprMsg);
	if (strlen(xprMsg) > 0) {
	    fprintf( stdout, "%s\n", xprMsg );
	}

The major thing this does not solve is what to do in case of license trouble. Since OsiXprSolverInterface::incrementInstanceCounter() is void, we cannot tell the caller about the problems, so I would almost suggest aborting the call completely .. though that might be an overkill?

In addition, the banner should be printed only if Osi is set to verbose - I simply do not know how to check for this. (By the way, the same should probably be valid also for the print line at the very start of OsiXprSolverInterface::incrementInstanceCounter().)

Change History (1)

comment:1 Changed 20 months ago by stefan

  • Resolution set to migrated
  • Status changed from new to closed

This ticket has been migrated to GitHub and will be resolved there: https://github.com/coin-or/Osi/issues/86

Note: See TracTickets for help on using tickets.