Old man Puzz rejects the design.
Puzz from Puzzlaria laughed at Cam's answer to the fence design.
But he rejected it very quickly. He said his horses wouldn't like
that design.
Puzz said he needed a fenced area of about 12 acres for his
horses to run and play and he was going to add a riding trail
for his grandchildren. He thought a circle would be nice.
He added some specifications. Fence wire was $1 per foot
for a three wire fence, and posts were $5 each. Posts were
to be placed at 15 to 18 foot intervals. It needed a 16 foot opening
for his gate which he already owned.
So his required design calls for the best cost per acre for 11.9 to 12.1 acres.
But he rejected it very quickly. He said his horses wouldn't like
that design.
Puzz said he needed a fenced area of about 12 acres for his
horses to run and play and he was going to add a riding trail
for his grandchildren. He thought a circle would be nice.
He added some specifications. Fence wire was $1 per foot
for a three wire fence, and posts were $5 each. Posts were
to be placed at 15 to 18 foot intervals. It needed a 16 foot opening
for his gate which he already owned.
So his required design calls for the best cost per acre for 11.9 to 12.1 acres.
Labels: Your Opinion





34 Comments:
All Puzz's horses are agoraphobic!
You haven't specified the problem well enough for it to be answerable i.e. How much do gate posts cost (or do you have those already)? Is the wire actually $1/yard (single)? What is the maximum length of a single wire. How much does a wire fixing hook cost (if you use such things)? What is the average cost of erecting a fence post? Can we assume that the ground is flat?
I could give an algebraic answer in lieu of useful information.
As there seem to several definitions of an acre, which one are you specifying?
What is the question that you want answered? If you simply want the lowest cost/acre, make the fence posts be 18 feet apart and choose 12.1 acres.
$813.25 per acre
The area will be a regular polygon.
Wire is $1 per foot for 3 wires, (3 wires are needed), so it's perimeter less 16' foot for a gate. Assume same post on either side of gate.
Puzz already has a gate to use.
Use acre = 43560 square feet
Post 18 foot apart make longer chords, and reduces the acreage
for a given radius.
Find the best fence cost per acre.
Sorry, a "regular polygon" would indicate all sections be equal. That might mean all sides 16' for the gate. Don't do that necessarily.
Sections can vary from 15 to 18, with one 16 foot opening for gate.
I've estimated for a 15 foot post dist, the area is about 0.7 sq ft less than the sector of a circle.
And almost 1.2 sqft less for 18 foot post distance.
Knightmare,
You must have had the wire wrong.
If the total perimeter is 100 feet
then the total wire cost is $100.
Chris is close, but he didn't
give enough info for the design.
To build it you need the number of posts, length of wire, and radius of the fence posts and the cost per acre.
Sorry. I've been really busy - didn't leave my last customer until gone 3 am. Prolly not going to get a chance until midnight or so (eight hours from now). I accept that it's a fairly challenging problem. I have started writing some code, but am dithering on the best optimization strategy. But I will post (groan) a solution - which almost certainly will be programmatic.
Due to customer unavailability, I've got some heuristic preliminary
results. I might tweak these figures later. I've assume that the gate
needs a $5 post at either side. I haven't allowed for wire being
folded back on itself or other wire splicing overheads.
For 11.9 acres, need 142 posts, 17.98904 feet apart. $3246.45.
For 12.1 acres, need 144 posts, 17.88681 feet apart. $3277.81.
This post has been removed by the author.
See Puzz's fence costs for the code.
From your code I got these results.
Radius =............... 406.2686955
Post Dist =............ 17.98902987
Arc Circum =........... 2552.661498
....Less Gate = ....... 2536.661498
Post Arc Len = ....... 17.99049974
Number post=........... 143
Remaining wire =....... 0.001034517
Wire Length =...........2536.454246
Wire Cost =.............$2,536.45
Post Cost =.............$715.00
Total Cost =............$3,251.45
Sqft one post = ........3653.294189 Tri area between two typical post
Sqft last post =........0.21014598 Tri area between gate post and last typical post
SqFt gate =.............3249.519378 Tri area to gate
Fenced acres =..........11.90000482
Unit Cost...............$273.23
This is what I have
I used a radius of 409.38 feet and a post distance of 18 feet, and got Unit Cost of $270.71
Radius = 409.3792
Post Dist = 18
Arc Circum = 2572.205375
.Less Gate = 2556.205375
Post Arc Len = 18.00145027
Number post= 143
Remaining wire= 17.99943648
Wire Length= 2555.999436
Wire Cost = $2,556.00
Post Cost = $715.00
Total Cost = $3,271.00
Sqft one post = 3683.52232
Sqft last post = 3683.407056
SqFt gate = 3274.408203
Fenced acres = 12.08297664
Unit Cost $270.71
I'll send you my code and you can review it.
Const Pi = 3.141592654
Const Tac = 43560
Sub fence()
munitcost = 99999
For r = 40500 To 41500
radius = r / 100
For pd = 1750 To 1800
postdist = pd / 100
arclen = arcleng(postdist, radius)
carea = Pi * radius ^ 2
ac = carea / Tac 'area of circle in acres
circum = radius * 2 * Pi
Arcl = arcleng(postdist, radius)
t1 = ArcFunc(radius, Arcl, "T")
nopost = Int((circum - 16) / Arcl) + 2
remainarc = (circum - 16) - (nopost - 2) * Arcl
Remainwire = ArcFunc(radius, remainarc, "C")
wiredist = (nopost - 2) * postdist + Remainwire
tr = ArcFunc(radius, remainarc, "T") 'area at remaining arc
tg = ArcFunc(radius, (arcleng(16, radius)), "T") 'area at gate
fencedacre = ((t1 * (nopost - 2)) + tr + tg) / Tac
cost = nopost * 5 + wiredist
unitcost = cost / fencedacre
If unitcost < munitcost Then
If fencedacre > 11.9 And fencedacre < 12.1 Then
munitcost = unitcost
mradius = radius
mpostdist = postdist
mradius = radius
mwire = wiredist
mnopost = nopost
mfencedacre = fencedacre
Debug.Print unitcost
End If
End If
Next pd
Next r
Debug.Print "cost"; Round(munitcost, 2)
Debug.Print "number of post"; mnopost
Debug.Print "fenced acres"; mfencedacre
Debug.Print "Radius"; mradius
Debug.Print "post dist"; mpostdist
End Sub
Function ArcFunc(radius, arclen, parm)
angrad = arclen / radius
halfang = angrad / 2
carea = halfang * radius ^ 2
halfchord = radius * Sin(halfang)
chord = halfchord * 2
leng = radius * Cos(halfang)
Tarea = leng * halfchord
Select Case parm
Case "T": ArcFunc = Tarea 'area of triangle
Case "C": ArcFunc = chord 'cord length of arc
Case "A": arcfun = carea 'area of circle
End Select
End Function
Function arcleng(chord, radius)
halfchord = chord / 2
x = halfchord / radius
halfarcleng = Atn(x / Sqr(-x * x + 1)) * radius
arcleng = halfarcleng * 2
End Function
I'll look at your code in a moment. I had a silly error in the displayed length of the wire - the published source code has now been fixed.
I've also added display of cost/acre.
For 11.9 acres, $272.81/acre
For 12.1 acres, $270.89/acre
I checked that for 12.08297644 acres that you do indeed get $270.71/acre.
I now understand your requirement more clearly i.e. I need to optimize for the best cost/acre, using min-max acreage as the constraint. I'd optimized for best cost per acre for a given acreage. In fact (although I'm not surprised) my code fails at 12.083 acres. Back soon.
I noted that I didn't figure the arc length of the gate... make a difference of about 1/1000 of a foot.
Here's a note. There what I called typical posts, that are separated by the typical distance between post.
The last post would be at the gate, if you began at the other side of the gate. This distance will be less that the typical distance (normally) and I called that the remaining section. If that remaining section is more that the typical distance, you would have to add another post, thereby moving the remaining section. To save a post make the remaining post equal or less that the typical distance.
Of course in reality, the difference may not be significant.
If you post distance is about 18 then at 12.083 acres your number of post will go up one.
I only used 3 decimal places and I sure you can find a more accurate solution, but cents in the unit cost probably won't change.
This one optimizes the cost/acre: Puzz's fence 2.
Not great code, but can't be bothered to take it further as I've started to get bored and I know that I won't be using it in real life.
I would simply add the widths of the two gateposts to the width of the gate.
Just caught your 6:48 PM post. Yeah, I'm working to a ridiculously high precision.
This post has been removed by the author.
I'd noticed my original code failed at 12.083 acres (I think) for that reason. I had added a test for that (but haven't updated the published code) as I got on with the second version instead.
In the last one I added a loop counter, and found it took 7 goes to get the radius right (to a ridiculously high precision). I'm probably hitting the limits of VB's precision - which I notice isn't very high.
... that way all the posts are typical.
Wow that was fast.
I' I want to look at "the remaining section". It must be close to 18 foot.
The "remainder" shows 0.0000003359
that means you hit the bit boundary or I suppose it means I did.
Your output...
Acreage = 12.0829867205458
Radius = 409.379451825398
Number of posts = 143
Length of three strand wire = 2556
Distance between posts = 18
Total cost = 3271
Cost/acre = 270.711213680142
I have to study your method.
The reason my first code went wonky is because it is precisely at the optimum condition that the number of posts could change. I could have fixed it by adding a (very small) tolerance/hysteresis, so that it wouldn't keep oscillating between adding and subtracting a post, and/or giving both solutions and leaving you to decide which to go for.
Summary
Start with 12.1 acres and 18 ft post distance, which would logically give the best unit cost.
That would be 527076 sqft. Figure the radius and get 409.602 feet, and a circumference of 2573.603 feet.
Subtract the arc length of the gate, and divide by the arc length of the post distance gives 142.078 post distances.
Use 142 times the arc of the post distances plus the arc length of the gate gives a new circumference of 2572.207 feet.
So we lost 1.396 feet in circumference to into tune the post distances and just below 12.1 acres.
When we get the radius of that, we get 409.379416093102 feet.
Chris got 409.379451825398
Yeah Chris!!
kick
This post has been removed by the author.
This post has been removed by the author.
This post has been removed by the author.
I've done a final update: Puzz's fence 2. I've used calculus to reduce the number of loops. Also this is to kick the other posts through.
I wondered why I did not have the exact numbers as you got.
If you read my "easy way", I computed the radius directly. But then I realize an error, a tiny one but still a problem. Once I had the radius, I did not correct the arc length of the gate and post section.
I recomputed each of these twice more and got the same radius you had, then the same unit cost also.
I had to laugh at the oversight. I also borrowed your function for Asin(). Thanks.
Thanks for your codes. They are a beauty to read.
I wish Cam had joined in. He possess a special light that reveal things I did not see.
This was my tweak to correct the arc lengths of the gate and post sections. This actually gives me the remaining section exactly 0... which is the same goal you made on your last code.
btw. Tac is 43560 (to acres)
Function EzyRad(acres, postdist)
sqft = acres * Tac 'Sqft at max acres
rad = Sqr(sqft / Pi) 'Radius at max acres
circ = Pi * rad * 2 'Circumference at max acres
gatearc = arcleng(16, rad) 'arc length of fence at max acres
postarc = arcleng(postdist, rad) 'arc length of fence section at max acres
Numpostsec = Int((circ - gatearc) / postarc) 'number of post sections needed,
circ = gatearc + postarc * Numpostsec
rad = circ / Pi / 2
'correct arc lengths
While Abs(Lastrad - rad) > 0.000000001
Lastrad = rad
gatearc = arcleng(16, rad)
postarc = arcleng(postdist, rad)
circ = gatearc + postarc * Numpostsec
rad = circ / Pi / 2
Wend
EzyRad = rad
End Function
Too my amazement, if allow the distance between the psost to be greater than 18, the cost per acre goes up, not down as I had assumed.
I've updated the proggy so that you can see that.
I've done a final update: Puzz's fence 2. This replaces my previous efforts.
Post a Comment
Links to this post:
Create a Link
<< Home