| 26 | std_fs::path output_dir_relative = "tinympc_generated_code_random_example/"; |
| 27 | |
| 28 | int main() |
| 29 | { |
| 30 | TinySolver *solver; |
| 31 | |
| 32 | tinytype rho_value = 0.1; |
| 33 | |
| 34 | tinytype Adyn_data[NSTATES * NSTATES] = {1, 5, 1, 2}; |
| 35 | tinytype Bdyn_data[NSTATES * NINPUTS] = {3, 3, 4, 1}; |
| 36 | tinytype Q_data[NSTATES] = {1, 1}; |
| 37 | tinytype R_data[NINPUTS] = {2, 2}; |
| 38 | |
| 39 | tinytype x_min_data[NSTATES * NHORIZON] = {-1, -2, -1, -2, -1, -2}; |
| 40 | tinytype x_max_data[NSTATES * NHORIZON] = {1, 2, 1, 2, 1, 2}; |
| 41 | tinytype u_min_data[NINPUTS * (NHORIZON - 1)] = {-2, -3, -2, -3}; |
| 42 | tinytype u_max_data[NINPUTS * (NHORIZON - 1)] = {2, 3, 2, 3}; |
| 43 | |
| 44 | tinyMatrix Adyn = Map<Matrix<tinytype, NSTATES, NSTATES, RowMajor>>(Adyn_data); |
| 45 | tinyMatrix Bdyn = Map<Matrix<tinytype, NSTATES, NINPUTS, RowMajor>>(Bdyn_data); |
| 46 | tinyVector fdyn = tiny_VectorNx::Zero(); |
| 47 | tinyVector Q = Map<Matrix<tinytype, NSTATES, 1>>(Q_data); |
| 48 | tinyVector R = Map<Matrix<tinytype, NINPUTS, 1>>(R_data); |
| 49 | |
| 50 | tinyMatrix x_min = Map<tiny_MatrixNxNh>(x_min_data); |
| 51 | tinyMatrix x_max = Map<tiny_MatrixNxNh>(x_max_data); |
| 52 | tinyMatrix u_min = Map<tiny_MatrixNuNhm1>(u_min_data); |
| 53 | tinyMatrix u_max = Map<tiny_MatrixNuNhm1>(u_max_data); |
| 54 | |
| 55 | // Set up problem |
| 56 | int verbose = 0; |
| 57 | int status = tiny_setup(&solver, |
| 58 | Adyn, Bdyn, fdyn, Q.asDiagonal(), R.asDiagonal(), |
| 59 | rho_value, NSTATES, NINPUTS, NHORIZON, verbose); |
| 60 | // Set bound constraints |
| 61 | status = tiny_set_bound_constraints(solver, x_min, x_max, u_min, u_max); |
| 62 | |
| 63 | // Solver options |
| 64 | solver->settings->abs_pri_tol = 1e-3; |
| 65 | solver->settings->abs_dua_tol = 1e-3; |
| 66 | solver->settings->max_iter = 100; |
| 67 | solver->settings->check_termination = 1; |
| 68 | |
| 69 | |
| 70 | tiny_codegen(solver, std_fs::absolute(output_dir_relative).string().c_str(), verbose); |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | } /* extern "C" */ |
nothing calls this directly
no test coverage detected