Message Boards Message Boards

Optimal lighting configuration of 5 lamps in a square room

Posted 11 years ago
With 5 point-source lights in a square room, what is the optimal configuration for even lighting?

To make this question concrete, say that each wall has length 1, the room has no height (i.e., two dimensional) and we have five identical lights that are pointsized and want to know the optimal placement that maximizes even lighting.  That could mean
f = 1/((x - x1)^2 + (y - y1)^2) + 1/((x - x2)^2 + (y - y2)^2) + 1/((x - x3)^2 + (y - y3)^2) + 1/((x - x4)^2 + (y - y4)^2) + 1/((x - x5)^2 + (y - y5)^2);

a) maximizing the value of the minimal illumination
Minimize[f, {x,0,1},{y,0,1}]
or an integral measure like

b) maximizing the total illumination where the brightest areas are considered as being some default value, e.g., the value of
Integrate[Min[f, f0], {x,0,1},{y,0,1}]

For an example configuration of light sources with
f = With[{n = 5}, Sum[1/((x - (.5 + .45 Cos[2 Pi i/n]))^2 + (y - (.5 + .45 Sin[2 Pi i/n]))^2), {i, 0, n - 1}]]
and then here is the minimum illumination
NMinimize[{f, 0 <= x <= 1 && 0 <= y <= 1}, {x, y}] (*{14.349, {x -> 1., y -> 1.}}*)
and here that point is shown on a contour plot

For that configuration here is the integral (which I had to approximate with a Sum)
Sum[Min[1.2 (14.349), f], {x, 0.0001, 1, .01}, {y, 0.0001, 1, .01}]/10^4 (*17.2146*)
I'd be interested in optimization approaches, but also aesthetic approaches, e.g., symmetries, angles, shadows, or patterns made by contour lines.

To generalize, not only other numbers of lights, but try tacking on albedo of 50% so the wall reflect half of the light they receive.
POSTED BY: Todd Rowland
12 Replies
This discussion was hot on Reddit and produced a few interesting comments: LINK.
POSTED BY: Vitaliy Kaurov
Perhaps I should answer some of the questions from that Reddit thread and summarize what I learned from this Community discussion.

> I'm not so convinced that the optimal configuration is symmetric.

It would be neat to find a candidate which was not symmetric.  One of the candidates above has only a mirror symmetry.

> Why would you put 5 lamps in a room?

The variables for basic light calculations involve the area of the room and the amount of light in each lamp, with no consideration for symmetry.  The desired light density depends on the activities taking place (which can take the form of building codes) and personal taste.

> Odd that you are looking for "even" lighting, but then use goal functions that don't take into account bright spots. If this is for actual use (I.e. Human eye) wouldn't you want to minimize the standard deviation or perhaps the magnitude of the gradient (I.e. No rapid changes in brightness)?

Vitaliy considered a total variance measure in one of his posts.  The reason why I preferred the minimal light level is that this replaces the measurement of (maximum light - minimum light) which won't work here because the light levels have vertical asymptotes at the point sized lamps (see the last plot in my most recent post for a 1D picture).  My bias here is not caring too much about bright spots because those areas will have enough light, and especially ignoring the vertical asymptotes.

Ok, what did I get out of this?  Vitaliy wrote an easy to use tool and Ed explained it was better to rely on human skill, which justifies just fiddling around with Vitaliy's tool.  With that it takes only a few minutes to find the candidates mentioned above. 
POSTED BY: Todd Rowland

I think that's one of the candidate configurations, which you can try out using Vitaliy's tool.  I prefer the above version where the Contour levels are fixed so you can compare between pictures.  You can see that in this configuration, the lights do a little better if moved towards the corner a little more than halfway.


Yes, that analysis does look difficult.  Your parameter s shows that you are a physicist.  The total variance is a possible measure of even lighting, but for this analysis the minimum value is simpler.  In the situation with two lights symmetrically placed, that value occurs either on the boundary or in the middle.  (If one wants to justify that, perhaps by convexity.) 
Maximize[ Min[ 1/d^2 + 1/(1-d)^2, 2/(1/2-d)^2]]

Since those two functions are monotonic, there will be one solution and

we can just find where they are equal, around d=.21
Solve[2/(1/2 - d)^2 == 1/d^2 + 1/(1 - d)^2, d] (*(3-Sqrt[3])/6*)

Maybe that was too light on the analysis, so here is the version with reflections (note that my earlier post got the reflection wrong and did pbc instead).  For perfect reflections on periodic boundary conditions, one has this sum
Sum[1/(x + a)^2, {a, -Infinity, Infinity}]

which has a nice closed form of Csc.

We can also get a closed form with albedo and relfections so we might as well go for it
g[d_]=Sum[(1/2)^Abs[2 a]/(x - d + 2 a)^2, {a, -Infinity, Infinity}]+Sum[(1/2)^Abs[2 a + 1]/(x + d + 2 a)^2, {a, -Infinity, Infinity}]
(2 HurwitzLerchPhi[1/4, 2, 1/2 (2 - d - x)] + HurwitzLerchPhi[1/4, 2, 1/2 (2 + d - x)] + 4 HurwitzLerchPhi[1/4, 2, 1/2 (-d + x)] + 2 HurwitzLerchPhi[1/4, 2, (d + x)/2])/16
and like above we just find what d is when g is the same at 0 and at 1/2.
FindRoot[(g[d]/.x->0)==(g[d]/.x->1/2), {d, .22}] (*d->.233*)

and the above is the plot with reflections.
POSTED BY: Todd Rowland
Posted 11 years ago
Another thought I've just had:
  • 1 in the center of the room
  • 1 in each of the midpoints of the center and the corners
Symmetry! My preceding thought was one in the center and one at the corners but then you're wasting part of your light.
POSTED BY: Clinton Weir
To show how complicated analytical analysis can get, let's consider 1D case of a room spanning from -1/2 to 1/2. There are just 2 lamps placed symmetrically at a distance d from zero - middle of the room. The distance d is optimization parameter. Now I'll give here another definition of what "even" distribution of light can be. Let's think of ow intensity of light changes in the room. If we want it to be flat, then
should be minimized with respect to d. To make this integral convergent we will do a trick - add a parameter s that removes divergencies, but at the end s will go to zero. Main idea is, if there is optimal value of d that minimizes "flatness" of intensity, then it should be independent of s in the limit s -> 0. Instead of Abs[...] I will use square. 
f[d_, s_] = Integrate[D[1/(s + (x + d)^2) + 1/(s + (x - d)^2), x]^2, {x, -1/2, 1/2}, Assumptions -> d > 0 && s > 0 && d < 1/2]

We get pretty complicated function which has a few extrema to find which analytically proves to be very difficult. The plot shows that as s->0 function has most prominent minimum for d=1/2, which means lights are at the corners of the room. Of course this is a very simple set up, with nice symmetry - 2 lights and 2 corners. It is just to show how complex equations can get.
LogPlot[f[d, #] & /@ Range[10^-3, 10^-2, 10^-3] // Evaluate, {d, 10^-2, 1/2},
  PlotRange -> {0, Automatic}, PlotLegends -> N@Range[10^-3, 10^-2, 10^-3]]

POSTED BY: Vitaliy Kaurov
Vitaliy,  that is interesting indeed.  I wonder why the math for the periodic boundary conditions comes out as finite because one might think the power output of the light sources is constant, and if there is no transmission loss, then the amount of light in the room is as if the light has been running forever.

Here I tried adding reflections, although only for one reflection allowed, and a slider for the albedo.
Manipulate[ContourPlot[s@Total[Flatten[{f[x, y] @@@ pt, albedo {f[x - 1, y] @@@ pt, f[x + 1, y] @@@ pt, f[x, y - 1] @@@ pt, f[x, y + 1] @@@ pt}}]], {x, 0, 1}, {y, 0, 1}, PlotPoints -> 40, ColorFunction -> "IslandColors", Contours -> Table[min + c, {c, 0, .5, .1}]], {{pt, .5 + .3 Table[{Cos[2 Pi k/5], Sin[2 Pi k/5]}, {k, 5}]}, Locator, LocatorAutoCreate -> True}, {{s, Identity, "log scale"}, {Log -> "Yes", Identity -> "No"}}, {min, 13, 80}, {{albedo, .5}, 0, 1}, Initialization :> (f[x_, y_][a_, b_] := 1/((x - a)^2 + (y - b)^2);)]
It seems like this symmetric configuration is better with no albedo
pt = {{0.776`, 0.794`}, {0.20800000000000002`, 0.77`}, {0.226`, 0.226`}, {0.794`, 0.19`}, {0.53`, 0.512`}}

and this one is better with 50%
pt = {{0.773`, 0.864`}, {0.196`, 0.786`}, {0.226`, 0.226`}, {0.794`,0.15400000000000003`}, {0.646`, 0.516`}}

but I can't be sure, just from these pictures. 
POSTED BY: Todd Rowland
It would also be interesting to consider periodic boundary conditions (PBC) for pairs of opposite sides of the room, - basically solving it on a torus. It is not a real room then of course, but it could shade some light, forgive my calembour. I must note that the original problem is not entirely realistic, because, apart from being from Flatland ;-),

it also neglects reflections of light from the walls which in most US houses are white and are pretty reflective. First thing I wonder if it makes it easier or harder to solve - for reflections vs PBC. Consider PBC in 1D case in a room of the size spanning from 0 to 1. There are no corners but there is periodicity in space. Pick a point in the room, say at 0.8:
Plot[1/x^2, {x, 1, 7}, GridLines -> {Range[7], None}, Filling -> 0,
Epilog -> {Red, PointSize[Large], Point[{.8 + #, 1/(.8 + #)^2} & /@ Range[6]]}]

Due to PBC light at points 0.8+1, 0.8+2, ..., 0.8+n will also end up in point 0.8. Will the room be infinitely overflowed with light? Nope - easy calculations show intensity of light at a point in a 1D room after infinitely many passes via PBC is finite and given by digamma function

In[1]:= Sum[1/(x + n)^2, {n, 0, Infinity}]
Out[1]= PolyGamma[1, x]
which is getting closer to the original (non-PBC) 1/x^2 shape as we getting closer to the point light source:
Series[PolyGamma[1, x], {x, 0, 2}]
POSTED BY: Vitaliy Kaurov
Posted 11 years ago
Posted 11 years ago
My first guess is that it would be a regular pentagon, with the "center" in the same spot as the center of the square. But which way would you orient the pentagon?
POSTED BY: Clinton Weir
Are you decorating your house? Well I hope that your actual room is a rectangle indeed and is not shaped like Roger Penrose or George Tokarsky unilluminable rooms ;-)

Quite interesting problem. I like that the number of lights - 5 - is different from rotational fold-symmetry of the room - 4. Makes it more complex. Here is an interactive app to play with intensities.
ContourPlot[s@Total[f[x, y] @@@ pt], {x, 0, 1}, {y, 0, 1},
  PlotPoints -> 40, ColorFunction -> "IslandColors"],
  {{pt, .5 + .3 Table[{Cos[2 Pi k/5], Sin[2 Pi k/5]}, {k, 5}]}, Locator, LocatorAutoCreate -> True},
  {{s, Identity, "log scale"}, {Log -> "Yes", Identity -> "No"}},
  Initialization :> (f[x_, y_][a_, b_] := 1/((x - a)^2 + (y - b)^2);)]

POSTED BY: Vitaliy Kaurov

Yes, indeed we are designing some real lighting.  Your tool is pretty easy to use.  Here I added a slider to adjust the contour lines near the minimum.  After trying a configuration, you can adjust the minimum slider to see what the minimum value is.  Not sure why this seems to work better than the builtin optimization functions.
Manipulate[ContourPlot[s@Total[f[x, y] @@@ pt], {x, 0, 1}, {y, 0, 1}, PlotPoints -> 40, ColorFunction -> "IslandColors", Contours -> Table[min + c, {c,
0, .5, .1}]], {{pt, .5 + .3 Table[{Cos[2 Pi k/5], Sin[2 Pi k/5]}, {k, 5}]}, Locator, LocatorAutoCreate -> True}, {{s, Identity, "log scale"}, {Log -> "Yes", Identity -> "No"}}, {min, 13, 30}, Initialization :> (f[x_, y_][a_, b_] := 1/((x - a)^2 + (y - b)^2);)]

You can try out Vitaliy's tool.  Seems like the pentagon is not the best.


How are the circle coverings found?  A max min type of thing, or more of a puzzle-fitting sort of thing?
POSTED BY: Todd Rowland
Posted 11 years ago
Various methods.  Random point placement followed by drifting / rattling works well.   After that, some point configurations can be analyzed and optimized by Mathematica, many of the current Heilbronn problem solutions were found that way. 

Humans are quite good at solving this sort of problem. 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract