[PEAK] trellis attrs
nicky van foreest
vanforeest at gmail.com
Fri Sep 30 08:05:28 EDT 2011
Dear Philip,
Thanks your answer, and sorry for the confusion. Hopefully the
following is a more illustrative example. It originates from a problem
of one of my students who is doing simulations on job schedules.
There are two jobs j1 and j2. Job j1 consists of tasks t11 and t12,
and job j2 of tasks t21 and t22. There is a machine that processes
these tasks as batches. Suppose a schedule is like this. The first
batch consists of task t11, the second batch of tasks t12 and t21, and
the third batch of task t22. Batches have to be served by the machine
in sequence, and a batch can only start when the previous batch in
finished. Thus, for instance, before batch 3 can start, all tasks in
batch 2 have to be finished. Given processing times for each task, I
need to compute the total completion time of all jobs.
I would like to implemented this with trellis, because this allows me
to formulate the problem in the form of a recursion. A batch can only
start when all previous tasks related to the jobs in the batch have
been finished (in the example of batch 3, this set of previous tasks
consists of task 21), and the starting time of a batch is the latest
finish time of all these previous tasks. Then the finish time of a
batch is its starting time plus its processing time, and the finish
times of all tasks in a batch are equal to the finish time of the
batch, and so forth. Moreover, if I change a processing time of some
task, the effect of this will be automatically propagated by trellis.
So all in all, I can write neat, nice and concise code, and let
trellis handle the hard parts.
Now it comes to implementing a batch. I had in mind to implement the
set of previous tasks (of a batch) as a trellis set, because if I add
another task to a batch, the set of previous tasks will be affected,
hence a lot of starting and finish times need to be updated (which I
would like to be handled by trellis). I tried the following, but this
failed.
class Batch(trellis.Component):
trellis.attrs(
prevs = trellis.Set([],
duration = 0,
)
...
The problem is that all batches use the same trellis.Set, but I want
each batch to have its own trellis.Set. How can I achieve this? Or
otherwise, suppose the set of previous tasks and batch tasks are
implemented in the form of regular python sets. How can I use trellis
to update the entire schedule (and all involved times) when I add or
remove tasks from the set of batch tasks? (I know that removing an
item from a trellis.set is impossible. For that reason I actually
would prefer to use regular sets, rather than trellis sets. )
Nicky
On 29 September 2011 23:57, PJ Eby <pje at telecommunity.com> wrote:
>
> On Thu, Sep 29, 2011 at 3:45 PM, nicky van foreest <vanforeest at gmail.com>
> wrote:
>>
>> Hi,
>>
>> I would like to have an trellis.component with a trellis.set as one of
>> its attributes. For instance, (stupid example) suppose a child's first
>> names will be the first names of all its uncles and aunts. Then I
>> don't know beforehand how many names the child will get, so I cannot
>> specify a fixed number of attrs at the beginning of the
>> trellis.component that represents a child. I tried to achieve this by
>> using a trellis.set, but then it turns out that each child gets the
>> same trellis.set, rather than its own. Is there some other way to
>> resolve this?
>
> You'll need to give a more concrete example, preferably including some code.
> So far, I have no idea what it is that you're trying to do. (It sounds
> like you're saying you want one attribute, but then later it sounds like you
> want more than one attribute, and at one place it sounds like you want a set
> that's derived from some other set, and then... I'm not sure what you want.
> ;-) )
>>
>> Thanks.
>>
>> Nicky
>> _______________________________________________
>> PEAK mailing list
>> PEAK at eby-sarna.com
>> http://www.eby-sarna.com/mailman/listinfo/peak
>
>
More information about the PEAK
mailing list