-3

我是 c++ 和 cplex 的新手,因此将不胜感激任何帮助。问题:我正在运行列生成代码。我的代码如下所示:

CPXENVptr *env = NULL;
CPXLPptr *lp= null;



  //---------COLUMN GENERATION BEGINS--------------------------------------------

   printf("\nStarting column generation.\n");
   num_iterations = 0;
   total_cols_generated = 0;

   while(1)
   {
   // we are about to do another pricing iteration
   num_iterations++;


   // get dual prices

   status=CPXgetpi(env,lp,dual_value,0,num_customers-1);
   if (status)
   {
      fprintf(stderr,"CPXgetpi Failed.\n");
      goto TERMINATE;
   }

   // call pricing routine

   printf ("\nPricing iteration %u.\n", num_iterations);

   cols_generated = generate_column(env, lp, num_nodes, num_customers, TT, service_time, start_of_window, end_of_window, out_degree, neighbour, arc_cost, arc_time, dual_value);
   total_cols_generated += cols_generated;

   if (cols_generated == 0)
         break;

   // re-optimize the master problem

   printf("Re-optimising master LP.\n");

    status =  CPXdualopt (env, lp);

   if ( status  ) {
      printf ("Failed to re-optimize master LP.\n");
      getchar();
      goto TERMINATE;
   }

   // get objective value

   status  = CPXgetobjval (env, lp, &lower_bound);
   if ( status ) {
      fprintf (stderr,"Failed to obtain objective value.\n");
      goto TERMINATE;
   }

   // print stuff to screen

    printf ("Current cost of RMP solution is %.3f\n", lower_bound);
    printf ("\nPress a key\n");
    getchar();

} // end while

在第二次优化中(第二次进入 while ),它在 status = CPXdualopt (env, lp); 处提供访问冲突写入位置。

任何想法?

4

1 回答 1

2

根据以下文档CPXgetpi

CPXCENVptr环境

指向 CPLEX 环境的指针,由CPXopenCPLEX().

CPXCLPptrLP

指向 CPLEX 问题对象的指针,由CPXcreateprob().

您没有将指针传递给这些对象。你正在NULL为他们两个通过。

文档CPXdualopt显示了同样的问题。

于 2013-03-28T22:39:52.487 回答