Changeset 3034
 Timestamp:
 Sep 20, 2010 11:28:20 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

coopr.pysp/trunk/scripts/computeconf
r3033 r3034 95 95 default=10) 96 96 conf_options_parser.add_option("confidenceintervalalpha", 97 help="The alpha level for the confidence interval. Default is 0. 10",98 action="store", 99 dest=" Conf_Alpha",97 help="The alpha level for the confidence interval. Default is 0.05", 98 action="store", 99 dest="confidence_interval_alpha", 100 100 type="float", 101 default=0. 10)101 default=0.05) 102 102 conf_options_parser.add_option("solvexhatwithph", 103 103 help="Perform xhat solve via PH rather than an EF solve. Default is False", … … 269 269 xstar_obj_gap = ef_results.solution(0).gap # assuming this is the absolute gap 270 270 xstar_obj_bound = xstar_obj  xstar_obj_gap # HERE  watch for signs on gap  is it absolute, or can it be negative? 271 print "Extensive form objective value given xstar="+str(xstar_obj)+"; gap="+str(xstar_obj_gap) 271 print "Extensive form objective value given xstar="+str(xstar_obj)+"; gap="+str(xstar_obj_gap)+"." 272 272 273 273 # to get f(xhat) for this sample, fix the firststage variables and resolve the extensive form. … … 297 297 g_var = g_var + (g_supk_of_xhat[k]  g_bar) * (g_supk_of_xhat[k]  g_bar) 298 298 g_var = g_var / (n_g  1) # sample var 299 print "" 299 300 print "g_bar=",g_bar 300 301 print "g_stddev=",math.sqrt(g_var) 301 302 print "Average f(xhat)=",sum_xstar_obj_given_xhat / n_g 302 303 304 if n_g in t_table_values: 305 print "" 306 t_table_entries = t_table_values[n_g] 307 for key in sorted(t_table_entries.keys()): 308 print "Confidence interval width for alpha="+str(key)+" is "+str(t_table_entries[key] * math.sqrt(g_var) / math.sqrt(n_g)) 309 else: 310 print "No builtin ttable entries for "+str(n_g)+" degrees of freedom  cannot calculate confidence interval width" 311 312 if options.write_xhat_solution is True: 313 print "" 314 print "xhat solution:" 315 scenario_tree = xhat_ph._scenario_tree 316 first_stage = scenario_tree._stages[0] 317 root_node = first_stage._tree_nodes[0] 318 for key, value in root_node._solutions.items(): 319 for idx in value: 320 if value[idx]() != 0.0: 321 print key, idx, value[idx]() 322 303 323 if options.append_file is not None: 304 324 output_file = open(options.append_file, "a") 305 325 print >>output_file, "\ninstancedirectory, ",options.instance_directory, ", seed, ",options.random_seed, ", N, ",scenario_count, ", hatn, ",num_scenarios_for_solution, ", n_g, ", options.n_g, ", Eoffofxhat, ", sum_xstar_obj_given_xhat / n_g, ", gbar, ", g_bar, ", sg, ", math.sqrt(g_var), ", objforxhat, ", xhat_obj, ", n,",num_scenarios_per_sample, 326 327 if n_g in t_table_values: 328 t_table_entries = t_table_values[n_g] 329 for key in sorted(t_table_entries.keys()): 330 print >>output_file, " , alpha="+str(key)+" , "+str(t_table_entries[key] * math.sqrt(g_var) / math.sqrt(n_g)), 306 331 307 332 if options.write_xhat_solution is True: … … 315 340 print >>output_file, key, idx, value[idx](), 316 341 output_file.close() 342 print "" 343 print "Results summary appended to file="+options.append_file 317 344 318 345 #
Note: See TracChangeset
for help on using the changeset viewer.