discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Challenge

G
GregL
Fri, May 21, 2021 10:56 AM

Back in the 60's, as a young engineer, I played with Optimisation using Hill
Climbing.  I had a robust hill climbing program, written in Fortran, and a
weird curved hill function to test it on.
Over the years the program has been translated into Delphi and Prolog for
searching in N dimensions
It is now time to shoe-horn it into OpenScad!!!
THE CHALLENGE
I have mislaid my old test function, so have created a flying saucer shape
to test my routine as it is built.  The shape is a bit too simple for my
liking – can you come up with a bigger challenge?
N=2 is fine!
//-----------------------------------------------------------------------------------------------------
// UFO for hill climbing test
R=10;      // radius of dome
A=80;      // angle of cone from vertical
// cone continues to infinity, but our UFO goes to disc radius D
D=50;
// height of cone H = (D-R)/tan(A);
H = (D-R)/tan(A);
$fn=100;
sphere(r=R);
translate([0,0,-H])cylinder(r1=D,r2=R,h=H);
//--------------------------------------------------------------------
// function to calculate the Z for X,Y of UFO
function ZZ(X,Y)
=  let(XY=sqrt(XX+YY))
XY<R ? sqrt(RR-XYXY)          // on dome
: (R - XY)/tan(A);                    // on disc
// test the function on our UFO
for (t= [0:36])translate([t,t,ZZ(t,t)])color("hotpink")sphere(r=0.4);
translate([R,0,ZZ(R,0)])color("hotpink")sphere(r=1);

--
Sent from: http://forum.openscad.org/

Back in the 60's, as a young engineer, I played with Optimisation using Hill Climbing. I had a robust hill climbing program, written in Fortran, and a weird curved hill function to test it on. Over the years the program has been translated into Delphi and Prolog for searching in N dimensions It is now time to shoe-horn it into OpenScad!!! THE CHALLENGE I have mislaid my old test function, so have created a flying saucer shape to test my routine as it is built. The shape is a bit too simple for my liking – can you come up with a bigger challenge? N=2 is fine! //----------------------------------------------------------------------------------------------------- // UFO for hill climbing test R=10; // radius of dome A=80; // angle of cone from vertical // cone continues to infinity, but our UFO goes to disc radius D D=50; // height of cone H = (D-R)/tan(A); H = (D-R)/tan(A); $fn=100; sphere(r=R); translate([0,0,-H])cylinder(r1=D,r2=R,h=H); //-------------------------------------------------------------------- // function to calculate the Z for X,Y of UFO function ZZ(X,Y) = let(XY=sqrt(X*X+Y*Y)) XY<R ? sqrt(R*R-XY*XY) // on dome : (R - XY)/tan(A); // on disc // test the function on our UFO for (t= [0:36])translate([t,t,ZZ(t,t)])color("hotpink")sphere(r=0.4); translate([R,0,ZZ(R,0)])color("hotpink")sphere(r=1); -- Sent from: http://forum.openscad.org/
A
adrianv
Fri, May 21, 2021 12:21 PM

What sort of hill climbing algorithm are you talking about?  (The term "hill
climbing" appears to be very vague, apparently referring to any algorithm
that tries to maximize by going "up" at each step...or maybe even not that
if you count "stochastic hill climbing".)

My challenge function for a maximization algorithm that doesn't use 2nd
order approximation:

f = function(x,y) 100-(xx+yy/50);

starting your optimization on the x or y axis is cheating.  (You can rotate
the function to a random angle so that you can't find the "easy" starting
points if you must.)  How many iterations to get 6 digits of accuracy?

GregL wrote

Back in the 60's, as a young engineer, I played with Optimisation using
Hill
Climbing.  I had a robust hill climbing program, written in Fortran, and a
weird curved hill function to test it on.
Over the years the program has been translated into Delphi and Prolog for
searching in N dimensions
It is now time to shoe-horn it into OpenScad!!!
THE CHALLENGE
I have mislaid my old test function, so have created a flying saucer shape
to test my routine as it is built.  The shape is a bit too simple for my
liking – can you come up with a bigger challenge?
N=2 is fine!
//-----------------------------------------------------------------------------------------------------
// UFO for hill climbing test
R=10;      // radius of dome
A=80;      // angle of cone from vertical
// cone continues to infinity, but our UFO goes to disc radius D
D=50;
// height of cone H = (D-R)/tan(A);
H = (D-R)/tan(A);
$fn=100;
sphere(r=R);
translate([0,0,-H])cylinder(r1=D,r2=R,h=H);
//--------------------------------------------------------------------
// function to calculate the Z for X,Y of UFO
function ZZ(X,Y)
=  let(XY=sqrt(XX+YY))
XY<R ? sqrt(RR-XYXY)          // on dome
: (R - XY)/tan(A);                    // on disc
// test the function on our UFO
for (t=
[0:36])translate([t,t,ZZ(t,t)])color("hotpink")sphere(r=0.4);
translate([R,0,ZZ(R,0)])color("hotpink")sphere(r=1);

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
To unsubscribe send an email to <email>discuss-leave@.openscad

What sort of hill climbing algorithm are you talking about? (The term "hill climbing" appears to be very vague, apparently referring to any algorithm that tries to maximize by going "up" at each step...or maybe even not that if you count "stochastic hill climbing".) My challenge function for a maximization algorithm that doesn't use 2nd order approximation: f = function(x,y) 100-(x*x+y*y/50); starting your optimization on the x or y axis is cheating. (You can rotate the function to a random angle so that you can't find the "easy" starting points if you must.) How many iterations to get 6 digits of accuracy? GregL wrote > Back in the 60's, as a young engineer, I played with Optimisation using > Hill > Climbing. I had a robust hill climbing program, written in Fortran, and a > weird curved hill function to test it on. > Over the years the program has been translated into Delphi and Prolog for > searching in N dimensions > It is now time to shoe-horn it into OpenScad!!! > THE CHALLENGE > I have mislaid my old test function, so have created a flying saucer shape > to test my routine as it is built. The shape is a bit too simple for my > liking – can you come up with a bigger challenge? > N=2 is fine! > //----------------------------------------------------------------------------------------------------- > // UFO for hill climbing test > R=10; // radius of dome > A=80; // angle of cone from vertical > // cone continues to infinity, but our UFO goes to disc radius D > D=50; > // height of cone H = (D-R)/tan(A); > H = (D-R)/tan(A); > $fn=100; > sphere(r=R); > translate([0,0,-H])cylinder(r1=D,r2=R,h=H); > //-------------------------------------------------------------------- > // function to calculate the Z for X,Y of UFO > function ZZ(X,Y) > = let(XY=sqrt(X*X+Y*Y)) > XY&lt;R ? sqrt(R*R-XY*XY) // on dome > : (R - XY)/tan(A); // on disc > // test the function on our UFO > for (t= > [0:36])translate([t,t,ZZ(t,t)])color(&quot;hotpink&quot;)sphere(r=0.4); > translate([R,0,ZZ(R,0)])color(&quot;hotpink&quot;)sphere(r=1); > > > > -- > Sent from: http://forum.openscad.org/ > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to &lt;email&gt;discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
C
cbernhardt
Sat, May 22, 2021 12:19 AM

adrianv wrote

GregL wrote

I have mislaid my old test function, so have created a flying saucer
shape
to test my routine as it is built.  The shape is a bit too simple for my
liking – can you come up with a bigger challenge?

adrianv wrote > GregL wrote >> I have mislaid my old test function, so have created a flying saucer >> shape >> to test my routine as it is built. The shape is a bit too simple for my >> liking – can you come up with a bigger challenge? Romulan Battle Bagel?? <http://forum.openscad.org/file/t1309/rombb.jpg> -- Sent from: http://forum.openscad.org/
GH
Gene Heskett
Sat, May 22, 2021 12:24 AM

On Friday 21 May 2021 20:19:42 cbernhardt wrote:

adrianv wrote

GregL wrote

I have mislaid my old test function, so have created a flying
saucer shape
to test my routine as it is built.  The shape is a bit too simple
for my liking – can you come up with a bigger challenge?

Chuckle, but needs more phaser ports?

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.

On Friday 21 May 2021 20:19:42 cbernhardt wrote: > adrianv wrote > > > GregL wrote > > > >> I have mislaid my old test function, so have created a flying > >> saucer shape > >> to test my routine as it is built. The shape is a bit too simple > >> for my liking – can you come up with a bigger challenge? > > Romulan Battle Bagel?? > <http://forum.openscad.org/file/t1309/rombb.jpg> > > Chuckle, but needs more phaser ports? > > > -- > Sent from: http://forum.openscad.org/ Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>
C
cbernhardt
Sat, May 22, 2021 11:59 AM

Gene Heskett wrote

Chuckle, but needs more phaser ports?

Gene Heskett wrote > Chuckle, but needs more phaser ports? <http://forum.openscad.org/file/t1309/rombb3.jpg> -- Sent from: http://forum.openscad.org/
GH
Gene Heskett
Sat, May 22, 2021 4:43 PM

On Saturday 22 May 2021 07:59:53 cbernhardt wrote:

Gene Heskett wrote

Chuckle, but needs more phaser ports?

Thats more like it. ;-)

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.

On Saturday 22 May 2021 07:59:53 cbernhardt wrote: > Gene Heskett wrote > > > Chuckle, but needs more phaser ports? > > <http://forum.openscad.org/file/t1309/rombb3.jpg> > Thats more like it. ;-) > > > -- > Sent from: http://forum.openscad.org/ Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>