Commit a3fed76f authored by Hynek Baran's avatar Hynek Baran

bugfix: infinity loop in `resolve/opts/postproc` fixed?

parent e7ef7293
......@@ -117,7 +117,7 @@
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets 5.92 test1 as of Oct 19, 2018 (2018-10-19 09:42:25)</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets.newresolve v 0.3 as of Oct 2018 (2018-10-29 15:01:07)</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets.newresolve v 0.3 as of Oct 2018 (2018-10-29 16:56:35)</Text-field>
</Output>
</Group>
<Group hide-output="false" labelreference="L936" drawlabel="true">
......
......@@ -17,7 +17,8 @@ printf("Jets.newresolve v 0.3 as of Oct 2018 (%s)\n",
`resolve/opts/postproc` := {'nonlinear', 'linear'}:
`resolve/1` := proc()
local as,bs,as1, as2, cs, ds, vl,i,ans, A, AL, AN, A1, A0, A1S, A1H, AE, APD, B, ff;
local as,bs,as1, as2, cs, ds, vl,i,ans, A, AL, AN, A1, A0, A1S, A1H, AE, APD, B, ff;
global old, new, new1; ############################!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
global `resolve/nonresrat`, `resolve/combine`;
Report(2, cat(`input `, nops([args])));
as := MaP(numer,{args}) minus {0};
......@@ -130,20 +131,54 @@ printf("Jets.newresolve v 0.3 as of Oct 2018 (%s)\n",
# sprintf("# LVars=%q\n", map(a->a:-Vars[1], B))));
ans := `resolve/lin/r`(convert(B, set), vl, ForceFail=ff);
Reportf(0, ["Resolving %a of %a input eqs given %a results", nops(B), nops(A), nops(ans)]);
if ans<>FAIL then
Reportf(0, ["Resolving %a (of %a input) eqs given %a results.", nops(B), nops(A), nops(ans)]);
else
Reportf(0, ["Resolving %a (of %a input) eqs failed.", nops(B), nops(A)]);
fi;
# if no usable results, lets try to generate pseudoremainders of polynomial pairs
if has(`resolve/opts/postproc`, 'nonlinear') and ans = FAIL then
Reportf(2, ["No solvable eqs found, trying to combine input eqs pairs into linear by pseudodivision"]);
AE := `resolve/nonlin/combine/1`(A);
Reportf(1, ["Combining %a eqs given %a results", nops(A), nops(AE)]);
Reportf(2, ["...whitch properties are [price, size, LM, Vars, LC]:\n%s",
StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-LM, a:-Vars, a:-LC]), AE))]);
old := convert(A,set);
Reportf(2, ["No solvable eqs found, trying to combine input %a eqs into linear by pseudodivision...", nops(old)]);
new := `resolve/nonlin/combine/1`(old);
new := new minus old;
Reportf(1, ["Combining %a eqs given %a new results", nops(old), nops(new)]);
Reportf(2, ["...whitch properties are [price, size, LM, Vars, size(LC)]:\n%s",
StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-LM, a:-Vars, size(a:-LC)]), [op(new)]))]);
ans := `resolve/lin/r`(convert(AE, set), ForceFail=ff);
Reportf(0, ["Resolving %a combined eqs (generated by pseudodivision from %a eqs) given %a results", nops(AE), nops(A), nops(ans)]);
ans := `resolve/lin/r`(new, ForceFail=ff);
if ans<>FAIL then
Reportf(0, ["Resolving %a combined eqs given %a results.", nops(new), nops(ans)]);
else
Reportf(0, ["Resolving %a combined eqs failed.", nops(new)]);
fi;
while ans = FAIL and nops(new) > 0 do
print(ANS, ans);
print(OLD, nops(old), map(a -> collect(a:-expr, a:-LV, length*Vars), old));
print(NEW, nops(new), map(a -> collect(a:-expr, a:-LV, length*Vars), new));
# print(OLD, nops(old), map(a -> a:-expr, old));
# print(NEW, nops(new), map(a -> a:-expr, new));
Reportf(2, ["No solvable eqs found, trying to combine %a against %a eqs into linear by pseudodivision...", nops(old), nops(new)]);
new1 := `resolve/nonlin/combine/2`(old, new);
new1 := new1 minus (old union new);
Reportf(1, ["Combining %a eqs given %a new results", nops(old), nops(new)]);
Reportf(2, ["...whitch properties are [price, size, LM, Vars, size(LC)]:\n%s",
StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-LM, a:-Vars, size(a:-LC)]), [op(new)]))]);
ans := `resolve/lin/r`(new1, ForceFail=ff);
Reportf(0, ["Resolving %a again combined eqs (generated by pseudodivision) given %a results.", nops(new), nops(ans)]);
old := old union new;
new := new1;
od;
fi;
#### if still no usable results, lets try to linearize nonlinear eqs by pd (linderive)
......@@ -317,7 +352,7 @@ end:
### linearize combined pairs
`resolve/nonlin/combine/2` := proc(as::list(record), bs::list(record), $)
`resolve/nonlin/combine/2` := proc(as::sequential(record), bs::sequential(record), $)
# combine on cartesian product
local Vs, res;
# collect leading Vars
......@@ -329,10 +364,10 @@ end:
`resolve/nonlin/combine/LV/2`(LV, as0, bs0)
end,
Vs);
return sizesort(map(`resolve/data/collect/detect`, res, source=''procname''), a->a:-size);
return convert(map(`resolve/data/collect/detect`, res, source=''procname''), set);
end:
`resolve/nonlin/combine/1` := proc(as::list(record), $)
`resolve/nonlin/combine/1` := proc(as::sequential(record), $)
# combine on pairs from single set (but single call on [a,b] ~ [b,a])
local Vs, res;
# collect leading Vars
......@@ -343,7 +378,7 @@ end:
`resolve/nonlin/combine/LV/1`(LV, as0)
end,
Vs);
return sizesort(map(`resolve/data/collect/detect`, res, source=''procname''), a->a:-size);
return convert(map(`resolve/data/collect/detect`, res, source=''procname''), set);
end:
`resolve/nonlin/combine/LV/2` := proc (LV, as, bs, $)
......@@ -387,13 +422,12 @@ end:
LV := F:-LV;
fi;
Reportf(2, ["Combining polynomials in %a^%a*(%a), %a^%a*(%a)", (F:-LV), (F:-degree), (F:-LC), (G:-LV), (G:-degree), (G:-LC)]);
Reportf(2, ["Combining polynomials in %a^%a*(%a), %a^%a*(%a)", (F:-LV), (F:-degree), size(F:-LC), (G:-LV), (G:-degree), size(G:-LC)]);
res := `resolve/nonlin/combine/pair/tool`(F, G);
if res <> NULL then
res := op(map(divideout@numer, {res}));
fi;
return res;
if nops(Vars(res)) > 0 then return res else return NULL fi; # omit unknownless expressions, to be error?
end:
`resolve/nonlin/combine/pair/tool` := `resolve/nonlin/combine/pair/tool/pseudodivision`:
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment