error: null parameter when calling GRBloadmodel

100 views Asked by At

In calling GRBloadmodel, I get the following error

ERROR 10002: NULL argument for required parameter

A code reproducing the error is below. Per the documentation, I think I have specified all the required arguments, so this error is puzzling.

/*
    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

There are 1 answers

0
Armali On

… the required that I was missing is: rhs. Strangely, the doc, on the … page … provided, say that this parameter can be null. – user1030312