I'm interested in maximising the area of intersection between two or more geometric regions (for now, in 2D). For instance, I can calculate the offset between the centres of two annuli with given radii and widths that maximises the area of intersection between the annuli:
kfup = 10; kfdn = 5; ω = 3.5;
q1[offset_] := {0, offset (kfup - kfdn)};
upwidth = ω/kfup; dnwidth = ω/kfdn;
regions = {ImplicitRegion[ kfdn^2 < ({x, y}).({x, y}) < (kfdn + dnwidth)^2, {{x, -2 kfup, 2 kfup}, {y, -2 kfup, 2 kfup}}],
ImplicitRegion[ kfup^2 < (-{x, y} + q1[offset]).(-{x, y} + q1[offset]) < (kfup + upwidth)^2, {{x, -2 kfup, 2 kfup}, {y, -2 kfup, 2 kfup}}]};
{time, {intersection, val}} = FindMaximum[RegionMeasure[RegionIntersection[regions]]
, {offset, 1.0, 1.1}] // AbsoluteTiming
However, this code runs quite slowly on my machine:
{13.0212, {2.41396, {offset -> 1.00885}}}
Is there a way to speed up this process, so that I can go on to maximise the intersection of more complicated regions? I'd eventually like to look at the intersection of four or more regions, which using the method above isn't feasible. I've been unable to parallelise this method, so any answers which show a way to parallelise it, or any answers giving completely different approaches to the problem, would be welcome. I'm using v11.0.0.
Edit:
The above timing data is using the code included above. However, if I change the definition of the function q1 to
q1[offset_?NumericQ] := {0, offset (kfup - kfdn)};
the FindMaximum is no longer able to converge the optimisation. I don't understand this behaviour, as the RegionMeasure[RegionIntersection[regions]]
should include only numeric expressions. Perhaps this is connected to the slow evaluation?