Kari Pahula wrote:
On Wed, Sep 14, 2005 at 07:33:25PM -0700, Lyle Kopnicky wrote:

b) Y = 2 - X ^ Z = 3 + X + Y ^ Z = 4

I wrote that in Oz as:

local X Y Z in
 Y = 2 - X
 Z = 3 + X + Y
 Z = 4
 {Browse [X Y Z]}
end

It didn't show an answer. Since it is an unsatisfiable problem, I had hoped to get an exception.

There's no magic. Search is not automatic as in Prolog. Kari made the right suggestion for you:

I suggest that you look at the finite domain constraint programming
tutorial.  There you can find out how to write a script to state
constraint problems and how to search for solutions for them.

You can search for integer solutions to your problem with the following program. It will find there is no solution.

declare
proc {ProblemB Sol}
   sol(x:X y:Y z:Z) = Sol     %% declare X,Y,Z
in
   Sol ::: FD.inf#FD.sup      %% initial domain of Sol
   Y =: 2 - X                 %% post constraints
   Z =: 3 + X + Y
   Z =: 4
   {FD.distribute ff Sol}     %% specify heuristics
end
{Browse {SearchAll ProblemB}}   %% shows nil (no solution)

local X Y in
 X + Y = 5
 X - Y = 12
 {Browse [X Y]}
end

I think it should give the answer [8.5 ~3.5], but it returned nothing.

The current official Mozart implementation does not provide constraints over real numbers. But there exists an additional library that does it; it is called XRI (http://home.gna.org/xrilpoz/). Such problems like yours can be solved efficiently by an LP solver.

Cheers,
raph

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to