Changeset 2698
- Timestamp:
- 01/28/12 13:31:36 (4 months ago)
- Location:
- simo/branches/memory_worker/src/simo
- Files:
-
- 2 edited
-
builder/lexicon/lexicon.py (modified) (1 diff)
-
matrix/brancher.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simo/branches/memory_worker/src/simo/builder/lexicon/lexicon.py
r2423 r2698 338 338 self._levels[level].variables[variable] = \ 339 339 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) 340 357 return True 341 358 -
simo/branches/memory_worker/src/simo/matrix/brancher.py
r2594 r2698 14 14 from collections import defaultdict, deque 15 15 from copy import deepcopy as dc 16 from datetime import date 16 17 17 18 from simo.utils.utils import update_dates … … 106 107 targets[at_count == 0] = False 107 108 targets *= bb 108 109 109 110 # make sure that locked tasks are not done 110 111 if numpy.all(targets == False): … … 257 258 new[i] = False 258 259 aborted = self._new_branches[self._aborted * new,:] 259 260 260 261 # get date and timestep information 261 262 cdates = data.get_date(self._new_branches) … … 264 265 unit = timespan.unit 265 266 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 267 276 # delete aborted objects from prediction and operation memories 268 277 # go through target objects and all their relatives and update the … … 281 290 pred_mem.del_objects(it, br, rels, level) 282 291 oper_mem.del_objects(it, br, rels, level) 283 292 284 293 # inactivate branches for which branching operations were not done 285 294 data.del_branch(aborted, bg_ind) 286 295 287 296 # store branching information 288 297 ab = self._aborted … … 296 305 # dictionary to branching information (history) 297 306 go = self._gokeys 298 307 299 308 # update active branching task map and 300 309 # the branching dates up to the end date of the current period 301 310 task_ind = self._task_index[bg_name][(self._task.name, branchname)] 302 311 303 312 if self._branching_info is None: 304 313 self._branching_info = {} … … 308 317 key = tuple(nb[i,0:3]) 309 318 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 311 320 self._bg_bind[key[0],key[1],key[2]] = bg_ind 312 321 # if the new branch has already been stored into the branching … … 319 328 pkey = tuple(pb[i,:3]) 320 329 fromto[pkey] = key 321 330 322 331 # copy the queued operation results from the parent branch to 323 332 # the new branch … … 332 341 copies.append(tuple(orcopy)) 333 342 opres_queue += copies 334 343 335 344 # update active branching groups 336 345 active_tasks = self._active_tasks[pb[:,0], pb[:,1], pb[:,2], :] … … 338 347 if numpy.any(active_count == 0): 339 348 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 341 350 new = dict(pairs) 342 351 self._branching_info.update(new) … … 389 398 self._task_index[bg_name] = defaultdict(dict) 390 399 tasks = deque([]) 391 bg_tasks, fb = bg_item 400 bg_tasks, fb = bg_item 392 401 # no_op_branch from ini overrides the free_branching attribute 393 402 # from model chain
Note: See TracChangeset
for help on using the changeset viewer.
