From ef800d4ffafdbde7d7a172ad73bd984b1695c138 Mon Sep 17 00:00:00 2001 From: Pasha Date: Fri, 27 Jan 2023 00:54:07 +0000 Subject: simplex-glpk with modified glpk for fpga --- glpk-5.0/examples/nppsamp.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 glpk-5.0/examples/nppsamp.c (limited to 'glpk-5.0/examples/nppsamp.c') diff --git a/glpk-5.0/examples/nppsamp.c b/glpk-5.0/examples/nppsamp.c new file mode 100644 index 0000000..65f0e69 --- /dev/null +++ b/glpk-5.0/examples/nppsamp.c @@ -0,0 +1,48 @@ +/* nppsamp.c */ + +#include +#include +#include + +int main(void) +{ glp_prep *prep; + glp_prob *P, *Q; + int ret; + prep = glp_npp_alloc_wksp(); + P = glp_create_prob(); + ret = glp_read_mps(P, GLP_MPS_DECK, NULL, "murtagh.mps"); + if (ret != 0) + { printf("Error on reading problem data\n"); + goto skip; + } + glp_set_obj_dir(P, GLP_MAX); + glp_npp_load_prob(prep, P, GLP_SOL, GLP_ON); + ret = glp_npp_preprocess1(prep, 0); + switch (ret) + { case 0: + break; + case GLP_ENOPFS: + printf("LP has no primal feasible solution\n"); + goto skip; + case GLP_ENODFS: + printf("LP has no dual feasible solution\n"); + goto skip; + default: + glp_assert(ret != ret); + } + Q = glp_create_prob(); + glp_npp_build_prob(prep, Q); + ret = glp_simplex(Q, NULL); + if (ret == 0 && glp_get_status(Q) == GLP_OPT) + { glp_npp_postprocess(prep, Q); + glp_npp_obtain_sol(prep, P); + } + else + printf("Unable to recover non-optimal solution\n"); + glp_delete_prob(Q); +skip: glp_npp_free_wksp(prep); + glp_delete_prob(P); + return 0; +} + +/* eof */ -- cgit v1.2.1