Warehouse
"Practical wisdom is only learnt in the school of experience." -Samuel Smiles
PROJECTS NEWS MESSAGES MAILING LIST  
AI Game Development
Learn how to create smart creatures in computer games that learn and react to their environment. Neural networks, genetic algorithms, reinforcement learning and more!
More information at Amazon US UK

Reply to Message

Not registered yet?

The AI Depot has a focused community of friendly users. Rather than let anyone abuse the site at the brink of promiscuity, we prefer to let only those with an active interest participate... this simply requires registering.

Why not sign up!

Joining the site's community is completely free. You can then post messages freely, and customise your personal profile at will. Specific privileges will also be granted to you, like being able to access printer-friendly articles without restrictions. So, why not register?

Username:
Password:
Subject:
Email me when someone replies.
Body:

Parent Message

Constraints...

Constraints look very interesting and seem like they would fit in as an interesting component. Just to make sure I understand what you're thinking, take a look at the following and let me know if it fits with your thoughts.

Let me think of a trivial example and some syntax. Hrmm... Never using that paradigm before, it is difficult for me to think of one. Well, I will have to do some programming in a language like Eclipse before I can implement something like that. Maybe a feature for version 2?

If I understand correctly, constraints define variables based on their relationship with other variables. Is that right?

As far as implementing the language goes, I plan on reading some in-depth material about both the Warren and Vienna Abstract Machines this weekend to fine tune my thoughts.

-Steven

7 posts.
Thursday 14 November, 19:15
Reply
Constraint Satisfaction Problems

Constraints are best used with multi-valued variables, i.e. variables with domains bigger than 2. First you define which variables exist and which are their domains, and then you add constraints that forbid some combinations of values to occur simultaneously.

A trivial example? Suppose you have two series A and B of "nucleotide" variables: A1 A2 A3 A4 ... and B1 B2 B3 B4 ... Each of this Ai and Bi variables have the same domain = {adenine, thymine, guanine, cytosine}.

Then you want to match the two series and add a "base pair" constraint between variable A1 and B1, another similar constraint between A2 and B2... Each constraint allows the variables to take only these value pairs: (Ai=adenine, Bi=thymine) (Ai=thymine, Bi=adenine) (Ai=guanine, Bi=cytosine) or (Ai=cytosine, Bi=guanine). All these constraints are equal except for the variables involved.

So if you later assign Ai with value adenine, you can propagate the constraint and prune from Bi the values adenine, guanine and cytosine which are not supported. In this example this leaves you with only 1 value left in the domain of Bi so you can also assign Bi with the value thymine.

If you ever reach a state with an empty domain, for example if Bi was previously decided not to be thymine, you have to backtrack and erase the decision to assign Ai with adenine.

Note that if later in the program you want to try and match the chain A with B shifted one place, i.e. clean the constraints Ai-Bi and put a new constraint between each Ai with B(i+1), then it is a different "constraint problem" and you have to restart the "constraint solver" procedure - the information gathered through the previous solution search is no longer applicable to this new problem.

28 posts.
Monday 18 November, 08:33
Reply
Realization...

That was the perfect example for me; thank you so much. I now understand what constraints are and how useful they can be. My mind is now in a similar state to when I first learned of functional programming after about seven years of imperative programming. Wow. :satisfied grin:

Tomorrow I present my project to the chair of the Computer Science Department for final approval. Methinks that adding constraints to the language will make an excellent project for the summer or fall semester.

On another note, does the syntax of the language bother anyone? Specifically the fact that a predicate can return a list? I'm afraid that some people -- especially those with a strong Prolog background -- may find that notion uneasy.

Thanks again!

-Steven

7 posts.
Monday 18 November, 20:10
Reply
-

Note that your language contains both predicates and functions. A clever idea would be to cleanly distinguish them.

You can define a Boolean type for predicates, and a typecast from empty and non-empty function returns to boolean. The typecast may be implicit (maybe in the :- operator?) or explicit.

28 posts.
Tuesday 19 November, 05:12
Reply
Predicates as a special function

I was thinking about that as I lay in bed this morning. My initial idea was to allow predicates to return lists, but my teacher was having trouble with that. So I started thinking of implementing predicates as a boolean function [easily definable in Haskell] with the ability to unify with other predicates, which actually seems to be easier from an implementation standpoint.

Boy, aren't the things I think about in bed oh-so interesting? :rolleyes:

-Steven

7 posts.
Tuesday 19 November, 09:17
Reply

Back to the AI Foundry.