# Optimal lighting configuration of 5 lamps in a square room

GROUPS:
 Todd Rowland 8 Votes 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 meanf = 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 likeb) 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 withf = 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 illuminationNMinimize[{f, 0 <= x <= 1 && 0 <= y <= 1}, {x, y}] (*{14.349, {x -> 1., y -> 1.}}*)and here that point is shown on a contour plotFor 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.
5 years ago
12 Replies
 Vitaliy Kaurov 6 Votes 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.Manipulate[ 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);)]
5 years ago
 Todd Rowland 3 Votes Vitaliy,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);)]Clinton,You can try out Vitaliy's tool.  Seems like the pentagon is not the best.Ed,How are the circle coverings found?  A max min type of thing, or more of a puzzle-fitting sort of thing?
5 years ago
 Ed Pegg 3 Votes 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.
5 years ago
 Clinton Weir 3 Votes 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?
5 years ago
 Ed Pegg 3 Votes Similar to: The Circle Covering Puzzle
5 years ago
 Vitaliy Kaurov 5 Votes 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 functionIn[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}]
5 years ago
 Todd Rowland 3 Votes 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 albedopt = {{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.
5 years ago
 Vitaliy Kaurov 2 Votes 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 Integral[Abs[Derivative["intensity"],x],{x,-1/2,1/2}]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]]
5 years ago
 Clinton Weir 2 Votes Another thought I've just had:1 in the center of the room1 in each of the midpoints of the center and the cornersSymmetry! My preceding thought was one in the center and one at the corners but then you're wasting part of your light.