On Tue, 18 Sep 2018 19:21:31 -0700 Fabrice L wrote:
The problem is that the process take hours of compilations, and tests are not easy to do. Anyway, I will enrich my « minimal » code to my « full » code in order to find the difference… and the problem. I will update the thread as soon as can.
My over 700k object graphics example, processed several times (repeatedly, over several pages with modifications) took less than one minute to process. In fact, each graphic took almost as long to render from
Le 19 septembre 2018 à 15:47:07, Fabrice L (fabrice.alpha@gmail.com) a écrit: Le 19 septembre 2018 à 15:28:54, Alan Braslau (braslau.list@comcast.net (mailto:braslau.list@comcast.net)) a écrit: the pdf as it did for metapost/lua to process.
Alan
I do not know what your example is (but I’m curious: can I see this
somewhere ?).
In my case, the long time needed is to check if a new object does not
intersect with any other object: so when I try to find the maximum size of
the 1000th object at a given position, I have to check with the 999 others…
I do this with « intersectiontimes ». And so on for the 10001th… I have a
course try to find solutions to gain time, like using the coordinate of a
new object: when the coordinate of a new object is chosen, I do not need to
check potential intersections with objects far away… but surprisingly (to
me) this take more time than to blindly check with every object.
This is an algorithmic problem more than a ConTeXt/Metapost one… but I you
have suggestions, I’m sure I can learn !
Below is minimal code. (Just to be clear, this code work, even for 20K
objects.)
Thanks.
\starttext
\startMPpage
path Obj[] , ObjTemp ;
pair ObjPos , Inter ;
numeric NObj ;
% Change herte "NObj" to a big numer (says 20K)
NObj := 100;
numeric Danger, MaxSize ;
% Draw an initial object of random shape and random size ;
Obj[1]:= fullsquare randomized .001in
scaled (uniformdeviate(.5)*1in)
shifted (uniformdeviate(5)*1in,uniformdeviate(5)*1in) ;
Obj[1] := curved ( Obj[1] );
fill Obj[1] withcolor cyan randomized (.2,1.5);
draw Obj[1] withcolor black randomized (.2,1.5);
for i=2 upto NObj :
Danger := 0;
% Choose a position for the object :
ObjPos := (uniformdeviate(5)*1in,uniformdeviate(5)*1in) ;
% Choose a form :
Obj[i] := fullsquare randomized .01in ;
Obj[i] := curved ( Obj[i] );
% Choose a scale so the object does not interact with any other object:
for j=1 upto 50:
MaxSize := (j*.01in) ;
ObjTemp := Obj[i] scaled MaxSize shifted ObjPos ;
%draw ObjTemp withcolor magenta ;
% Check if this temporary object intersect with any other object :
for k=1 upto (i-1):
string trace ;
Inter := Obj[k] intersectiontimes ObjTemp ;
if (xpart Inter) <> -1 : Danger := 1; fi ;
if Danger=1: MaxSize := ((j-1)*.01in) ; fi;
exitif Danger = 1;
endfor;
exitif Danger = 1;
endfor ;
Obj[i] := Obj[i] scaled MaxSize shifted ObjPos ;
fill Obj[i] withcolor cyan randomized (.2,1.5);
draw Obj[i] withcolor black randomized (.2,1.5);
endfor;
\stopMPpage
\stoptext
So after some hours of computation, this code above breaks for me if the
number of objects, NObj in my code, is too large. Of course, perhaps an
error occurs at some point and is not caused directly by the number of
objects, because according to what has been said in this thread this should
not be is not a problem. I put below the log. If somebody has a hint in
which direction I should look… thanks !
Fabrice.
mtx-context | run 1: luatex
--fmt="/Users/fabricel/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en"
--jobname="0030-0018-minimal2"
--lua="/Users/fabricel/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui"
--no-parse-first-line --c:currentrun=1
--c:fulljobname="./0030-0018-minimal2.tex"
--c:input="./0030-0018-minimal2.tex" --c:kindofrun=1 --c:maxnofruns=1
--c:runs="1" "cont-yes.mkiv"
This is LuaTeX, Version 1.08.0 (TeX Live 2018)
system commands enabled.
open source > level 1, order 1, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv'
system >
system > ConTeXt ver: 2018.05.17 18:32 MKIV beta fmt: 2018.5.18
int: english/english
system >
system > 'cont-new.mkiv' loaded
open source > level 2, order 2, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system > beware: some patches loaded from cont-new.mkiv
close source > level 2, order 2, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system > files > jobname '0030-0018-minimal2', input
'./0030-0018-minimal2', result '0030-0018-minimal2'
fonts > latin modern fonts are not preloaded
languages > language 'en' is active
open source > level 2, order 3, name
'/Users/fabricel/Dropbox/Divers/Création/P030-Remplissage/0030-0018-minimal2.tex'
fonts > preloading latin modern fonts (second stage)
fonts > 'fallback modern-designsize rm 12pt' is loaded
metapost > initializing instance 'metafun' using format 'metafun'
metapost > loading 'metafun' as
'/Users/fabricel/context/tex/texmf-context/metapost/context/base/mpiv/metafun.mpiv'
using method 'default'
metapost > initializing number mode 'scaled'
tex error > mp error on line 45 in file
/Users/fabricel/Dropbox/Divers/Création/P030-Remplissage/0030-0018-minimal2.tex:
! Emergency stop.