Embedded Systems December 2000 Vol13_13

Issue link:

Contents of this Issue


Page 33 of 197

PROGRAMMER'S TOOLBOX • The implication here is that one should understand the nature of the function one is trying to minimize. A graph is always a good idea. You just can't use .these routines blindly, trusting them to replace common sense. LISTING 3 iThe skeleton state machine 1* gLobaL variabLes * * These variabLes are used as gLobaL variabLes, * shared by the minimization routines. DecLaring * them static makes them invisibLe to prying eyes. *1 static int bisect_Left = TRUE; typedef enum{INIT, BISECT, PARAFIT, TEST_BI, TEST-PAR, SUCCEED, FAIL} STATE; static STATE state = INIT; II parameters for the haLt criterion static doubLe xrange; static doubLe yrange; static doubLe bi9-.Y; static doubLe L ittLey; static doubLe EPS; static doubLe xeps; static doubLe yeps; II Stub function for second-order search doubLe findmin(doubLe (*f)(doubLe), doubLe xO, doubLe yO, doubLe x1, doubLe y1, doubLe x2, doubLe y2, doubLe eps){ doubLe x; doubLe y; II don't exit untiL Simon sez whi Le(1){ swi tch (state){ case INIT: xrange = x2 - xO; bi9-.Y = max(yO, y2); L ittley = y1; EPS = eps; xeps = sqrt(eps) * xrange; yeps = eps * (topy - bottomy); II do first two bisections goLd_shrink_Left(xO, yO, x1, y1, x2, y2); save_best

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems December 2000 Vol13_13