Esempio n. 1
0
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)