| |||||||||||||||||
Resource profiles Description
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
resource_profile.mos (!**************************************************************** CP example problems =================== file resource_profile.mos ````````````````````````` Scheduling tasks with non-constant resource usage profiles. (c) 2008 Artelys S.A. and Fair Isaac Corporation *****************************************************************!) model "Non constant resource usage" uses "kalis" forward procedure print_solution(tasks: set of cptask, resources: set of cpresource) declarations res1,res2: cpresource taska,taskb,taskc: cptask end-declarations taska.start <= 15 taska.duration = 4 taskb.start <= 15 taskb.duration = 3 taskc.start <= 15 taskc.duration = 5 ! Define a discrete resource with periods of unavailability set_resource_attributes(res1, KALIS_DISCRETE_RESOURCE, 6) setcapacity(res1, 0, 15, 0) setcapacity(res1, 1, 5, 6) setcapacity(res1, 7, 11, 6) requires(taska, {resusage(res1,[1,3,5,6])}) requires(taskb, {resusage(res1,[5,3,1])}) requires(taskc, {resusage(res1,1,1)}) ! Define a resource with initial capacity at 0 set_resource_attributes(res2, KALIS_DISCRETE_RESOURCE, 0) provides(taska, resusage(res2,[1,3,1,2])) consumes(taskb, resusage(res2,[3,1,2])) produces(taskc, resusage(res2,[3,1,2,0,2])) if not cp_propagate then writeln("Problem is infeasible"); exit(1) end-if while (cp_find_next_sol) do print_solution({taska,taskb,taskc},{res1,res2}) end-do !------------------------------------------------------------- !**** Display results **** procedure print_solution(tasks: set of cptask, resources: set of cpresource) forall(res in resources) do writeln("Resource ", res.name) forall(timeindex in 0..getub(getmakespan)) do write(strfmt(timeindex,3), " Cap: ", getcapacity(res,timeindex)) forall(t in tasks) if getrequirement(t,res,timeindex)>0 then write(", ", t.name, "(req):", getrequirement(t,res,timeindex)) elif getproduction(t,res,timeindex)>0 then write(", ", t.name, "(prod):", getproduction(t,res,timeindex)) elif getconsumption(t,res,timeindex)>0 then write(", ", t.name, "(cons):", getconsumption(t,res,timeindex)) elif getprovision(t,res,timeindex)>0 then write(", ", t.name, "(prov):", getprovision(t,res,timeindex)) end-if writeln end-do end-do end-procedure end-model | |||||||||||||||||
© Copyright 2023 Fair Isaac Corporation. |