错误:调用GRBloadmodel

时间:2016-12-23 01:39:02

标签: c gurobi

在致电GRBloadmodel时,我收到以下错误

  

错误10002:必需参数的空参数

重现错误的代码如下。 根据文档,我认为我已经指定了所有必需的参数, 所以这个错误令人费解。

/*
    compilation
        export GUROBI_HOME="/opt/gurobi701/linux64"
        export PATH="${PATH}:${GUROBI_HOME}/bin"
        export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

        gcc exp_loadmodel.c -I$GUROBI_HOME/include -L$GUROBI_HOME/lib -lgurobi70

        ./a.out

*/
#include <stdlib.h>
#include <stdio.h>
#include "gurobi_c.h"

int main(int   argc, char *argv[])
{
  GRBenv *env = NULL;
  GRBmodel *model = NULL;
  int error = 0;
  int vbeg[1] = {1};
  int vlen[1] = {1};
  int vind[1] = {1};
  double vval[1]={1};

/*
int GRBloadmodel(
GRBenv *env, GRBmodel **modelP, const char *Pname, int numvars, int numconstrs,
int objsense, double objcon, double *obj, char *sense, double *rhs,
int *vbeg, int *vlen, int *vind, double *vval, double *lb, double *ub, char *vtype,
char **varnames, char **constrnames);
*/

  printf("start\n");

  error = GRBloadenv(&env, NULL);
  if (error) {printf("load ERROR: %s\n", GRBgeterrormsg(env));}
  printf("load retcode %d\n", error);

  error = GRBloadmodel(
    env, //env
    &model, //modelP
    NULL, //Pname
    1, //numvars
    1, //numconstrs
    -1, //objsense
    0., //objcon
    NULL, //obj
    NULL, //sense
    NULL, //rhs
    vbeg, //vbeg
    vlen, //vlen,
    vind, //vind
    vval, //vval
    NULL, //lb
    NULL, //ub
    NULL, //vtype
    NULL, //varnames
    NULL //constrnames
  );
  if (error) {printf("model ERROR: %s\n", GRBgeterrormsg(env));}
  printf("newmodel retcode %d\n", error);

  printf("end\n");

}

1 个答案:

答案 0 :(得分:0)

...我想念的是:jars=['/CorrectPath/tdgssconfig.jar','/CorrectPAth/terajdbc4.jar'] 。奇怪的是,提供的… page …上的文档说此参数可以为null。                     –user1030312