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 = "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)