Changeset 2705


Ignore:
Timestamp:
02/02/12 21:50:38 (4 months ago)
Author:
jussi
Message:

fix:text var when combining lexicons / fix:branching forced operation past end date

Location:
simo/trunk/src/simo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simo/trunk/src/simo/builder/lexicon/lexicon.py

    r2423 r2705  
    338338                self._levels[level].variables[variable] = \ 
    339339                    copy(lexicon.levels[level].variables[variable]) 
     340                # variable type 
     341                llevel = lexicon.levels[level] 
     342                if variable in llevel.categorical: 
     343                    if len(self._levels[level]._categorical) == 0: 
     344                        self._levels[level]._categorical = set([variable]) 
     345                    else: 
     346                        self._levels[level]._categorical.add(variable) 
     347                elif variable in llevel.numerical: 
     348                    if len(self._levels[level]._numerical) == 0: 
     349                        self._levels[level]._numerical = set([variable]) 
     350                    else: 
     351                        self._levels[level]._numerical.add(variable) 
     352                elif variable in llevel.textual: 
     353                    if len(self._levels[level]._textual) == 0: 
     354                        self._levels[level]._textual = set([variable]) 
     355                    else: 
     356                        self._levels[level]._textual.add(variable) 
    340357        return True 
    341358 
  • simo/trunk/src/simo/matrix/brancher.py

    r2594 r2705  
    1414from collections import defaultdict, deque 
    1515from copy import deepcopy as dc 
     16from datetime import date 
    1617 
    1718from simo.utils.utils import update_dates 
     
    106107        targets[at_count == 0] = False 
    107108        targets *= bb 
    108          
     109 
    109110        # make sure that locked tasks are not done 
    110111        if numpy.all(targets == False): 
     
    257258                new[i] = False 
    258259        aborted = self._new_branches[self._aborted * new,:] 
    259          
     260 
    260261        # get date and timestep information 
    261262        cdates = data.get_date(self._new_branches) 
     
    264265        unit = timespan.unit 
    265266        ndates = update_dates(cdates, timesteps, unit, deduceaday=True) 
    266          
     267        if timespan.ending.type == 'end_date': 
     268            end_month = timespan.ending.target.month 
     269            end_day = timespan.ending.target.day 
     270            end_year = timespan.ending.target.year 
     271            end_date = date(end_year, end_month, end_day) 
     272            for ind in range(len(ndates)): 
     273                if ndates[ind] > end_date: 
     274                    ndates[ind] = end_date 
     275 
    267276        # delete aborted objects from prediction and operation memories 
    268277        # go through target objects and all their relatives and update the 
     
    281290                pred_mem.del_objects(it, br, rels, level) 
    282291                oper_mem.del_objects(it, br, rels, level) 
    283          
     292 
    284293        # inactivate branches for which branching operations were not done 
    285294        data.del_branch(aborted, bg_ind) 
    286          
     295 
    287296        # store branching information 
    288297        ab = self._aborted 
     
    296305        # dictionary to branching information (history) 
    297306        go = self._gokeys 
    298          
     307 
    299308        # update active branching task map and 
    300309        # the branching dates up to the end date of the current period 
    301310        task_ind = self._task_index[bg_name][(self._task.name, branchname)] 
    302          
     311 
    303312        if self._branching_info is None: 
    304313            self._branching_info = {} 
     
    308317                key = tuple(nb[i,0:3]) 
    309318                self._active_tasks[pb[i,0],pb[i,1],pb[i,2],task_ind] = False 
    310                 # bind the object to the current branching group  
     319                # bind the object to the current branching group 
    311320                self._bg_bind[key[0],key[1],key[2]] = bg_ind 
    312321                # if the new branch has already been stored into the branching 
     
    319328                pkey = tuple(pb[i,:3]) 
    320329                fromto[pkey] = key 
    321          
     330 
    322331        # copy the queued operation results from the parent branch to 
    323332        # the new branch 
     
    332341                copies.append(tuple(orcopy)) 
    333342        opres_queue += copies 
    334                  
     343 
    335344        # update active branching groups 
    336345        active_tasks = self._active_tasks[pb[:,0], pb[:,1], pb[:,2], :] 
     
    338347        if numpy.any(active_count == 0): 
    339348            m = active_count == 0 
    340             self._active_bgs[pb[m,0], pb[m,1], pb[m,2], bg_ind] = False       
     349            self._active_bgs[pb[m,0], pb[m,1], pb[m,2], bg_ind] = False 
    341350        new = dict(pairs) 
    342351        self._branching_info.update(new) 
     
    389398            self._task_index[bg_name] = defaultdict(dict) 
    390399            tasks = deque([]) 
    391             bg_tasks, fb = bg_item  
     400            bg_tasks, fb = bg_item 
    392401            # no_op_branch from ini overrides the free_branching attribute 
    393402            # from model chain 
Note: See TracChangeset for help on using the changeset viewer.