Jorge Marques Pelizzoni wrote:
Mark,
Your current problem must not be hard to solve, but I guess your
sample code does not show enough to help you. Depending on how things
are set up before (and inside) it, it might just as well work
perfectly...
I'll see if I can explain things a bit more..
This example code is similar to my problem (although a large amount of
propagation is missing)
declare Min Max
Lookup={NewCell nil}
%a list of cardinality values
Lookup:=["min 3#max 5" "min 1#max 4" "min 1#max 1"]
Num=50 %number of actors
%proc to split cardinality strings
proc {GetCard Str ?Min ?Max}
Split1 Split2 in
{String.token Str &# Split1 Split2}
Min={String.toInt {String.token Split1 32 _ $}}
Max={String.toInt {String.token Split2 32 _ $}}
end
proc {Script Root}
%a list of actors
Ls={List.number 1 50 1}
%a record of FS's representing other participants of action
Set={FS.var.record.upperBound solution {List.number 1 50 1} 1#50}
%a FD list of actions available to 'actors'
Actions={FD.list 50 1#3}
in
%create tuple to represent solution of
%actor(x)#action(y)#recipient-actors(z1..zn)
Root={Record.mapInd Set fun {$ I A} {Nth Ls I}#{Nth Actions I}#A end}
%each FS in Set is disjoint and their union is the set of all 'actors'
{FS.partition Set {FS.value.make [1#50]}}
%distribute actions randomly
{FD.distribute generic(value:fun {$ A}
{List.map
{List.sort
{List.map
{FD.reflect.domList A}
fun {$ X}
X#{OS.rand}
end}
fun {$ Y Z}
M N in Y=_#N Z=_#M
N>M
end}
fun {$ A}
O in A=O#_ O
end}.1
end) Actions}
%distribute sets (could just as easily be 'naive')
{FS.distribute generic(sel:min cost:card comp:unknown) Set}
end
{Explorer.one Script}
This script as it stands gives a solution (all 50 actors doing some
action with the first actor in Ls).
The two things I need to express are:
1. Each action value X in the list of Actions is used to get the
cardinality values for it's associated set. The cardinality of each FS
should be EITHER 0 or between Min and Max as returned from {GetCard..}.
One of the attempts I made (ignoring the 'either 0' part) is:
thread
{Record.forAllInd Set proc {$ I A}
Min MaxTemp Max in
{GetCard {Nth @Lookup {Nth Actions I}} Min
MaxTemp}
if Num<MaxTemp then Max=Num else Max=MaxTemp end
%if not enough actors to do the action
if Num<Min then {FS.card A 0} else
%otherwise limit card
case {FS.reflect.card A} of L#U then
(L>Min)=true
(U=<Max)=true
%what if card of A is determined?
[] D then
(D>Min)=true
(D=<Max)=true
end
end
end}
end
...which is completely wrong!!! What I want is a choice statement
between 0 or Min<card(set)<Max but I gather you can't use choice within
a search script? If I try to just use cardRange I can use Min and Max
but I exclude the possibility that cardinality could be 0.
2. For every X in a determined FS, {FS.card Set.X 0}. In other words if
an actor has been used in an action, make their corresponding set the
empty set.
In essence, what I'm looking to get from the search script is a record
of main-actor#action#{set of other-actors} tuples where each actor
appears as (the main-actor with attached other-actors) OR (in the set of
other-actors AND as the main-actor with an empty set of other actors).
Also each FS should either be empty or have a cardinality between Min
and Max as returned from {GetCard...}. The distribution should be as
random as possible - as a side note, would the randomised distribution
method work with FS also?
The main problem I have is either posting two possible constraints on
the cardinality of the same set or a badly modelled problem :+)
I'm still not convinced I've explained this very well but if anyone can
offer any suggestions I'd be very grateful.
Regards
Mark
--
Mark Richardson MBCS
Research Assistant
University of Teesside, UK
Email: [email protected]
[email protected]
Skype: mark.richardson.
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users