From: Barry B. <bar...@st...> - 2008-11-13 20:05:02
|
Hi Thomas, Thanks for your interest in IRIS! I've had a look at your program and have some comments. First of all, anything in quotes (single or double) is interpreted as a string. So these values won't give any results when used with arithmetic built-ins predicates. Numbers with no '.' are assumed to be integers and numbers with a '.' are double precision, i.e. java 'double' type. You can even be more specific by using constructors, e.g. _float(1.2), _decimal(3), etc. Assuming you want to use floating point numbers, I re-wrote your program to: database(1.0, 10.0, 100.0). database(2.0, 5.0, -10.0). score(?s, ?x1, ?x2) :- 3 * ?x1 =?wx1, 2 * ?x2 = ?wx2, ?wx1 + ?wx2 = ?s. ds(?id, ?s) :- database(?id, ?x1, ?x2), score(?s, ?x1, ?x2). ?-ds(?id, ?s). However, I'm not sure what you are trying to do. Certainly, the rule with "score(?s, ?x1, ?x2)" in the head is un-safe (unbound head variables). IRIS can be configured to handle un-safe rules, however, but it seems you are trying to 'pass' values for ?x1 and ?x2 and 'return' something for ?s, i.e. use score() like a function call. This may be possible in proper logic programming, but sadly not so in simple'ish Datalog. However, if you combine the two rules: database(1.0, 10.0, 100.0). database(2.0, 5.0, -10.0). ds(?id, ?s) :- database(?id, ?x1, ?x2), 3 * ?x1 =?wx1, 2 * ?x2 = ?wx2, ?wx1 + ?wx2 = ?s. ?-ds(?id, ?s). Then you get rid of the unsafe rule and this computes quite nicely: Query: ?- ds(?id, ?s). ==>> 2 rows in 0ms Variables: ?id, ?s (1.0, 230.0) (2.0, -5.0) I hope this helps, barry -- Barry Bishop Senior Scientific Programmer Semantic Technology Institute (STI) University of Innsbruck, Austria ----------------------------------- E-Mail: bar...@st... Tel: +43 512 507 96873 ----------------------------------- Thomas TRIPLET wrote: > Hello all ! > > I need to use Datalog and I found IRIS which looks like it is exactly > what I am looking for. > > I'm kinda struggling with the syntax though. this should work but does not: > > database('1', '10', '100'). database('2', '5', '-10'). score(?s, ?x1, > ?x2) :- 3 * ?x1 =?wx1, 2 * ?x2 = ?wx2, ?wx1 + ?wx2 = ?s. ds(?id, ?s) :- > database(?id, ?x1, ?x2), score(?s, ?x1, ?x2). ?-ds(?id, ?s). > > I > have a database with an id and 2 values for each. I need to computer a weighted sum of those values for each id and return the sum. > But for some reason, this doesn't work. It's working with another Datalog interpreter (MLPQ) so I am not sure what I am missing here. > > By the way does anyone know if IRIS uses double or simple precision for numbers? > > > Thanks for any input! > Thomas > > -- > Thomas Triplet > PhD student - Bioinformatics > Computer Science and Engineering Department > University of Nebraska - Lincoln, USA > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > iris-reasoner-support mailing list > iri...@li... > https://lists.sourceforge.net/lists/listinfo/iris-reasoner-support |