Can we get gradient of a linear programming problem ?

5 visualizaciones (últimos 30 días)
Kallam Haranadha Reddy
Kallam Haranadha Reddy el 22 de Jul. de 2018
Respondida: J. Alex Lee el 23 de Jul. de 2018
How can we get the gradient of the objective function of a linear programming problem in MATLAB.
i.e
if the problem looks as follows
Maximize Z = f(x,y)------------------------- (1)
If we fix y=1;
Let the solution to (1)is Z1.
If we fix y=2;(i.e) unit increase
Let the solution to (1) is Z2.
Then the gradient of f(x,y) at y=1 is Z2-Z1/(2-1)

Respuesta aceptada

J. Alex Lee
J. Alex Lee el 23 de Jul. de 2018
Your example actually only gave 1 component of the gradient, at an unspecified fixed value of x. The gradient of your scalar function f(x,y) is a vectorial quantity with components in both x and y directions, so at any given set of coordinates (x1,y1), there will be 2 gradient components w1 and v1.
There is a function "gradient" in base matlab since R2006a, if you want to compute your objective function on a grid (Matlab's definition of a well-defined grid) and compute the gradient numerically from that.
x = xMin:d:xMax
y = yMin:d:yMax
[X,Y] = meshgrid(x,y)
Z = f(X,Y)
[W,V] = gradient(Z,d)
This method depends on the resolution of the grid that you pre-compute on, as I believe the gradient function simply implements a centered finite difference on the grid, with maybe some special consideration at the edge.
If you are ultimately interested in the optimization of f(x,y), a non-gradient method for optimizing would probably be pretty easy/fast in 2 dimensions? There is "fminsearch" in base matlab that could be useful.

Más respuestas (0)

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by