[PPL-devel] [GIT] ppl/ppl(master): Corrected PIP_Problem test04 to properly call predicate ppl_*_artificials( ).
Enea Zaffanella
zaffanella at cs.unipr.it
Mon Apr 5 20:49:19 CEST 2010
Module: ppl/ppl
Branch: master
Commit: cac4da6e7ece70ff7ebd8b0bfc16e07d41e375af
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=cac4da6e7ece70ff7ebd8b0bfc16e07d41e375af
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Mon Apr 5 20:46:24 2010 +0200
Corrected PIP_Problem test04 to properly call predicate ppl_*_artificials().
Applied a few renamings to the implementation of the predicate.
---
interfaces/Prolog/ppl_prolog_common.cc | 25 +++++++++++--------------
interfaces/Prolog/ppl_prolog_common.defs.hh | 2 +-
interfaces/Prolog/tests/pl_check.pl | 9 ++++++---
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/interfaces/Prolog/ppl_prolog_common.cc b/interfaces/Prolog/ppl_prolog_common.cc
index 2b5a2bc..1c945a2 100644
--- a/interfaces/Prolog/ppl_prolog_common.cc
+++ b/interfaces/Prolog/ppl_prolog_common.cc
@@ -1405,13 +1405,11 @@ grid_generator_term(const Grid_Generator& g) {
}
Prolog_term_ref
- artificial_parameter_term(const PIP_Tree_Node::Artificial_Parameter& art) {
+artificial_parameter_term(const PIP_Tree_Node::Artificial_Parameter& art) {
Prolog_term_ref t = Prolog_new_term_ref();
- Prolog_construct_compound
- (t,
- a_divided_by,
- get_linear_expression(art),
- Coefficient_to_integer_term(art.denominator()));
+ Prolog_construct_compound(t, a_divided_by,
+ get_linear_expression(art),
+ Coefficient_to_integer_term(art.denominator()));
return t;
}
@@ -3036,25 +3034,24 @@ ppl_PIP_Tree_Node_as_decision(Prolog_term_ref t_pip,
CATCH_ALL;
}
-/* FIXME: (Commented) test in pl_check.pl gives segmentation fault! */
extern "C" Prolog_foreign_return_type
-ppl_PIP_Tree_Node_artificials(Prolog_term_ref t_pip,
+ppl_PIP_Tree_Node_artificials(Prolog_term_ref t_tree_node,
Prolog_term_ref t_artlist) {
static const char* where = "ppl_PIP_Tree_Node_artificials/2";
try {
- const PIP_Tree_Node* pip = term_to_handle<PIP_Tree_Node>(t_pip, where);
- PPL_CHECK(pip);
+ const PIP_Tree_Node* node
+ = term_to_handle<PIP_Tree_Node>(t_tree_node, where);
+ PPL_CHECK(node);
Prolog_term_ref tail = Prolog_new_term_ref();
Prolog_put_atom(tail, a_nil);
for (PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator
- i = pip->art_parameter_begin(),
- arts_end = pip->art_parameter_end(); i != arts_end; ++i)
+ i = node->art_parameter_begin(),
+ arts_end = node->art_parameter_end(); i != arts_end; ++i)
Prolog_construct_cons(tail, artificial_parameter_term(*i), tail);
- if (Prolog_unify(t_artlist, tail)) {
+ if (Prolog_unify(t_artlist, tail))
return PROLOG_SUCCESS;
- }
}
CATCH_ALL;
}
diff --git a/interfaces/Prolog/ppl_prolog_common.defs.hh b/interfaces/Prolog/ppl_prolog_common.defs.hh
index e935de8..e1be161 100644
--- a/interfaces/Prolog/ppl_prolog_common.defs.hh
+++ b/interfaces/Prolog/ppl_prolog_common.defs.hh
@@ -1054,7 +1054,7 @@ ppl_PIP_Tree_Node_as_decision(Prolog_term_ref t_tree_node,
Prolog_term_ref t_dec_node);
extern "C" Prolog_foreign_return_type
-ppl_PIP_Tree_Node_artificials(Prolog_term_ref t_pip_tree,
+ppl_PIP_Tree_Node_artificials(Prolog_term_ref t_tree_node,
Prolog_term_ref t_artlist);
extern "C" Prolog_foreign_return_type
diff --git a/interfaces/Prolog/tests/pl_check.pl b/interfaces/Prolog/tests/pl_check.pl
index d0cb260..0db2379 100644
--- a/interfaces/Prolog/tests/pl_check.pl
+++ b/interfaces/Prolog/tests/pl_check.pl
@@ -2457,9 +2457,8 @@ pip_solution :-
clean_ppl_new_PIP_Problem(
4, [3*J >= -2*I + 8, J =< 4*I - 4, J =< M, I =< N], [M,N], PIP),
ppl_PIP_Problem_solution(PIP, Tree_Node),
-%% ppl_PIP_Tree_Node_artificials(PIP, Artificials),
-%% write(Artificials), nl,
-%% compare_artificials_lists(Artificials, ),
+ ppl_PIP_Tree_Node_artificials(Tree_Node, Artificials),
+ Artificials = [],
\+ ppl_PIP_Tree_Node_as_solution(Tree_Node, _Sol),
ppl_PIP_Tree_Node_constraints(Tree_Node, _CS),
ppl_PIP_Tree_Node_as_decision(Tree_Node, Dec),
@@ -2472,6 +2471,10 @@ pip_solution :-
ppl_PIP_Tree_Node_as_solution(TTChild, TTChild_Sol),
ppl_PIP_Solution_Node_get_parametric_values(TTChild_Sol, I, _TPV),
ppl_PIP_Decision_Node_get_false_child(TChild_Dec, FTChild),
+ ppl_PIP_Tree_Node_artificials(FTChild, FTChild_Artificials),
+ FTChild_Artificials = [Art_LinExpr/Art_Den],
+ compare_lin_expressions(Art_LinExpr, M),
+ Art_Den = 2,
ppl_PIP_Tree_Node_as_solution(FTChild, FTChild_Sol),
ppl_PIP_Solution_Node_get_parametric_values(FTChild_Sol, I, _FPV),
ppl_PIP_Problem_OK(PIP),
More information about the PPL-devel
mailing list