Re: [Help-glpk] Operand following / has invalid type
On Thu, 10 Sep 2020, Andrew Makhorin wrote: On Wed, 2020-09-09 at 18:17 -0300, yami...@cock.li 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 henne...@web.cs.ndsu.nodak.edu "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
Re: [Help-glpk] Operand following / has invalid type
On Wed, 2020-09-09 at 18:17 -0300, yami...@cock.li wrote: > Hey, > > I'm trying to make a program that populates a binary matrix keeping > as > many blank lines as possible, e.g. > > > 00| > > 11| > > 10| > > instead of > > > 10| > > 10| > > 10| > > > 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]); > > I made a few tests and some constraints, I'm pretty sure it's not a > problem with the sets, the matrix, or a typo. > If I had to guess I'd say the error is being caused by the nested > sums, > but I couldn't find much on that. > > Can this be fixed in any way? > Thanks. > > 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.
[Help-glpk] Operand following / has invalid type
Hey, I'm trying to make a program that populates a binary matrix keeping as many blank lines as possible, e.g. |00| |11| |10| instead of |10| |10| |10| 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]); I made a few tests and some constraints, I'm pretty sure it's not a problem with the sets, the matrix, or a typo. If I had to guess I'd say the error is being caused by the nested sums, but I couldn't find much on that. Can this be fixed in any way? Thanks.