[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-glpk] Can't use variable within abs()?
From: |
glpkuser |
Subject: |
[Help-glpk] Can't use variable within abs()? |
Date: |
Tue, 28 Aug 2007 03:41:53 +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);
Here is my entire .mod file:
set BUCKETS;
set ITEMS;
param item_weight{i in ITEMS};
/*** decision variables ***/
/* MAP[i, b] is 1 if item i is in bucket b */
var MAP{i in ITEMS, b in BUCKETS} binary >= 0;
var BucketWeight{b in BUCKETS} >= 0;
var AveBucketWeight >= 0;
/*** constraints ***/
/* all items must be assigned to a bucket */
s.t. all_items{i in ITEMS}: sum{b in BUCKETS} MAP[i, b] = 1;
/* calculate the weight of each bucket */
s.t. bucket_weight{b in BUCKETS}: BucketWeight[b] = sum{i in ITEMS} MAP[i,
b] * item_weight[i];
/* calculate the average weight across all buckets */
s.t. ave_bucket_weight: AveBucketWeight = (sum{b in BUCKETS}
BucketWeight[b]) / 3.0;
/*** objective ***/
/*** PROBLEM OCCURS HERE ***/
minimize z: sum{b in BUCKETS} abs(BucketWeight[b] - AveBucketWeight);
/*** data ***/
data;
set BUCKETS := 1 2 3;
set ITEMS := 1 2 3 4 5 6 7 8 9 10;
/* item i has a weight of i */
param item_weight :=
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10;
end;
--
View this message in context:
http://www.nabble.com/Can%27t-use-variable-within-abs%28%29--tf4338572.html#a12358437
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.
- [Help-glpk] Can't use variable within abs()?,
glpkuser <=