Control: tag -1 patch
On Thu, Jun 21, 2018 at 01:01:44PM +0200, Julian Andres Klode wrote:
> Package: mccs
> Version: 1:1.1-7
> Severity: wishlist
>
> With the attached patch, mccs understands clasps output (which does
> not always end with a space at the end of a line, as mccs seems to
> expect) and writes the PB problem in a way that clasp understands it,
> by rendering <= constraints as >= ones.
Actually attaching the patch.
--
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer i speak de, en
Description: Make mccs work with clasp
clasp needs to changes to work:
1. It does not output an empty space at the end of each line, so where
the code fails to correctly read the result
2. Less equal constraints need to be converted to greater-equal ones
as clasp only understands those.
Author: Julian Andres Klode <[email protected]>
Last-Update: 2018-06-21
Bug-Debian: https://bugs.debian.org/902003
--- mccs-1.1.orig/sources/pblib_solver.c
+++ mccs-1.1/sources/pblib_solver.c
@@ -173,7 +175,7 @@ int pblib_solver::solve() {
if (c == '\n')
break;
else if (c == '-')
- while (! feof(fsol)) { if (fgetc(fsol) == ' ') break;}
+ while (! feof(fsol)) { int x= fgetc(fsol); if (x == ' ') break; if (x == '\n') { ungetc(x, fsol); break; }}
else if (c == 'x')
if (fscanf(fsol, "%d", &rank) > 0) solution[rank-1] = 1;
}
@@ -282,10 +284,10 @@ int pblib_solver::add_constraint_leq(CUD
if (nb_coeffs > 0) {
for (int i = 0; i < nb_coeffs; i++) {
- fprintf(ctpbfile, "%s"CUDFflagsplus"%cx%d", sep, coefficients[i], mult, sindex[i]);
+ fprintf(ctpbfile, "%s"CUDFflagsplus"%cx%d", sep, coefficients[i] == '+' ? '-' : '+', mult, sindex[i]);
sep = (char *)" ";
}
- if (bound == 0) fprintf(ctpbfile, " <= 0;\n"); else fprintf(ctpbfile, " <= "CUDFflags";\n", bound);
+ if (bound == 0) fprintf(ctpbfile, " >= 0;\n"); else fprintf(ctpbfile, " >= "CUDFflags";\n", -bound);
nb_constraints++;
}
return 0;