Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Freeing Arrays?

    Posted 08/18/14 02:21 PM

    Originally posted by: jlbark


    I am calling CPLEX from within a C program using the callable library. Suppose I have solved an LP and I want to add some cuts of my own.  I malloc some arrays, populate them, and then call CPXaddrows to add them to the LP.  At that point, should I free the arrays that I have malloced? So far I have been assuming that the answer is "yes," and that CPXaddrows will make its own copy of the data that I pass to it, so that I should free the arrays that I malloced in order to prevent memory leaks. However, I am getting some strange errors from CPLEX.  I am trying to track down whether it is a bug in my own code or whether my above assumption is incorrect, and that I should *not* free those arrays.


    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Freeing Arrays?

    Posted 08/18/14 02:33 PM

    CPXaddrows() makes a deep copy of whatever data you pass it. So yes, you should free the arrays to avoid memory leaks.

    You may want to enable CPX_PARAM_DATACHECK to have CPLEX perform a quick sanity check on the data you pass.

    What exactly is the strange behavior you observe?


    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Freeing Arrays?

    Posted 09/04/14 12:47 PM

    Originally posted by: jlbark


    Thank you for your answer...that clarifies things.  In the meantime, I have discovered the bug in my own code that was causing the problem.  It was a buffer overflow, but the bad effects of the buffer overflow did not become evident until I called a CPLEX subroutine, and that gave the illusion that the CPLEX subroutine was causing the problem.


    #DecisionOptimization
    #MathematicalProgramming-General