Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Using external functions (density) when building model in Java.

    Posted 04/26/13 11:04 AM

    Originally posted by: MaxSid


    Hello,

    i have encountered a problem when building a model in Java.

    In my objective function i need to calculate the cumulative density of a standard normal distribution in dependency of my objective variable.

    The code looks like this:

    import org.apache.commons.math3.distribution.NormalDistribution;

    NormalDistribution snd = new NormalDistribution(0,1);

    IloNumVar[]OrderQuantity= cp.numVarArray(n, 0, Double.MAX_VALUE);

    code with the error:        snd.cumulativeProbability(OrderQuantity[j]);

    It says: The method density(double) in the type NormalDistribution is not applicable for the arguments (IloNumExpr)

    snd.cumulativeProbability expects a double value while my decision variable is IloNumExpr.

    I hope i could make clear what my problem is. Is there a way to solve this?

     

    Maybe it is possible to propose a list to the solver giving the values for a number of OrderQuantities e.g. looking up values for predefined possible values for OrderQuantities?

    Maybe it is possible to calculate the density itself without using the external function? Therefore i would have to use the exponent function e^() but i cant seem to find it in the documentation. Also i would need the erf() (errorfunction).

     

    Thank you for any advice.

    Max

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Using external functions (density) when building model in Java.

    Posted 04/29/13 07:40 AM

    An IloNumVar is not a number but an (abstract) modeling object. Since these things are not numbers you cannot pass them to functions that expect concrete numbers.

    Using the exponential function in the objective function would turn the model into a type of non-linear model that cannot be handled by CPLEX.

    You could try to approximate the non-linear objective function by means of a piecewise linear function. That is something CPLEX can handle.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Using external functions (density) when building model in Java.

    Posted 04/29/13 04:00 PM

    Originally posted by: MaxSid


    Thank you for your answer Daniel,

    i have implemented both functions as piecewise linear functions (wasnt that hard at all) , and now it turns out that my objective function is yielding:

     CPLEX Error  5002: Q in objective is not positive semi-definite.

    Now i am aware what that means, but i wonder if there is any kind of workaround so i can still use CPLEX as my solver?

    Here is my problem:

                        double[] points = new double[] {0, 5, 10};
                        double[] slopes = new double[] { 0,0.1, -0.1,0}

                        (triangle)
                       
                        double[] pointskum = new double[] {-1, 1}
                        double[] slopeskum = new double[] { 0,1,0}

                        (reversed Z)

                        cp.prod(cp.piecewiseLinear(z[j], points, slopes, 0, 0),cp.piecewiseLinear(z[j],pointskum,slopeskum,0,0));
                        Where z[j] contains my objevtive variable.

    Anyway i will mark my answer as solved, since my followup question doesnt have to do anything with the topic. It would still be nice to know the answer :).

    Greetings

    Max

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Using external functions (density) when building model in Java.

    Posted 05/14/13 12:52 AM

    OK, you multiply two piecewise linear functions and this results in a non-convex function.

    The only way around this problem that I see at the moment is to linearize the product of the two piecewise linear functions (if possible).


    #CPLEXOptimizers
    #DecisionOptimization