Building Problem

Author

Eric W. Weisstein
February 7, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Optimization/BuildingProblem.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/BuildingProblem.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Different Methods

v4.2

<<DiscreteMath`NMinimize`

ColumnForm[a=Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@exact

ColumnForm[Timing[{#,NMinimize[{d l w,
d+h==7/2n&&
l==GoldenRatio w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

v5

ColumnForm[approx=Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@approx

ColumnForm[exact=Timing[{#,NMinimize[{d l w,
d+h==7/2n&&
l==GoldenRatio w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@exact

v5.2

ColumnForm[approx=Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@approx

ColumnForm[exact=Timing[{#,NMinimize[{d l w,
d+h==7/2n&&
l==GoldenRatio w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@exact

v6

ColumnForm[approx=Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@approx

ColumnForm[exact=Timing[{#,NMinimize[{d l w,
d+h==7/2n&&
l==GoldenRatio w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

d l w/.#[[2,2,2]]&/@exact

Specifying n to be an integer

v4.2

ColumnForm[Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤w≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

v5

ColumnForm[Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤w≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

v5.2

ColumnForm[Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤w≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

v6

ColumnForm[Timing[{#,NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤w≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},
Method->#]}]&/@{"DifferentialEvolution","NelderMead","RandomSearch","SimulatedAnnealing"}]

Random Search

Not an Integer

ColumnForm[trials=Table[NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100
},{n,d,h,l,w},Method->{"RandomSearch","RandomSeed"->i}]//Timing,
{i,20}]]

Sort[Rest/@trials]//ColumnForm

min=Min[#[[2,1]]&/@trials]

n an Integer

v5.2

ColumnForm[trials=Table[NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},Method->{"RandomSearch","RandomSeed"->i}]//Timing,
{i,20}]]

DeleteCases[trials,_?(#[[2,1]]==0.&)]

min=Min[#[[2,1]]&/@DeleteCases[trials,_?(#[[2,1]]==0.&)]]

v6

ColumnForm[trials=Table[NMinimize[{d l w,
d+h==3.5n&&
l==1.618 w&&
100(2h l+2h w+l w)≤225000&&
0≤l≤50&&
n l w≥20000&&
1≤n≤100&&
0≤d≤100&&
0≤h≤100&&
n∈Integers
},{n,d,h,l,w},Method->{"RandomSearch","RandomSeed"->i}]//Timing,
{i,20}]]

...hangs when run in a FE...

By hand

n=27
d=81.028397
h=13.471603
l=34.619990
w=21.396330
giving dlw=60021.03

With[{d=81.028397,l=34.619990,h=13.471603,w=21.396330},
{d l w,
(d+h)/3.5,
l/w,
100(2h l+2h w+l w)
}]

With[{d=81.03,l=34.62,h=13.47,w=21.40},
{d l w,
(d+h)/3.5,
l/w,
100(2h l+2h w+l w)
}]