def Main(outfile = "testPiecewiseConstantDiffusion", grid_points = tuple([2000]), L_max = 3, algo_name = "whtp", gamma = 1.035, abar = 5, variability = None, L_min = 1, sampling_name = "p", nb_iter = 50, epsilon = 1e-4, nb_tests = None, dat_constant = 10): ## SPDEModel d = 13 # epsilon = 50 # Is used for the number of iterations in whtp # mesh_size = int(d*math.floor(float(grid_points)/float(d))) # Create FEMModel with given diffusion coefficient, goal functional and initial mesh size if variability is None: variability = abar/(d+1) #upper_bound = abar + variability #a = [LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound)] # Make sure you have d of those spde_model = PiecewiseConstantDiffusionFEMModelML(abar, ConstantCoefficient(1.0), variability, grid_points, Average()) test_result = outfile, None for s in range(L_min,L_max+1,1): ## Reconstruction Model v = [gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, gamma, np.inf] # This has to be done better too wr_model = WR.WRModel(WR.Algorithms.whtp, WR.Operators.Chebyshev, v, get_sampling_type(sampling_name), WR.check_cs) num_tests = nb_tests # change from 10 for Quinoa tests ## Don't forget to reset the original mesh spde_model.refine_mesh(2**(-s)) ### Execute test test_result = test(spde_model, wr_model, nb_iter, epsilon, s, [CrossCheck(num_tests)], dat_constant, *test_result)
def Main( outfile="thatTest", d=5, grid_points=tuple([2000]), L_max=4, algo_name="whtp", gamma=1.035, L_min=1, sampling_name="p", nb_iter=500, epsilon=1e-3, nb_tests=None, alpha=2.0, abar=4.3, dat_constant=10, ): # if algo_name == 'whtp': # Really have to find a way to deal with the epsilon/eta/nbIter parameter # epsilon = 50 # This will be rescaled later # elif algo_name == 'wiht': # epsilon = 1e-4 # elif algo_name == 'womp': # epsilon = 1e-4 # elif algo_name == 'bpdn': # epsilon = 1e-4 # else: # epsilon = 50 # This will be rescaled later # Create FEMModel with given diffusion coefficient, goal functional and initial mesh size spde_model = DiffusionFEMModelML(TrigCoefficient(d, alpha, abar), ConstantCoefficient(10.0), Average(), grid_points) # Still have to concatenate the output file name with the parameters (i.e. d and h_0) test_result = outfile, None # test_result = '_'.join([algo_name, str(d), str(grid_points),outfile]), None for s in range(L_min, L_max + 1, 1): # s corresponds to the number of levels here ### Reconstruction Model v = np.hstack((np.repeat(gamma, 2 * d), [np.inf])) wr_model = WR.WRModel(algo_name, WR.Operators.Chebyshev, v, get_sampling_type(sampling_name), WR.check_cs) # wr_model = WR.WRModel(WR.Algorithms.whtp, WR.Operators.Chebyshev, v, # WR.cs_pragmatic_m, WR.check_cs) # or cs_theoretic_m print "wr_model created" ## Number of tests num_tests = nb_tests # change from 10 for Quinoa tests ## Don't forget to reset the original mesh spde_model.refine_mesh(2 ** (-s)) ### Execute test test_result = test( spde_model, wr_model, nb_iter, epsilon, s, [CrossCheck(num_tests)], dat_constant, *test_result )
def Main(): parser = argparse.ArgumentParser(description = "") parser.add_argument("-d", "--nb-parts", help="Number of splits (i.e. nb of parameters)", default=10, required=False) parser.add_argument("-o", "--output-file", help="File to write the results", default="outputDiffusionML", required=False) parser.add_argument("-L", "--nb-level", help="Number of levels used", default=4, required=False) parser.add_argument("-m", "--mesh-size", help="Size of the coarsest level (number of grid points)", default=2000, required=False) parser.add_argument("-N", "--nb-iter", help="Number of iterations for the (potential) iterative greedy algorithm", default=500, required=False) parser.add_argument("-r", "--recovery-algo", help="String for the algorithm for weighted l1 recovery", default="whtp", required=False) args = parser.parse_args() # Corseast grid outfile = args.output_file grid_points = int(args.mesh_size) d = int(args.nb_parts) L_max = int(args.nb_level) algo_name = args.recovery_algo.lower() if algo_name == 'whtp': # Really have to find a way to deal with the epsilon/eta/nbIter parameter epsilon = 50 # This will be rescaled later elif algo_name == 'wiht': epsilon = 1e-4 elif algo_name == 'womp': epsilon = 1e-4 elif algo_name == 'bpdn': epsilon = 1e-4 else: epsilon = 50 # This will be rescaled later ##d = None, abar = None, coefs = None, parts = None # Create FEMModel with given diffusion coefficient, goal functional and initial mesh size spde_model = DiffusionFEMModelML(PartitionUnityConstantCoefficient(d, 5), ConstantCoefficient(10.0), Average(), grid_points) # Still have to concatenate the output file name with the parameters (i.e. d and h_0) test_result = '_'.join([algo_name, str(d), str(grid_points),outfile]), None for s in range(1,L_max+1,1): # s corresponds to the number of levels here for gamma in np.arange(1.055, 1.06, 0.01)[::-1]: ### Reconstruction Model v = np.hstack((np.repeat(gamma, 2*d), [np.inf])) wr_model = WR.WRModel(algo_name, WR.Operators.Chebyshev, v, WR.cs_theoretic_m_new, WR.check_cs) #wr_model = WR.WRModel(WR.Algorithms.whtp, WR.Operators.Chebyshev, v, # WR.cs_pragmatic_m, WR.check_cs) # or cs_theoretic_m ## Number of tests num_tests = 1000 # change from 10 for Quinoa tests ## Don't forget to reset the original mesh spde_model.refine_mesh(2**(-s)) ### Execute test test_result = test(spde_model, wr_model, epsilon, s, [CrossCheck(num_tests)], *test_result)
def Main(outfile = "testPiecewiseConstantDiffusionPoly", grid_points = 2000, L_max = 3, algo_name = "whtp", c = 1, alpha = 1/2, abar = 5, variability = None, L_min = 1, sampling_name = "p", nb_tests = None): if algo_name == 'whtp': # Really have to find a way to deal with the epsilon/eta/nbIter parameter epsilon = 1e-4 # This will be rescaled later elif algo_name == 'wiht': epsilon = 1e-4 elif algo_name == 'womp': epsilon = 1e-4 elif algo_name == 'bpdn': epsilon = 1e-4 else: epsilon = 1e-4 # This will be rescaled later ## SPDEModel d = 13 # epsilon = 50 # Is used for the number of iterations in whtp mesh_size = int(d*math.floor(float(grid_points)/float(d))) # Create FEMModel with given diffusion coefficient, goal functional and initial mesh size if variability is None: variability = abar/(d+1) #upper_bound = abar + variability #a = [LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound)] # Make sure you have d of those spde_model = PiecewiseConstantDiffusionFEMModelML(abar, ConstantCoefficient(1.0), variability, mesh_size, Average()) test_result = outfile, None for s in range(L_min,L_max+1,1): ## Reconstruction Model v = np.hstack((c*np.power([val+1 for val in range(d)], alpha), [np.inf])) wr_model = WR.WRModel(WR.Algorithms.whtp, WR.Operators.Chebyshev, v, get_sampling_type(sampling_name), WR.check_cs) num_tests = nb_tests # change from 10 for Quinoa tests ## Don't forget to reset the original mesh spde_model.refine_mesh(2**(-s)) ### Execute test test_result = test(spde_model, wr_model, epsilon, s, [CrossCheck(num_tests)], *test_result)
def Main(outfile = "testPiecewiseConstantDiffusion2D", grid_points = tuple([200,200]), L_max = 3, algo_name = "whtp", gamma = 1.035, abar = 5, variability = None, L_min = 1, sampling_name = "p", nb_iter = 50, epsilon = 1e-3, nb_tests = None, dat_constant = 10): # if algo_name == 'whtp': # Really have to find a way to deal with the epsilon/eta/nbIter parameter # epsilon = 1e-4 # This will be rescaled later # elif algo_name == 'wiht': # epsilon = 1e-4 # elif algo_name == 'womp': # epsilon = 1e-4 # elif algo_name == 'bpdn': # epsilon = 1e-4 # else: # epsilon = 1e-4 # This will be rescaled later ## SPDEModel d = 16 # mesh_size = int(d*math.floor(float(grid_points)/float(d))) # Create FEMModel with given diffusion coefficient, goal functional and initial mesh size if variability is None: variability = abar/(d+1) #upper_bound = abar + variability #a = [LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), # LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound), LinearCoefficient(abar, upper_bound)] # Make sure you have d of those spde_model = PiecewiseConstantDiffusionFEMModelML2D_small(abar, ConstantCoefficient(1.0), variability, grid_points, Average()) test_result = outfile, None for s in range(L_min,L_max+1,1): ## Reconstruction Model v = np.hstack((np.repeat(gamma, d), [np.inf])) # The 2D PW constant has been implemented as a 5 times 5 grid wr_model = WR.WRModel(algo_name, WR.Operators.Chebyshev, v, get_sampling_type(sampling_name), WR.check_cs) num_tests = nb_tests # change from 10 for Quinoa tests ## Don't forget to reset the original mesh spde_model.refine_mesh(2**(-s)) ### Execute test test_result = test(spde_model, wr_model, nb_iter, epsilon, s, [CrossCheck(num_tests)], dat_constant, *test_result)