Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Find maximum of function with 2 variables

    Posted 02/06/13 05:06 PM

    Originally posted by: TobiasUni-Hohenheim


    Hi there,

    I am new to CPLEX. Is there a way for cplex to find the maximum of a function with 2 linear variables? For example, find maximum of

    f(x,y) = 3x - 2y

    I was hoping cplex will give me (x,y) where f(x,y) is maximal. Of course, x and y may be in some predefined bounds.

    How can I implement such a model?

    Thanks!
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Find maximum of function with 2 variables

    Posted 02/06/13 05:52 PM

    Originally posted by: T_O


    Hi Tobias,

    this sounds trivial. Do you really have a linear objective function and only constraints that are in fact bounds of variables? Then you can trivially calculate the optimal value. Just take the upper or lower bound of every variable depending on the sign of the corresponding objective coefficient.

    In your case, take the upper bound of x and the lower bound of y, because you are maximizing.

    Of course, you can do this with CPLEX but I think you can do this faster with a trivial code.
    Or are your "bounds" more difficult (e.g. linear functions)?

    Best regards,
    Thomas
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Find maximum of function with 1 variable

    Posted 02/07/13 01:10 PM

    Originally posted by: TobiasUni-Hohenheim


    Thanks! But sorry, it was my fault. I am looking to find the (local) maximum of a function like this:

    f(x) = 4 * sqrt(x) - 2 * x

    This is not possible with cplex, or?
    Thanks!
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Find maximum of function with 1 variable

    Posted 02/07/13 05:16 PM

    Originally posted by: SystemAdmin


    You can't do it directly with CPLEX. You could implement a cutting plane method (which is very old-school) using CPLEX, but it would be easier to use a program designed to solve nonlinear optimization problems.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Find maximum of function with 1 variable

    Posted 02/07/13 07:58 PM

    Originally posted by: SystemAdmin


    Your function f(x) is concave, so any local maximum will be globally maximal. In general you cannot solve nonlinear problems using CPLEX, but in this case your problem can be made into a conic quadratic that CPLEX can handle: maximize 4*y - 2*x, subject to y^2 <= x and x >= 0. Indeed I wrote it in AMPL as
    var x >= 0; var y;
    maximize obj: 4*y - 2*x;
    subj to ydef: y^2 <= x;
    

    and CPLEX happily solved it:
    ampl: option solver cplex;
    ampl: solve;
     
    CPLEX 12.5.0.0: optimal solution; objective 1.999999999
    7 barrier iterations
    No basis.
     
    ampl: display x, y;
    x = 0.999999
    y = 0.999999
    

    (Probably the reported objective would be exactly 2 if you set some tolerances a little tighter.) In the documentation of the CPLEX quadratic solvers, there's some discussion of the kinds of quadratic problems that can be solved.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Find maximum of function with 1 variable

    Posted 02/08/13 05:21 AM

    Originally posted by: TobiasUni-Hohenheim


    Excellent, 4er! That answered my question!
    #CPLEXOptimizers
    #DecisionOptimization