예제 #1
0
# Set x limits for each variable based on target:
x_limits = []
for i in range(target._dim):
    limits = [np.min(samples[:, i]), np.max(samples[:, i])]
    x_limits.append(limits)

# Build up srom_size-to-SROM object map for plotting routine.
sroms = OrderedDict()

for srom_size in srom_sizes:

    # Generate SROM from file:
    srom = SROM(srom_size, target._dim)
    srom_filename = "srom_m" + str(srom_size) + ".txt"
    srom_filename = os.path.join(srom_dir, srom_filename)
    srom.load_params(srom_filename)
    sroms[srom_size] = srom

# Font size specs & plotting.
axis_font_size = 25
legend_font_size = 20
Postprocessor.compare_srom_cdfs(sroms,
                                target,
                                plot_dir="plots",
                                plot_suffix=plot_suffix,
                                variable_names=variables,
                                x_limits=x_limits,
                                x_ticks=x_ticks,
                                cdf_y_label=cdf_y_label,
                                axis_font_size=axis_font_size,
                                legend_font_size=legend_font_size)
예제 #2
0
sromsize = 20

#Data files for EOL samples, EOL finite difference samples, and SROM inputs
srom_eol_file = "srom_data/srom_eol_m" + str(sromsize) + ".txt"
srom_fd_eol_file = "srom_data/srom_fd_eol_m" + str(sromsize) + ".txt"
srom_input_file = "srom_data/srom_m" + str(sromsize) + ".txt"

#Get MC input/EOL samples
MC_inputs = np.genfromtxt(mc_input_file)
MC_eols = np.genfromtxt(mc_eol_file)

#Get SROM EOL samples, FD samples and input SROM from file
srom_eols = np.genfromtxt(srom_eol_file)
srom_fd_eols = np.genfromtxt(srom_fd_eol_file)
input_srom = SROM(sromsize, dim)
input_srom.load_params(srom_input_file)

#Get FD step sizes from file (the same for all samples, just pull the first)
#Step sizes chosen as approximately 2% of the median sample value of inputs
stepsizes = [0.0065, 0.083, 0.025]

#Calculate gradient from FiniteDifference class:
gradient = FD.compute_gradient(srom_eols, srom_fd_eols, stepsizes)

#Create SROM surrogate, sample, and create random variable solution
surrogate_PWL = SROMSurrogate(input_srom, srom_eols, gradient)
srom_eol_samples = surrogate_PWL.sample(MC_inputs)
solution_PWL = SampleRandomVector(srom_eol_samples)

#Store EOL samples for plotting later:
eolfile = "srom_data/srom_eol_samples_m" + str(sromsize) + ".txt"
예제 #3
0
#Set x limits for each variable based on target:
xlimits = []
for i in range(target._dim):
    lims = [np.min(samples[:, i]), np.max(samples[:, i])]
    xlimits.append(lims)

#Build up sromsize-to-SROM object map for plotting routine
sroms = OrderedDict()

for sromsize in sromsizes:

    #Generate SROM from file:
    srom = SROM(sromsize, target._dim)
    sromfile = "srom_m" + str(sromsize) + ".txt"
    sromfile = os.path.join(srom_dir, sromfile)
    srom.load_params(sromfile)
    sroms[sromsize] = srom

#Font size specs & plotting
axisfontsize = 25
legendfontsize = 20
Postprocessor.compare_srom_CDFs(sroms,
                                target,
                                plotdir="plots",
                                plotsuffix=plot_suffix,
                                variablenames=varz,
                                xlimits=xlimits,
                                xticks=xticks,
                                cdfylabel=cdfylabel,
                                axisfontsize=axisfontsize,
                                legendfontsize=legendfontsize)