[packages/ppl] - added glpk-api12 patch (update glpk API usage; should be compatible with 4.38 .. 4.49+)
qboosh
qboosh at pld-linux.org
Tue May 14 21:44:45 CEST 2013
commit 5dc40de002c6fd8e035328f58abd282098f1a965
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Tue May 14 21:44:49 2013 +0200
- added glpk-api12 patch (update glpk API usage; should be compatible with 4.38 .. 4.49+)
ppl-glpk-api12.patch | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++
ppl.spec | 4 +-
2 files changed, 281 insertions(+), 1 deletion(-)
---
diff --git a/ppl.spec b/ppl.spec
index 2235f0e..7930d20 100644
--- a/ppl.spec
+++ b/ppl.spec
@@ -31,6 +31,7 @@ Source0: ftp://ftp.cs.unipr.it/pub/ppl/releases/%{version}/%{name}-%{version}.ta
# Source0-md5: e8caeb84cd858f64b36333c368891c7b
Patch0: %{name}-ciao.patch
Patch1: %{name}-gmp-5.1.0.patch
+Patch2: %{name}-glpk-api12.patch
URL: http://www.cs.unipr.it/ppl/
%if %{with xsb}
BuildRequires: XSB
@@ -44,7 +45,7 @@ BuildRequires: Yap-static >= 5.1.1
%endif
BuildRequires: autoconf >= 2.61
BuildRequires: automake >= 1:1.11
-BuildRequires: glpk-devel >= 4.13
+BuildRequires: glpk-devel >= 4.38
BuildRequires: gmp-c++-devel >= 4.1.3
BuildRequires: gmp-devel >= 4.1.3
BuildRequires: libstdc++-devel
@@ -379,6 +380,7 @@ Parma Polyhedra Library.
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
%build
%{__libtoolize}
diff --git a/ppl-glpk-api12.patch b/ppl-glpk-api12.patch
new file mode 100644
index 0000000..7513b39
--- /dev/null
+++ b/ppl-glpk-api12.patch
@@ -0,0 +1,278 @@
+--- ppl-1.0/demos/ppl_lpsol/ppl_lpsol.c.orig 2012-06-28 12:50:33.000000000 +0200
++++ ppl-1.0/demos/ppl_lpsol/ppl_lpsol.c 2013-05-14 16:00:07.647977701 +0200
+@@ -565,7 +565,9 @@
+ static mpq_t tmp1_q;
+ static mpq_t tmp2_q;
+ static ppl_Coefficient_t ppl_coeff;
+-static LPX* glpk_lp;
++static glp_prob* glpk_lp;
++#define GLPK_CLASS_LP 100
++#define GLPK_CLASS_MIP 101
+ static int glpk_lp_problem_kind;
+ static int glpk_lp_num_int;
+ static ppl_dimension_type* integer_variables;
+@@ -579,37 +581,42 @@
+ if (!check_results)
+ return;
+
+- /* Disable GLPK output. */
+- lpx_set_int_parm(glpk_lp, LPX_K_MSGLEV, 0);
+-
+- if (no_mip || glpk_lp_problem_kind == LPX_LP)
++ if (no_mip || glpk_lp_problem_kind == GLPK_CLASS_LP)
+ treat_as_lp = 1;
+
+- lpx_set_obj_dir(glpk_lp, (maximize ? LPX_MAX : LPX_MIN));
++ glp_set_obj_dir(glpk_lp, (maximize ? GLP_MAX : GLP_MIN));
+
+ if (treat_as_lp) {
++ glp_smcp lp_parms;
++ glp_init_smcp(&lp_parms);
++ /* Disable GLPK output. */
++ lp_parms.msg_lev = GLP_MSG_OFF;
++
+ /* Set the problem class to LP: MIP problems are thus treated as
+ LP ones. */
+- lpx_set_class(glpk_lp, LPX_LP);
+- lpx_exact(glpk_lp);
+- glpk_status = lpx_get_status(glpk_lp);
++ glp_exact(glpk_lp, &lp_parms);
++ glpk_status = glp_get_status(glpk_lp);
+ }
+ else {
+ /* MIP case. */
+- lpx_intopt(glpk_lp);
+- glpk_status = lpx_mip_status(glpk_lp);
++ glp_iocp mip_parms;
++ glp_init_iocp(&mip_parms);
++ /* Disable GLPK output. */
++ mip_parms.msg_lev = GLP_MSG_OFF;
++ glp_intopt(glpk_lp, &mip_parms);
++ glpk_status = glp_mip_status(glpk_lp);
+ }
+ /* If no_optimization is enabled, the second case is not possibile. */
+ if (!((ppl_status == PPL_MIP_PROBLEM_STATUS_UNFEASIBLE
+- && (glpk_status == LPX_NOFEAS || glpk_status == LPX_I_NOFEAS))
++ && (glpk_status == GLP_NOFEAS))
+ || (ppl_status == PPL_MIP_PROBLEM_STATUS_UNBOUNDED
+- && (glpk_status == LPX_UNBND || glpk_status == LPX_I_UNDEF))
++ && (glpk_status == GLP_UNBND))
+ || (ppl_status == PPL_MIP_PROBLEM_STATUS_OPTIMIZED
+- && ((glpk_status == LPX_OPT || glpk_status == LPX_I_OPT)
++ && ((glpk_status == GLP_OPT)
+ /* If no_optimization is enabled, check if the problem is
+ unbounded for GLPK. */
+- || (no_optimization && (glpk_status == LPX_UNBND
+- || glpk_status == LPX_I_UNDEF)))))) {
++ || (no_optimization && (glpk_status == GLP_UNBND
++ || glpk_status == GLP_UNDEF)))))) {
+
+ if (ppl_status == PPL_MIP_PROBLEM_STATUS_UNFEASIBLE)
+ ppl_status_string = "unfeasible";
+@@ -621,22 +628,16 @@
+ ppl_status_string = "<?>";
+
+ switch (glpk_status) {
+- case LPX_NOFEAS:
++ case GLP_NOFEAS:
+ glpk_status_string = "unfeasible";
+ break;
+- case LPX_UNBND:
++ case GLP_UNBND:
+ glpk_status_string = "unbounded";
+ break;
+- case LPX_OPT:
++ case GLP_OPT:
+ glpk_status_string = "optimizable";
+ break;
+- case LPX_I_NOFEAS:
+- glpk_status_string = "unfeasible";
+- break;
+- case LPX_I_OPT:
+- glpk_status_string = "optimizable";
+- break;
+- case LPX_I_UNDEF:
++ case GLP_UNDEF:
+ glpk_status_string = "undefined";
+ break;
+ default:
+@@ -652,8 +653,8 @@
+ else if (!no_optimization
+ && ppl_status == PPL_MIP_PROBLEM_STATUS_OPTIMIZED) {
+
+- double glpk_optimum_value = treat_as_lp ? lpx_get_obj_val(glpk_lp)
+- : lpx_mip_obj_val(glpk_lp);
++ double glpk_optimum_value = treat_as_lp ? glp_get_obj_val(glpk_lp)
++ : glp_mip_obj_val(glpk_lp);
+
+ if (fabs(ppl_optimum_value - glpk_optimum_value) > check_threshold) {
+ error("check failed: for GLPK the problem's optimum is %.20g,"
+@@ -667,7 +668,7 @@
+
+ static const char*
+ variable_output_function(ppl_dimension_type var) {
+- const char* name = lpx_get_col_name(glpk_lp, var+1);
++ const char* name = glp_get_col_name(glpk_lp, var+1);
+ if (name != NULL)
+ return name;
+ else
+@@ -681,10 +682,10 @@
+ ppl_Constraint_t ppl_c;
+ ppl_Linear_Expression_t ppl_le2;
+ switch (type) {
+- case LPX_FR:
++ case GLP_FR:
+ break;
+
+- case LPX_LO:
++ case GLP_LO:
+ mpz_mul(tmp_z, den_lcm, mpq_numref(rational_lb));
+ mpz_divexact(tmp_z, tmp_z, mpq_denref(rational_lb));
+ mpz_neg(tmp_z, tmp_z);
+@@ -699,7 +700,7 @@
+ ppl_delete_Constraint(ppl_c);
+ break;
+
+- case LPX_UP:
++ case GLP_UP:
+ mpz_mul(tmp_z, den_lcm, mpq_numref(rational_ub));
+ mpz_divexact(tmp_z, tmp_z, mpq_denref(rational_ub));
+ mpz_neg(tmp_z, tmp_z);
+@@ -715,7 +716,7 @@
+ ppl_delete_Constraint(ppl_c);
+ break;
+
+- case LPX_DB:
++ case GLP_DB:
+ ppl_new_Linear_Expression_from_Linear_Expression(&ppl_le2, ppl_le);
+
+ mpz_mul(tmp_z, den_lcm, mpq_numref(rational_lb));
+@@ -746,7 +747,7 @@
+ ppl_delete_Constraint(ppl_c);
+ break;
+
+- case LPX_FX:
++ case GLP_FX:
+ mpz_mul(tmp_z, den_lcm, mpq_numref(rational_lb));
+ mpz_divexact(tmp_z, tmp_z, mpq_denref(rational_lb));
+ mpz_neg(tmp_z, tmp_z);
+@@ -1032,6 +1033,7 @@
+ mpq_t optimum;
+ mpz_t den_lcm;
+ int optimum_found;
++ glp_mpscp mps_parms;
+
+ #ifdef PPL_LPSOL_SUPPORTS_TIMINGS
+
+@@ -1041,12 +1043,14 @@
+ #endif /* defined(PPL_LPSOL_SUPPORTS_TIMINGS) */
+
+ if (verbosity == 0) {
+- /* FIXME: find a way to suppress output from lpx_read_mps. */
++ /* FIXME: find a way to suppress output from glp_read_mps. */
+ }
+
+- glpk_lp = lpx_read_mps(file_name);
+
+- if (glpk_lp == NULL)
++ glpk_lp = glp_create_prob();
++ glp_init_mpscp(&mps_parms);
++
++ if ((glpk_lp == NULL) || (glp_read_mps(glpk_lp, GLP_MPS_FILE, &mps_parms, file_name) < 0))
+ fatal("cannot read MPS file `%s'", file_name);
+
+ #ifdef PPL_LPSOL_SUPPORTS_TIMINGS
+@@ -1060,21 +1064,21 @@
+
+ #endif /* defined(PPL_LPSOL_SUPPORTS_TIMINGS) */
+
+- glpk_lp_problem_kind = lpx_get_class(glpk_lp);
+- if (glpk_lp_problem_kind == LPX_MIP && !no_mip && !use_simplex)
++ glpk_lp_problem_kind = (glp_get_num_int(glpk_lp) == 0) ? GLPK_CLASS_LP : GLPK_CLASS_MIP;
++ if (glpk_lp_problem_kind == GLPK_CLASS_MIP && !no_mip && !use_simplex)
+ fatal("the enumeration solving method can not handle MIP problems");
+
+- dimension = lpx_get_num_cols(glpk_lp);
++ dimension = glp_get_num_cols(glpk_lp);
+
+ /* Read variables constrained to be integer. */
+- if (glpk_lp_problem_kind == LPX_MIP && !no_mip && use_simplex) {
++ if (glpk_lp_problem_kind == GLPK_CLASS_MIP && !no_mip && use_simplex) {
+ if (verbosity >= 4)
+ fprintf(output_file, "Integer variables:\n");
+- glpk_lp_num_int = lpx_get_num_int(glpk_lp);
++ glpk_lp_num_int = glp_get_num_int(glpk_lp);
+ integer_variables = (ppl_dimension_type*)
+ malloc((glpk_lp_num_int + 1)*sizeof(ppl_dimension_type));
+ for (i = 0, j = 0; i < dimension; ++i)
+- if (lpx_get_col_kind(glpk_lp, i+1) == LPX_IV) {
++ if (glp_get_col_kind(glpk_lp, i+1) == GLP_IV) {
+ integer_variables[j] = i;
+ if (verbosity >= 4) {
+ ppl_io_fprint_variable(output_file, i);
+@@ -1101,18 +1105,20 @@
+ fprintf(output_file, "\nConstraints:\n");
+
+ /* Set up the row (ordinary) constraints. */
+- num_rows = lpx_get_num_rows(glpk_lp);
++ num_rows = glp_get_num_rows(glpk_lp);
+ for (row = 1; row <= num_rows; ++row) {
+ /* Initialize the least common multiple computation. */
+ mpz_set_si(den_lcm, 1);
+ /* Set `nz' to the number of non-zero coefficients. */
+- nz = lpx_get_mat_row(glpk_lp, row, coefficient_index, coefficient_value);
++ nz = glp_get_mat_row(glpk_lp, row, coefficient_index, coefficient_value);
+ for (i = 1; i <= nz; ++i) {
+ set_mpq_t_from_double(rational_coefficient[i], coefficient_value[i]);
+ /* Update den_lcm. */
+ mpz_lcm(den_lcm, den_lcm, mpq_denref(rational_coefficient[i]));
+ }
+- lpx_get_row_bnds(glpk_lp, row, &type, &lb, &ub);
++ type = glp_get_row_type(glpk_lp, row);
++ lb = glp_get_row_lb(glpk_lp, row);
++ ub = glp_get_row_ub(glpk_lp, row);
+ set_mpq_t_from_double(rational_lb, lb);
+ mpz_lcm(den_lcm, den_lcm, mpq_denref(rational_lb));
+ set_mpq_t_from_double(rational_ub, ub);
+@@ -1150,7 +1156,9 @@
+
+ /* Set up the columns constraints, i.e., variable bounds. */
+ for (column = 1; column <= dimension; ++column) {
+- lpx_get_col_bnds(glpk_lp, column, &type, &lb, &ub);
++ type = glp_get_col_type(glpk_lp, column);
++ lb = glp_get_col_lb(glpk_lp, column);
++ ub = glp_get_col_ub(glpk_lp, column);
+
+ set_mpq_t_from_double(rational_lb, lb);
+ set_mpq_t_from_double(rational_ub, ub);
+@@ -1179,10 +1187,10 @@
+ mpz_set_si(den_lcm, 1);
+
+ mpq_init(objective[0]);
+- set_mpq_t_from_double(objective[0], lpx_get_obj_coef(glpk_lp, 0));
++ set_mpq_t_from_double(objective[0], glp_get_obj_coef(glpk_lp, 0));
+ for (i = 1; i <= dimension; ++i) {
+ mpq_init(objective[i]);
+- set_mpq_t_from_double(objective[i], lpx_get_obj_coef(glpk_lp, i));
++ set_mpq_t_from_double(objective[i], glp_get_obj_coef(glpk_lp, i));
+ /* Update den_lcm. */
+ mpz_lcm(den_lcm, den_lcm, mpq_denref(objective[i]));
+ }
+@@ -1240,7 +1248,7 @@
+
+ ppl_delete_Linear_Expression(ppl_objective_le);
+
+- if (glpk_lp_problem_kind == LPX_MIP)
++ if (glpk_lp_problem_kind == GLPK_CLASS_MIP)
+ free(integer_variables);
+
+ if (optimum_found) {
+@@ -1287,7 +1295,7 @@
+ ppl_delete_Coefficient(optimum_n);
+ ppl_delete_Generator(optimum_location);
+
+- lpx_delete_prob(glpk_lp);
++ glp_delete_prob(glpk_lp);
+ }
+
+ static void
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/ppl.git/commitdiff/5dc40de002c6fd8e035328f58abd282098f1a965
More information about the pld-cvs-commit
mailing list