From 614e7ab8564ee4f91fab0ccfbeb862f69fbda2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Wed, 4 Sep 2013 17:01:37 +0100 Subject: [PATCH] initialize FloatVar --- library/gecode/gecode4_yap.cc | 13 +++++++++++++ library/gecode/gecode4_yap_hand_written.yap | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/library/gecode/gecode4_yap.cc b/library/gecode/gecode4_yap.cc index 429564ab9..640a03f8b 100644 --- a/library/gecode/gecode4_yap.cc +++ b/library/gecode/gecode4_yap.cc @@ -599,6 +599,17 @@ extern "C" return YAP_Unify(ivar, y_i); } + static int gecode_new_floatvar_from_bounds(void) + { + YAP_Term ivar = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + double lo = YAP_FloatOfTerm(YAP_ARG3); + double hi = YAP_FloatOfTerm(YAP_ARG4); + int i = space->new_fvar(lo, hi); + YAP_Term y_i = YAP_MkIntTerm(i); + return YAP_Unify(ivar, y_i); + } + static int gecode_list_length(YAP_Term l) { @@ -1707,6 +1718,8 @@ extern "C" gecode_new_intvar_from_bounds, 4); YAP_UserCPredicate("gecode_new_intvar_from_intset", gecode_new_intvar_from_intset, 3); + YAP_UserCPredicate("gecode_new_floatvar_from_bounds", + gecode_new_floatvar_from_bounds, 4); YAP_UserCPredicate("gecode_new_boolvar", gecode_new_boolvar, 2); YAP_UserCPredicate("gecode_new_setvar_1", gecode_new_setvar_1, 8); YAP_UserCPredicate("gecode_new_setvar_2", gecode_new_setvar_2, 7); diff --git a/library/gecode/gecode4_yap_hand_written.yap b/library/gecode/gecode4_yap_hand_written.yap index 8aef14527..8cd832f0f 100644 --- a/library/gecode/gecode4_yap_hand_written.yap +++ b/library/gecode/gecode4_yap_hand_written.yap @@ -410,6 +410,14 @@ new_intvar(IVar, Space, IntSet) :- !, gecode_new_intvar_from_intset(Idx,Space_,L), IVar='IntVar'(Idx,-1). +new_floatvar(FVar, Space, Lo, Hi) :- !, + assert_var(IVar), + assert_is_Space_or_Clause(Space,Space_), + assert_float(Lo), + assert_float(Hi), + gecode_new_floatvar_from_bounds(Idx,Space_,Lo,Hi), + FVar='FloatVar'(Idx,-1). + new_boolvar(BVar, Space) :- !, assert_var(BVar), assert_is_Space_or_Clause(Space,Space_),