[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Help-glpk] Re: GLPK help for solving a linear optimization problem

**From**: |
Xypron |

**Subject**: |
[Help-glpk] Re: GLPK help for solving a linear optimization problem |

**Date**: |
Sat, 06 Jun 2009 21:16:25 +0200 |

**User-agent**: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16 |

Hello Senjutib,
address@hidden wrote:

Thanks you so much for your response! Really appreciated!
However, I realize that my requirement is a little different. My optimization
function is linear with non-linear equality and inequality constraints.
More specifically,
This is what I want:
Maximize z= 0.5 a + 0.5 b + c
s.t,
c = 1- abs(a-b)
0 <= a <= c1
0<=b <= c2
abs(a-b) <= c3

`
`

`If you have a nonlinear function (like abs) you have to replace it by a
``linear approximation.
`For abs two inequalities are needed. In the concave case you need an
additional binary variable to describe in which part of the abs function

`you are. Your example is convex. You can rewrite it as below and feed it
``to glpsol.
`
Changing your first constraint to
c <= 1 + abs(a-b);
makes the problem concave.
Further below you will find how to add the binary.
Best regards
Xypron
# convex case
param c1;
param c2;
param c3;
var a, >=0, <= c1;
var b, >=0, <= c2;
var c, >= 1 - c3;
maximize z :
.5 * a + .5 * b + c;
s.t. con1:
c <= 1- (a-b);
s.t. con2:
c <= 1- (b-a);
s.t. con3:
-c3 <= a-b <= c3;
solve;
display a,b,c;
data;
param c1 := 1;
param c2 := 4;
param c3 := 50;
end;
# concave case
param c1;
param c2;
param c3;
param M := 2 * c3;
var a, >=0, <= c1;
var b, >=0, <= c2;
var c, >= 1 - c3;
var x, binary;
maximize z :
.5 * a + .5 * b + c;
s.t. con1:
c <= 1+ (a-b) + M * x;
s.t. con2:
c <= 1+ (b-a) + M * (1 - x);
s.t. con3:
-c3 <= a-b <= c3;
solve;
display a,b,c;
data;
param c1 := 3;
param c2 := 4;
param c3 := 5;
end;

[Prev in Thread] |
**Current Thread** |
[Next in Thread] |

**[Help-glpk] Re: GLPK help for solving a linear optimization problem**,
*Xypron* **<=**