help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Can't use variable within abs()?


From: Andrew Makhorin
Subject: Re: [Help-glpk] Can't use variable within abs()?
Date: Tue, 28 Aug 2007 03:57:08 +0400

> I'm getting an error saying that "argument for abs has invalid type".

> I'm trying to model a load-balancing scenario where 10 weighted
> items are distributed across 3 buckets. I want to minimise the
> difference between each bucket's total weight and the average weight
> of all buckets, so I'm trying to do the following, which is not
> working:

> minimize z:  sum{b in BUCKETS} abs(BucketWeight[b] - AveBucketWeight);

You cannot use variables in abs(), because this leads to non-linear
objective not allowed in glpk.

However, in your case the objective is piecewise linear and convex,
so it can be easily reformulated as follows:

var u{b in BUCKETS}; /* auxiliary variable */

s.t. aaa{b in BUCKETS}: u[b] >= BucketWeight[b] - AveBucketWeight;

s.t. bbb{b in BUCKETS}: u[b] >= AveBucketWeight - BucketWeight[b];

minimize z: sum{b in BUCKETS} u[b];





reply via email to

[Prev in Thread] Current Thread [Next in Thread]