예제 #1
0
def pick_scenarios(lnsas, weights, multi, numeps):
  '''this function takes some scenarios with an annual rate of occurrence > 10e-5 OR does it based on some other criteria, called get_praveen_results'''
  scenarios = []
  wout = []
  index = 0
  easy = True #whether to just take scenarios that are of engineering interest or do some complicated other thing
  print 'length of lnsas: ', len(lnsas)
  print 'length of weights: ', len(weights)
  print 'numeps: ', numeps
  wsum = 0
  if easy == True:
    print 'easy'
    for w in weights:
      wsum += weights[w]
      if weights[w]> 0.00001/float(numeps): #0.0000001/numeps: #10^-5 divided by num eps because the weights get renormalized when take more than one epsilon realization per scenario
        scenarios.append(index)
        wout.append((index, weights[w]))
      index += 1
  else:
    (scenarios, wout) = get_praveen_results(lnsas)
  util.write_2dlist(time.strftime("%Y%m%d")+'_weights_' + str(numeps) + 'eps.txt', wout) #save the weights of the chosen scenarios
  print 'number of chosen scenarios: ', len(scenarios)
  print 'weights of all scenarios: ', wsum
  print 'the sum of the subset weights: ', sum([ww[1] for ww in wout])
  return scenarios
예제 #2
0
def pick_scenarios(lnsas, weights, multi=True):
  scenarios = []
  wout = []
  index = 0
  easy = True #whether to just take scenarios that are of engineering interest or do some complicated other thing
  print 'length of lnsas: ', len(lnsas)
  print 'length of weights: ', len(weights)
  numeps = int(round(len(lnsas)/4993.0))
  print 'numeps: ', numeps
  wsum = 0
  if easy == True:
    print 'easy'
    print 0.00001/float(numeps)
    for w in weights:
      wsum += weights[w]
      print weights[w]
      if weights[w]> 0.00001/float(numeps): #0.0000001/numeps: #10^-5 divided by num eps because the weights get renormalized when take more than one epsilon realization per scenario
        scenarios.append(index)
        wout.append((index, weights[w]))
      index += 1
  else:
    (scenarios, wout) = get_praveen_results(lnsas)
  util.write_2dlist(time.strftime("%Y%m%d")+'_weights2.txt', wout) #save the weights of the chosen scenarios
  print 'number of chosen scenarios: ', len(scenarios)
  print 'weights of all scenarios: ', wsum
  print 'the sum of the subset weights: ', sum([ww[1] for ww in wout])
  return scenarios