Changeset 2688 for simo


Ignore:
Timestamp:
01/13/12 00:33:29 (4 months ago)
Author:
jouni
Message:

fix: log reduction if only log exists (not any pulp) - trees with big dbh and little height

File:
1 edited

Legend:

Unmodified
Added
Removed
  • simo/trunk/simulator/models/operation/harvestop.py

    r2596 r2688  
    765765                                              bmassortmentlabel) 
    766766             
     767            # pulp price 
     768            for row in pricematrix: 
     769                if row[0]==pulplabel: 
     770                    pulp_price=row[-1] 
     771                    break 
     772                else: 
     773                    continue 
     774                 
    767775            # Do the tree level log reduction for each of the assortments 
    768776            if self.hdata.cdata['log_reduction_type'] in (1,3): 
    769777                timber = self._log_reduction(timber, sp, pulplabel, 
    770                                              bmassortmentlabel, log_reduction) 
     778                                             bmassortmentlabel, log_reduction, pulp_price) 
    771779            # Do the regional log reduction for each of the assortments 
    772780            if self.hdata.cdata['log_reduction_type'] in (2,3): 
    773                 timber = self._regional_log_reduction(timber, sp, pulplabel) 
     781                timber = self._regional_log_reduction(timber, sp, pulplabel, pulp_price) 
    774782             
    775783        return stemvol 
     
    989997        return hs 
    990998 
    991     def _log_reduction(self, timber, species, pulplabel, bmassortmentlabel, log_reduction): 
     999    def _log_reduction(self, timber, species, pulplabel, bmassortmentlabel, log_reduction, pulp_price): 
    9921000        """ 
    9931001        reduce the bucked volume and value of logs with a given reduction 
     
    9951003        volumered = 0.0  # total volume removed from log assortments 
    9961004        redp = log_reduction 
    997         totprice = 0.0 
    998         totvol = 0.0 
    9991005        for assortment, values in timber.iteritems(): 
    10001006            # reduce the volume only if not pulp or biomass assortment 
     
    10041010            values[0] *= redp  # reduce the volume by percentage 
    10051011            values[1] *= redp  # reduce the value by percentage 
    1006             totprice += values[1] 
    1007             totvol += values[0] 
    10081012        if volumered > EPSILON and timber[pulplabel][0] > 0: 
    10091013            increase = 1 + volumered / timber[pulplabel][0] 
     
    10121016        elif volumered > EPSILON: 
    10131017            timber[pulplabel][0] = volumered 
    1014             timber[pulplabel][1] = totprice / totvol 
     1018            timber[pulplabel][1] = volumered*pulp_price 
    10151019        return timber 
    10161020 
    1017     def _regional_log_reduction(self, timber, species, pulplabel): 
     1021    def _regional_log_reduction(self, timber, species, pulplabel, pulp_price): 
    10181022        """ 
    10191023        reduce the bucked volume and value of logs with a given reduction 
     
    10231027        log_assortment_count = 0 # counts number of log assortments 
    10241028        redp = self.hdata.cdata['regional_log_reduction'] 
    1025         totprice = 0.0 
    1026         totvol = 0.0 
    10271029        if redp <= 1: 
    10281030            for assortment, values in timber.iteritems(): 
     
    10321034                values[0] *= redp  # reduce the volume by percentage 
    10331035                values[1] *= redp  # reduce the value by percentage 
    1034                 totprice += values[1] 
    1035                 totvol += values[0] 
    10361036            #increase pulp volume 
    10371037            if volumered > EPSILON and timber[pulplabel][0] > 0: 
     
    10411041            elif volumered > EPSILON: 
    10421042                timber[pulplabel][0] = volumered 
    1043                 if totvol > 0: 
    1044                     timber[pulplabel][1] = totprice / totvol 
    1045                 else: 
    1046                     timber[pulplabel][1] = 0.0 
     1043                timber[pulplabel][1] = volumered*pulp_price 
    10471044        else: # redp > 1, ie. add log volume and reduce pulp volume 
    10481045            for assortment, values in timber.iteritems(): 
     
    10661063                        values[0] *= redp_pulp  # reduce the volume by % 
    10671064                        values[1] *= redp_pulp  # reduce the value by % 
    1068                         totprice += values[1] 
    1069                         totvol += values[0] 
    10701065            #increase log volume 
    10711066            if volumered > EPSILON: 
Note: See TracChangeset for help on using the changeset viewer.