Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
4 replies Latest Post - ‏2013-02-15T19:14:18Z by SystemAdmin
SystemAdmin
SystemAdmin
7929 Posts
ACCEPTED ANSWER

Pinned topic Number of parameters at ILOLAZYCONSTRAINTCALLBACK

‏2013-01-26T01:20:02Z |
Hi all
I am facing problem using ILOLAZYCONSTRAINTCALLBACK. It seems ILOLAZYCONSTRAINTCALLBACK with maximum 7 parameters is implementable. Is possible to implement ILOLAZYCONSTRAINTCALLBACK with more than 7 parameteres. For example is it possible to write a macro like ILOLAZYCONSTRAINTCALLBACK10(BendersLazyCallback, IloNumVar, x,IloNumVar, y,IloNumVar, z, IloCplex, workerCplex, IloNumVarArray, v, IloNumVarArray, u, IloNumVarArray, w, IloNumVarArray, p, IloNumVarArray, q, IloObjective, workerObj ) . I tried but it give me errors.It would be very helpful, if someone would make a comment on it.
Thanks in advance.

Roni
Updated on 2013-02-15T19:14:18Z at 2013-02-15T19:14:18Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: Number of parameters at ILOLAZYCONSTRAINTCALLBACK

    ‏2013-01-28T14:46:01Z  in response to SystemAdmin
    Based on Paul Rubin comment , I handled too many arguments by creating a container class and passing an instance of that class to the LOLAZYCONSTRAINTCALLBACK1/ILOUSERCUTCALLBACK1.
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: Number of parameters at ILOLAZYCONSTRAINTCALLBACK

    ‏2013-01-28T14:46:46Z  in response to SystemAdmin
    A couple of options: skip the macro and define your callback class directly; or create a container class, put your arguments into an instance of that class, and pass that instance to ILOLAZYCONSTRAINTCALLBACK1.
  • SystemAdmin
    SystemAdmin
    7929 Posts
    ACCEPTED ANSWER

    Re: Number of parameters at ILOLAZYCONSTRAINTCALLBACK

    ‏2013-01-28T15:10:07Z  in response to SystemAdmin
    What exactly were the errors you got? Writing your own ILOLAZYCONSTRAINTCALLBACK10 macro that is similar to the other macros should be pretty simple. The following works for me without problem:
    
    #include <ilcplex/ilocplex.h>   #define ILOLAZYCONSTRAINTCALLBACK10(name, type1, x1, type2, x2,         \ type3, x3, type4, x4, type5, x5,    \ type6, x6, type7, x7, type8, x8,    \ type9, x9, type10, x10)             \ 
    
    class name##I : 
    
    public IloCplex::LazyConstraintCallbackI 
    {           \ type1 x1;                                                         \ type2 x2;                                                         \ type3 x3;                                                         \ type4 x4;                                                         \ type5 x5;                                                         \ type6 x6;                                                         \ type7 x7;                                                         \ type8 x8;                                                         \ type9 x9;                                                         \ type10 x10;                                                       \ 
    
    public:                                                              \ ILOCOMMONCALLBACKSTUFF(name)                                      \ name##I(IloEnv env, type1 xx1, type2 xx2, type3 xx3,           \ type4 xx4, type5 xx5, type6 xx6, type7 xx7,            \ type8 xx8, type9 xx9, type10 xx10)                     \ : IloCplex::LazyConstraintCallbackI(env), x1(xx1), x2(xx2), \ x3(xx3), x4(xx4), x5(xx5), x6(xx6), x7(xx7), x8(xx8),     \ x9(xx9), x10(xx10) 
    {
    }                                     \ 
    
    void main();                                                      \ 
    };                                                                   \ IloCplex::Callback name(IloEnv env, type1 x1, type2 x2, type3 x3,    \ type4 x4, type5 x5, type6 x6, type7 x7,      \ type8 x8, type9 x9, type10 x10) 
    {            \ 
    
    return (IloCplex::Callback(
    
    new (env) name##I(env, x1, x2, x3, x4, \ x5, x6, x7, x8, x9,  \ x10)));              \ 
    }                                                                    \ 
    
    void name##I::main()   ILOLAZYCONSTRAINTCALLBACK10(CB, int, a1, int, a2, int, a3, int, a4, int, a5, int, a6, int, a7, int, a8, int, a9, int, a10) 
    { 
    // nothing 
    }   
    
    int main(
    
    void) 
    { IloEnv env; IloCplex cplex(env); cplex.use(CB(env, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); env.end(); 
    
    return 0; 
    }
    
    • SystemAdmin
      SystemAdmin
      7929 Posts
      ACCEPTED ANSWER

      Re: Number of parameters at ILOLAZYCONSTRAINTCALLBACK

      ‏2013-02-15T19:14:18Z  in response to SystemAdmin
      Thank you very much Daniel