Re: Operand following / has invalid type
Michael Hennebry <[email protected]> Thu, 10 Sep 2020 10:38:58 -0500 (CDT)
| Newsgroups | gmane.comp.gnu.glpk |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 10 Sep 2020, Andrew Makhorin wrote: > On Wed, 2020-09-09 at 18:17 -0300, [email protected] wrote: >> I'm trying to make a program that populates a binary matrix keeping >> as >> many blank lines as possible, e.g. Add another variable for each row in the binary matrix: z[row]>=m[row, col] minimize its sum. The z's need not be binary. It can be done with a single z, but I expect user-defined cuts would be necessary. Note that GLPK assumes cuts are not mathematically necessary. GLPK might return a solution you deem infeasible. In that case, you would neeed to add a cut and rerun. Keeping the previously discovered cuts would not be automatic. >> Since I know the sum of the lines won't be too big I decided to use >> an >> approach based on division, but I'm getting a "operand following / >> has >> invalid type" error. >> >> /* binary matrix */ >> var m{x in X, y in Y} binary; >> /* minimizes total (sum of line)^-1, a full line is better than two >> half-full lines*/ >> minimize maxEmpty: sum{x in X} 1/(1 + sum{y in Y} m[x,y]); This can be done, sort of. Again you would need an auxillary variable for each matrix row. I expect the additional constraints could be inserted with the original set. Again it coulod be done with a single z and the same complications are before. > In constraints and objectives you can divide only by a constant > expression. In your case you divide by a linear form that leads to a > non-linear objective function, which is not allowed. Probably you need > to reformulate your model. -- Michael [email protected] "Sorry but your password must contain an uppercase letter, a number, a haiku, a gang sign, a heiroglyph, and the blood of a virgin." -- someeecards