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!
Topic
This topic has been locked.
5 replies
Latest Post
 20130208T10:20:32Z by TobiasUniHohenheim
ACCEPTED ANSWER
Pinned topic Find maximum of function with 2 variables
20130206T22:05:42Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
Updated on 20130208T10:20:32Z at 20130208T10:20:32Z by TobiasUniHohenheim

ACCEPTED ANSWER
Re: Find maximum of function with 2 variables
20130206T22:52:18Z in response to TobiasUniHohenheimHi 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
ACCEPTED ANSWER
Re: Find maximum of function with 1 variable
20130207T18:09:42Z in response to T_OThanks! 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!
ACCEPTED ANSWER
Re: Find maximum of function with 1 variable
20130207T22:16:09Z in response to TobiasUniHohenheimYou can't do it directly with CPLEX. You could implement a cutting plane method (which is very oldschool) 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) 
ACCEPTED ANSWER
Re: Find maximum of function with 1 variable
20130208T00:58:29Z in response to TobiasUniHohenheimYour 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.Updated on 20140324T22:40:25Z at 20140324T22:40:25Z by ironman
ACCEPTED ANSWER
Re: Find maximum of function with 1 variable
20130208T10:20:32Z in response to SystemAdminExcellent, 4er! That answered my question!


