[Osi-tickets] [COIN-OR Open Solver Interface] #86: improve license handling for Xpress

COIN-OR Open Solver Interface coin-trac at coin-or.org
Tue Sep 22 07:03:33 EDT 2009


#86: improve license handling for Xpress
-------------------------+--------------------------------------------------
 Reporter:  mkaut        |       Owner:  mjs    
     Type:  enhancement  |      Status:  new    
 Priority:  trivial      |   Milestone:         
Component:  OsiXpr       |     Version:  0.100.0
 Keywords:               |  
-------------------------+--------------------------------------------------
 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().)

-- 
Ticket URL: <https://projects.coin-or.org/Osi/ticket/86>
COIN-OR Open Solver Interface <http://projects.coin-or.org/Osi>
An API for a variety of LP and MIP solvers (and more).



More information about the Osi-tickets mailing list