help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] is there a function for count in MATHPROG?


From: Andrew Makhorin
Subject: Re: [Help-glpk] is there a function for count in MATHPROG?
Date: Sat, 07 Apr 2012 01:36:01 +0400

> I'm looking for a function that count number of objects that belong to a 
> specific cluster but I dont know if such function exists.
> 
> For example I'm trying to count number of objects in variable Z[i] but 
> with Cardinal function I get an error tha says "invalid preceding 
> operator == "  what does it mean?

>      s.t. Proporcion{k in 1..card(CATEGORIAS)}: card({i in ITEMS: k in 
> Z[i]}) <= noitems*Porcentaje[k];

You cannot write 'k in Z[i]', because Z[i] is not a set.

Assuming that Z models an indicator function (does it?) of a subset of
some predefined set, which (subset) needs to be found, and Z[i] is a
binary variable, the cardinality of that subset can be expressed as 
'sum{i in ...} Z[i]', so you could write your constraint as follows:

s.t. Proporcion{k in 1..card(CATEGORIAS)}: 
       sum{i in ITEMS: k in ...} noitems * Porcentaje[k] * Z[i];






reply via email to

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