Open Collections

UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

A practical system for determining optimal tree bucking at the stump Waddell, David Andrew 1988

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-UBC_1988_A6 W32.pdf [ 3.76MB ]
Metadata
JSON: 831-1.0097608.json
JSON-LD: 831-1.0097608-ld.json
RDF/XML (Pretty): 831-1.0097608-rdf.xml
RDF/JSON: 831-1.0097608-rdf.json
Turtle: 831-1.0097608-turtle.txt
N-Triples: 831-1.0097608-rdf-ntriples.txt
Original Record: 831-1.0097608-source.json
Full Text
831-1.0097608-fulltext.txt
Citation
831-1.0097608.ris

Full Text

A PRACTICAL SYSTEM FOR DETERMINING OPTIMAL TREE BUCKING AT THE STUMP by DAVID ANDREN WADDELL B.S.F., U n i v e r s i t y o f B r i t i s h Columbia, 1982 A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF FORESTRY. in THE FACULTY OF GRADUATE STUDIES (The F a c u l t y o f Fo r e s t r y ) We accept t h i s t h e s i s as conforming to the required standard THE UNIVERSITY OF BRITISH COLUMBIA APRIL 1988. © David Haddell, 1988 In p r e s e n t i n g t h i s t h e s i s i n p a r t i a l f u l f i l m e n t o f the requirements f o r an advanced degree at the U n i v e r s i t y o f B r i t i s h Columbia, I agree t h a t the L i b r a r y s h a l l make i t f r e e l y a v a i l a b l e f o r r e f e r e n c e and study. I f u r t h e r agree t h a t p e r m i s s i o n f o r e x t e n s i v e copying o f t h i s t h e s i s f o r s c h o l a r l y purposes may be granted by the head of my department or by h i s or her r e p r e s e n t a t i v e s . I t i s understood t h a t copying or p u b l i c a t i o n of t h i s t h e s i s f o r f i n a n c i a l g a i n s h a l l not be allowed without my w r i t t e n p e r m i s s i o n . Department of The U n i v e r s i t y of B r i t i s h Columbia 1956 Main Mall Vancouver, Canada V6T 1Y3 Date A ^ T ' A \S^ g> -6 (3/81) i i ABSTRACT The o b j e c t i v e o f t h i s study i s to develop a p r a c t i c a l system f o r determining optimal bucking patterns at the stump. The log bucking system was developed f o r implementation on an IBM-PC micro-computer using data f o r westen hemlock (Tsuga h e t e r o p h v l l a (Raf.) Sarg.). The log bucking system i s based on a two-phase o p t i m i z a t i o n algorithm which u t i l i z e s dynamic programming-to determine the optimal bucking pattern with the o b j e c t i v e o f maximizing p o t e n t i a l tree value. The f i r s t phase determines the ulti m a t e bucking pattern w i t h i n the t r e e such that p o t e n t i a l gross value o f derived products i s maximized. This p a t t e r n r e f l e c t s log lengths that would be cut i f the t r e e were at the m i l l . The second phase determines which of the f i r s t phase optimal cuts should be made at the stump at the time of tree f e l l i n g such that e x t r a t i o n costs are minimized. The s o l u t i o n to these two phases y i e l d s a bucking pattern that maximizes p o t e n t i a l net value from the t r e e . The log bucking system incorporates assessment o f log grade, assignment of value based on log grade and premium log lengths, c o n s i d e r a t i o n o f standard product lengths, and c o n s i d e r a t i o n of e x t r a c t i o n c o s t s . The log bucking system inc l u d e s an algorithm f o r ev a l u a t i n g unusual bucking s i t u a t i o n s when there are p r a c t i c a l c o n s t r a i n t s imposed on saw cut l o c a t i o n s . For a set o f t e s t data, the p o t e n t i a l net value o f logs bucked using the o p t i m i z a t i o n a l g o r i t h m w i t h i n the log bucking system showed an increase of 4.2% over the p o t e n t i a l net value o f trees bucked using present i n d u s t r y bucking p r a c t i c e s . A two way a n a l y s i s o f variance f o r pa i r e d observations determined that t h i s increase was s i g n i f i c a n t at a 0.05% l e v e l of s i g n i f i c a n c e . i i i TABLE OF CONTENTS Page ABSTRACT i i TABLE OF CONTENTS i i i LIST OF TABLES v LIST OF FIGURES vi ACKNOWLEDGEMENTS vi i 1. INTRODUCTION 1 2. LITERATURE REVIEW 5 2.1 DYNAMIC PROGRAMMING 5 2.2 DYNAMIC PROGRAMMING IN LOG BUCKING 8 3. OPTIMIZATION ALGORITHM 17 3.1 OVERVIEW OF APPROACH 17 3.2 VALUE MAXIMIZATION 21 3.3 COST MINIMIZATIONM 27 3.4 MAXIMIZED POTENTIAL NET VALUE 31 3.5 VALIDITY OF THE OPTIMIZATION ALGORITHM 32 4. LOG GRADE, VALUE AND COST SPECIFICATIONS 35 4.1 LOG GRADES 35 4.2 LOG VALUE 38 4.3 LOG EXTRACTION COSTS 42 5. DESCRIPTION OF THE LOG BUCKING SYSTEM 44 5.1 OVERVIEW 44 5.2 USER INTERFACE 46 5.2.1 DATA INPUT 46 5.2.2 SYSTEM CONTROL 48 5.3 OPTIMIZATION ALGORITHM 48 5.4 CONSTRAINED VALUATION ALGORITHM 48 6. METHODOLOGY FOR HYPOTHESIS TESTING 51 6.1 FIELD STUDY AREA 51 6.2 SAMPLING TECHNIQUE 53 6.3 DATA COMPILATION 54 6.4 HYPOTHESIS 56 i v Page 7. RESULTS AND DISCUSSION 57 7.1 RESULTS 57 7.2 DISCUSSION 60 8. SUMMARY AND CONCLUSIONS 64 9. LITERATURE CITED 66 APPENDIX 1 69 APPENDIX 2 71 APPENDIX 3 73 V LIST OF TABLES TABLE PAGE 1 Tree Quality Assessment 37 2 Hemlock Log Grade Specifications 38 3 Hemlock. Log Grade Values and Standard Log Lengths 41 4 Distribution of Tree Dimensions 55 5 ANOVA : Maximized Potential Net Value 57 6 Summary of Results 59 v i LIST OF FIGURES FIGURE PAGE 1 Value Maximization 22 2 Taper Measurement 24 3 Log Production Length . . 25 4 Cost Minimization Stage Definition 28 5 Extraction Cost Relation 43 6 Schematic of Log Bucking System 45 VI1 ACKNOWLEDGEMENTS The author would l i k e to thank MacMillan Bloedel personnel f o r t h e i r input and support. In p a r t i c u l a r , the author would l i k e to thank Brent Sauder, Ron Greenough and Peter Chaston. The author would a l s o l i k e to thank P r o f e s s o r G. Young and Dr. A. Howard f o r t h e i r guidance and te c h n i c a l advice. F i n a l l y , the author would l i k e to thank the Natural Science and Engineering Research Council o f Canada and the Department o f Supplies and Serv i c e s f o r p r o v i d i n g funding to undertake t h i s p r o j e c t . 1 1. INTRODUCTION Tree bucking i s the c u t t i n g of f e l l e d t rees i n t o l o g s. I t i s a c r i t i c a l step i n the conversion of standing timber i n t o end products and plays a fundamental r o l e i n determining the p r o f i t a b i l i t y of a f o r e s t company. Bucking d e c i s i o n s at the time of tree f e l l i n g predetermine and l i m i t the number, type and value o f products that can be produced from the r e s u l t i n g l o g s. The c o a s t a l area of B r i t i s h Columbia has an allowable annual cut of 3 approximately 26,000,000 m ( M i n i s t r y of F o r e s t s , 1985). At an average 3 value o f $46/m (Sauder, 1986), t h i s represents a value of $1,196,000,000. Recent studies have estimated that increases of between 12% and 20% i n average t r e e value could be a t t a i n e d by employing a more a n a l y t i c a l approach to determining bucking patterns (Faaland and Briggs, 1985; MacMillan B l o e d e l , 1981). Other studies have recognized the impact o f improper or poor bucking on t r e e value (Dobie, 1975; Lefebvre, 1978; Ortman, 1973). Although the f o r e s t i n d u s t r y has been aware o f the p o t e n t i a l value o f improved bucking patterns f o r many years, a p r a c t i c a l system f o r o p t i m i z i n g bucking patterns i s not a v a i l a b l e . This study addresses t h i s c r i t i c a l need. The current approach to t r e e bucking, as exemplified by MacMillan Bloedel L t d . , i s to provide the f a l l e r with a f i x e d set of bucking i n s t r u c t i o n s . These i n s t r u c t i o n s s p e c i f y p r e f e r r e d log lengths by tree species and s p e c i f i c MacMillan Bloedel log grades. The p r e f e r r e d log 2 lengths are combinations of primary log lengths required to produce standard lumber i n c l u d i n g t r i m . These p r e f e r r e d lengths are e s t a b l i s h e d in d i s c u s s i o n s between the various management personnel at conversion f a c i l i t i e s and the logging d i v i s i o n s (Greenough, 1986). The MacMillan Bloedel log grades are based on Forest S e r v i c e grading procedures ( M i n i s t r y of F o r e s t s , 1980), but are s i m p l i f i e d and adapted to meet species mix and sawmill requirements w i t h i n t h e i r operating areas. The o b j e c t i v e of t h i s study i s to develop a p r a c t i c a l system f o r determining optimal bucking patterns at the stump. The system, r e f e r r e d to as the log bucking system, i s intended to improve upon current i n d u s t r y bucking p r a c t i c e s . The major components of a log bucking problem, when formulated as an o p t i m i z a t i o n problem, are as follows : assessment of log grade, assignment of log value, c o n s i d e r a t i o n o f standard product lengths and c o n s i d e r a t i o n of production costs (Faaland and Briggs, 1985; McPhalen, 1978; and Pnevmaticos and Mann, 1973). These components were incorporated i n t o the log bucking system. This study uses dynamic programming (DP) w i t h i n an o p t i m i z a t i o n a l g o r i t h m to solve the log bucking problem. Previous s t u d i e s mentioned above a l s o used DP, however, t h i s study d i f f e r s from those studies in the way the problem was formulated. Here, the log bucking problem i s decomposed i n t o two phases. The f i r s t phase o f the problem i s to determine the f i n a l bucking p a t t e r n w i t h i n a t r e e such that p o t e n t i a l gross value i s maximized. This p a t t e r n r e f l e c t s the lengths of logs that would be cut i f the tree were 3 at a sawmill. This phase i s c a l l e d value maximization. The second phase of the problem i s to determine which o f the cuts i d e n t i f i e d by the s o l u t i o n i n the f i r s t phase should be made at the stump, at the time of tree f e l l i n g , such that e x t r a c t i o n costs are minimized. This phase i s c a l l e d cost minimization. The sequential s o l u t i o n to these two phases y i e l d s a bucking p a t t e r n that maximizes the p o t e n t i a l net value from a t r e e at the m i l l . This bucking p a t t e r n i s defined as the optimal bucking p a t t e r n . The a p p l i c a t i o n o f a log bucking system at the stump may have a number of p r a c t i c a l c o n s t r a i n t s imposed on p o s s i b l e l o c a t i o n s o f saw cuts along the length o f a t r e e . These c o n s t r a i n t s could be due to t e r r a i n , weather or sa f e t y c o n s i d e r a t i o n s . Unlike previous studies which assumed that a saw cut could be placed at any l o c a t i o n along the t r e e , the log bucking system developed i n t h i s study includes an algorithm which allows f o r the c a l c u l a t i o n o f tree value under constrained c o n d i t i o n s . This algorithm i s r e f e r r e d to as the constrained v a l u a t i o n algorithm. A t r e e value c a l c u l a t e d under these c o n d i t i o n s w i l l not n e c e s s a r i l y be a maximum value. However, comparison o f the value o f d i f f e r e n t bucking patterns w i l l allow f o r the determination o f the best bucking pattern under the given c o n d i t i o n s . The log bucking system contains the o p t i m i z a t i o n algorithm (value maximization and cost minimization) as well as the constrained v a l u a t i o n algorithm. A user i n t e r f a c e provides system co n t r o l as well as tree data input. The log bucking system was i n s t a l l e d on an IBM-PC micro-computer. I t was developed as part o f a study funded by the Department o f Supplies and Serv i c e s (DSS), Canada, which i n v e s t i g a t e d the use o f a hand-held computer 4 4 to optimize log bucking i n the f i e l d (Young and Waddell, 1986). As part of the DSS study, the log bucking system was used to t e s t the f e a s i b i l i t y of an o p t i m i z a t i o n a lgorithm f o r log bucking before implementation on a hand-held computer. The o b j e c t i v e of developing a p r a c t i c a l log bucking system led to the formulation of the f o l l o w i n g hypothesis : bucking patterns derived by the o p t i m i z a t i o n a lgorithm w i t h i n the log bucking system y i e l d a higher p o t e n t i a l net value than present i n d u s t r y bucking p r a c t i c e s . 5 2. LITERATURE REVIEW 2.1 DYNAMIC PROGRAMMING DP i s a mathematical programming technique that can be a p p l i e d to sequential d e c i s i o n problems. I t was developed by Richard Bellman (1957). The f o l l o w i n g i s an i n t r o d u c t i o n to the terminology used i n DP. For a more complete d i s c u s s i o n , see H i l l e r and Lieberman (1967:239-264) or Wagner (1969:253-291). In DP, a d e c i s i o n process i s separated i n t o a s e r i e s o f sub-problems, each o f smaller dimension than the o v e r a l l problem. Each sub-problem i s c a l l e d a stage and i s f o r m a l l y defined as the opportunity to make a d e c i s i o n . At each stage there e x i s t a set of p o s s i b l e s t a t e s , with s t a t e being defined as a s i m p l i f i e d d e s c r i p t i o n of the current status of the system. The e f f e c t of a d e c i s i o n at any stage i s to transform the system from i t s present s t a t e i n t o a s t a t e at the next stage. This transformation i s d i c t a t e d by a t r a n s i t i o n f u n c t i o n which l i n k s the current stage to the next stage and a l s o determines the new s t a t e . In other problem formulations ( i . e . the log bucking problem), the t r a n s i t i o n f u n c t i o n determines the next stage as a f u n c t i o n o f the current stage and d e c i s i o n . At each stage, a return (or cost) i s generated. This return i s a f u n c t i o n of the d e c i s i o n and the s t a t e at the current stage. 6 I f DP i s to be used to solve a problem, then the p r i n c i p a l of o p t i m a l i t y must be s a t i s f i e d . This p r i n c i p a l i s as follows : given the current stage and s t a t e of the system, an optimal set of d e c i s i o n s f o r any remaining stages i s independent o f the process that was required to reach the current stage and s t a t e (Bellman, 1957). That i s , the optimal set o f d e c i s i o n s f o r the remaining stages depends only upon the current stage and not upon the means that the system used i n a r r i v i n g at that stage (Turban and Meredith, 1985:387-401). The s o l u t i o n procedure f o r DP i s as f o l l o w s . Decomposition i s used to separate a DP problem i n t o N stages, with n being the current stage. A r e c u r s i v e r e l a t i o n then l i n k s a given n stage with the p r e v i o u s l y solved n-1 stage process. This r e c u r s i v e r e l a t i o n i s used to determine the optimal d e c i s i o n f o r each s t a t e at stage n, given that the optimal d e c i s i o n f o r each s t a t e o f the n-1 stage process has already been determined. The general form o f t h i s r e l a t i o n i s as follows : f n ( s ) = [ R n ( s , x n ) + f p _ i [ t ( s , x n ) ] ] f n ( s ) = opt [ R n ( s , x n ) + f p _ i [ t ( s , x n ) ] ] *n where : n = index f o r current stage n-1 = previous stage s = s t a t e of the system i n the current stage x n = d e c i s i o n v a r i a b l e at the current stage f n ( s ) = t o t a l return f o r an n-stage process s t a r t i n g i n s t a t e s 7 •fn(s) = t o t a l optimized return f o r an n-stage process s t a r t i n g i n st a t e s R n ( s , x n ) = return f u n c t i o n f o r d e c i s i o n x n when s t a r t i n g i n s t a t e s f n _ l [ t ( s , x n ) ] = t o t a l optimized return f o r an n-1 stage process f o r d e c i s i o n x n when s t a r t i n g i n st a t e s t ( s , x n ) = t r a n s i t i o n f u n c t i o n f o r d e c i s i o n x n when s t a r t i n g i n s t a t e s. The r e c u r s i v e r e l a t i o n shown above i s used i n the s o l u t i o n procedure known as forward r e c u r s i o n . An optimal s o l u t i o n i s found at each stage, f o r a l l s t a t e s , by the a d d i t i o n o f the current stage return plus the optimized return from the previous ( n - l ) - s t a g e process. The procedure s t a r t s i n the i n i t i a l stage and progresses forward u n t i l the optimal s o l u t i o n at the f i n a l stage i s found. An a l t e r n a t i v e procedure i s known as backward r e c u r s i o n . Here, the procedure s t a r t s i n the f i n a l stage and works backward to the i n i t i a l stage. The optimal s o l u t i o n i s found i n a manner s i m i l a r to forward r e c u r s i o n , except that backward r e c u r s i o n uses the optimized returns from the (n+l)-stage process, rather than from the previous ( n - l ) - s t a g e process. I t can be s a i d that forward r e c u r s i o n works forward while looking backward and that backward r e c u r s i o n works backward while looking forward. 8 2.2 DYNAMIC PROGRAMMING IN LOG BUCKING Optimal log bucking i s a complex problem. Even when log grading procedures are r i g o r o u s l y followed, i t i s d i f f i c u l t to make the de c i s i o n s r e q u i r e d to buck logs o p t i m a l l y (Pnevmaticos and Mann, 1973). Poor bucking r e s u l t s i n a lo s s i n volume and a loss i n value (Lefebvre, 1978; Pnevmaticos and Mann, 1973). Log bucking d e c i s i o n s are a l s o i n t e r r e l a t e d with log sawing d e c i s i o n s , since bucking d e c i s i o n s can l i m i t sawing o p p o r t u n i t i e s (Faaland and Briggs, 1984). Given these complex c o n d i t i o n s , value losses can e a s i l y occur during the bucking process. Although there have been many examples of the use of DP to solve log bucking problems, none of the examples give a complete s o l u t i o n i n terms of a p r a c t i c a l system f o r determining bucking patterns at the time o f f e l l i n g . The algorithms proposed by Dykstra (1984:297-305), Faaland and Briggs (1984), McPhalen (1978) and Pnevmaticos and Mann (1973) were based on the assumption that a l l optimal cuts are to be made at the time o f s o l u t i o n . This i s f e a s i b l e only i f the log i s at a sawmill. I f a l l the cuts necessary to optimize value were made at the time o f f e l l i n g , p o t e n t i a l l y a large number of pieces would be produced and t h i s would incr e a s e e x t r a c t i o n c o s t s . A separate problem t h e r e f o r e e x i s t s to determine which, i f any, of the optimal value cuts to make such that e x t r a c t i o n costs are minimized. The determination o f an optimal bucking pattern i n v o l v e s value maximization and e x t r a c t i o n cost minimization. This separation i n t o two o p t i m i z a t i o n phases d i f f e r s from a l l previous s t u d i e s . 9 To t r y and improve log bucking, a number of studies i n v e s t i g a t e d the use of DP. Pnevmaticos and Mann (1973) used a DP algorithm to solve the log bucking problem. The o b j e c t i v e o f t h e i r o p t i m i z a t i o n was to cut a tree i n t o logs such that t o t a l r e t urn was maximized. In t h e i r f o r m u l a t i o n , t o t a l tree length was d i v i d e d i n t o segments, each of a s p e c i f i e d minimum length. These segments formed the stages f o r t h e i r DP algorithm. The d e c i s i o n at a stage was the length o f log to produce, with the length s p e c i f i e d i n terms of number of minimum length segments. The set of p o s s i b l e d e c i s i o n s at each stage was constrained by a minimum and maximum log length as determined by management. Log length was used as a s t a t e v a r i a b l e to de s c r i b e the log at each stage. Log grade was p r e d i c t e d based on the assumption that the p r o b a b i l i t y of a log being a c e r t a i n grade was r e l a t i v e to i t s l o c a t i o n along the stem. There was a high p r o b a b i l i t y o f a log being the highest grade when located c l o s e to the butt, with the p r o b a b i l i t y decreasing as d i s t a n c e from the butt i n c r e a s e d . Log value was based on length, top diameter, bottom diameter and log grade. Diameters wi t h i n the t r e e stem were c a l c u l a t e d using uniform taper. The t r a n s i t i o n f u n c t i o n used i n t h i s DP algorithm does not l i n k stage n to stage n-1, as i n the standard DP formulation. Rather, the t r a n s i t i o n f u n c t i o n reduces the number of remaining stages by the number of minimum lengths removed from the stem. This formulation i s r e l a t i v e l y e f f i c i e n t as 1 0 the s p e c i f i c a t i o n o f t r a n s i t i o n f u n c t i o n has the e f f e c t of reducing the average number of c a l c u l a t i o n s c o n s i d e r a b l y , when compared to a formulation such as Dykstra (1984:297-305). I f c i s the average number of c a l c u l a t i o n s per stage, with n being the number of stages and m being the average number of p o s s i b l e d e c i s i o n s at each stage, then the s o l u t i o n r e q u i r e s on the order of m*n*c c a l c u l a t i o n s . The algorithm proposed by Pnevmaticos and Mann i s well s u i t e d f o r bucking at a sawmill. However, i n a p r a c t i c a l s i t u a t i o n such as bucking at the stump, some adaptations would improve the algorithm. Pnevmaticos and Mann used a p r o b a b i l i t y d i s t r i b u t i o n to s p e c i f y log grade, r a t h e r than actual log grade. Log grades can be assessed a f t e r f e l l i n g and these grades, r a t h e r than p r e d i c t e d log grades, should be used. Values were based on log grade which i s a r e a l i s t i c v a l u a t i o n method f o r a logging d i v i s i o n . However, the values used by Pnevmaticos and Mann did not r e f l e c t any premiums paid f o r p r e f e r r e d log lengths w i t h i n log grades. To optimize at the stump, v a l u a t i o n of logs must consider premium log lengths. The cost component included i n the r e c u r s i v e equation included only the cost of making a cut. This i s appropriate at a sawmill. However, to achieve r e a l i s t i c r e s u l t s when bucking at the stump, a l l e x t r a c t i o n costs such as y a r d i n g , loading and t r a n s p o r t a t i o n , should be included i n the s o l u t i o n . 11 The o p t i m i z a t i o n algorithm used by Pnevmaticos and Mann, considered minimum and maximum log lengths, but d i d not c o n s t r a i n log lengths to any recog n i z a b l e production lengths. In r e a l i t y , the products produced from logs have d i s c r e t e and s p e c i f i c lengths. These are the lengths that w i l l cut out standard lumber lengths, given an allowance f o r t r i m . Pnevmaticos and Mann suggested that t h e i r algorithm would best be ap p l i e d i n a mechanized bucking a p p l i c a t i o n where a l l optimal cuts can be made at one time. They a l s o suggested that an adaptation to t h e i r algorithm could be made so that information gained a f t e r each cut could be used i n planning the remaining c u t s . McPhalen (1978) used DP to c a l c u l a t e optimal log bucking patterns as a sub-problem f o r log sawing s t r a t e g i e s . In t h i s problem, l i n e a r programming was used as the s o l u t i o n technique f o r the master problem o f log sawing s t r a t e g i e s , while DP was used as a s o l u t i o n technique f o r the sub-problem of determining optimal log bucking patterns w i t h i n each log sawing st r a t e g y . Stage was defined as the lengthwise p o s i t i o n i n a t r e e . The d e c i s i o n at a current stage was the length o f log to produce. The s t a t e v a r i a b l e was defined as the t o t a l length o f log at the current stage. The value o f a bucking d e c i s i o n was determined from the value o f products that could be sawn from the r e s u l t i n g l o g . These products were s p e c i f i e d based on one o f f i v e sawing p a t t e r n s . This method of v a l u a t i o n was b e t t e r than that suggested by Pnevmaticos and Mann because value was 12 based on actual end products. However, the value was s t i l l l i m i t e d to the value o f the f i v e sawing patterns and the values s p e c i f i e d f o r these patterns were c a l c u l a t e d from empirical t e s t s . D i s c r e t e log lengths were i m p l i c i t l y included i n the sawing patterns and the lengths that they s p e c i f y . McPhalen suggested that a l t e r n a t i v e sawing patterns could be assessed, but that s o l u t i o n time increased c o n s i d e r a b l y with the number of a l t e r n a t i v e patterns to be evaluated. McPhalen's algorithm was s i m i l a r i n formulation to that proposed by Pnevmaticos and Mann, except that a cost component was not included i n the r e c u r s i o n . Again, t h i s was an e f f i c i e n t formulation and the number of c a l c u l a t i o n s required to reach a s o l u t i o n would be on the order of m*n*c c a l c u l a t i o n s . Faaland and Briggs (1984) considered bucking trees and sawing lumber in a s i n g l e o p t i m i z a t i o n algorithm. T h e i r DP algorithm incorporated a tree d e s c r i p t i o n , a log and lumber grading system, a t a b l e of lumber s i z e s and values, and t e c h n i c a l sawing c h a r a c t e r i s t i c s such as saw blade thickness and sawing method. T h e i r algorithm determined where to buck a t r e e to maximize the value of lumber cut from the r e s u l t i n g logs. Faaland and Briggs used a two-dimension o p t i c a l scanner to obtain log grade and s i z e information. The d i s t r i b u t i o n of lumber grades f o r each of t h e i r four log grades was estimated from sawmill recovery s t u d i e s . The tree was d i v i d e d i n t o segments and each segment was assigned the lowest log grade 1 3 w i t h i n i t s length. Lumber p r i c e s f o r D o u g l a s - f i r were used to c a l c u l a t e the value of lumber that could be sawn out of the l a r g e s t c y l i n d e r f o r the given log dimensions and log grade. Lumber values i d e n t i f i e d any premium p r i c e s paid f o r c e r t a i n s i z e s of boards. Log production and sawmilling costs were not included due to a lack o f current and c o n s i s t e n t published data. The DP algorithm used by Faaland and Briggs d i v i d e d the t r e e length i n t o segments, which served as DP stages. Two o p t i m i z a t i o n s were used, one to determine where to buck to maximize value and w i t h i n t h i s , a second o p t i m i z a t i o n to determine the maximum value of the l a r g e s t c y l i n d e r within each log being considered f o r bucking. P o s s i b l e d e c i s i o n lengths were const r a i n e d to be standard lumber lengths i n c l u d i n g t r i m allowance. The t r a n s i t i o n f u n c t i o n was s i m i l a r to that use by Pnevmaticos and Mann (1973) i n that the t r a n s i t i o n f u n c t i o n reduces the number of remaining stages by the number of minimum lengths removed from the stem. This formulation r e q u i r e s approximately the same number o f c a l c u l a t i o n s as that of Pnevmaticos and Mann. Faaland and Briggs pointed out many o f the f a c t o r s underlying a log bucking problem. However, the s o l u t i o n that they proposed i s again more s u i t a b l e to a sawmill a p p l i c a t i o n r a t h e r than at the stump. O p t i c a l scanners, while useful i n a sawmill, have not been s u c c e s s f u l l y used i n the rugged c o n d i t i o n s where f a l l i n g takes p l a c e . Another method of determining s i z e and grade information must t h e r e f o r e be used f o r o p t i m i z a t i o n at the stump. 14 Faaland and Briggs d i d not i n c l u d e costs i n t h e i r DP r e c u r s i v e equation due to a lack o f e x t r a c t i o n and sawmilling cost data. MacMillan Bloedel Ltd. has made a v a i l a b l e t h e i r current e x t r a c t i o n costs and as these costs are an important component i n making bucking d e c i s i o n s at the stump, a p r a c t i c a l a p p l i c a t i o n should i n c l u d e them. Faaland and Briggs stated that there was a need to develop algorithms that have the a b i l i t y to determine s o l u t i o n s q u i c k l y and serve as r e a l - t i m e o p e r a t i n g a i d s . To f a c i l i t a t e these needs, t h e i r a l g o r i t h m was implemented on a VAX 11/780 minicomputer. This computer i s s u i t a b l e f o r a sawmill i n s t a l l a t i o n . However, a much smaller and more po r t a b l e computer i s r e q u i r e d f o r an algorithm that i s to be used at the stump. Dykstra (1984:297-305) a l s o used DP to solve a log bucking example with a formulation which d i f f e r e d s i g n i f i c a n t l y from a l l previous examples. Stage was defined as the number of i n d i v i d u a l logs being considered f o r bucking. That i s , at stage three, three logs would be produced. The s t a t e at any stage was defined as the t o t a l length of a l l logs cut from the stem at the current stage. The d e c i s i o n at each stage was how long to make the l a s t log a s s o c i a t e d with that stage and was constrained to be one o f three production lengths. For example, at stage f o u r , four logs would be produced and the d e c i s i o n would be how much length to a l l o c a t e to the f o u r t h log. The t r a n s i t i o n f u n c t i o n i n t h i s formulation l i n k s stage n to stage n-1 as in the standard DP f o r m u l a t i o n . 15 Log value was given as a f u n c t i o n o f log length and log grade which i s a r e a l i s t i c method o f log v a l u a t i o n f o r a logging d i v i s i o n . Log grading r u l e s , which were based on s p e c i f i e d minimum s c a l i n g diameters and minimum lengths, were used to s p e c i f y log grades. Q u a l i t y of the wood, which i s a major f a c t o r i n log value, was not considered i n the grading r u l e s . This example used three d i s c r e t e log production lengths, however, value merely increased with length. Premium lengths w i t h i n a log grade were not i d e n t i f i e d . To r e a l i s t i c a l l y value logs f o r bucking, premium lengths as well as production lengths, must be recognized. Dykstra did not consider e x t r a c t i o n costs i n h i s o p t i m i z a t i o n . He assumed that bucking costs were n e g l i g i b l e compared to value and th e r e f o r e excluded them. This assumption may be true i f a l l cuts are being made at the time of o p t i m i z a t i o n . However, when bucking at the stump, a second o p t i m i z a t i o n problem does e x i s t whereby e x t r a c t i o n costs must be minimized. This i s e s p e c i a l l y true i f e x t r a c t i o n costs decrease as piece s i z e i n c r e a s e s . To develop a p r a c t i c a l system f o r determining optimal bucking patterns at the stump, the major components of a log bucking problem must be inc o r p o r a t e d . These components are as f o l l o w s : 16 1) methodology f o r assessing log grade must be developed; 2) log value should be assigned based on log grade assessment; 3) log values should be based on the value of end products manufactured from the logs; 4) standard lumber lengths should be used as a c o n s t r a i n t on i n d i v i d u a l log lengths; and 5) production c o s t s , which i n c l u d e a l l e x t r a c t i o n c o s t s , should be considered i n the o p t i m i z a t i o n . 17 3. OPTIMIZATION ALGORITHM 3.1 OVERVIEW OF APPROACH The purpose of t h i s study was to develop a p r a c t i c a l log bucking system f o r determining bucking patterns at the stump a f t e r t r e e f e l l i n g . This system takes i n t o account the major components of a log bucking problem as i d e n t i f i e d by previous s t u d i e s . The o p t i m i z a t i o n algorithm developed f o r use i n the log bucking system u t i l i z e s DP i n a two-phase o p t i m i z a t i o n process. The f i r s t phase, value maximization, optimizes bucking patterns based on p o t e n t i a l gross value. The bucking patterns derived f o r a tree i n t h i s phase represent the lengths of log that would be cut i f the tree were at a sawmill. The log lengths determined by value maximization are those primary log lengths used f o r lumber production. The second phase o p t i m i z a t i o n determines which of the cuts, as i d e n t i f i e d by the s o l u t i o n i n the f i r s t phase, should be made to minimize e x t r a c t i o n c o s t s . This phase i s c a l l e d cost minimization. The only cuts made i n the t r e e at the time of f e l l i n g are those defined by the second phase s o l u t i o n . Therefore, the bucking pattern generated i n the second phase o p t i m i z a t i o n i s composed of s i n g l e and/or combinations of log lengths from the f i r s t phase o p t i m i z a t i o n . A two-phase o p t i m i z a t i o n process which separates the value and e x t r a c t i o n cost o p t i m i z a t i o n s i s used instead of a one-phase o p t i m i z a t i o n (as used by Pnevmaticos and Mann, 1973) f o r three reasons. F i r s t , a 18 two-phase o p t i m i z a t i o n separates the bucking problem i n t o two major phases: value maximization and cost minimization. This separation allows each phase to be solved s e p a r a t e l y . In a p r a c t i c a l sense, the separation i n t o two phases models the log bucking problem at the stump. Cuts f o r e x t r a c t i o n purposes must be made i n order to get the log to a sawmill, where the f i n a l cuts w i l l be made. Therefore, the e x t r a c t i o n d e c i s i o n s should be separate from, but take i n t o c o n s i d e r a t i o n , the f i n a l cuts to be made at the sawmill. I f a whole tree i s already at the sawmill, a one-phase o p t i m i z a t i o n such as used by Pnevmaticos and Mann i s more app r o p r i a t e , as there are no e x t r a c t i o n d e c i s i o n s to be made. Second, the use of a two-phase o p t i m i z a t i o n process allows d i f f e r e n t c o n s t r a i n t s on log length to be considered i n each separate phase. The length c o n s t r a i n t s f o r value maximization r e l a t e to the minimum and maximum log lengths that can be processed i n a sawmill. These c o n s t r a i n t s are imposed by sawmill design. The length c o n s t r a i n t s f o r cost minimization r e l a t e to minimum and maximum log lengths f o r ya r d i n g , loading, t r u c k i n g and shipp i n g . Too short a log can cause loading problems, whereas too long a log can cause problems when being transported on narrow roads with sharp turns or can cause loading problems. T h i r d , a two-phase o p t i m i z a t i o n i s computationally more e f f i c i e n t than a one-phase o p t i m i z a t i o n . Consider the comparison of the f o l l o w i n g o p t i m i z a t i o n processes represented by t h e i r r e s p e c t i v e r e c u r s i v e equations. 19 A one-phase o p t i m i z a t i o n process with a cost f u n c t i o n included i n the r e c u r s i v e r e l a t i o n (as used by Pnevmaticos and Mann, 1973) can be expressed with the f o l l o w i n g r e c u r s i v e equation : f*(n) = max [R(d) - C(d) + f*(n-d)] d where : n = stage = 1,...,N f( n ) = o b j e c t i v e f u n c t i o n ; d = d e c i s i o n ; R(d) = return based on d e c i s i o n ; and C(d) = cost based on d e c i s i o n . I f the t o t a l number of stages p o s s i b l e d e c i s i o n s at each stage, r e q u i r e d to solve the N-stage process # operations = 0(3Nb). i s N, and b i s the average number of then the t o t a l number of operations can be approximated as : A two-phase o p t i m i z a t i o n process that has cost i n only one phase of the o p t i m i z a t i o n can be expressed with the f o l l o w i n g r e c u r s i v e equation : T*(n) = max [R(d) + T*(n-d)]; * * G (m) = minCC(d) + G (m-d)]; and F* = T*(n) + G*(n) 20 where: n = stage i n f i r s t phase = 1.....N; m = stage i n second phase= 1,...,M; f(n ) = o b j e c t i v e f u n c t i o n ; T (n) = optimized f i r s t phase o b j e c t i v e f u n c t i o n ; G (n) = optimized second phase o b j e c t i v e f u n c t i o n ; F = optimized two-phase o b j e c t i v e f u n c t i o n ; d = d e c i s i o n ; R(d) = return based on d e c i s i o n ; and C(d) = cost based on d e c i s i o n . I f the t o t a l number o f stages i n the f i r s t phase o p t i m i z a t i o n i s N, the t o t a l number of stages i n the second phase i s M, and with b being the average number of p o s s i b l e d e c i s i o n s at each stage, then the t o t a l number of operations r e q u i r e d to solve the two-phase process can be approximated as : # operations = 0(2Nb + 2Mb). I f the number o f operations f o r each o p t i m i z a t i o n process are equated, the p o i n t where t h e i r e f f i c i e n c y i s equal can be determined. 3Nb = 2Nb + 2Mb N/2 = M M must t h e r e f o r e be l e s s than 1/2 N f o r the two-phase o p t i m i z a t i o n process to be more e f f i c i e n t computationally then the one-phase o p t i m i z a t i o n . This comparison assumes the worst case s c e n a r i o where the average number of d e c i s i o n s i n the two-phase o p t i m i z a t i o n i s the same i n both phases. In 21 r e a l i t y , the average number of d e c i s i o n s i n the second phase w i l l be much le s s than i n the f i r s t phase and t h e r e f o r e the two-phase o p t i m i z a t i o n i s even more e f f i c i e n t than shown. 3.2 VALUE MAXIMIZATION Value maximization determines the f i n a l bucking p a t t e r n to maximize the p o t e n t i a l gross value o f a t r e e . Total t r e e length (L) i s d i v i d e d i n t o N segments each of length i (stage i n t e r v a l ) , which serve as stages i n the value maximization (Figure 1). The d e c i s i o n (k) to be made at the current stage (n) i s the length o f log to produce s p e c i f i e d i n m u l t i p l e s of i . Stage i n t e r v a l was used to s p e c i f y log lengths so that log length would be defined by an i n t e g e r value. The stage i n t e r v a l f o r value maximization was set at ten centimetres. This value was chosen because i t r e f l e c t s the smalles t rounded tr i m allowance, converted and rounded down from inches to centimetres, which i s a l s o an i n t e g e r m u l t i p l e o f the smallest d i f f e r e n c e between bucking lengths. Trim allowance i n a logging d i v i s i o n v a r i e s from 10.16 to 30.48 centimetres (4" to 1'), which can be rounded to 10 and 30 cm r e s p e c t i v e l y . This allowance accounts f o r t r i m losses i n length when a log i s converted to lumber and a l s o accounts f o r d i f f i c u l t i e s i n making a s t r a i g h t cut in large diameter logs. The smalles t d i f f e r e n c e between bucking lengths, as s p e c i f i e d i n MacMillan Bloedel Ltd. bucking standards, i s 30.48 cm. 22 Figure 1. Value Maximization Ik l < - i - | I I I I I I 0 1 2 n N < — stages |< k 1 L = t o t a l t r e e length; N = t o t a l number of stages; n = current stage; l n = t o t a l length o f log at current stage; 1^ = length o f log based on d e c i s i o n k; 1 = stage i n t e r v a l ; and k = d e c i s i o n . The t o t a l length o f log at the current stage (1 ) i s given as n * i . The length o f a log based on d e c i s i o n (1^) i s given as k * i . Any d e c i s i o n i s c o n s t r a i n e d to be the minimum of n or the nearest whole i n t e g e r of the maximum product length d i v i d e d by i d m a x ) - I n t h i s study, the maximum product length considered was 8.1 metres. This length r e f l e c t s the maximum length o f lumber produced by MacMillan Bloedel Ltd. and includes t r i m allowance (Greenough, 1986). 23 The log volume (m ) at any stage and d e c i s i o n ( V n ( k ) ) i s defined by the log contained i n stage n to stage n-k. The volume i s a f u n c t i o n of length, top diameter and bottom diameter, as follows : 3 The log value ($/m ) at any stage and d e c i s i o n ( r n ( k ) ) i s a f u n c t i o n o f top and bottom diameters, log length and the governing wood q u a l i t y i n d i c a t o r (q) defined over the i n t e r v a l [n, n-k]. Therefore : r n ( k ) = f [ d n , d n _ k , l k , q(n,n-k)]. The r e t u r n ( R n ( k ) ) at stage n and f o r d e c i s i o n k i s a f u n c t i o n of the log volume and the log value. Therefore : R (k) = V n ( k ) * r ( k ) n n n Log q u a l i t y i n d i c a t o r s and log s i z e i n terms o f top diameter, butt diameter and length are used to determine grade, with the grade s p e c i f i c a t i o n s f o l l o w i n g MacMillan Bloedel log grade s p e c i f i c a t i o n s . Value, 3 on a $/m by log grade b a s i s , i s based on values from the Vancouver Log Market and r e f l e c t s p r i c e premiums paid f o r c e r t a i n lengths w i t h i n a log grade. The d e t a i l e d s p e c i f i c a t i o n s f o r grade and value are given i n Chapter 4. 24 The diameter at any point along the stem i s determined using l i n e a r taper. To remove the e f f e c t s o f pronounced butt s w e l l , taper i s c a l c u l a t e d based on t r e e top diameter ( d ^ ) , a diameter measurement near the butt (d.) above butt swell and the length (1.) between d. and d. (see Figure 2). The diameter at any poin t along the stem (d ) can then be A c a l c u l a t e d using the dis t a n c e O x ) from the t r e e top to the l o c a t i o n of d x as fo l l o w s : d x = d t + (dj - d t) * l x . Figure 2. Taper Measurement |< L >| L = t o t a l t r ee length (m); dt = top diameter (cm); dj = diameter measurement near butt, above butt swell (cm); l j = length between diameter measurements (m); d x = diameter to be c a l c u l a t e d (cm); and l x = dis t a n c e between dt and d x (m). 25 The c a l c u l a t i o n of log volumes and values i s complicated by standard production lengths which are d i s c r e t e . These lengths are s p e c i f i e d to the nearest 30.48 cm ( T ) because lumber i s cut i n m u l t i p l e s of 1 f o o t . Because stage i n t e r v a l was set at 10 cm, not a l l lengths being considered f o r bucking w i l l be a standard production length. Consider the problem of f i n d i n g the value o f a log with length 1^ (see Figure 3). I f the length of log being considered (1^) i s not equal to a standard production length C I ) , then volume c a l c u l a t i o n and v a l u a t i o n of the t o t a l length must be based on the two separate length components, 1 and 1 . This process p e must be used to c a l c u l a t e the actual log value because the value a s s o c i a t e d with a standard production length i s higher than that a s s o c i a t e d with a non-standard excess length. Figure 3. Log Production Length l< l k > \ < — 1 e — > < lp > lk. = t o t a l log length; lp = nearest lower log production length; l e = excess length = l k - l p -and 26 Volume and value i n each length component are f u n c t i o n s o f top diameter, bottom diameter and length. Volume c a l c u l a t i o n i s based on Smalian's formula (Husch et a l . , 1973:120-122) as f o l l o w s : V(d , d b , l ) = volume (m 3) = rf* 1 * i(d2 + d^)/800003 a b where : d & , d^ = diameters (cm); 1 = length (m); and 3 80000 = conversion f a c t o r to give volume i n m . The r e c u r s i v e equation f o r value maximization can t h e r e f o r e be defined as f o l l o w s : F n = [R n ( k ) + F*_ k] Fp = max F n 0 s< k v< min ( n , l m a x ) where: F n = t o t a l r e t u r n f o r an n stage process; Fn-k = t o t a l maximized return derived f o r an (n-k)-stage process; and F^ = t o t a l maximized return derived f o r an n-stage process. 27 A complete d e s c r i p t i o n o f a log i s given by top and bottom diameters, length and the governing wood q u a l i t y i n d i c a t o r over the length of the log. As stage and d e c i s i o n can be used to d e r i v e the complete log d e s c r i p t i o n , a st a t e v a r i a b l e was not necessary and was not included i n the r e c u r s i v e equation. The t r a n s i t i o n f u n c t i o n used i n value maximization reduces the number of remaining stages by the number of stage i n t e r v a l s s p e c i f i e d by the d e c i s i o n . That i s , the t r a n s i t i o n f u n c t i o n l i n k s the n-stage process to the (n-k)-stage process. 3.3 COST MINIMIZATION Cost minimization determines which cuts, as s p e c i f i e d by value maximization, to make such that e x t r a c t i o n costs are minimized. The t o t a l length of t r e e (L) i s d i v i d e d i n t o M stages. These stages are defined by the number and l o c a t i o n o f optimal logs from value maximization. For example, i f the value maximization determines that logs of lengths 1 ^ 1 2 and l g should be cut, then there w i l l be three stages i n the cost minimization (see Figure 4). The sum of the i n d i v i d u a l log lengths from value maximization (1.) i s equal to the t o t a l t r ee length. 28 Figure 4. Cost Minimization Stage D e f i n i t i o n optimized lengths from value > maximization < - IT — > < i 2 _ _ — > < i 3 > l o c a t i o n o f stages f o r cost >0 2 3 minimization The d e c i s i o n (z) at any stage (m) i s again the length of log to produce measured i n stage i n t e r v a l s . However, the p o s s i b l e log lengths are now constrained to be comprised of s i n g l e and/or combinations of optimized log lengths from value maximization. Therefore, stage i n t e r v a l may not be constant due to d i f f e r e n t optimized log lengths. At stage m the t o t a l log length (1 ) i s given as : m j=l The log length (1 ) to cut at any stage and d e c i s i o n i s determined as f o l l o w s : m where u = log p o s i t i o n counter = m-z+1. 29 The d e c i s i o n length i s constrained by minimum and maximum length c o n s t r a i n t s ^ xmin* xmax^ a s defined by s i z e l i m i t a t i o n s f o r ya r d i n g , loading and t r a n s p o r t a t i o n . These lengths are as follows : minimum e x t r a c t i o n length = 3.0 m; and maximum e x t r a c t i o n length = 16.8 m. In cost minimization, stage i n t e r v a l i s not g e n e r a l l y constant. Therefore, the minimum and maximum log length c o n s t r a i n t s cannot be expressed i n stages and must be s p e c i f i e d i n metres. A minimum e x t r a c t i o n length c o n s t r a i n t i s required so that bucking does not produce short logs that can f a l l between the bunks o f a logging truck. Although some short logs can be stacked on top of a tru c k load, a log shorter than the minimum length can not be handled e f f i c i e n t l y . The maximum e x t r a c t i o n length represents the length o f the longest log that can be e f f i c i e n t l y loaded and hauled to a s o r t i n g f a c i l i t y . Logs with a length longer than t h i s could be transported, but s p e c i a l trucks and co n s i d e r a t i o n s f o r narrow roads and sharp curves would be necessary. The e x t r a c t i o n cost at any stage ( c m ( z ) ) i s comprised of two components. (1) The piece cost a s s o c i a t e d with the removal of one log ; and (2) a volume cost a s s o c i a t e d with the volume of log extracted (see Section 4.3). These costs i n c l u d e f e l l i n g , bucking, y a r d i n g , loading, 30 t r a n s p o r t a t i o n , s o r t i n g and handling c o s t s . The t o t a l e x t r a c t i o n cost i s given by : C m ( z ) = f [ V ( l 2 ) , C r C 2] = CC 1 * V ( l z ) + c2] where C 1 = volume e x t r a c t i o n cost ($/m ); C 2 = piece cost f o r e x t r a c t i o n ( $ ) ; and V O z ) = volume of log of length 1 as defined by a d e c i s i o n z (m 3). The r e c u r s i v e equation f o r cost minimization can t h e r e f o r e be defined as follows : Gm = cm( z> + Gm - z G m = min G m xmin ^ ^z ^  xmax where : G m = t o t a l e x t r a c t i o n cost f o r an m-stage process; Gm-z = t o t a l minimized e x t r a c t i o n cost f o r an (m-z)-stage process; and Gj^ = t o t a l minimized e x t r a c t i o n cost f o r an m-stage process. 31 3.4 MAXIMIZED POTENTIAL NET VALUE The p o t e n t i a l gross value f o r a tree i s determined by value maximization. The maximized net p o t e n t i a l value f o r a t r e e can be determined by s u b t r a c t i n g the minimized e x t r a c t i o n cost from the maximized p o t e n t i a l gross value. The two separate phases of the bucking o p t i m i z a t i o n can be combined i n t o one equation : H*(L) = F*(L) - G*(L) where : * H (L) = maximized p o t e n t i a l net value f o r a tree of length L; F*(L) = maximized gross p o t e n t i a l value f o r a t r e e of length L; and G*(L) = minimized e x t r a c t i o n cost f o r a tree of length L. The value derived i n t h i s equation y i e l d s the maximum p o t e n t i a l net value, which leads to the optimal bucking p a t t e r n . For a p r a c t i c a l a p p l i c a t i o n the two phase o p t i m i z a t i o n i s the c o r r e c t model. However, a n a l y t i c a l l y the two phases are not e x p l i c i t l y l i n k e d and thus some sub-optimization may occur. 32 3.5 VALIDITY OF THE OPTIMIZATION ALGORITHM To use dynamic programming as a s o l u t i o n technique f o r the log bucking problem, the c o n d i t i o n s of decomposition and s e p a r a b i l i t y must be s a t i s f i e d (Wilde and B e i g h t l e r , 1967:345-355). These c o n d i t i o n s must be s a t i s f i e d f o r the value maximization, the cost minimization and the two-phase o p t i m i z a t i o n process as a whole. Decomposition i s defined as the use of a sequential problem s t r u c t u r e to transform the d e c i s i o n process i n t o a set of smaller d e c i s i o n problems (Wilde and B e i g h t l e r , 1967:345-355). In the bucking problem, both value maximization and cost minimization have been broken i n t o separate stages. At each o f these stages, a s i m p l i f i e d bucking problem must optimize over a set of d e c i s i o n s . Because both the value maximization and the cost minimization can be d i v i d e d i n t o these separate stages, the c o n d i t i o n of decomposition has been s a t i s f i e d . Value maximization and cost minimization can be thought of as separate DP stages i n the two-phase o p t i m i z a t i o n . Each stage must be optimized over a set o f d e c i s i o n s . Again, because the problem has been d i v i d e d i n t o separate stages, the c o n d i t i o n of decomposition has been s a t i s f i e d f o r the two-phase o p t i m i z a t i o n . 33 S e p a r a b i l i t y governs whether or not a r e c u r s i v e r e l a t i o n can be used to c a l c u l a t e r e t u r n values f o r a stage (Hastings, 1973:25-33). The s e p a r a b i l i t y c o n d i t i o n i s s a t i s f i e d i f stage returns are a d d i t i v e . That i s , i f the r e c u r s i v e r e l a t i o n can be w r i t t e n i n the form : F(n) = fi [R n(k ) ,F(n-k)] (3.1) and where there e x i s t a set of stage returns F(n-k) = f 2[R n(n-k ) , . . . , R o(0)] where f^ and a r e appropriate f u n c t i o n s (Hastings, 1973:25-33). The value maximization and cost minimization r e c u r s i v e equations can both be w r i t t e n i n the form of equation 3.1 above. There a l s o e x i s t , f o r each o p t i m i z a t i o n , a set of returns f o r stages 0 n. These stage returns are a d d i t i v e i n both o p t i m i z a t i o n s . S e p a r a b i l t y i s t h e r e f o r e s a t i s f i e d f o r the two i n d i v i d u a l phases. The combination o f value maximization and cost minimization i n t o a two-phase o p t i m i z a t i o n process i s o f the form : H(n) = f [F(n), G(m)] where: F(n) = the value maximization r e c u r s i v e equation; G(m) = the cost minimization r e c u r s i v e equation; and H(n) = the two-phase o p t i m i z a t i o n f o r bucking. 34 The two o p t i m i z a t i o n components, F(n) and G(m), s a t i s f y the s e p a r a b i l t y c o n d i t i o n and t h e i r combination can be expressed as a simple known f u n c t i o n , H(n). In the two-phase o p t i m i z a t i o n , the stage returns from each component are s t i l l a d d i t i v e . Therefore, the s e p a r a b i l t y c o n d i t i o n f o r the two-phase o p t i m i z a t i o n has been s a t i s f i e d . Dynamic programming can t h e r e f o r e be used as a s o l u t i o n technique f o r the two-phase log bucking problem developed i n t h i s study. 35 4. LOG GRADE, VALUE AND COST SPECIFICATIONS 4.1 LOG GRADES Logs are c l a s s i f i e d by grades to provide information f o r v a l u a t i o n . Standard log grades f o r a l l commercial t r e e species i n B.C. are defined i n the Forest S e r v i c e S c a l i n g Manual ( M i n i s t r y o f F o r e s t s , 1980). Each grade i s made up of a grade r u l e and the log requirements to meet the r u l e . The grade r u l e s p e c i f i e s minimum log length and minimum r a d i u s . I t a l s o s p e c i f i e s the percentage of gross volume that must be a v a i l a b l e to cut out as an end product such as lumber or veneer. I f the end product i s lumber, then a minimum percentage of merchantable lumber of a s p e c i f i c lumber grade i s d e f i n e d . Log requirements to meet the grade r u l e s p e c i f y the f o l l o w i n g q u a l i t y i n d i c a t o r s : conk, number o f annual rings per centimetre, allowable knot s i z e and frequency, and the tolerances f o r t w i s t , r o t , shake, s h a t t e r , s p l i t and sweep. MacMillan Bloedel (1985) uses a s i m p l i f i c a t i o n of the M i n i s t r y of Forests grading system and i d e n t i f i e s four log grades f o r hemlock. Their grading system c l a s s i f i e s a log based on the f o l l o w i n g c r i t e r i a : minimum length, minimum top diameter, maximum top diameter, minimum butt diameter and q u a l i t y i n d i c a t o r s such as r o t , shake, knots, sweep, t w i s t , g o i t e r , p i s t o l g r i p and f r o s t check. The four grades i d e n t i f i e d are : High Grade (HG), Sawlog (SL), Sawlog Gang (SLG) and Pulp (P). 36 The log grading system developed f o r use i n the log bucking system uses an adaptation of the MacMillan Bloedel log grading system. Log grade s p e c i f i c a t i o n i s separated i n t o two components : (1) s i z e c r i t e r i a and (2) q u a l i t y i n d i c a t o r s . The major q u a l i t y i n d i c a t o r s f o r a l l four grades are i d e n t i f i e d and each i s assigned a code (see Table 1). The acceptable q u a l i t y codes f o r the i n d i v i d u a l log grades are then determined and these codes, coupled with the dimension of the l o g , are used to s p e c i f y log grades (see Table 2). The separation of s i z e and q u a l i t y c r i t e r i a f o r log grade s p e c i f i c a t i o n allows the log bucking system to determine log grades f o r any length and l o c a t i o n w i t h i n the tree stem. Previous st u d i e s simply s p e c i f i e d log grade as an input to the o p t i m i z a t i o n algorithm and d i d not account f o r those bucking d e c i s i o n s w i t h i n the t r e e stem that cross over changes i n log grade. 37 Table 1. Tree Q u a l i t y Assessment DEFECT QUALITY CODE QUALITY ASSESSMENT C l e a r Knots up to 6.4 cm Knots up to 8.9 cm Large knots ( i n f r e q u e n t ) 3 Large knots (frequent) 4 Shake/Butt Rot > 1/3 Shake/Butt Rot > 1/2 Conk No external q u a l i t y i n d i c a t o r s or v i s i b l e defects Scattered knots, l e s s than 6.4 cm in diameter Scattered knots, greater than 6.4 cm i n diameter and l e s s than 8.9 cm i n diameter Scattered knots, greater than 8.9 cm i n diameter at a frequency of less than 1 knot i n 3 metres o f length Knots greater than 8.9 cm in diameter at a frequency greater than 1 knot i n 3 metres of length Shake/Butt Rot g r e a t e r than 1/3 of the butt diameter but l e s s than 1/2 the butt diameter. Assume shake extends e n t i r e length. Shake/Butt Rot g r e a t e r than 1/2 of the butt diameter. Conk or conk knots v i s i b l e P i s t o l g r i p or other waste defe c t 8 S i g n i f i c a n t d e f e c t i n butt p o r t i o n of t r e e , rendering t r e e as unusable 38 Table 2. Hemlock Log Grade S p e c i f i c a t i o n s Grade min butt top acceptable length d i a d i a q u a l i t y (m) (cm) (cm) codes HG 3.0 - >60.1 0,1,2,3 SL 3.0 >60.1 >20.3 0,1,2,3,5 SLG 3.0 <60.1 >20.3 0,1,3 P 3.0 <60.1 <20.3 1,2,3,5 P ANY ANY ANY 4,6,7,8 4.2 LOG VALUE The log grade s p e c i f i c a t i o n s d e t a i l e d above can be used to determine the 3 grade o f a p a r t i c u l a r l o g . Once log grade i s determined, value ($/m ) can be assigned. I d e a l l y , t h i s value should be based on the value of the end products that would be derived from the l o g . End products such as lumber are cut i n t o standard lengths, with c e r t a i n lengths having a higher value than others. These premium lengths are s p e c i f i c to the grade o f log being cut. To assign value to a log based on end products, values should be tabulated so that premium lengths are i d e n t i f i e d w i t h i n a log grade. 39 There are a number o f problems inherent i n t h i s method of value assignment. F i r s t , the time between tree f e l l i n g and f i n a l t r e e processing i n t o an end product can vary from one month to one year. Therefore i t i s d i f f i c u l t to a ssign a log value at the time of f e l l i n g . Second, even i f the end product use o f a log i s known, i t i s d i f f i c u l t to c o r r e l a t e log value with end product value i n a manner that i d e n t i f i e s premium log lengths (Yamada, 1986). Middleton (1981, 1985) examined lumber values and lumber y i e l d s from log grades, but d i d not i d e n t i f y premium log lengths based on end product value. Studies by Bruce (1970), Dobie (1966), Fahey et a l . (1974) and Lane (1973) considered product y i e l d , log grades and end product values, but a l s o did not i d e n t i f y premium log lengths or premium log values w i t h i n log grade. Premium values based on length do e x i s t f o r end products such as lumber and these values are r e f l e c t e d i n lumber p r i c e s . However, premium length values w i t h i n s p e c i f i c log grades have not been tabulated i n a formal manner (Greenough, 1986; Middleton, 1986; Young, 1985). Assuming that the end product of a log i s known and that r e l a t i v e log values are constant, the lack of log value data i n a s u i t a b l e form can be overcome. Log values were developed based on the Vancouver Log Market average p r i c e s f o r the hemlock log grades. Within each log grade, the standard primary log lengths were i d e n t i f i e d . These are the lengths used to produce s p e c i f i c lumber lengths and i n c l u d e a t r i m allowance f o r 40 p r o c e s s i n g . The product lengths r e f l e c t s p e c i f i c market demands f o r log grades. High grade i s intended p r i m a r i l y f o r export lumber production f o r the Japanese market, whereas sawlog grades are intended f o r the domestic market (Bjarnason, 1986; Chaston, 1986). The standard log lengths i n c l u d i n g t r i m are summarized i n Table 3. For each of the standard log lengths w i t h i n a grade, any lengths with a higher than average value were i d e n t i f i e d . For the HG grade, three premium lengths, not i n c l u d i n g t r i m allowance, were i d e n t i f i e d : 3.0m (10'), 4.0m 0 3 ' ) and 6.1m ( 2 0 1 ) . For SLG and SL grades, the premium lengths, not i n c l u d i n g t r i m , were : 4.9m (16') and 5.6m 0 8 ' ) . Values were assigned to each of the standard log lengths, i n c l u d i n g t r i m allowance, w i t h i n each grade using the f o l l o w i n g procedure. The average value f o r a log grade from the Vancouver Log Market was used as a base value. Any premium lengths w i t h i n a grade were adjusted upwards from the base value by an amount r e f l e c t i n g the r e l a t i v e value of that log length. A l l non-premium log lengths assume the base value f o r the grade. The r e s u l t s are tabulated i n Table 3. This approach i s c o n s i s t e n t with other attempts to value logs. 41 Table 3. Hemlock Log Grade Values and Standard Log Lengths Grade Standard Log Length Value ( i n c l u d i n g trim) $/m3 High Grade 3.1 (10 1) 1 * 72.19 4.1 (13') 85.94 6.1 (20') * 75.63 6.5 ( 2 D 68.75 7.1 (23 1) 68.75 7.7 (25') 68.75 Saw Log Gang 3.1 (10') 35.38 3.8 (12') 35.38 4.3 (14') 35.38 4.9 (16') 38.92 5.6 (18 1) 37.15 6.2 (20') 35.38 6.8 (22') 35.38 7.4 (24') 35.38 8.0 (26') 35.38 Saw Log 3.1 (10') 50.12 3.8 (12') 50.12 4.3 (14 1) 50.12 4.9 (16 1) 55.12 5.6 (18 1) 52.66 6.2 (20') 50.12 6.8 (22') 50.12 7.4 (24') 50.12 8.0 (26') 50.12 Pulp 24.73 Note: premium lengths are i n d i c a t e d with an Length i n brackets = standard lumber product length, i n Imperial u n i t s , not i n c l u d i n g t r i m . 42 4.3 LOG EXTRACTION COSTS Log e x t r a c t i o n costs are a major c o n s i d e r a t i o n i n the p r a c t i c a l determination o f optimal bucking patterns at the stump. E x t r a c t i o n costs i n c l u d e a l l downstream costs from the point of f e l l i n g such as : f a l l i n g , bucking, y a r d i n g , loading, t r a n s p o r t a t i o n , s o r t i n g and handling c o s t s . Because the log bucking system was intended f o r use i n a logging d i v i s i o n , only those costs a s s o c i a t e d with logging were i n c l u d e d . Therefore, processing costs f o r the conversion of logs to an end product were not considered i n t h i s study. The e x t r a c t i o n cost i s broken i n t o a f i x e d cost (piece cost) and a v a r i a b l e cost (volume c o s t ) . These e x t r a c t i o n costs were supplied by MacMillan Bloedel Ltd. s p e c i f i c a l l y f o r t h i s study and t h e i r d e r i v a t i o n i s c o n f i d e n t i a l . Total u n i t cost f o r e x t r a c t i o n i s thus given i n the f o l l o w i n g equation (Matthews, 1942): Total u n i t cost = f i x e d cost/output + v a r i a b l e u n i t c o s t 1 where : Total u n i t cost i s given i n $/m Fixed cost = piece cost = $14.00 3 V a r i a b l e Unit cost = volume cost = 12.77 $/m 1. A f i x e d cost i s defined as decreasing on a per u n i t basis as production increases and a v a r i a b l e cost i s defined as remaining constant per u n i t volume (Wackerman et a l . , 1966). 43 In the above cost equation, e x t r a c t i o n costs ($/m ) decrease as piece 3 s i z e (m ) incr e a s e s (Figure 5.) This means that cost savings can be r e a l i z e d by using cost minimization to determine which cuts to make at the time o f t r e e f e e l i n g . Figure 5. E x t r a c t i o n Cost R e l a t i o n 200 -190 -180 -170 -0 -J 1 1 1 1 1 1 1 1 1 j 1 1 1 1 1 1 1 1 1 0 0.5 1 1.5 2 PIECE SIZE (CUBIC METRES) 44 5. DESCRIPTION OF THE LOG BUCKING SYSTEM 5.1 OVERVIEW The log bucking system was developed as part of a Department of Supplies and S e r v i c e s (DSS) study to i n v e s t i g a t e the use of a hand-held computer to optimize bucking i n the f i e l d (Young and Waddell, 1986). In t h i s context, the log bucking system was used to t e s t the f e a s i b i l i t y o f an o p t i m i z a t i o n algorithm f o r log bucking before implementation on a hand-held computer. The log bucking system was implemented on an IBM-PC microcomputer. Programming of the system was undertaken using M i c r o s o f t 'C (TM). This language was chosen f o r ease of programming and to allow f o r the e f f i c i e n t t r a n s f e r of an executable program to a hand-held computer using programmable read only memory (PROM). To implement the system on the hand-held computer used i n the DSS study, the executable program must be t r a n s l a t e d i n t o Mark Williams 'C (TM). (See program l i s t i n g s , Appendix 3.) The log bucking system has three main components (see Figure 6). (1) The User I n t e r f a c e ( S e c t i o n 5.2); (2) The O p t i m i z a t i o n Algorithm (Section 5.3); and (3) Constrained V a l u a t i o n Algorithm (Se c t i o n 5.4). Figure 6. Schematic of Log Bucking System USER INTERFACE INPUT : tree data PRE-PROCESSING c a l c u l a t e diameter at each stage determine q u a l i t y over each stage i n t e r v a l OPTIMIZATION ALGORITHM choo§e f u n c t i o n •> 2 CONSTRAINED VALUATION ALGORITHM va]ue maximization . cost minimization OUTPUT : - maximized p o t e n t i a l net value - optimal bucking p a t t e r n log value _ data ($/m3) by log grade input proposed bucking pattern c a l c u l a t e value and e x t r a c t i o n cost o f i n d i v i d u a l logs OUTPUT : - p o t e n t i a l net value 46 5.2 USER INTERFACE 5.2.1 DATA INPUT The current f a l l i n g / b u c k i n g sequence used by MacMillan Bloedel Ltd. i s as f o l l o w s . A t r e e i s f e l l e d , measured f o r length and assessed f o r q u a l i t y s t a r t i n g at the butt and working towards the top. The t r e e i s bucked a f t e r a l l measurement and assessment i s complete. Bucking i s supposed to s t a r t at the butt and progress to the top, but the order i s sometimes reversed. Because the log bucking system was intended as a p r a c t i c a l system to be used at the stump, the data input s e c t i o n was designed to minimize i n t e r f e r e n c e with the f a l l i n g / b u c k i n g sequence and follows a p a t t e r n s i m i l a r to that of the present assessment system. The data input sequence i s as f o l l o w s : (1) The input process s t a r t s with a measurement o f the average butt diameter, i n s i d e bark, i n centimetres. To remove the e f f e c t s of pronounced butt f l a r e , t h i s measurement i s taken above butt s w e l l . The diameter i s measured with a s c a l e s t i c k to the nearest centimetre. I f the cross s e c t i o n of the t r e e stem at the measurement l o c a t i o n i s e c c e n t r i c , then an average diameter i s taken. This i s accomplished by taking two diameter measurements at 90° to each other and averaging the measurements. 47 (2) The di s t a n c e from the butt to the diameter measurement above butt swell i s measured using a f a l l e r ' s tape. Length i s measured i n metres to the nearest tenth o f a metre. No allowance i s made f o r t r i m i n these measurements. (3) The q u a l i t y code f o r the s e c t i o n o f log from the butt to the f i r s t diameter measurement i s determined. This i s based on the q u a l i t y codes as defined i n Chapter 4. The most s i g n i f i c a n t d e f e c t code that defines the lowest log grade f o r the length being considered i s input. (4) The uniform wood q u a l i t y s e c t i o n s f o r the remainder o f the t r e e are i d e n t i f i e d . These are the se c t i o n s within the t r e e where the wood q u a l i t y i s constant. The length, to the nearest tenth o f a metre, from the butt of the tree to the end of the q u a l i t y s e c t i o n i s measured and the q u a l i t y code f o r the s e c t i o n i s determined. The process i s repeated u n t i l the top of the t r e e i s reached. (5) The f i n a l input i s a measurement of the top diameter, i n s i d e bark, i n centimetres. 48 5.2.2 SYSTEM CONTROL Once the data input i s complete, the user i n t e r f a c e provides system c o n t r o l . The o p t i m i z a t i o n algorithm can be implemented, the constrained v a l u a t i o n algorithm can be chosen, or a new data input sequence can be s t a r t e d . 5.3 OPTIMIZATION ALGORITHM The o p t i m i z a t i o n algorithm u t i l i z e s value maximization and cost minimization as documented i n Chapter 3. The requ i r e d inputs to t h i s s e c t i o n are the s p e c i f i c tree q u a l i t y and s i z e c h a r a c t e r i s t i c s , and the log values on a d o l l a r per cubic metre by log grade b a s i s . The outputs from t h i s s e c t i o n are the maximized p o t e n t i a l net value and the optimal bucking p a t t e r n . 5.4 CONSTRAINED VALUATION ALGORITHM Under c e r t a i n c o n d i t i o n s , the number of p o s s i b l e saw cut l o c a t i o n s i n the t r e e may be l i m i t e d . Placement of a saw cut i n these l o c a t i o n s may present a s a f e t y hazard to the f a l l e r , r e s u l t i n damage to the tree or be p h y s i c a l l y impossible. This s i t u a t i o n can a r i s e f o r a number of reasons. Steep or broken t e r r a i n with g u l l i e s may l i m i t the p o s s i b l e l o c a t i o n of saw 49 c u t s . The l o c a t i o n of o b s t a c l e s such as stumps or other f e l l e d trees may impose c o n s t r a i n t s on bucking. Weather co n d i t i o n s can a l s o have an e f f e c t on p o s s i b l e bucking l o c a t i o n s . A m o d i f i c a t i o n to the log bucking system was developed to allow f o r unusual s i t u a t i o n s where the f a l l e r cannot buck at the optimal bucking l o c a t i o n s as s p e c i f i e d by the o p t i m i z a t i o n algorithm. This algorithm, c a l l e d the constrained v a l u a t i o n algorithm, allows the f a l l e r to input tree c h a r a c t e r i s t i c s and a proposed bucking pattern f o r the t r e e . The r e s u l t i n g p o t e n t i a l net value of the proposed bucking pattern i s then c a l c u l a t e d . The c o n s t r a i n e d v a l u a t i o n algorithm c a l c u l a t e s the value and e x t r a c t i o n cost o f a proposed bucking p a t t e r n . Each of the i n d i v i d u a l logs w i t h i n the bucking p a t t e r n i s evaluated s e p a r a t e l y . Value maximization i s used to c a l c u l a t e the p o t e n t i a l gross value o f each l o g . E x t r a c t i o n cost i s c a l c u l a t e d based on the t o t a l number and s i z e of logs w i t h i n the proposed bucking p a t t e r n . P o t e n t i a l net t r e e value i s obtained by s u b t r a c t i n g the e x t r a c t i o n cost from the sum of the gross values f o r each l o g . The a d d i t i o n o f the constrained v a l u a t i o n algorithm to the log bucking system d i f f e r s from previous s t u d i e s , which have assumed that a l l the optimal cuts are p o s s i b l e . This assumption i s true only i f a t r e e i s at the sawmill. For a p r a c t i c a l a p p l i c a t i o n o f a log bucking system at the stump, the system must be able to evaluate unusual bucking s i t u a t i o n s . Used in t h i s manner, the system resembles simulation r a t h e r than o p t i m i z a t i o n . The 50 f a l l e r may have to t r y d i f f e r e n t bucking patterns and choose that which returns the highest value. A tree value c a l c u l a t e d under these c o n d i t i o n s w i l l not n e c e s s a r i l y be an optimal value. 51 6. METHODOLGY FOR HYPOTHESIS TESTING An e v a l u a t i o n o f the log bucking system and a t e s t i n g of hypothesis was undertaken through a f i e l d study. The hypothesis that was t e s t e d was as f o l l o w s : bucking patterns derived by the o p t i m i z a t i o n a l g o r i t h m w i t h i n the log bucking system y i e l d a higher p o t e n t i a l net value than present i n d u s t r y bucking p r a c t i c e s . 6.1 FIELD STUDY AREA Data c o l l e c t i o n took place i n March 1986, i n MacMillan Bloedel's Eve River Logging D i v i s i o n . This d i v i s i o n i s located north of Campbell River on Vancouver I s l a n d . The f i e l d study area was i n Tree Farm Licence 39, c u t t i n g permit 12, on road LA100C, i n a f e l l e d and bucked s e t t i n g (see Appendix 1). The general t e r r a i n c o n d i t i o n s i n the study area were not as steep and rugged as some coa s t a l B.C. c o n d i t i o n s . The average slope was 20% - 40% and was broken with small g u l l i e s . The cut block had been l a i d out f o r cable y a r d i n g and a grapple yarder was operating i n the block as the study took p l a c e . The broken t e r r a i n and lean patterns i n the standing timber l i m i t e d f a l l i n g p a t t e r n s . Instead of p r o g r e s s i v e l y f a l l i n g timber i n a p a r a l l e l p a t t e r n , the p a t t e r n of f e l l e d and bucked timber was random. The species mix i n the study area, as shown by MacMillan Bloedel c r u i s e data, was 49% Hemlock and 31% Balsam (Abies amabi1is (Doug.) Forbes). The t o t a l area of the s e t t i n g was approximately 33.1 hectares. 52 This s e t t i n g was chosen as the study area f o r the f o l l o w i n g reasons : (1) There was good road access to the area. Travel time to the area was short and t h e r e f o r e more time could be spent on data c o l l e c t i o n . Also, t e r r a i n c o n d i t i o n s allowed f o r i n d i v i d u a l measurements i n r e l a t i v e l y short periods o f time. (2) The s e t t i n g had been r e c e n t l y f e l l e d and bucked. Data c o l l e c t i o n t h e r e f o r e c l o s e l y represented t r e e c o n d i t i o n s at the time of f a l l i n g . This c o n d i t i o n was necessary because defects such as crack or shake tend to increa s e a f t e r a t r e e has been f e l l e d . At the time of f e l l i n g , these d e f e c t s may not be evident. To minimize any d i f f e r e n c e s between the f a l l e r ' s q u a l i t y assessment at the time of f a l l i n g and the q u a l i t y assessment at the time o f data compilation, the time d i f f e r e n c e must be minimized. A l s o , to minimize the e f f e c t s o f market value changes f o r logs, the values i m p l i c i t l y used by a f a l l e r when making bucking d e c i s i o n s must be the same as those used i n the o p t i m i z a t i o n algorithm at the time of the f i e l d study. (3) The s e t t i n g had a species composition f a v o u r i n g hemlock and balsam. Balsam was included i n the sample because i t i s graded s i m i l a r l y to hemlock and has the same grade values. 53 The actual area o f f e l l e d and bucked timber was smaller than that shown on the map (see Appendix 2). F a l l i n g was taking place i n the North-East corner o f the block and yarding was taking place i n the South-East corner. Both of these operations i n t e r f e r e d with the sampling and l i m i t e d the s i z e of area from which a sample tree population could be obtained. 6.2 SAMPLING TECHNIQUE The p a t t e r n o f the f e l l e d and bucked trees made i t d i f f i c u l t to i d e n t i f y s i n g l e trees f o r measurement. Some trees were stacked one on top of the other and trees underneath could not be measured. Other bucked trees had been d i s t u r b e d by subsequent f e l l i n g and logs from the tr e e were missing. The sampling was thus l i m i t e d to f i n d i n g those trees i n which the logs could be pieced together to form the complete t r e e . As the s i z e o f the study area was r e l a t i v e l y small, a l l trees that could be reconstructed were measured and inc l u d e d i n the sample. 6.3 DATA COMPILATION Dimension and grade information was compiled f o r a sample of 47 f e l l e d and bucked t r e e s . The actual bucking p a t t e r n , as i t e x i s t e d i n the f i e l d , was a l s o recorded. MacMillan Bloedel personnel were present at the time of the f i e l d study and any unusual bucking s i t u a t i o n s were i d e n t i f i e d and explained by them. The p o s s i b l e reasons f o r the unusual bucking patterns were recorded. Tree data were input to the log bucking system using the procedures described i n Chapter 5. The o p t i m i z a t i o n algorithm was used to c a l c u l a t e the maximium p o t e n t i a l net value and optimal bucking p a t t e r n of the sample t r e e s , assuming no bucking had taken p l a c e . The constrained v a l u a t i o n algorithm was used to determine the p o t e n t i a l net value f o r the actual bucking p a t t e r n . A summary of the dimensions of the sample trees i s shown i n Table 4. Table 4. D i s t r i b u t i o n o f Tree Dimensions Butt Diameter Class (cm) Number o f Observations by Lenqth Class (m) Total 20.1 20.1-25 25.1-30 30.1-35 35.1 < 50.0 1 4 1 6 50.1 - 70.0 2 3 6 1 12 70.1 - 90.0 3 8 1 12 90.1 - 110.0 1 1 4 5 11 110.1 - 130.0 1 1 2 1 5 130.1 - 150.0 1 1 Total 5 12 20 8 2 47 56 6.4 HYPOTHESIS To assess the u t i l i t y o f the o p t i m i z a t i o n algorithm, the maximized p o t e n t i a l net value o f the optimized bucking patterns was compared to the p o t e n t i a l net value o f the actual bucking p a t t e r n s . Based on t h i s comparison, the f o l l o w i n g hypothesis was formulated : = 0.05 where : ui = average maximum p o t e n t i a l net value (optimized bucking patterns) u 2 = average p o t e n t i a l net value (actual bucking p a t t e r n s ) . The hypothesis was teste d using a two way a n a l y s i s o f variance f o r paired o b s e r v a t i o n s , at a 0.05 l e v e l o f s i g n i f i c a n c e (Sokal and Rholf, 1969:354-359; Nalpole, 1982:260-262). This method of a n a l y s i s was chosen f o r the f o l l o w i n g reasons. (1) The observations are p a i r e d because the value comparison of the o p t i m i z a t i o n algorithm to the actual bucking pattern i s made f o r the same t r e e ( i n d i v i d u a l ) . (2) The two-way a n a l y s i s of variance gives a measure of v a r i a b i l i t y between trees ( i n d i v i d u a l s ) . 57 7. RESULTS AND DISCUSSION 7.1 RESULTS The a n a l y s i s of variance t a b l e f o r the comparison d e t a i l e d i n Chapter 6 was compiled and i s shown i n Table 5. Table 5. ANOVA : Maximized P o t e n t i a l Net Value. Source df SS MS F Value D i f f e r e n c e 1 9379.97 9379.97 20.84 Between Trees 46 21264808.80 462278.45 1027.06 Residual 46 20704.53 450.10 Total 93 21294893.30 F0.05H.46] = 4.08 F0.05L"46,46] = 1.69 58 The F value (20.84) f o r the value d i f f e r e n c e between the optimized bucking patterns and the actual bucking patterns i s g r e a t e r than the c r i t i c a l F value (4.08). Therefore, the n u l l hypothesis i s r e j e c t e d and the a l t e r n a t i v e hypothesis i s accepted. At the 0.05 l e v e l of s i g n i f i c a n c e , the net value o f the optimized bucking patterns i s s i g n i f i c a n t l y g r eater than the net value of the actual bucking p a t t e r n s . The s i g n i f i c a n t F value (1027.06) between trees shows that there e x i s t s a s i g n i f i c a n t v a r i a t i o n i n value between the i n d i v i d u a l trees sampled. The r e s u l t s are summarized and compared as shown i n Table 6. For the t e s t data, the p o t e n t i a l net value of logs bucked using the o p t i m i z a t i o n algorithm shows an increase of 4.2% over the p o t e n t i a l net value of actual bucking p a t t e r n s . The i n t e r v a l estimate f o r 95% shows an i n c r e a s e from 2.6% to 5.9%. Value maximization shows an i n c r e a s e of 2.6% in p o t e n t i a l gross value and cost minimization shows a 2.1% decrease i n c o s t s . The i n c r e a s e i n p o t e n t i a l net value i s based on the log values and e x t r a c t i o n costs assumed i n Chapter 4. As a f u r t h e r e v a l u a t i o n of the log bucking system, the actual bucking patterns were compared to the optimized bucking p a t t e r n s . By i n s p e c t i o n of the sample data, i t was seen that the optimized bucking patterns were very s i m i l a r to the actual bucking p a t t e r n s . 59 Table 6. Summary of Results Optimization Algorithm Actual Bucking Patterns Di fference^ $ 1 % P o t e n t i a l Gross Value ($) 1 29751.97 28966.97 785.00 2.6 E x t r a c t i o n Cost ( $ ) 2 7468.56 7622.55 -153.99 -2.1 P o t e n t i a l Net Value ( $ ) 3 22283.41 21344.42 939.00 4.2 1. P o t e n t i a l gross value f o r the o p t i m i z a t i o n a l g o r i t h m i s obtained from the value maximization phase. P o t e n t i a l gross value f o r the actual bucking p a t t e r n i s obtained from the constrained v a l u a t i o n algorithm. Neither value has e x t r a c t i o n cost deducted from i t . 2. E x t r a c t i o n cost f o r the o p t i m i z a t i o n algorithm i s obtained from the cost minimization phase. E x t r a c t i o n cost f o r the actual bucking pattern i s c a l c u l a t e d based on the input p a t t e r n . 3. P o t e n t i a l net value i n both cases i s determined by the s u b t r a c t i o n of e x t r a c t i o n cost from p o t e n t i a l gross value. 4. D i f f e r e n c e r e f l e c t s the increase of the o p t i m i z a t i o n a l g o r i t h m bucking p a t t e r n values and costs over the actual bucking p a t t e r n . A decrease i s shown as a negative value. 60 7.2 DISCUSSION The bucking patterns derived by the o p t i m i z a t i o n algorithm, f o r the t e s t data used, showed an increase i n p o t e n t i a l net value o f 4.2% over the value of the actual bucking p a t t e r n s . This percentage i n c r e a s e i n value could have been i n f l u e n c e d by a number of f a c t o r s . (1) Log values were derived from average log grade p r i c e s from the Vancouver Log Market. Premium log lengths i d e n t i f i e d w i t h i n a log grade were assigned a higher value depending on the r e l a t i v e value o f that premium log length. The r e l a t i v e adjustment was based on the best judgment of informed i n d u s t r i a l sources (Chaston, 1986; Greenough, 1986). However, these r e l a t i v e adjustments were s u b j e c t i v e and may have undervalued the premium log lengths. Thus, the maximum value f o r a t r e e may be undervalued and the percentage increase i n value may be low. (2) The logging d i v i s i o n i n which the tree data were c o l l e c t e d had a rigorous q u a l i t y c o n t r o l program. In t h i s respect, f a l l e r s had been t r a i n e d to recognize many of the f a c t o r s that the o p t i m i z a t i o n algorithm considered, i n c l u d i n g log v a l u a t i o n and log grading. This program may account, i n part, f o r the encountered i n c r e a s e i n value. I t i s p o s s i b l e that i n another logging d i v i s i o n , a higher increase i n value would be found. 61 (3) The t e r r a i n found i n the f i e l d study area provided very easy f a l l i n g and bucking c o n d i t i o n s f o r the f a l l i n g crew. This c o n d i t i o n , plus the a d d i t i o n a l t r a i n i n g of the crew, led to the area having higher bucking standards than normal. This i n turn may have lowered the incre a s e i n value somewhat. (4) In gener a l , the q u a l i t y of wood found i n the study area was very good. There was a very low percentage of r o t or other d e f e c t s found i n the sample t r e e s . Q u a l i t y was f a i r l y homogeneous w i t h i n each sample t r e e , with grade breaks being e a s i l y recognized. This made bucking d e c i s i o n s e a s i e r , on the part o f the f a l l e r , and tended to r a i s e the value o f the actual bucking p a t t e r n s . This i n turn lowered the expected i n c r e a s e i n value from the o p t i m i z a t i o n algorithm. Regardless of whether or not the increase i n value i n t h i s study i s low, in terms o f b e n e f i t s to the coa s t a l f o r e s t i n d u s t r y , an incre a s e o f 4.2% i n log value i s s u b s t a n t i a l . At a time when p r o f i t a b i l i t y on the coast i s of great concern to the i n d u s t r y , t h i s i s a very s i g n i f i c a n t f i g u r e . I f indeed an i n c r e a s e i n value o f greater than 4.2% can be achieved, then t h i s system o f f e r s even g r e a t e r o p p o r t u n i t i e s to improve p r o f i t a b i l i t y . 62 In terms of other b e n e f i t s that can be derived through the use of the log bucking system, the separation o f s i z e and q u a l i t y c r i t e r i a f o r log grading means that a f a l l e r can concentrate on q u a l i t y c r i t e r i a r a t her than s i z e c r i t e r i a . This would be useful f o r t r a i n i n g new f a l l e r s and to introduce them to s p e c i f i c company grading procedures. In p a r t i c u l a r , the use o f the system w i l l draw a f a l l e r s a t t e n t i o n to log q u a l i t y . This examination o f log q u a l i t y i s a key f a c t o r i n log v a l u a t i o n . I f the q u a l i t y of bucked logs i s improved through proper bucking p r a c t i c e s , then value w i l l be improved. Pnevmaticos and Mann (1973) suggested that information gained a f t e r each cut could be used i n planning remaining c u t s . While not e x p l i c i t l y included i n the log bucking system, t h i s method could be used with i t . A f t e r making the f i r s t cut, i f q u a l i t y d i f f e r s from the i n i t i a l input q u a l i t y , the remaining t r e e could be re-optimized using the a d d i t i o n a l q u a l i t y i n f o r m a t i o n . This s i t u a t i o n could a r i s e i f a hidden d e f e c t , such as pocket r o t , i s encountered. The e v a l u a t i o n o f bucking patterns i s dependant on the log values used i n the o p t i m i z a t i o n algorithm. Due to a lack o f end product data tabulated on a length by grade b a s i s , log values had to be derived from the Vancouver Log Market. This i s one area that would b e n e f i t g r e a t l y from f u r t h e r research. The c l o s e r end product outturn and value information can be t i e d back to log grades, the b e t t e r the ev a l u a t i o n o f bucking patterns i n the woods. 63 The use of the o p t i m i z a t i o n algorithm i n d i c a t e s that p o t e n t i a l gross value can be increased by 4.2%. However, to achieve t h i s i n c r e a s e i n value, the f i n a l bucking pattern must be cut out at the sawmill. I f changes to the optimal bucking pattern are made at the sawmill, then the value derived w i l l not n e c e s s a r i l y be a maximum value. 64 8. SUMMARY AND CONCLUSIONS This t h e s i s documents the development of a p r a c t i c a l log bucking system f o r determining optimal bucking patterns at the stump a f t e r t r e e f e l l i n g . The system u t i l i z e s a two-phase dynamic programming al g o r i t h m such that value and e x t r a c t i o n costs are optimized. The log bucking system in c o r p o r a t e s assessment of log grade, assignment of log value based on premium log lengths w i t h i n log grades, c o n s i d e r a t i o n o f standard log product lengths and e x t r a c t i o n cost information. The log bucking system was developed as part o f a Department of Supplies and Se r v i c e s study to i n v e s t i g a t e the f e a s i b i l i t y and use of a hand-held computer to optimize bucking patterns i n the f i e l d . I t was implemented on an IBM-PC microcomputer. In a d d i t i o n to the o p t i m i z a t i o n algorithm, the log bucking system contains a constrained v a l u a t i o n algorithm f o r the eva l u a t i o n of bucking patterns where there are c o n s t r a i n t s imposed on p o s s i b l e l o c a t i o n of sawcuts along the length o f the t r e e . This study shows that a hand-held a p p l i c a t i o n f o r o p t i m i z i n g bucking patterns at the stump i s t e c h n i c a l l y f e a s i b l e . A two-phase o p t i m i z a t i o n algorithm i s the appropriate DP formulation at the stump and the e f f i c i e n c y o f t h i s formulation y i e l d s very f a s t s o l u t i o n times. As w e l l , the measurements requ i r e d f o r input to the log bucking system are very s i m i l a r 65 to those p r e s e n t l y used. Therefore, the data input s e c t i o n o f the log bucking system does not i n t e r f e r e s i g n i f i c a n t l y with the present f a l l i n g / b u c k i n g sequence and could e a s i l y be incorporated i n t o production use. The use of a computerized log bucking system to optimize tree value provides the o p p o r t u n i t y to q u i c k l y adapt bucking p r a c t i c e s to changes in market c o n d i t i o n s . Changes i n log values and/or log grade s t r u c t u r e s can e a s i l y be incorporated i n t o the log bucking system to respond to market o p p o r t u n i t i e s and thus increase p r o f i t a b i l i t y . Use of the constrained v a l u a t i o n algorithm would acquaint the f a l l e r with log grading and log v a l u a t i o n as well as log bucking p r a c t i c e s . This could serve as a f a l l e r t r a i n i n g guide or serve as a useful tool f o r a n a l y z i n g d i f f i c u l t bucking s i t u a t i o n s . The r e s u l t s o f t h i s study support previous studies i n that net value can be increased through the use of an o p t i m i z a t i o n algorithm. For the t e s t data used, the optimized bucking patterns showed a s i g n i f i c a n t increase i n p o t e n t i a l net value of 4.2% over the p o t e n t i a l net value of the actual bucking p a t t e r n s . The actual impact that the use o f the log bucking system would have on the f o r e s t i n d u s t r y i s dependant on the log values used. I f r e a l i s t i c values are used, then t h i s system o f f e r s a s i g n i f i c a n t opportunity to i n c r e a s e p r o f i t a b i l i t y i n the c o a s t a l f o r e s t i n d u s t r y . 66 9. LITERATURE CITED 9.1 LITERATURE CITED 1. Bellman, R.E. 1957 Dynamic Programming. Princeton U n i v e r s i t y Press, P r i n c e t o n , New Jersey. 340 pp. 2. Bruce, D. 1970. P r e d i c t i n g Product Recovery from Logs and Trees. U.S.D.A. For. Serv. Res. Pap. PNW-107, 15 pp. 3. Dobie, J . 1966. Product Y i e l d and Value, F i n a n c i a l Rotations and B i o l o g i c a l R e l a t i o n s h i p o f Good S i t e D ouglas-Fir. M.F. The s i s , U n i v e r s i t y o f B r i t i s h Columbia, Vancouver, B.C. 29 pp. 4. . 1975. Lumber Recovery P r a c t i c e s i n B r i t i s h Columbia Coastal Sawmills. Can. For. Serv. West. For. Prod. Lab. In f . Rep. VP-X-151, Vancouver, B.C. 29 pp. 5. Dykstra, D.P. 1984. Mathematical Programming f o r Natural Resource Management. McGraw-Hill, New York. 318 pp. 6. Faaland, B. and D. Briggs. 1984. Log Bucking and Lumber Production Using Dynamic Programming. Management Science, V o l . 30, No. 2, 245-257. 7. Fahey, T.D. and D.C. Martin. 1974. Lumber Recovery from Second Growth Doug l a s - F i r . U.S.D.A. For. Serv. Res. Pap. PNW-177. 20 pp. 8. Hastings, N.A.J. 1973. Dynamic Programming with Management A p p l i c a t i o n s . Crane, Russak and Company Inc., New York. 173 pp. 9. H i l l i e r , F.S. and G.J. Lieberman. 1967. I n t r o d u c t i o n to Operations Research. Holden-Day Inc., San Fr a n c i s c o , C a l i f o r n i a . 639 pp. 10. Husch, B., C.J. M i l l e r , and T.W. Beers. 1973. Forest Mensuration. John Wiley and Sons, New York. 410 pp. 11. Lane, P.H., J.W. Henley, R.O. Woodfin J r . and M.E. Plank. 1973. Lumber Recovery form Old-Growth Douglas-Fir. U.S.D.A. For. Ser. Res. Pap. PNW-154. 44 pp. 12. Lefebvre, E. 1978. How Improper Log Bucking Reduces Lumber Revenues. Canadian Forest I n d u s t r i e s . 98(9):21-25. 13. MacMillan Bloedel Ltd. 1985. Log Grading S p e c i f i c a t i o n s . MacMillan Bloedel L t d . , Powell River Region, Campbell River, B.C. 39 pp. 67 14. . 1985. A Guide to Log Recovery and Log Improvement. MacMillan Bloedel Ltd., F r a n k l i n River D i v i s i o n , B.C. 36 pp. 15. MacMillan Bloedel Research. 1981. C o n f i d e n t i a l Report. Wood Harvesting Research, MacMillan Bloedel Ltd., Vancouver, B.C. 16. McPhalen, J.C. 1978. A Method of E v a l u a t i n g Bucking and Sawing S t r a t e g i e s f o r Sawlogs. M.F. T h e s i s , U n i v e r s i t y of B r i t i s h Columbia, Vancouver, B.C. 124 pp. 17. Matthews, D.M. 1942. Cost Control i n Logging. McGraw-Hill Book Co. Inc., New York. 374 pp. 18. Middleton, G.R. 1981. Log Grade C l a s s i f i c a t i o n o f Coastal Hemlock. F o r i n t e k Canada Corp., Vancouver, B.C. C o n f i d e n t i a l Report. 19. and B.D. Munro. 1985. Product Outturn Values f o r B r i t i s h Columbia Coastal Log Grades : an Information Report. F o r i n t e k Canada Corp., Vancouver, B.C. 32 pp. 20. Ortman, J.L. 1973. Q u a l i t y Control i n the Sawmill f o r Maximum Value. Vancouver Wood Forum, Vancouver, B.C. Nov. 6 pp. 21. Pnevmaticos, S.M. and S.H. Mann. 1973. Dynamic Programming i n Tree Bucking. Forest Products J o u r n a l , 22:26-30. 22. Province o f B r i t i s h Columbia, M i n i s t r y o f F o r e s t s . 1980. Forest S e r v i c e S c a l i n g Manual. V i c t o r i a , B.C. 102 pp. 23. Province of B r i t i s h Columbia, M i n i s t r y o f F o r e s t s . 1985. Allowable Annual Cut Rationale Report. V i c t o r i a , B.C. 145pp. 24. Sokal, R.R. and F.J. Rholf. 1969. Biometry. W.H.Freeman and Company, New York. 859 pp. 25. Turban, E. and J.R. Meredith. 1985. Fundamentals of Management Science. Business P u b l i c a t i o n s Inc., P l a t o , Texas. 821 pp. 26. Wackerman, A.E., W.D. Hagerstein and A.S. M i t c h e l l . 1966. Harvesting Timber Crops. McGraw-Hill Books Co. Inc., New York. 540 pp. 27. Wagner, H.M. 1969. P r i n c i p l e s of Operations Research, with A p p l i c a t i o n s to Managerial D e c i s i o n s . P r e n t i c e - H a l l , Englewood C l i f f s , New Jersey. 937 pp. 28. Walpole, R.E. 1982. I n t r o d u c t i o n to S a t i s f i e s . MacMillan P u b l i s h i n g Co. Inc., New York. 521 pp. 68 29. Wilde, R.E. and C.S. B e i g h t l e r . 1967. Foundations o f Op t i m i z a t i o n . P r e n t i c e - H a l l Inc., Englewoods C l i f f s , New Jersey. 480 pp. 30. Young, G.G. and D.A. Waddell. 1986. A Model f o r the I n t e r a c t i v e O p t i m i z a t i o n o f Log Bucking U t i l i z i n g Dynamic Programming. Research Report, Department of Supplies and Se r v i c e s Contract : lst84-00469. U n i v e r s i t y o f B.C., Vancouver, B.C. 84 pp. 9.2 PERSONAL COMMUNICATIONS 1. Bjarnason, B. 1986. MacMillan Bloedel Ltd., Powell Region Woodlands, Campbell River, B.C. 2. Chaston, P. 1986. Q u a l i t y Control Supervisor, MacMillan Bloedel Ltd., Powell Region Woodlands, Campbell River, B.C. 3. Greenough, R. 1986. MacMillan Bloedel Research, MacMillan Bloedel Ltd., Vancouver,' B.C. 4. Middleton, G.R.. 1986. For i n t e k Canada Corp., Vancouver, B.C. 5. Sauder, B.J. 1986. MacMillan Bloedel Research, MacMillan Bloedel Ltd., Vancouver, B.C. 6. Yamada, M. 1986. MacMillan Bloedel Ltd., Vancouver, B.C. 7. Young, R. 1985. MacMillan Bloedel Ltd., A l b e r n i P a c i f i c D i v i s i o n , Port A l b e r n i , B.C. APPENDIX 1. Map Showing General Study Location. study area l o c a t i o n ' M » R O « I C K E I S L 1 K I I X •7' Kelsey Bay Division M B irUuitfial main roada. active togging, raslnclad accaaa MHH^ H M B tndualnal aacoftdary roadl. activa togging. radrictaQ »CC»M 1 M.S. indutitiai main roadl opan to trallic 24 hour* a Oar ^ ™ M 8. induttnai aacondary road a opan to Irallic 24 hovra a day ™ _ _ _ _ Public reads IT.- ••• ; Othar mdusirial main roads SCSKSMCSB Othar nduatrtai aacondary road* — — — Tr»i(t Roadinamai and/of numbara 62-MAIN LINE Disianca, ahown batwaan dota (in mtlas) • Q • Park and raaarva boundanaa — . — Campsda */ Piemre ailo • Boa • launch a> Pomta of mtaratt and viaarpointa v FOR YOUR SAFETY WATCH FOR THESE SIGNS • _ Thii sign maani lha road n in activa togging uaa. It la ^ * * " A _ siltiar cloaad io public iravai bacauaa ol tha hazard. or * may ba dnvan only during non-oparating hours, • • postad. r This sign maani tha road it opan io public Iraldc but atao la IJ7*^ *v„,IL„, uaad by hasvy vahiclaa. Driva with antra ma caution and always yiatd io togging traffic. KHomatraa 0 1 2 3 4 8 AA MacMillan Bloedel 71 APPENDIX 2. Map Showing Study Area. 72 \ area where tree samples were taken from SCALE 1:3200 APPENDIX 3. Program L i s t i n g s . 74 C:/DAVB >01/05/84 SYSTEM UTILITIES - FILE DISPLAY 22:06:46 C:/DAVE/MAIN.C PAGE 1 /* main.c */ l i n c l u d e <stdio.h> I i n c l u d e <fbuck.h> { i n c l u d e < i b s t r . h > d o a b l e p r i c e _ a r r a y [ 7 8 4 1 ; /* a r r a y o f l o g p r i c e s from d a t a b a s e */ unsig n e d l o n g l e n g t h _ c l a s s _ d e f [ 1 4 ] ; / * a r r a y of l e n g t h c l a s s d e f i n i t i o n s */ unsig n e d l o n g b u t t _ c l a s s _ d e f [ 3 1 ; /* a r r a y o f b u t t d i a m e t e r c l a s s d e f i n i t i o n s */ unsi g n e d l o n g t o p _ c l a s s _ d e f [ 4 1 ; /* a r r a y of t o p d i a m e t e r c l a s s d e f i n i t i o n s */ ex t e r n double i n p u t j a t t e r n O ; /tttttttttttttttttmttttttttttttttttttmttmttttttt MAIS PROGRAM i t t t tmtt t t t tmttmmHHti t t tmt i t t imtt tmt**/ main() I i n t nnmber_inpat; /* number of i n p u t l o g s e c t i o n s */ i n t i n p u t _ q u a l i t y _ a r r a y [ 3 0 ] ; /* i n p u t l o g q u a l i t i e s */ unsig n e d l o n g i n p a t _ l e n g t h _ a r r a y [ 3 0 ) ; /* i n p u t l o g l e n g t h s */ i n t n u m b e r j t a g e s ; /* number of s t a g e s */ unsig n e d l o n g d i a m _ t o p f d i a m _ b u t t ; /* top and b u t t d i a m e t e r s */ unsig n e d l o n g s t a g e _ d i a m e t e r s [ 4 2 0 ] ; /* a r r a y of d i a m e t e r s by s t a g e */ i n t s t a g e _ q u a l i t y [ 4 2 0 J ; /* a r r a y of q u a l i t i e s by s t a g e */ unsig n e d l o n g o p t i m a l _ v o l u m e _ a r r a y [ 4 2 0 ] ; / t a r r a y o f o p t i m a l volumes */ i n t o p t i m a l _ d e c i s i o n _ a r r a y [ 4 2 0 1 ; /* a r r a y o f o p t i m a l d e c i s i o n s */ unsi g n e d l o n g d i a _ s q u a r e [ 4 2 0 ] ; /* a r r a y o f s t a g e d i a m e t e r s s q u a r e d */ i n t ext_number; /* number of e x t r a c t i o n l o g s */ i n t o p t; /* o p t i o n number */ i n t main_opt; /* o p t i o n number */ doubl e e x t _ l e n g t h [ 3 0 ] ; /* e x t r a c t i o n l e n g t h s */ doubl e e x t _ v o l u m e [ 3 0 ] ; /* e x t r a c t i o n volumes */ doubl e o p t _ v a l u e ; double f a l l e r _ v a l u e ; d o u b l e e x t _ v a l u e ; double t j i u m ; d o u b l e e x _ c o s t ; d o u b l e v o l ; c h a r o u t [ 2 0 ] ; 01/05/84 SYSTEM UTILITIES - F I L E DISPLAY 22:06:46 C:/DAVE/MAII.C PAGE 2 75 q t _ o n ( ) ; o p t _ v a l u e = 0.0; f a l l e r _ v a l u e = 0.0; w o r k i n g ! ) ; £ill_array(); d e £ _ c l a s s ( ) ; i n i t i a l i z e ( o p t i m a l _ v o l u m e _ a r r a y , o p t i i a l _ d e c i s i o n _ a r r a y ) ; c p y r t O ; do { q t _ c l s ( ) ; q t _ g o t o x y ( l , l ) ; q t _ p u t s ( " L O G BUCKING" J; q t _ g o t o x y ( l , 2 ) ; q t _ p u t s ( " l . ) s t a r t i n p u t " ) ; qt g o t o x y ( l , 3 ) ; q t _ p u t s ( " 2 . ) q u i t " ) ; q t _ g o t o x y ( l , 4 ) ; q t _ p u t s ( " e n t e r c h o i c e : " ) ; main_opt = g e t c h l ) ; i f ( m a i n j p t == 50){ break; } e l s e { q t _ c l s | ) ; q t g o t o x y ( l , l ) ; } i n p u t f i n p u t _ l e n g t h _ a r r a y , i n p u t _ q u a l i t y _ a r r a y , 4diam_top /Sdiam_butt,«number_inpat,Snumber_stages); w o r k i n g ) ) ; c a l c j i a f s t a g e j i a m e t e r s j d i a j q u a r e j d i a m j o p j d i a m j j u t ^ n u m b e r j t a g e s ) ; c a l c qual(number i n p u t , i n p u t l e n g t h a r r a y , i n p u t q u a l i t y a r r a y , s t a g e q u a l i t y ) ; do{ q t _ c l s ( ) ; q t _ g o t o x y ( l , l ) ; q t _ p u t s ( " l . opt b u c k i n g ' ) ; q t _ g o t o x y ( l , 2 ) ; q t _ p u t s ( " 2 . optimum v a l u e " ) ; 76 01/05/84 SYSTEM UTILITIES - FILE DISPLAY 22:06:46 C:/DAVE/MAIS.C PAGE 3 q t _ g o t o x y ( l , 3 ) ; qt_puts("3. input p a t t e r n " ) ; q t _ g o t o x y ( l , 4 ) ; qt_puts("4. q u i t " ) ; opt = g e t c h f ) ; if (opt == 49){ working!); opt_value = optimize_buckinq(number_stages,stage_diameters f s t a g e _ q u a l i t y , o p t i n i a l _ d e c i s i o n _ a r r a y , optimal_volume_array,dia_square); e x tjumber = t r a c e _ b a c k ( n u i b e r _ s t a g e s , o p t i a a l _ d e c i s i o n _ a r r a y , o p t i i a l _ v o l u m e _ a r r a y , ext_length,ext_voluiae); t_num = extract(ext_length,ext_volume,ext_number); v o l = number_stages * p r i c e j a c t o r * (dia_squareI01 f dia_square(number_st ages)); ext value = v o l * volume_cost + (piece cost * (t num t 1 ) ) ; } /*~end i f opt = 0 */ if (opt - 50){ if (opt_value — 0){ q t _ c l s ( ) ; q t _ g o t o x y ( l , l ) ; qt_puts("optimum v a l u e " ) ; q t _ g o t o x y ( l , 2 ) ; qt_puts("has not been"); q t _ g o t o x y ( l , 3 ) ; q t _ p u t s ( " c a l c u l a t e d " ) ; q t _ g o t o x y ( l , 4 ) ; q t _ p u t s ( " press CR "); g e t c b d ; } else { q t . c l s O ; qt g o t o x y ( l ( l ) ; qt_puts("OPT VALUE :\n"); tcvt(opt_value/100.0,2 (out); q t _ p u t s ( o u t ) ; q t j u t s ( " \ n l e s s cost :\n"); t c v t ( e x t _ v a l u e , 2 , o u t ) ; q t _ p u t s ( o u t ) ; g e t c h f J ; ) } if (opt == 51)1 f a l l e r _ v a l u e = input j a t t e r n ( n u B b e r _ s t a g e s , s t a g e _ d i a i e t e r s , s t a g e _ q u a l i t y , o p t i m a l _ d e c i s i o n _ a r r a y , optimal volume_array,dia square); ) 01/05/84 SYSTEM UTILITIES - FILE DISPLAY C:/DAVE/HAIH.C if (opt == 52){ break; } }while(opt != 52); Iwhile ( m a i n j p t != 50); q t _ c l s ( ) ; q t _ g o t o x y ( i , l ) ; qt_puts("end of run"); } /* end l a i n */ 01/06/84 SYSTEM U T I L I T I E S - F I L E DISPLAY 02:55:29 78 C:/DAVE/MESS.C PAGE 1 /* me s s . c */ { i n c l u d e < s t d i o . h > /mtttttttttmttttttmtmtttmttttitttttttmmt c o p y r i g h t n o t i c e i t t t t t t t t t t t t t J t t t t t l t t t t t t t t J t t t t t t t t t t t t t t i t t t t t t t t t / c p y r t l ) { q t _ c l s ( ) ; q t j o t o x y ( l , l ) ; q t j u t s f " LOG B U C K I S G \ n ' ) ; q t j u t s f " O P T I M I Z A T I O N ^ " ) ; q t j u t s f ' ( C ) COPYRIGHT\n"); q t j u t s l "FORESTRY U . B . C . " ) ; g e t c h f ) ; q t . c l s f ) ; } /* e n d c p y r t */ /tttttttitttttttttttttttttttttttttttttttttttttttttttttttt w o r k i n g m e s s a g e t t t * t * t t t t t t t t t t l t i t t t t t t t t t t J t t t » t t t t » t i l t t t t t t t t l * t t l * t / w o r k i n g ! ) I q t . c l s f ) ; q t _ g o t o x y ( l , l ) ; q t j u t s f " » O R K I N G \ n " ) ; q t _ p u t s ( " P L E A S E F A I T \ n ° ) ; } /* end w o r k i n g */ 79 01/05/84 SYSTEM UTILITIES - F I L E DISPLAY 22:13:23 C:/DAVE/SETUP.C PAGE 1 /* s e t u p . c */ f i n c l u d e <stdio.h> l i n c l o . d e <fbuck.h> t i n c l u d e < i b s t i . h > ( i n c l u d e <var.h> i d e f i n e TRIM 1 / t tmt t t t t t t t t t tmt t t t tmt i t t t t t t tmt t j t f i l l a r r a y w i t h p r i c e s and m u l t i p l y by p r i c e f a c t o r ttttttttttttttttttttttttttttttttttttttttttttttt/ f i l l a r r a y ! ) { i n t i ; /* l o o p c o u n t e r */ for(i=0;i<=755 ; H i ) { p r i c e a r r a y l i ] = 2 4 7 3 . 0 * p r i c e f a c t o r ; } f o r (i=756;i<=783;++i){ p r i c e a r r a y l i ] - 0; } p r i c e _ a r r a y I 6 3 ) = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 6 4 ) = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e a r r a y 1 6 6 ] - 3 5 3 8 . 0 * p r i c e f a c t o r ; for(i=90;i<=93 ; H i ) { p r i c e a r r a y l i ] = 5 0 1 2 . 0 * p r i c e f a c t o r ; } p r i c e a r r a y [ 9 5 ] = 5 0 1 2 . 0 * p r i c e f a c t o r ; for(i=99;i<=102 ; H i ) { p r i c e a r r a y l i ] = 7 2 1 9 . 0 * p r i c e f a c t o r ; ] p r i c e _ a r r a y ! 1 0 4 ] = 5 0 1 2 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 1 1 7 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y ( 1 1 8 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e a r r a y [ 1 2 0 ] = 3 5 3 8 . 0 * p r i c e f a c t o r ; for(i=144;i<=147;++i){ p r i c e _ a r r a y [ i ] = 5 0 1 2 . 0 * p r i c e f a c t o r ; J p r i c e a r r a y ! 1 4 9 ] - 5 0 1 2 . 0 * p r i c e f a c t o r ; for(i=153;i<=156;++i) { p r i c e a r r a y l i ] = 5 0 1 2 . 0 * p r i c e f a c t o r ; } p r i c e a r r a y [ 1 5 8 ] = 5 0 1 2 . 0 * p r i c e f a c t o r ; £or{i=207;i<=210;++i}{ p r i c e a r r a y l i ] = 8 5 9 4 . 0 * p r i c e f a c t o r ; 1 01/05/84 SYSTEM UTILITIES - FILE DISPLAY 22:13:23 C:/DAVE/SETUP.C PAGE 2 p r i c e _ a r r a y [ 2 2 5 1 = 3 5 3 8 . 0 t p r i c e _ f a c t o r ; p r i c e _ a r r a y l 2 2 6 ] = 3 5 3 8 . 0 * p i i c e _ f a c t o r ; p r i c e a r r a y [ 2 2 8 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; for(i=252;i<=255;++i){ p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; I p r i c e a r r a y I 2 5 7 ] = 5012.0*price f a c t o r ; for(i=261;i<=264 ;Hi ) { p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; } p r i c e _ a r r a y [ 2 6 6 ] = 5012.0*price_£actor; p r i c e _ a r r a y [ 2 7 9 ] = 3892.0»price_factor; p r i c e _ a r r a y [ 2 8 0 ] = 3 8 9 2 . 0 * p r i c e ~ f a c t o r ; p r i c e _ a r r a y l 2 8 2 ] = 3 8 9 2 . 0 * p r i c e _ f a c t o r ; for(i=306;i<=309;++i) ( p r i c e a r r a y l i ] = 5513.0*price f a c t o r ; J p r i c e a r r a y [ 3 1 1 ] = 5513.0*price f a c t o r ; f o r ( i = 3 1 5 ; i < = 3 1 8 ; n i ) | p r i c e a r r a y l i ] = 5513.0*price f a c t o r ; I p r i c e _ a r r a y [ 3 2 0 ] = 5 5 1 3 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y l 3 3 3 ] = 3 7 1 5 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y ( 3 3 4 ] = 3 7 1 5 . 0 * p r i c e _ f a c t o r ; p r i c e a r r a y [ 3 3 6 ] = 3715.0*price f a c t o r ; for(i=360;i<=363;++i){ p r i c e a r r a y l i ] = 5266.0*price f a c t o r ; J p r i c e a r r a y [ 3 6 5 ] = 5266.0*price f a c t o r ; for(i=369;i<=372 ;Hi ) { p r i c e a r r a y l i ] = 5266.0*price f a c t o r ; ) p r i c e _ a r r a y ( 3 7 4 ] = 5 2 6 6 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y | 3 8 7 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 3 8 8 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e a r r a y ( 3 9 0 ] = 3 5 3 8 . 0 * p r i c e ~ f a c t o r ; for(i=414;i<=417;++I) { p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; } p r i c e a r r a y | 4 1 9 ] = 5012.0*price f a c t o r ; for(i=423;i<=426 ; H i ) { p r i c e a r r a y l i ] = 7563.0*price f a c t o r ; } p r i c e a r r a y [ 4 2 8 ] = 5012.0*price f a c t o r ; for|i=477;i<=480 ; H i ) | p r i c e a r r a y l i ] = 6875.0*price f a c t o r ; ] p r i c e _ a r r a y [ 4 9 5 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 4 9 6 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 4 9 8 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; 81 01/05/84 SYSTEM UTILITIES - FILE DISPLAY 22:13:23 C:/DAVE/SETUP.C PAGE 3 f o r ( i = 5 2 2 ; i < = 5 2 5 ; B i ) { p r i c e a r r a y l i l = 5012.0*price f a c t o r ; 1 p r i c e array[527] = 5012.0*price f a c t o r ; for(i=531;i<=534;+fi){ p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; 1 p r i c e _ a r r a y [ 5 3 6 J = 5012.0*price f a c t o r ; for(i=585;i<=588 ;Hi){ p r i c e a r r a y l i ] = 6875.0*price f a c t o r ; } p r i c e _ a r r a y [ 6 0 3 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 6 0 4 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e array[60GJ = 3538.0*price f a c t o r ; for(i=630;i<=633;tti){ p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; } p r i c e a r r a y l 6 3 5 ] = 5012.0*price f a c t o r ; f o r (i=639;i<=642;ni){ p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; } p r i c e a r r a y l 6 4 ^ 1 = 5012.0*price f a c t o r ; f o r ( i = 6 9 3 ; i < = 6 9 6 ; H i ) { p r i c e a r r a y l i ] = 6875.0*price f a c t o r ; } p r i c e _ a r r a y [ 7 1 1 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 7 1 2 ] = 3 5 3 8 . 0 * p r i c e _ f a c t o r ; p r i c e _ a r r a y [ 7 1 4 ] = 3538.0*price f a c t o r ; f o r ( i = 7 3 8 ; i < = 7 4 1 ; B i ) { p r i c e a r r a y l i ] = 5012.0*price f a c t o r ; J p r i c e _ a r r a y [ 7 4 3 ] = 5012.0*price f a c t o r ; for(i=747;i<=750;++i){ p r i c e a r r a y l i ] - 5012.0*price f a c t o r ; } p r i c e a r i a y l 7 5 2 ] = 5012.0*price_£actor; } /* end f i l l _ a r r a y */ /JtttttttttttttttlttttttttttttttttttJtlttttti d e f i n e l e n g t h , t o p , b u t t c l a s s e s j t t t t t t t t t t j t t t t t t t t t tmi t t i t t tmmmtsm/ d e f _ c l a s s ( ) i /* a l l l e n g t h c l a s s e s i n do */ 82 01/05/84 C:/DAVB/SBTUP.C SYSTEM UTILITIES - FILE DISPLAY 22:13:23 PAGE 4 length, length, length, length, length, length, length, length, length, length, length, length, length, length. c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s j e f c l a s s def OJ 1] 21 31 41 51 6] 71 8 9 101 1 1 30 36 40 42 48 54 62 64 68 70 TRIM; TRIM; TRIM; TRIM; TRIM; TRIM; TRIM; TRIM; TRIM; TRIM; = 74 t TRIM; = 76 t TRIM; = 80 f TRIM; = 10000 + TRIM; /' diameter c l a s s e s in mm */ b u t t _ c l a s s j e f [ 0 1 = 600; b u t t _ c l a s s j e f [ l l = 10000; b u t t _ c l a s s j e f l 2 ) = 0; t o p _ c l a s s j e f | 0 1 = 200; t o p _ c l a s s J e f [ l l = 600; t o p _ c l a s s J e f [ 2 ) = 10000; t o p _ c l a s s J e f [ 3 1 = 0; 1 /* end d e f _ c l a s s V / t m t t t t t t t t t t t m t t m t m t m t t t m m t t m t t m t t t t t t t t t t t i n i t i a l i z e optimal r e t u r n and optimal volume arrays to 0 tttttttttttttttutttttttttttttttttttttutttttttttttttttttttttt/ i n i t i a l i z e ( o p t i m a l _ v o l u m e , o p t i m a l J e c i s i o n ) unsigned long optimal_volume[4001; i n t o p t i m a l J e c i s i o n [ 2 0 0 1 ; { i n t i ; f o r (i=0 ;i<=201;++i){ optimal volume!i] - 0; 1 for (i=0;i<=201;tti){ o p t i m a l j e c i s i o n l i l - 0; } /* end i n i t i a l i z e */ 01/06/84 SYSTEM UTILITIES - PILE DISPLAY 02:56:27 83 C:/DAVE/IHPUT.C PAGE 1 /* i n p u t . c */ {i n c l u d e <stdio.h> i i n c l u d e <math.h> { i n c l u d e <fbuck.h> I i n c l u d e <ibstr.h> i i n c l u d e <var.h> /tttttt*tttiltttttt*lHttttHtttttttttttttttttttt*t*tt f a l l e r i n p u t f o r b u t t diameter l e n g t h and q u a l i t y t m t t t t t x i x t t x m t t t m t x t m t t m t t t t t t i m t m m i t / i n p u t ( i n p u t _ l e n g t h , i n p u t _ q n a l i t y ; d _ t o p , d _ b u t t , n u m b e r / n o _ s t a g e s ) unsigned long i n p u t l e n q t h [ ]; /' a r r a y of in p u t l e n g t h s */ i n t i n p u t _ q u a l i t y [ l ; /* a r r a y of in p u t q u a l i t i e s */ unsigned long * d _ t o p , * d _ b u t t ; /* top and b u t t diameter */ i n t dumber; /* number of i n p u t l o g s e c t i o n s */ i n t *no_stages; /* number of stages */ { i n t i ; /* loop counter */ unsigned long t o t a l _ l e n g t h ; /* t o t a l t r e e l e n g t h double i n p u t ; /* temporary f l o a t i n g p o i n t v a r i a b l e double h o l d ; /* temporary f l o a t i n g p o i n t v a r i a b l e char i n p u t _ s t r [ 2 0 ] ; /* in p u t s t r i n g b u f f e r */ q t _ g o t o x y ( l , l ) ; qt_puts("BUTT DIA : "); g e t _ n s t r ( i n p u t _ s t r , 1 2 , l ) ; /* get b u t t diameter */ *d_butt = a t o f ( i n p u t _ s t r ) * d i a m e t e r _ c o n v e r s i o n ; /* co n v e r t s t r i n g t o i n t e g e r */ f o r (i=0;i<=MAXQUAL;t+i){ q t _ c l s ( ) ; q t _ g o t o x y ( l , l ) ; qt_puts("CR TO END "); qt g o t o x y [ l , 2 ) ; qt_puts("LENGTH : '); g e t _ n s t r ( i n p u t _ s t r , l l , 2 ) ; /* get l o g l e n g t h sequence */ inpu t = a t o f ( i n p u t _ s t r ) ; /* i n f l o a t i n g p o i n t */ hold = inp u t * l e n g t h _ c o n v e r s i o n ; i n p u t l e n g t h l i ] = h o l d ; /* con v e r t to i n t e g e r */ i f ( i n p u t s t i [ 0 ] = = , \ 0 ' ) { i - = l ; break; } if ( i n p u t l e n g t h l i ] == 0){ i -= 1; break; 1 */ */ 84 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 02:56:27 C:/DAVE/IHPUT.C PAGE qt _ g o t o x y ( l , 3 ) ; q t j u t s l "QUALITY : " ) ; g e t _ n s t r ( i n p u t _ s t r , 1 1 , 3 ) ; /* get q u a l i t y sequence */ input q u a l i t y ! i ] = a t o i { i n p u t s t i ) ; ) q t _ c l s ( ) ; qt g o t o x y ( l , l ) ; q t j u t s C T O P DIA : " ) ; g e t j s t r l i n p u t j t r , 12,1); /* get top d i a i e t e r V *d_top = a t o f ( i n p u t j t r ) ' d i a m e t e r _ c o n v e r s i o n ; /» convert to integer */ 'number = i ; t o t a l J e n g t h = inputjengthl'number I; ' n o j t a g e s = t o t a l j e n g t h / r e s o l u t i o n ; ) /* end input */ / t » t t t t » t t t * t * * t * t t t t t t t t t * * t t t t t t i t t t t * » l t t t t t t t t t t * f l o a t i n g point to s t r i n g conversion t t » t t t t t * t t i t t l t » t t t t t t t t t » t t t » t * t t t t t » i t t t t m t t t t t * / v o i d t c v t l i n p u t j l t , f r a c t i o n , b u f f e r ) double i n p u t j l t ; /* Double value to be converted. */ in t f r a c t i o n ; /* Maximum width allowed f o r r e s u l t . '/ char ' b u f f e r ; /* S t r i n g to put the r e s u l t i n . */ double dtemp; /* Temporary place to play with the value. */ long o r i g i n a l , truncated, new; /* Temporary i n t for conversion purposes. */ in t buf j t r ; /* P o i n t e r to the char i n the b u f f e r . */ int i ; char exchange; /* Temp l o c a t i o n while the buf i s reversed */ dtemp = i n p u t j l t ; /* Get the input double. »/ f o r i i=0; K f r a c t i o n ; i++ ) dtemp *= 10; /' Get the f r a c t i o n s i z e wanted. «/ o r i g i n a l = dtemp; /* Truncate the r e s t . */ buf j t r = 0; /* Point to the f i r s t char i n the b u f f e r . */ 01/06/84 SYSTEM UTILITIES - F I L E DISPLAY 02:56:27 C:/DAVE/IHPUT.C PAGE 3 f o r ( i=0; K f r a c t i o n ; i n ) { new = o r i g i n a l / 1 0 ; t r u n c a t e d = new*10; b u f f e r ( b u f _ p t r H ] = '0* t o r i g i n a l - t r u n c a t e d ; /* C r e a t e the ch a r f o r the b u f f e r . */ /* The ch a r = the l ' s d i g i t p l u s T . */ o r i g i n a l - new; /* Get r i d of the l ' s d i g i t . S t a r t a g a i n . */ I b u f f e r ! b u f _ p t r H ) = ' . ' ; /* I n s t a l l the d e c i i a l p o i n t . */ f o r ( i=0; new>0; i H ) { new - o r i g i n a l / 1 0 ; t r u n c a t e d = new*10; b u f f e r l b u f _ p t r H ] = '0' + o r i g i n a l - t r u n c a t e d ; o r i g i n a l = new; I b u f f e r l b u f _ p t r ] = '\0'; /« I n s t a l l the n u l l byte b e h i n d l a s t char */ b u f _ p t r ~ ; /* P o i n t a t the l a s t d i g i t , not the n u l l . */ f o r t i=0; K b u f j t r ; ) I exchange = b u f f e r l i ] ; /* Get the f i r s t c h a r out o f the way */ b u f f e r l i ] = b u f f e r [ b u f j t r ]; /* Hove l a s t c h a r to f i r s t */ b u f f e r l b u f _ p t r I = exchange; /* Swap the f i r s t c h a r l a s t . */ i n ; /* F i x the v a r i o u s p t r s */ b u f j t r — ; J } /• end t c v t */ /ttttt»jt»t«itttttttttttttttttitttttt»tttttt»tt»tttttt g e t n u i e r i c s t r i n g from ibm keyboard t t t S t J t t t t t t t t t t t t t t t t i t t t J t t t t t t t t t t t t t t t t t t t t t t i t J t * / 86 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 02:56:27 C:/DAVE/INPUT.C PAGE 4 char g e t _ n s t r ( i n s t r i n g , x j o c a t i o n , y j o c a t i o n ) char i n s t r i n g U ; /* input s t r i n g */ int x j o c a t i o n ; /* screen x l o c a t i o n to stop d e s t r u c t i v e backspace */ in t y j o c a t i o n ; /* screen y l o c a t i o n to stop d e s t r u c t i v e backspace */ { i n t j ; /* character counter f o r input b u f f e r s t r i n g '/ char c; /* input character i n char form */ in t ch; /* input character i n integer form */ j = 0; qt bsxyfx l o c a t i o n , y j o c a t i o n ) ; /* set back stop f o r backspace */ while ((ch = g e t c h f ) ) !=CB)f if (ch >= »0' 45 ch <= '9' II ch == ' . M l c = ch; q t j u t c f c ) ; i n s t r i n g U ] = c; J if (ch « BS)f c = ch; qt p u t c ( c ) ; i f (i>=D "ii } ) i n s t r i n g U J = '\0'; } /* end g e t j i s t r */ 0 1 / 0 6 / 8 4 SYSTEM UTILITIES - PILE DISPLAY C:/DAVE/CALC.C PAGE /* c a l c . c */ {i n c l u d e <fbuck.h> ( i n c l u d e < i b s t r . h > l i n c l u d e <vai.h> / t t t t * t t t * t » t t i i t J t i t t t * i « t i » t t m t t t t t t t t t i t * i t i t t t t t t d i a m e t e r sequence c a l c u l a t i o n e x e c t u t e d i n f l o a t i n g p o i n t tttttmttmtttmttmttttttttmtttttttittttttttttt/ c a l c _ d i a ( d i a m e t e r , d _ s q u a r e , d t o p , d b u t t , n o j t a g e s ) u n s i g n e d l o n g d i a m e t e r ! ] ; /* a r r a y of s t a g e d i a m e t e r s */ unsi g n e d l o n g d _ s q u a r e [ ) ; /* a r r a y of s t a g e d i a m e t e r s s q u a r e d */ unsi g n e d l o n g d t o p ; /* top d i a m e t e r */ unsi g n e d l o n g d b u t t ; /* b u t t d i a m e t e r */ i n t n o j t a g e s ; /* number of s t a g e s »/ ! i n t i ; /* lo o p c o u n t e r */ doubl e f p _ b , f p _ t ; /* f l o a t i n g p o i n t b u t t and t o p d i a m e t e r s */ double t a p e r ; /* f l o a t i n g p o i n t t a p e r c o n s t a n t */ double s _ q r ; /* temporary v a r i a b l e f o r s q u a r i n g */ doubl e h o l d f 3 1 ; /* temporary v a r i a b l e f o r s q u a r i n g */ doubl e num; /» f l o a t i n g p o i n t number of s t a g e s V f p j = d b u t t ; /* c o n v e r t b u t t d i a m e t e r t o f l o a t */ f p _ t = dto p ; /* c o n v e r t t o p d i a m e t e r to f l o a t */ num = n o j t a g e s ; /* c o n v e r t number of s t a g e s t o f l o a t */ tap e r = U f p j - fp_t)/num) * 10.0; /* c a l c u l a t e t a p e r */ dia m e t e r l O ] = fp _ b ; /* c a l c u l a t e i n t d i a [ 0 ] V d s q u a r e l O ] = fp b * fp b t 0.5; /' square d i a m e t e r */ hol d 101 = db u t t * 1 0 . 0 ; f o r ( i = l ; i < = n o j t a g e s ; H i ) ! h o l d l l l = hol d [ 0 1 - t a p e r ; /* c a l c u l a t e d i a m e t e r */ d i a m e t e r [ i ] - hold!11/10.0 t 0.5; /* and s q u a r e d d i a m e t e r */ s j r = ( h o l d l l l * h o l d l l l / 100.0) + 0.5; d s q u a r e ! i ] - s q r ; holdI01= h o l d l l l ; 1 } /* end c a l c j i a */ /tmttttttttmtttttttmmtttmtmttttmmttttt q u a l i t y sequence c a l c u l a t i o n ttttmttmtttttmttttttttttiittttttttttHtjtttttttt/ c a l c j u a l ( n o _ i n p u t , l e n g t h , q u a l i t y , s t g _ q u a l i t y ) 88 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 03:06:39 C:/DAVE/CALC.C PAGE 2 i n t n o j n p u t ; /* number of input l og s e c t i o n s */ unsigned long l e n g t h ! ] ; /* input length a r r a y */ int q u a l i t y ! ] ; /* input q u a l i t y a r r a y */ int s t g j u a l i t y ! ] ; /* array of stage q u a l i t i e s */ { i n t c n t , s t a r t , s t o p ; /* loop counters */ int tempi; /* temporary v a r i a b l e for length c a l c u l a t i o n */ in t i , j ; /* loop counters */ tempi - l e n g t h ! 0 ] / r e s o l u t i o n ; /* set counter for number of stages in */ cnt = tempi; /* f i r s t l o g s e c t i o n */ for (i=0;i<=cnt;tti}{ /« f i l l q u a l i t y a r r a y i n f i r s t l o g */ stg q u a l i t y l i ] = q u a l i t y l O ] ; /* s e c t i o n */ } cnt t = l ; stop = cnt; for (i=l;i<=no_input;Hi){ s t a r t = stop; tempi - l e n g t h ! i ] / r e s o l u t i o n ; stop - tempi; stop +=1; for (j=start;i<stop;Hj){ s t g q u a l i t y l j ] = q u a l i t y l i ] ; } "/« end j V } I* end i •/ } /* end c a l c _ q u a l */ 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 02:51:38 C:/DAVE/BUCK.C PAGE 1 /» buck.c «/ {include <stdio.h> {include <math.h> {include <fbuck.b> {include <ibstr.h> {include <var.b> / t t t t t t t t t t t t t t t t t t t t t m t t t t t i t m t t i l t t t i m t m t t t * dynamic program section lt*itttttttlJlJ»tlttt»lttttttt*tttt»t»tttt»t»tllttlttt/ double optiDize_bucking(no_stages,diameter ;quality,opt_decision,opt_volume,d_squ are) int nojtages; /* number of stages */ unsigned long diameter!]; /* stage diameter array */ int qu a l i t y ! ] ; /* stage quality array */ int opt_decision(]; /* optimal decision array */ unsigned long opt_volume[]; /* optimal volume array */ unsigned long d_square(]; /* array of squared diameters */ ! double sort_index(); register int stage; register int decision; struct l o g j d e f i n i t i o n log; unsigned long volume; unsigned long max_ret; /* maximum stage return */ unsigned long dec_ret; /* decision return */ unsigned long opt_vol; /* volume at optimum */ int opt_dec; /* optimum decision */ unsigned long optimal_ret(420]; /* array of optimal return values */ int maxjnc; /* maximum increment */ double value; /* stage return value */ unsigned long temp_hold; int nev_stage; int c u t j o s n ; int prod_posn; unsigned long b u t t j i a ; int i , j ; int stop; int b r e a k j n t ; flo a t f.stage, Mncrement, f_break; unsigned long b_square,t_square; /* squared diameters */ 90 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 02:51:38 C:/DAVE/BUCK.C PAGE 2 optima l _ r e t [ 0 ] - 0; log. l e n g t h - 0; log.top_phi = 0; l o g . butt j h i = 0; l o g . q u a l i t y = 0; value = p r i c e _ a r r a y I 0 ] ; l o g . q u a l i t y = 0; / » t l t l t t t t t t t t t t t t * * t S t t t t l t t t t i i t l t t » J t l l « t * t t t t t t t t * t t t t t i * * t set up for d e c i s i o n = stage a t lengths l e s s than f i r s t l o g production length * i t t t t t t t l t t i t t l t t i l i t t t t t t J t t t t t t t t t t t l t t » t t t t J » l t t t t » t t » t t t t » t t / stop = l e n g t h _ c l a s s _ d e f [ 0 ] - 1; if (no_stages < length_class_def(01){ stop - no stages; 1 f o r (stage=l;stage<=stop;++stage){ opt_volume[stage] = stage * (d_square(01 t d j q u a r e ( s t a g e l ) ; o p t i m a l _ r e t ( s t a g e ] = opt_volume(stage] * value; o p t _ d e c i s i o n ( s t a g e ] = stage; } /* end stage loop < l e n g t h _ c l a s s _ d e f [ 0 ] */ l o g . c o r r e c t i o n = 0; stop = l e n g t h _ c l a s s _ d e f [ 0 1 ; if (no_stages >= Iength_class_def(0]){ for (stage=length_class_def[0];stage<= no_stages;Hstage){ l o g . t o p j h i - diameter [stage ]; t j q u a r e = d j q u a r e [ s t a g e ] ; i a x _ r e t = 0; opt_dec = 0; opt_vol = 0; l o g . q u a l i t y = 0; log. l e n g t h = 0; if (stage < 81)1 max inc = stage; } else maxjnc = 81; f o r ( d e c i s i o n = l ; d e c i s i o n <=max_inc;++decision)l n e v j t a g e = stage t 1 - d e c i s i o n ; c u t j o s n = stage - d e c i s i o n ; log.butt j h i = diameter (cut _posn]; b_square = d_square[cut_posnl; log.length - d e c i s i o n ; l o g . p r o d u c t i o n j e n - l o g . l e n g t h ; if ( l o g . q u a l i t y < quality(new_stage]){ l o g . q u a l i t y - q u a l i t y l n e v s t a g e ] ; } 91 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 02:51:38 C:/DAVE/BUCK.C PAGE 3 value = sortJndex(Slog); i f (value <= price_array[0]){ /* pulp log */ volume = log.length * (b_square t t_square); else { prod_posn - stage - log.productionjen; b_square = d_square[prodjosnl; volume - log.production len * (b square + t square); 1 tempjold = volume * value; /* floating point calculation */ dec ret = temp hold t optimal_ret[cut_posn]; i f [stage > 13)I i f (dec_ret >= max_ret)( max_ret = dec_ret; o p t j e c = decision; opt vol = volume; } 1 /* end for decision */ optimal_ret[stage] = max_ret; opt_decision[stage] - o p t j e c ; opt_volume[stage] - opt_vol; i f (stage > 79)( } } /* end stage */ } /• end i f */ return(optimal_ret[no_stagesl); J /*end optimize_bucking */ 92 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 02:46:01 C:/DAVE/EXTRACT.C PAGE 1 /* extract.c */ {include <stdio.h> (include <math.h> (include <fbuck.h> (include <ibstr.h> Iinclude <var.b> / t t t t t i t t t t t t » t t t * * * * t t t t * j f t i t t t t t t t t t i t t t t i t t t t » t j t * t * t i traceback to re-reference extraction lengths and volumes x i m x x m i m x t t t t t t i i t m t t x i i m i x i m t m x t m t t t t m t / trace_back(no_stages,opt_dec,opt_vol,ext_len,ext_vol) int nojtages; /* number of stages */ int o p t j e c l ] ; /* optimal decision array */ unsigned long opt_vol[]; /* optimal volume array */ double e x t j e n d ; /* array of extraction lengths */ double ext_vol(]; /* array of extraction volumes */ I int i , j , k ; /» loop counters */ int decision!30]; /* decision array traced from optimal bucking */ double volume[301; /* volume array referenced to decision */ char out(20]; /* output string */ i = no stages; k = i f while (opt_dec[il !- OH /* traceback optimal bucking decision */ j = i ; /* path starting at stage n (top) and V i = j - o p t j e c l j l ; /* working to stage 0 */ decisionlk] = o p t j e c l j I; volume[k] = opt_vol[j]; ttk; } k -=1; e x t j e n ( l ) = decisionlk] * resolution; /* re-reference extraction */ ext _ v o l [ l l = volumelk] tprice_factor; /* lengths starting at butt */ for ( i = 2; i<= k;++i)( /* for extraction optimization */ e x t j e n ( i ) = dec i s i o n l k - i r l ] * resolution; ext v o l l i l = volume[k-i+l]*price factor; } q t . c l s l ) ; qt_gotoxy(l,l); qt_puts("BUCKING LENGTHS"); qt_gotoxy(l ;2); for(i=l;i<=k;+H){ 93 01/06/84 SYSTEM UTILITIES - F I L E DISPLAY 02:46:01 C:/DAVE/fiXTRACT.C PAGE 2 i f f i -- 3)1 qt g o t o x y ( l , 3 ) ; } ifIi « 5)1 qt gotoxy(l,4); } t c v t ( e x t _ l e n ! i l / l e n g t h _ c o D v e r s i o n , 2 , o u t ) ; /* d i s p l a y o p t i m a l bucking */ q t j u t s ( o u t ) ; /* pattern on screen */ q t j u t s l • ' ) ; I g e t c h f ) ; r e t u r n ( k ) ; ) /* end tr a c e j a c k * / / tmt t t t t t t t t t t t t t i t tmtt t t t t t t t t tmtt t t t t t t t t t t t t t E x t r a c t i o n O p t i m i z a t i o n ttttttttttttttttttttttttttttttttttttttttttttttttttttttf d o u b l e e x t r a c t ( e x _ l e n g t h , e x _ v o l u m e , n u m b e r ) d o u b l e e x j e n g t h l l ; /* a r r a y of e x t r a c t i o n l e n g t h s */ doubl e e x j o l u m e f l ; /* a r r a y of e x t r a c t i o n volumes */ i n t number; /* number of e x t r a c t i o n s e c t i o n s */ f i n t i , j , k ; /* l o o p c o u n t e r s */ doubl e o p t i m a l j o s t ( 3 0 1 ; /* o p t i m a l c o s t a r r a y */ doubl e o p t i m a l _ l e n g t h ( 3 0 1 ; /* o p t i m a l l e n g t h a r r a y */ doubl e o p t _ p o s i t i o n [ 3 0 1 ; /* o p t i m a l p o s i t i o n a r r a y */ i n t o p t _ d e c i s i o n [ 3 0 1 ; /* o p t i m a l d e c i s i o n a r r a y */ doubl e m i n c o s t ; /* minimum c o s t */ doubl e b u c k j e n g t h ; /* e x t r a c t i o n b u c k i n g l e n g t h */ doubl e l e n g t h _ d e c ; /* d e c i s i o n l e n g t h */ doubl e v o l u m e J e c ; /* d e c i s i o n volume */ double e x t j o s t ; /* e x t r a c t i o n c o s t */ char o u t E 2 0 ] ; /* ou t p u t s t r i n g */ op t i m a l _ c o s t ( 0 1 -0.0; e x _ l e n g t h [ 0 1 = 0.0; ex_volume[01 =0.0; o p t _ d e c i s i o n [ 0 1 = 0; o p t i m a l _ l e n g t h [ 0 1 = 0.0; m i n c o s t = 10000.0; f o r ( i=l;i<=number;+ti){ m i n c o s t - 10000.0; 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 02:46:01 C:/DAVE/EXTRACT.C PAGE opt_decisionIi] = 1; buckjength = 0 . 0 ; for [j=l;j<=i;nj){ l e n g t h j e c = 0 . 0 ; /* for each optima bucking */ volume J e c - 0 . 0 ; /* length calculate decision */ /* lengths and volumes */ for (k =0; k<=j-l;+fk)l l e n g t h j e c = l e n g t h j e c + ex_length(i-k]; volume dec - volume dec t ex volume!i - k l ; } /* end for k */ " /* calculate extraction cost */ ext_cost = volume_dec * volume_cost t piece_cost + o p t i m a l _ c o s t [ i - j l ; /* penalty function for < or > min or max log lengths */ i f ( l e n g t h j e c > max_extract_length II l e n g t h j e c < min_extractjength)( ext_cost = ext_cost * 1 0 0 0 0 . 0 ; i f (ext_cost <= mincostll aincost = ext_cost; buckjength = l e n g t h j e c ; opt d e c i s i o n l i ] - j ; } /* end i f */ } /* end for j */ optimal_cost[ij = mincost; optimal lengthli] - buck length; } /* end for i */ ex_length [0 ] = optimalJengthlnumber); /* traceback to find optimal */ i = number - opt decisionlnumber]; /* extraction pattern */ 3 = i ; while (optimal J e n g t h l i ] 0 . 0 ){ ex length!j] - optimal length[opt d e c i s i o n ( i ) ] ; i = i - opt d e c i s i o n l i ] ; J o p t j o s i t i o n l O ] = optimal J e n g t h l O l ; /* calculate extraction position */ for(i=l;i<=j;Hi){ o p t j o s i t i o n l i ] = opt_position(i-l] + optimal J e n g t h l i ] ; f o r l i i = 0 ; i < = j ; t t i ) l o p t i m a l j e n g t h l i ] = ex_length[j-i]; q t . c l s O ; qt_gotoxy(l,l); 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 02:46:01 C:/DAVE/EXTRACT.C PAGE 4 q t j u t s l ' e x t r a c l e n g t h " ) ; /* output e x t r a c t i o n log lengths */ qt_ g o t o x y ( l , 2 ) ; £or(i=0;i<=j;++i){ if ( i == 2){ qt g o t o x y ( l , 3 ) ; 1 if ( i == 4){ qt g o t o x y ( l , 4 ) ; 1 t c v t ( o p t i m a l _ l e n g t h I i ) / l e n g t h _ c o n v e r s i o n , 2 ; o u t ) ; q t j u t s ( o u t ) ; q t j u t s l " " ) ; 1 g e t c h l ) ; q t j l s l ) ; q t _ g o t o x y ( l , l ) ; q t j u t s l ' e x t r a c p o s i t i o n " ) ; /* output e x t r a c t i o n bucking p o s i t i o n */ q t j o t o x y ( l , 2 ) ; for(i=0;i<=j;+ti){ i f ( l « 2)1 q t j o t o x y ( l , 3 ) ; ) if ( i ==4J{ qt g o t o x y ( l , 4 ) ; I t c v t l o p t j o s i t i o n l i I/length j o n v e r s i o n , 2 , o u t ) ; q t j u t s ( o u t ) ; q t j u t s l " " ) ; 1 g e t c h f ) ; mincost - j ; re t u r n ( m i n c o s t ) ; } /* end e x t r a c t */ 96 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 03:09:43 C:/DAVE/PATTBRN.C PAGE 1 /* p a t t e r n . c */ I i n c l u d e <stdio.h> I i n c l u d e <math.h> i i n c l u d e <fbuck.h> I i n c l u d e < i b s t r . h > I i n c l u d e <var.h> /ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt CONSTRAINED VALUATION ALGORITHH tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt/ d o u b l e i n p u t j a t t e r n ( n u m b e r _ s t a g e s , s t a g e _ d i a m e t e r s , s t a g e _ q u a l i t y , o p t i m a l _ d e c i s i o n _ a r r a y , o p t i i a l _ v o l u i e _ a r r a y , d i a _ s q u a r e ) i n t number_stages; u n s i g n e d l o n g s t a g e J i a m e t e r s U ; i n t s t a g e j j u a l i t y i l ; i n t o p t i a a l _ d e c i s i o n _ a r r a y [ ] ; u n s i g n e d l o n g o p t i m a l _ v o l u m e _ a r r a y [ ] ; u n s i g n e d l o n g d i a j q u a r e l l ; I i n t i , j , k ; i n t number; i n t num; i n t c o u n t ; i n t s t a r t , s t o p ; double i n p u t ; d o u b l e h o l d ; u n s i q n e d l o n g b u c k _ l e n g t h [ 1 2 ) ; double v o l ; uns i g n e d l o n g l e n g t h ; double t o t a l _ v a l u e ; double v a l u e ; d o u b l e t o t a l _ c o s t ; double c o s t ; u n s i g n e d l o n g d i a m e t e r [ 4 2 0 ] ; u n s i g n e d l o n g volume 14201; u n s i g n e d l o n g square 1420]; i n t d e c i s i o n [ 4 2 0 1 ; i n t q u a l i t y [ 4 2 0 j ; char i n p u t _ s t r l 2 0 ] ; char o u t [ 2 0 1 ; 01/06/84 SYSTEM UTILITIES - PILE DISPLAY 0 3 : 0 9 : 4 3 C:/DAVE/PATTERN.C PAGE 2 total_value = 0.0; t o t a l j o s t = 0.0; input = 0.0; hold = 0.0; f o r d = 0;i<= MAXQUAL;Bi)| q t _ c l s ( ) ; q t j o t o x y ( l , l ) ; q t j u t s l "CR TO END " ) ; qt gotoxy(l,2); q t j u t s l "LENGTH : " ) ; g e t j s t r ( i n p u t j t r , l l , 2 ) ; /* get log length sequence */ input = a t o f ( i n p u t j t r ) ; /* in floating point */ hold = input * lengthjonversion; buck length!i) = hold; /* convert to integer */ i f (input strl0]=='\0 ,)l i-=l; break; } i f (buck length!!] == 0)1 i -= 1; break; 1 1 /* end for */ q t j l s O ; working!J; number = i ; total_value = 0.0; t o t a l j o s t = 0.0; start = 0; for(j=0;i<=number;ft]'){ stop - start + buck length!j]; k = 0; count = stop - start; for ( i = start;i<= stop;Bi){ diameter[k] - stage j i a m e t e r s l i ] ; volumelk] = optimal_volumejrray|il; squarelk] = d i a j q u a r e ( i ) ; decisionlkl = optimal_decision_array[i]; qualitylk] = stage j u a l i t y M J ; Hk; } /* end i •/ start = stop; value - optimizejackingfcount,diameter,quality, decision,volume,square); t o t a l value = to t a l value + value; } /*"end j * / vol = numberjtages 1 p r i c e j a c t o r * IdiajquarelO] + diajquarelnumberjtagesl); 98 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 03:09:43 C:/DAVE/PATTERN.C PAGE 3 total_cost = vol * volume_cost t (piece_cost * (number * 1)); total_value = total_value/100.0; q t _ c l s ( ) ; qt_gotoxy(l,l); q t j u t s l "TOTAL VALUE :\n"); tcvt(total_value,2,out); q t j u t s ( o u t ) ; q t j u t s ( " \ n t o t a l cost :\n°); t c v t ( t o t a l j o s t , 2 , o u t ) ; q t j u t s ( o u t ) ; getchl); return!total_value); 1 01/05/84 SYSTEM UTILITIES - FILE DISPLAY C:/DAVE/SORTER.C /* s o r t e r . c */ f i n c l u d e <fbuck.h> I i n c l u d e < i b s t r . h > { i n c l u d e <var.h> / t t t t t t m t t t s t t t m m t t t t t t t m m t t t m t t m m t t t t t s o r t to f i n d index * * * i t t t t t t t J t * t t t * t t t t i t t * * t t t * t t t t t t t t t t * t t t t J t * t t J t t t / double s o r t _ i n d e x ( i n p u t _ l o g ) s t r u c t l o g _ d e f i n i t i o n * i n p u t _ l o g ; { i n t i n d e x ; /* lo o p counter */ i n t l e n _ c l a s s , b u t _ c l a s s , t p _ c l a s s ; /* c l a s s c o u n t e r s */ i n t o f f s e t ; /* a r r a y index */ double v a l ; /* d o l l a r v a l u e */ index = -1; /* f i n d index f o r l e n g t h c l a s s */ do! t t i n d e x ; } w h i l e ( i n p u t _ l o g - > l e n g t h >= l e n g t h _ c l a s s _ d e f ( i n d e x j ) ; l e n _ c l a s s = index; i f I l e n _ c l a s s > 0){ i n p u t _ l o g - > p r o d u c t i o n _ l e n = l e n g t h _ c l a s s _ d e f [ l e n _ c l a s s - l ] i n p u t l o g - > c o r r e c t i o n = in p u t l o g - > p r o d u c t i o n l e n ; } index = -1; dof /* find index for butt diameter class */ Hindex; }while(input_log->buttjhi >= butt_class_def[index]); but_class = index; index = -1; dof /* find index for top diameter class */ Hindex; }«hile(input_log->top_phi >= top_class_def[index]); tp_class = index; offset = len_class*multiplier2 t /* calcualte array index */ but_class*multiplierl t tp_class*no_guality_class + input_log->quality; val = price_array[offset]; /* look up price */ 100 01/05/84 SYSTEH UTILITIES - FILE DISPLAY 22:11:20 C:/DAVE/SORTER.C PAGE 2 retutn(val); } /* end sort_index */ 101 01/06/84 SYSTEM U T I L I T I E S - F I L E DISPLAY 03:13:06 C:/DAVE/STDIO.H PAGE 1 /* * s t d i o . h t * d e f i n e s t h e s t r u c t u r e u s e d by t h e l e v e l 2 I/O ( " s t a n d a r d I/O") r o u t i n e s * and some o f t h e a s s o c i a t e d v a l u e s and m a c r o s , i * ( C ) C o p y r i g h t M i c r o s o f t C o r p o r a t i o n 1984, 1985 */ { d e f i n e BUPSIZ 512 ( d e f i n e J F I L E 20 t d e f i n e F I L E s t r u c t J o b u f . d e f i n e EOF (-1) l i f d e f M J 8 6 L H ( d e f i n e NULL 0L f e l s e ( d e f i n e NULL 0 ( e n d i f e x t e r n F I L E { c h a r * _ p t r ; i n t _ c n t ; c h a r * _ b a s e ; c h a r _ f l a g ; c h a r f i l e ; } J o b i j F I L E ) ; ( d e f i n e s t d i n ( & _ i o b [ 0 1 ) ( d e f i n e s t d o u t ( S _ i o b ( l l ) ( d e f i n e s t d e r r ( i _ i o b [ 2 I ) t d e f i n e s t d a u x ( & _ i o b ( 3 1 ) ( d e f i n e s t d p r n ( & _ i o b [ 4 1 ) ( d e f i n e J O R E A D 0x01 ( d e f i n e _IO»RT 0x02 ( d e f i n e IONBF 0x04 ( d e f i n e J O M Y B U F 0x08 ( d e f i n e IOEOF 0x10 ( d e f i n e IOERR 0x20 ( d e f i n e J O S T S G 0x40 ( d e f i n e J O R V 0x80 ( d e f i n e g e t c ( f ) ( — ( f ) - > _ c n t >= 0 ? O x f f s *(f)->_ptm : f i l b u f ( f ) ) I d e f i n e p u t c ( c , f ) ( - - ( f ) - > c n t >= 0 ? O x f f S (*(f)->_ptm -- ( c ) ) : \ f l s b u f ( ( c ) , ( f ) ) ) (define getcharO g e t c ( s t d i n ) (define putchar(c) putc((c),stdout) 01/06/84 SYSTEH UTILITIES - FILE DISPLAY C:/DAVE/STDIO.H (define feof(f) |(f)->_flag i JOEOF) Idefine ferror(f) ((f)-> flag S JOERR) (define f i l e n o ( f ) [ ( f ) - > _ f i l e ) /* fnnction declarations for those vho vant strong type checking * on arguments to l i b r a r y function c a l l s V ( i f d e f LINTJRGS /* arg. checking enabled */ void clearerr(FILE * ) ; int fclose(FILE * ) ; int f c l o s e a l l ( v o i d ) ; FILE *fdopen(int, char * ) ; int fflush(FILE * ) ; int fgetclFILE * ) ; int fgetchar(void); char *fgets(char *, i n t , FILE * ) ; int f l o s h a l l ( v o i d ) ; FILE *fopen(char *, char * ) ; int fprintf(FILE *, char *, ); int f p u t c l i n t , FILE * ) ; int fputchar(int); int fputs(char *, FILE * ) ; int freadfchar *, int, int, FILE * ) ; FILE *freopen(char *, char FILE * ) ; int fscanf(FILE *, char *, ); int fseek(FILE *, long, i n t ) ; long f t e l l f F I L E * ) ; int fwrite(char *, i n t , i n t , FILE * ) ; char *gets(char * ) ; int getw(FILE * ) ; int printflchar *, ); int puts(char * ) ; int putwtint, FILE * ) ; int re«ind(FILE * ) ; int scant(char *, ); void setbuf(FILE *, char * ) ; int sprintflchar *, char *, ); int sscanflchar *, char *, ); int ungetcfint, FILE * ) ; (else /* arg. checking disabled - declare return type V extern FILE 'fopenO, *freopent), *fdopen(); extern long f t e l l O ; extern char *gets(), *fgets(); (endif /* LIHTJRGS */ 103 Ql/06/84 SYSTEH UTILITIES - PILE DISPLAY 03:15:42 C:/DAVE/HATH.H PAGE 1 /* * math.b i * constant definitions and external subroutine declarations for the math * subroutine l i b r a r y , t * Copyright (C) Microsoft Corporation, 1984 */ /* d e f i n i t i o n of exception struct - this struct i s passed to the matherr * routine vhen a floating point exception is detected V struct exception { int type; /* exception type - see below */ char •name; /* name of function where error occured */ double argl ; /* f i r s t argument to function */ double arg2; /* second argument ( i f any) to function */ double retval; /* value to be returned by function */ I ; /* d e f i n i t i o n of a complex struct to be used by those who use cabs and * want type checking on their argument */ struct complex { double x,y; /* real and imaginary parts */ 1 ; /* Constant definitions for the exception type passed in the exception * struct. */ (define DOMAIN 1 /* argument domain error */ (define SING 2 /* argument singularity */ (define OVERFLOW 3 /* overflow range error */ (define UNDERFLOW 4 /* underflow range error */ (define TLOSS 5 /* t o t a l loss of precision */ (define PLOSS 6 /* p a r t i a l loss of precision */ /* d e f i n i t i o n of HUGE - a value return in case of error by a number of * the floating point math routines */ extern double HUGE; /* function declarations for those who want strong type checking * on arguments to l i b r a r y function c a l l s V 104 01/06/84 SYSTEH UTILITIES - F I L E DISPLAY 03:15:42 C:/DAVE/HATH.H PAGE 2 t i f d e f LIHT_ARGS /* a r g . c h e c k i n g e n a b l e d */ dou b l e a c o s ( d o u b l e ) ; d o u b l e a s i n ( d o u b l e ) ; d o u b l e a t a n ( d o u b l e ) ; d o u b l e a t a n 2 ( d o u b l e , d o u b l e ) ; double a t o f ( c h a r * ) ; d o u b l e c a b s ( s t r u c t complex); d o u b l e c e i l ( d o u b l e ) ; d o u b l e c o s ( d o o b l e ) ; d o u b l e c o s h ( d o u b l e ) ; d o u b l e e x p ( d o u b l e ) ; double f a b s ( d o u b l e ) ; d o u b l e f l o o r ( d o u b l e ) ; d ouble fmod(double, d o u b l e ) ; d o u b l e f r e x p l d o u b l e , i n t * ) ; d o u b l e h y p o t ( d o u b l e , d o u b l e ) ; double j O ( d o u b l e ) ; d o u b l e j l ( d o u b l e ) ; d o u b l e j n l i n t , d o u b l e ) ; d o u b l e l d e x p l d o u b l e , d o u b l e ) ; d o u b l e l o g ( d o u b l e ) ; d o u b l e l o g l O ( d o u b l e ) ; i n t m a t h e r r ( s t r u c t e x c e p t i o n * ) ; d o u b l e modf(double, double * ) ; d o u b l e p o v t d o u b l e , d o u b l e ) ; d o u b l e s i n ( d o u b l e ) ; d o u b l e s i n h ( d o u b l e ) ; d o u b l e s q r t ( d o u b l e ) ; d o u b l e t a n ( d o u b l e ) ; d o u b l e t a n h ( d o u b l e ) ; d o u b l e y O ( d o u b l e ) ; d o u b l e y l ( d o u b l e ) ; d o u b l e y n ( i n t , d o u b l e ) ; i e l s e /* a r g . c h e c k i n g d i s a b l e d , d e f i n e r e t u r n t y p e */ e x t e r n d o u b l e a c o s ( ) , a s i n ( ) , a t a n ( ) , a t a n 2 ( ) ; e x t e r n d o u b l e c o s ( ) , s i n ( ) , t a n ( ) ; e x t e r n double c o s h ( ) , s i n h O , t a n h O ; e x t e r n d o u b l e a t o f ( ) ; e x t e r n double j O O , j l ( ) , j n ( ) , y O O , y l ( ) , y n ( ) ; e x t e r n d o u b l e c e i l ( ) , f a b s O , f l o o r ! ) , f m o d l ) ; e x t e r n d o u b l e e x p ( ) , l o g ( ) , l o g l O O , p o v ( ) , s q r t ( ) ; e x t e r n double f r e x p O , I d e x p O , m o d f ( ) ; e x t e r n d o u b l e h y p o t l ) , c a b s l ) ; l e n d i f /* LIHT_ARGS */ 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 03:19:01 C:/DAVB/VAR.H PAGE 1 /* vat.h */ /* external declarations for a l l functions */ extern float price_array[760); /* array of log prices from database */ extern int length_class_defU4J; /* array of length class definitions */ extern int butt_class_def[3]; /* array of butt diameter class definitions */ extern int top_class_def[41; /* array of top diameter class definitions */ 106 01/06/84 SYSTEH UTILITIES - FILE DISPLAY 03:25:31 C:/DAVE/IBSTR.H PAGE 1 /* ibstr.h «/ / t t t t t t t t t t t t » t t t t t t t t l t t t t l t * t « t * t l l t i t l t t l i i t t t t t t l t t t l i s t of a l l external functions called by bucking program t m t t t m t i m t t t t t t t t t m t m m i t s t t t t t t t t t t j t m i t t t / extern c p y r t l ) ; /* display copyrigth notice */ extern f i l l _ a r r a y ( ) ; /* fill price array */ extern def_class(); /» define l,b,t classes */ extern i n i t i a l i z e d ; /* i n i t i a l i z e main arrays */ extern input!); /* f a l l e r input */ extern working!); /* working message */ extern calc_dia(); /* calculate stage diameters */ extern calc_qual(); /* calculate stage q u a l i t i e s */ extern double optimize_bucking(); /* dynamic program (bucking) */ extern trace_back(); /* optimal decision traceback */ extern extract!); /* dynamic program (extraction) */ extern void t c v t O ; /* general conversion ftoa */ extern double sort_index(); /* sort routine */ extern char get_nstr(); /* get key board numeric s t r i n g */ 1 0 7 01/06/84 SYSTEH UTILITIES - PILE DISPLAY 03:26:41 C:/DAVE/FBUCK.H PAGE 1 /* fbuck.h */ ( d e f i n e m a x _ l o g _ l e n g t h 80 /* maximum l o g l e n g t h - 80 dm */ I d e f i n e r e s o l u t i o n 1 /* s t a g e r e s o l u t i o n = 10 dm */ /* maximum l o g in c r e m e n t i n s t a g e s */ ( d e f i n e m a x j o g i n c ( m a x _ l o g _ l e n g t h / r e s o l u t i o n ) I d e f i n e volume_cost 12.77 /* e x t r a c t i o n volume c o s t */ I d e f i n e p i e c e _ c o s t 14.00 /* e x t r a c t i o n p i e c e c o s t */ I d e f i n e m a x _ e x t r a c t _ l e n g t h 168.0 /* maximum e x t r a c t i o n l e n g t h */ I d e f i n e m i n _ e x t r a c t _ l e n g t h 36.0 /* minimum e x t r a c t i o n l e n g t h */ ( d e f i n e d i a m e t e r _ c o n v e r s i o n 10.0 /* c o n v e r s i o n f a c t o r cm to mm */ I d e f i n e l e n g t h _ c o n v e r s i o n 10.0 /* c o n v e r s i o n f a c t o r m to dm */ ( d e f i n e v a l u e _ c o n v e r s i o n 1.0 /* c o n v e r s i o n $/m3 t o c/m3 */ I d e f i n e cm_m_conversion 10000.0 /* c o n v e r s i o n cm2 t o m2 */ ( d e f i n e mm_conversion 1000.0 /* c o n v e r s i o n mm2 t o m2 */ I d e f i n e dm_conversion 10.0 /* c o n v e r s i o n dm to m */ ( d e f i n e s c a l e f a c t o r (mm conversion'mm c o n v e r s i o n ^ c o n v e r s i o n ) I d e f i n e p i 3.14159265359~ I d e f i n e p r i c e j a c t o r ( p i / ( 8 . 0 * s c a l e _ f a c t o r ) ) I d e f i n e n o _ l e n g t h _ c l a s s 13 /* number of l e n g t h c l a s s e s */ I d e f i n e n o _ b u t t _ c l a s s 2 /* number of b u t t d i a m e t e r c l a s s e s */ I d e f i n e n o _ t o p _ c l a s s 3 /* number o f t o p d i a m e t e r c l a s s e s V I d e f i n e n o _ g u a l i t y _ c l a s s 9 /* number o f q u a l i t y c l a s s e s */ /* m u l t i p l i e r f o r c a l c u l a t i n g a r r a y o f f s e t */ I d e f i n e m u l t i p l i e r l ( n o _ q u a l i t y _ c l a s s t n o _ t o p _ c l a s s ) /* m u l t i p l i e r f o r c a l c u l a t i n g a r r a y o f f s e t */ I d e f i n e m u l t i p l i e d ( m u l t i p l i e r l * n o _ b u t t _ c l a s s ) I d e f i n e CR OxOD I d e f i n e BS '\b* I d e f i n e MAIQUAL 30 s t r u c t l o g _ d e f i n i t i o n { u n s i g n e d l o n g l e n g t h ; u n s i g n e d l o n g t o p _ p h i ; u n s i g n e d l o n g b u t t j h i ; i n t q u a l i t y ; i n t c o r r e c t i o n ; u n s i g n e d l o n g p r o d u c t i o n l e n ; ); 108 01/06/84 SYSTEM UTILITIES - FILE DISPLAY 03:18:28 C:/DAVE/QTERH.H PAGE 1 e x t e r n i n t g o t o x y O ; e x t e r n i n t c n r _ o f f ( ) ; e x t e r n i n t c u r _ o n ( ) ; e x t e r n i n t c l s ( ) ; 

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
https://iiif.library.ubc.ca/presentation/dsp.831.1-0097608/manifest

Comment

Related Items