Skip to content

Compile error for space-time GCV in qsr.h #14

@Marco2103-polimi

Description

@Marco2103-polimi

The compile error in qsr.h for the space–time GCV arises because the optimizer is passing a single smoothing parameter, while the space–time version of the model requires two distinct smoothing parameters. The mismatch leads to a compilation failure.

int test_gcv() {

    // geometry 
    using PointT = Eigen::Matrix<double, 2, 1>;

    Eigen::Matrix<double, Dynamic, Dynamic> points = read_csv<double>("my_data/mesh/unit_square_reduced_censoring_476/points.csv").as_matrix();
    Eigen::Matrix<int, Dynamic, Dynamic> elements = read_csv<int>("my_data/mesh/unit_square_reduced_censoring_476/elements.csv").as_matrix();
    Eigen::Matrix<int, Dynamic, Dynamic> boundary = read_csv<int>("my_data/mesh/unit_square_reduced_censoring_476/boundary.csv").as_matrix();

    elements.array() -= 1; // non necessario

    std::string datadir = "my_data/msr/06-missing/";
    const unsigned int M = 8; 
    Triangulation<1, 1> T = Triangulation<1, 1>::Interval(0, 1, M);  
    Triangulation<2, 2> D(points, elements, boundary);

    GeoFrame data(D, T);

    // data 
    auto& l = data.insert_scalar_layer<POINT, POINT>("layer", std::pair{"my_data/msr/06/space_locs.csv", "my_data/msr/06/time_locs.csv"});
    l.load_csv<double>(datadir + "response.csv");
    l.load_csv<double>(datadir + "design_matrix.csv");

    std::cout << "geoframe:" << data[0] << std::endl;

    // physics 
    FeSpace Vh(D, P1<1>);   // functional space definition

    // trial and test function definition
    TrialFunction f(Vh);
    TestFunction v(Vh);
    auto a_D = integral(D)(dot(grad(f), grad(v)));
    // homogeneous forcing linear form
    ZeroField<2> u_D;
    auto F_D = integral(D)(u_D * v);

    BsSpace Bh(T, 3);   // cubic B-splines in time
    TrialFunction g(Bh);
    TestFunction  w(Bh);
    auto a_T = integral(T)(dxx(g) * dxx(w));
    ZeroField<1> u_T;
    auto F_T = integral(T)(u_T * w);    


    std::vector<double> lambdas_d;
    std::vector<double> lambdas_t;
    std::vector<Eigen::Matrix<double, Dynamic, 1>> lambdas_d_t;
    for(double xs = -4.5; xs <= -3.0; xs += 0.5)
        lambdas_d.push_back(std::pow(10,xs));

    for(double xt = -4.0; xt <= -2.0; xt += 2.0)
        lambdas_t.push_back(std::pow(10,xt));

    for(auto i = 0; i < lambdas_d.size(); ++i)
        for(auto j = 0; j < lambdas_t.size(); ++j) 
            lambdas_d_t.push_back(Eigen::Matrix<double, 2, 1>(lambdas_d[i], lambdas_t[j]));
    
    Eigen::Matrix<double, Dynamic, 2> lambda_grid(lambdas_d.size()*lambdas_t.size(), 2);
    for(int i = 0; i < lambdas_d.size(); ++i) { 
        for (int j = 0; j < lambdas_t.size(); ++j) {
            lambda_grid(i * lambdas_t.size() + j, 0) = lambdas_d[i];
            lambda_grid(i * lambdas_t.size() + j, 1) = lambdas_t[j];
        }
    }
    std::cout << "Lambda grid: " << lambda_grid << std::endl;

    GridSearch<2> opt;

    QSRPDE m_qsr("y ~ x1 + x2 + f", data, 0.50, fe_ls_separable_mono(std::pair {a_D, F_D}, std::pair {a_T, F_T}));
    opt.optimize(m_qsr.gcv(200, 1234), lambda_grid);


    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions