Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  define parameter in cplex

    Posted 01/26/16 10:48 AM

    Originally posted by: guabiik


    Hi, 

    I'm using Cplex in C to solve a big amount of problems, i have the diferent data in .txt, so i want to read the parameters and define the problem. I have "n" numbers of nodes, 3*n+2 variables and 3*n constraints, so i want to find a way to define this in reference to a constant "n".

    I think that the objective is a vector, but i couldn't define it like one ("obj[n]").

    Can you define this things with loops or a auxiliar array?

    Thanks


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: define parameter in cplex

    Posted 01/27/16 05:43 AM

    Have you looked at the various C examples that are shipped with CPLEX?

    If you find yourself trying to do something like 'obj[n]' (where 'n' is a variable) then you should probably also check a C programming manual about dynamic allocation of memory in C.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: define parameter in cplex

    Posted 01/27/16 09:26 AM

    Originally posted by: guabiik


    Yes, now i have looked better. Thanks.

     

    But, i have another problem. I'm using now a CPXaddrows and CPXnewcols, with a and b are integers:

     

            int status;
    
            if ( (status=CPXnewcols(env , lp , a, obj,lb, ub, NULL, cname)) != 0 )
          goto TERMINATE;
            
            if ( (status=CPXaddrows(env , lp , 0, b , 2*b , rhs , sense, rbeg, rind, rval, NULL, NULL)) != 0 )
          goto TERMINATE;
    

    but i have errors:

    cplex2.c:667:63: warning: passing argument 8 of 'CPXaddrows' from incompatible pointer type [-Wincompatible-pointer-types]
      if ( (status=CPXaddrows(env , lp , 0, b , 2*b , rhs , sense, rbeg, rind, rval, NULL, NULL)) != 0 )
                                                                   ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h:62:4: note: expected 'const int *' but argument is of type 'double *'
        CPXaddrows (CPXCENVptr env, CPXLPptr lp, int ccnt, int rcnt,
        ^
    cplex2.c:667:69: warning: passing argument 9 of 'CPXaddrows' from incompatible pointer type [-Wincompatible-pointer-types]
      if ( (status=CPXaddrows(env , lp , 0, b , 2*b , rhs , sense, rbeg, rind, rval, NULL, NULL)) != 0 )
                                                                         ^
    In file included from cplex2.c:3:0:
    C:/Program Files/IBM/ILOG/CPLEX_Studio1261/opl/include/ilcplex/cplex.h:62:4: note: expected 'const int *' but argument is of type 'double *'
        CPXaddrows (CPXCENVptr env, CPXLPptr lp, int ccnt, int rcnt,
        ^

     

     


    #CPLEXOptimizers
    #DecisionOptimization