-dp- wrote: > One version of my delayed goals looks like this (where BIN stands for > apparently opaque binary content): > > prop_ic_con(ic_con(BIN, 1, BIN, BIN, [](_2355{-1.4142135623731 .. > 1.4142135623731}, ExpectedYPos{27.5857864376269 .. > 30.4142135623731}), 'SUSP-_2399-susp')) > binop_function(pow_int, _2355{-1.4142135623731 .. > 1.4142135623731}, 2.0, _2445{0.0 .. 2.0}, 'SUSP-_2459-susp') > rpow(_2445{0.0 .. 2.0}, 2, 0.5, 0.5, _2355{-1.4142135623731 .. > 1.4142135623731}, 'SUSP-_2523-susp') > > prop_ic_con(ic_con(BIN, 1, BIN, BIN, [](_2771{-1.4142135623731 .. > 1.4142135623731}, ExpectedXPos{42.5857864376269 .. > 45.4142135623731}), 'SUSP-_2815-susp')) > binop_function(pow_int, _2771{-1.4142135623731 .. > 1.4142135623731}, 2.0, _2861{0.0 .. 2.0}, 'SUSP-_2875-susp') > rpow(_2861{0.0 .. 2.0}, 2, 0.5, 0.5, _2771{-1.4142135623731 .. > 1.4142135623731}, 'SUSP-_2939-susp') > > prop_ic_con(ic_con(BIN, 1, BIN, BIN, [](_2445{0.0 .. 2.0}, _2861{0.0 > .. 2.0}), 'SUSP-_3015-susp')) > > > If I coded it right, this should represent a circle of real-valued > points centered at (44, 29) with radius 2 (the constraint was coded as: > 2 $>= (ExpectedXPos - 44) ^ 2 + (ExpectedYPos - 29) ^ 2). > > How should I interpret prop_ic_con, ic_con, binop_function, and rpow so > I can plot, say, a circle in my upcoming visualization? To "decode" the delayed goals, you can use portray_term/3: ?- 2 $>= (ExpectedXPos - 44) ^ 2 + (ExpectedYPos - 29) ^ 2, delayed_goals(Gs), (foreach(G,Gs) do portray_term(G,P,goal), writeln(P)). _10987{-1.4142135623731 .. 1.4142135623731} - ExpectedYPos{27.5857864376269 .. 30.4142135623731} $= -29 _11062{0.0 .. 2.0} $= _10987{-1.4142135623731 .. 1.4142135623731} ^ 2 _10987{-1.4142135623731 .. 1.4142135623731} $= rpow(_11062{0.0 .. 2.0}, 2) _11171{-1.4142135623731 .. 1.4142135623731} - ExpectedXPos{42.5857864376269 .. 45.4142135623731} $= -44 _11246{0.0 .. 2.0} $= _11171{-1.4142135623731 .. 1.4142135623731} ^ 2 _11171{-1.4142135623731 .. 1.4142135623731} $= rpow(_11246{0.0 .. 2.0}, 2) _11062{0.0 .. 2.0} + _11246{0.0 .. 2.0} $=< 2 But as you see, the original constraint has been broken up into several propagators, and there is no way to reverse this process. In your case, you may be able to extract the information you need despite this. Note that you can ignore the constraints involving rpow because they are only the inverse form of the exponentiation constraints (nonlinear constraints are usually implemented via several unidirectional propagators). It is probably easier to set up a dedicated delayed goal for visualisation, independent of the propagators, which either remembers your constraint in its original form, or even contains only the data you actually need for the visualisation. For example: vis_circle(X, Y, R) :- writeln(draw_circle(X,Y,R)), suspend(monitor_circle(X,Y,R), 1, [X,Y,R]->constrained). :- demon(monitor_circle/3). monitor_circle(X,Y,R) :- writeln(update_circle(X,Y,R)). Now monitor_circle will get woken every time any of the variables change, and can update your display: ?- [X,Y,R]::0.0..9.9, vis_circle(X, Y, R), R $>= 4, Y $=< 3, X = 8. draw_circle(X{0.0 .. 9.9}, Y{0.0 .. 9.9}, R{0.0 .. 9.9}) update_circle(X{0.0 .. 9.9}, Y{0.0 .. 9.9}, R{4.0 .. 9.9}) update_circle(X{0.0 .. 9.9}, Y{0.0 .. 3.0}, R{4.0 .. 9.9}) update_circle(8, Y{0.0 .. 3.0}, R{4.0 .. 9.9}) X = 8 Y = Y{0.0 .. 3.0} R = R{4.0 .. 9.9} Delayed goals: monitor_circle(8, Y{0.0 .. 3.0}, R{4.0 .. 9.9}) Yes (0.00s cpu) -- JoachimReceived on Fri Dec 11 2009 - 04:17:12 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET