Re: Resource ALlocation in ECLiPSe

From: Joachim Schimpf <J.Schimpf_at_icparc.ic.ac.uk>
Date: Thu 29 Jul 1999 01:27:04 PM GMT
Message-ID: <37A056A8.D961683C@icparc.ic.ac.uk>
Ranjana Deshpande wrote:
> 
> I need to do some resource allocation work using ECLiPSe.


> TaskSkill5 #= 5..5,
> TaskSkill4 #= 4..4,
> TaskSkill2 #= 2..2,

This should be

  TaskSkill5 #= 5,
  TaskSkill4 #= 4,
  TaskSkill2 #= 2,

The .. notation is not accepted here.



> Resources =[RT1,RT2,RT3],
> Resources ::[a,b,c],
> 
> R1 = resource with [id:a , skill:TaskSkill5],
> R2 = resource with [id:b , skill:TaskSkill4],
> R3 = resource with [id:c , skill:TaskSkill2],
>
> label_resource_assignment(Tasks,Resources),
> labeling(Resources),

You are confusing your resource structures and resource identifiers.
label_resource_assignment/2 expects a list of resource structures
and labeling/1 expects a list of variables ranging over identifiers.

Your code should be:

  ResIds =[RT1,RT2,RT3],
  ResIds ::[a,b,c],

  Resources=[R1,R2,R3],
  R1 = resource with [id:a , skill:TaskSkill5],
  R2 = resource with [id:b , skill:TaskSkill4],
  R3 = resource with [id:c , skill:TaskSkill2],

  label_resource_assignment(Tasks,Resources),
  labeling(ResIds),



With these changes, your program works - in this particular case.
There is another problem in the logic of your
label_resource_assignment/2:

> label_resource_assignment(Tasks,Resources):-
> 
>         (foreach(Task,Tasks), param(Resources) do
>                 (foreach(Resource,Resources), param(Task) do
>                         Task = task with [skill: TaskSkill, resID :Res],
>                         Resource = resource with [skill:ResSkill, id :
> ResId],
>                         ( TaskSkill == ResSkill ->
>                             Res =ResId
>                         ;
>                             true
>                         )
>                 )
>         ).

You assign (in the inner loop) ALL resources with the right skill
to the task - this will fail if there is more than one resource for a
skill.

What you could do is to first eliminate all resource ids that do not
have the required skill - that will leave the resID variable for the
task ranging just over the possible resources - and then use standard
labeling on these resource id variables, as you already do.


 restrict_resource_assignment(Tasks,Resources):-    
        (foreach(Task,Tasks), param(Resources) do
                (foreach(Resource,Resources), param(Task) do
                        Task = task with [skill: TaskSkill, resID :Res],
                        Resource = resource with [skill:ResSkill, id
:ResId],
                        ( TaskSkill == ResSkill -> 
                            true
                        ;
                            Res #\= ResId
                        )
                )
        ).



 
------------------------------------------------------------------------
 Joachim Schimpf                /               phone: +44 171 594 8187
 IC-Parc, Imperial College     /              mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK           /      http://www.icparc.ic.ac.uk/eclipse
Received on Thu Jul 29 14:34:04 1999

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:04 PM GMT GMT