vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

Finding right setup parameters #406

Open kikke88 opened 2 years ago

kikke88 commented 2 years ago

Dear FORM community,

I have a C++ program that sometimes has coefficients (fractions with polynomials), which need to be simplified. It uses fork and execl to start form and communicates with form through the pipes. The program sends the coefficient to form, waits for its simplification with https://github.com/vermaseren/form/issues/398#issuecomment-971587108 and reads the result. Then the program sends the next coefficient and everything repeats The working time of the main program can be calculated in weeks, which means that a very large number of coefficients is simplified, and the size of the coefficients can exceed 100'000 characters.

When simplifying large coefficients, I have seen such errors: 1)

ERROR: PolyRatFun doesn't fit in a term
(1) num size = 45232, den size = 9292,  MaxTer = 160000

I have increased MaxTermSize to 10MB.

2)

=== Workspace overflow. 40000000 bytes is not enough.
=== Change parameter WorkSpace in form.set

I have increased WorkSpace to 1GB.

3)

(1)Output should fit inside a single term. Increase MaxTermSize?
Called from EndSort

I could not find the MaxTermSize and WorkSpace values at which the program would work. I read the entire 17th chapter of the documentation, but I couldn't figure out what another settings could help me with this error.

(In the attached archive .frm and .set files on which I get the error) Thanks in advance.

example.zip

jodavies commented 2 years ago

The problem is that the intermediate "incomplete simplification" caused by the .sort on your line 28 is really enormous.

This .sort isn't actually necessary, I think, and if you remove it your test file runs with the default memory parameters.

tueda commented 2 years ago

This .sort isn't actually necessary, I think, and if you remove it your test file runs with the default memory parameters.

Good point! I was trying to increase the buffer sizes: with that .sort, at least MaxTermSize=200M and WorkSpace=50G (1TB memory allocated) was not sufficient...

jodavies commented 2 years ago

Removing that sort is not a guaranteed fix, I suppose, since one can surely construct nested input which will cause the same problem in the first iteration through the FromPolynomial loop which follows. That one is necessary, however...

kikke88 commented 2 years ago

Thanks a lot for the advice, deleting .sort really helped. But the program began to fall on very simple coefficients 2/((8*d*s^3+16*d*s^2-40*s^3-80*s^2)/(d-4)). "ERROR: polynomials and polyratfuns must contain symbols only". As I understand it, this is because of the characters generated by ArgToExtraSymbol

jodavies commented 2 years ago

OK, then this sort is necessary for sufficiently nested input. One solution is to help reduce the number of extrasymbols produced by bringing things to a more minimal form first. Adding after Denominators den;:

FactArg den;
ChainOut den;
Normalize,^-1 den;
Repeat Identify den(den(x?)) = x;
.sort

seems to work for all of your test cases, for me.

vermaseren commented 1 year ago

There are some settings that are a bit more obscure in this respect. You can look this up in this part of the latest course:

https://www.nikhef.nl/~form/maindir/courses/capp2021/five.pdf https://www.nikhef.nl/~form/maindir/courses/capp2021/five.pdf

This program ran into similar problems and in the text it is explained what happened and what could be done about it. It looks very similar to your problems.

On 30 Mar 2022, at 11:19, Mokrov Kirill @.***> wrote:

Dear FORM community,

I have a C++ program that sometimes has coefficients (fractions with polynomials), which need to be simplified. It uses fork and execl to start form and communicates with form through the pipes. The program sends the coefficient to form, waits for its simplification with #398 (comment) https://github.com/vermaseren/form/issues/398#issuecomment-971587108 and reads the result. Then the program sends the next coefficient and everything repeats The working time of the main program can be calculated in weeks, which means that a very large number of coefficients is simplified, and the size of the coefficients can exceed 100'000 characters.

When simplifying large coefficients, I have seen such errors: 1)

ERROR: PolyRatFun doesn't fit in a term (1) num size = 45232, den size = 9292, MaxTer = 160000 I have increased MaxTermSize to 10MB.

=== Workspace overflow. 40000000 bytes is not enough. === Change parameter WorkSpace in form.set I have increased WorkSpace to 1GB.

(1)Output should fit inside a single term. Increase MaxTermSize? Called from EndSort I could not find the MaxTermSize and WorkSpace values at which the program would work. I read the entire 17th chapter of the documentation, but I couldn't figure out what another settings could help me with this error.

Please tell me which setup parameters I need to change and to what values so that in the described situation form works without errors? Why .str files are always empty, can using them help? (In the attached archive .frm and .set files on which I get the error) Thanks in advance.

example.zip https://github.com/vermaseren/form/files/8379053/example.zip — Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/406, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEXSDP35L2NPPA5CY63VCQMBXANCNFSM5SBIH36A. You are receiving this because you are subscribed to this thread.