[PPL-devel] [GIT] ppl/ppl(ppl-0_11-branch): Corrected efficiency bugs in the C interface and in MIP_Problem.
Enea Zaffanella
zaffanella at cs.unipr.it
Fri Sep 17 18:51:10 CEST 2010
Module: ppl/ppl
Branch: ppl-0_11-branch
Commit: f1c00c8f1177749c33c7551d73d853ec561d36d0
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=f1c00c8f1177749c33c7551d73d853ec561d36d0
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Fri Sep 17 18:45:33 2010 +0200
Corrected efficiency bugs in the C interface and in MIP_Problem.
---
NEWS | 6 ++++++
interfaces/C/ppl_c_implementation_common.cc | 2 +-
src/MIP_Problem.cc | 8 ++++----
src/PIP_Tree.cc | 10 +++++-----
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index 76dce77..8346e7d 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,12 @@ NEWS for version 0.11.1 (release date to be decided)
Bugfixes
========
+o Corrected an efficiency bug in the C language interface function
+ int ppl_Linear_Expression_add_to_coefficient()
+
+o Corrected an efficiency bug in method
+ MIP_Problem::compute_generator()
+
o Corrected a bug affecting the input routine of ppl_lpsol, whereby
the inhomogeneous term of the objective function was disregarded.
diff --git a/interfaces/C/ppl_c_implementation_common.cc b/interfaces/C/ppl_c_implementation_common.cc
index 3380207..b95451a 100644
--- a/interfaces/C/ppl_c_implementation_common.cc
+++ b/interfaces/C/ppl_c_implementation_common.cc
@@ -536,7 +536,7 @@ ppl_Linear_Expression_add_to_coefficient(ppl_Linear_Expression_t le,
ppl_const_Coefficient_t n) try {
Linear_Expression& lle = *to_nonconst(le);
const Coefficient& nn = *to_const(n);
- lle += nn * Variable(var);
+ add_mul_assign(lle, nn, Variable(var));
return 0;
}
CATCH_ALL
diff --git a/src/MIP_Problem.cc b/src/MIP_Problem.cc
index c388715..641d539 100644
--- a/src/MIP_Problem.cc
+++ b/src/MIP_Problem.cc
@@ -1425,12 +1425,12 @@ PPL::MIP_Problem::compute_generator() const {
if (is_in_base(split_var, row)) {
const Row& t_row = tableau[row];
if (t_row[split_var] > 0) {
- split_num = -t_row[0];
+ neg_assign(split_num, t_row[0]);
split_den = t_row[split_var];
}
else {
split_num = t_row[0];
- split_den = -t_row[split_var];
+ neg_assign(split_den, t_row[split_var]);
}
// We compute the lcm to compute subsequently the difference
// between the 2 variables.
@@ -1463,7 +1463,7 @@ PPL::MIP_Problem::compute_generator() const {
// Finally, build the generator.
Linear_Expression expr;
for (dimension_type i = external_space_dim; i-- > 0; )
- expr += num[i] * Variable(i);
+ add_mul_assign(expr, num[i], Variable(i));
MIP_Problem& x = const_cast<MIP_Problem&>(*this);
x.last_generator = point(expr, lcm);
@@ -1502,7 +1502,7 @@ PPL::MIP_Problem::second_phase() {
const dimension_type split_var = mapping[i].second;
working_cost[original_var] = new_cost[i];
if (mapping[i].second != 0)
- working_cost[split_var] = - new_cost[i];
+ neg_assign(working_cost[split_var], new_cost[i]);
}
// Here the first phase problem succeeded with optimum value zero.
// Express the old cost function in terms of the computed base.
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index e3f45c1..004ddfc 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -2165,7 +2165,7 @@ PIP_Solution_Node::solve(const PIP_Problem& pip,
dimension_type j = 1;
for (Variables_Set::const_iterator p = all_params.begin(),
p_end = all_params.end(); p != p_end; ++p, ++j)
- expr += t_test[j] * Variable(*p);
+ add_mul_assign(expr, t_test[j], Variable(*p));
using namespace IO_Operators;
std::cerr << "Found mixed parameter sign row: " << best_i << ".\n"
<< "Solution depends on sign of parameter "
@@ -2549,8 +2549,8 @@ PIP_Solution_Node::generate_cut(const dimension_type index,
Linear_Expression expr1(ctx1[0]);
Linear_Expression expr2(ctx2[0]);
for (dimension_type j = 1; j <= num_params; ++j, ++p) {
- expr1 += ctx1[j] * Variable(*p);
- expr2 += ctx2[j] * Variable(*p);
+ add_mul_assign(expr1, ctx1[j], Variable(*p));
+ add_mul_assign(expr2, ctx2[j], Variable(*p));
}
std::cout << "Inserting into context: "
<< Constraint(expr1 >= 0) << " ; "
@@ -2594,9 +2594,9 @@ PIP_Solution_Node::generate_cut(const dimension_type index,
dimension_type si = 0;
for (dimension_type j = 0; j < space_dimension; ++j) {
if (parameters.count(j) == 1)
- expr += cut_t[ti++] * Variable(j);
+ add_mul_assign(expr, cut_t[ti++], Variable(j));
else
- expr += cut_s[si++] * Variable(j);
+ add_mul_assign(expr, cut_s[si++], Variable(j));
}
std::cout << "Adding cut: "
<< Constraint(expr + cut_t[0] >= 0)
More information about the PPL-devel
mailing list