(!******************************************************
CP Example Problems
===================
file b5paint_ka.mos
```````````````````
Planning of paint production
(See "Applications of optimization with Xpress-MP",
Section 7.5 Paint production)
*** This model cannot be run with a Community Licence
for the provided data instance ***
(c) 2008 Artelys S.A. and Fair Isaac Corporation
*******************************************************!)
model "B-5 Paint production (CP)"
uses "kalis"
declarations
NJ = 5 ! Number of paint batches (=jobs)
JOBS=1..NJ
DUR: array(JOBS) of integer ! Durations of jobs
CLEAN: array(JOBS,JOBS) of integer ! Cleaning times between jobs
CB: array(JOBS) of integer ! Cleaning times after a batch
succ: array(JOBS) of cpvar ! Successor of a batch
clean: array(JOBS) of cpvar ! Cleaning time after batches
y: array(JOBS) of cpvar ! Variables for excluding subtours
cycleTime: cpvar ! Objective variable
end-declarations
initializations from 'Data/b5paint.dat'
DUR CLEAN
end-initializations
forall(j in JOBS) do
1 <= succ(j); succ(j) <= NJ; succ(j) <> j
1 <= y(j); y(j) <= NJ
end-do
! Cleaning time after every batch
forall(j in JOBS) do
forall(i in JOBS) CB(i):= CLEAN(j,i)
clean(j) = element(CB, succ(j))
end-do
! Objective: minimize the duration of a production cycle
cycleTime = sum(j in JOBS) (DUR(j)+clean(j))
! One successor and one predecessor per batch
all_different(succ)
! Exclude subtours
forall(i in JOBS, j in 2..NJ | i<>j)
implies(succ(i) = j, y(j) = y(i) + 1)
! Solve the problem
if not cp_minimize(cycleTime) then
writeln("Problem is infeasible")
exit(1)
end-if
cp_show_stats
! Solution printing
writeln("Minimum cycle time: ", getsol(cycleTime))
writeln("Sequence of batches:\nBatch Duration Cleaning")
first:=1
repeat
writeln(" ", first, strfmt(DUR(first),8), strfmt(getsol(clean(first)),9))
first:=getsol(succ(first))
until (first=1)
end-model
|
(!******************************************************
CP Example Problems
===================
file b5paint2_ka.mos
```````````````````
Planning of paint production
(See "Applications of optimization with Xpress-MP",
Section 7.5 Paint production)
- Alternative formulation using disjunctions and
2D element constraints -
(c) 2008 Artelys S.A. and Fair Isaac Corporation
*******************************************************!)
model "B-5 Paint production (CP)"
uses "kalis"
declarations
NJ = 5 ! Number of paint batches (=jobs)
JOBS=1..NJ
DUR: array(JOBS) of integer ! Durations of jobs
CLEAN: array(JOBS,JOBS) of integer ! Cleaning times between jobs
rank: array(JOBS) of cpvar ! Number of job in position k
clean: array(JOBS) of cpvar ! Cleaning time after batches
cycleTime: cpvar ! Objective variable
end-declarations
initializations from 'Data/b5paint.dat'
DUR CLEAN
end-initializations
forall(k in JOBS) setdomain(rank(k), JOBS)
! Cleaning time after every batch
forall(k in JOBS)
if k<NJ then
element(CLEAN, rank(k), rank(k+1)) = clean(k)
else
element(CLEAN, rank(k), rank(1)) = clean(k)
end-if
! Objective: minimize the duration of a production cycle
cycleTime = sum(j in JOBS) DUR(j) + sum(k in JOBS) clean(k)
! One position for every job
all_different(rank)
! Solve the problem
if not cp_minimize(cycleTime) then
writeln("Problem is infeasible")
exit(1)
end-if
cp_show_stats
! Solution printing
writeln("Minimum cycle time: ", getsol(cycleTime))
writeln("Sequence of batches:\nBatch Duration Cleaning")
forall(k in JOBS)
writeln(" ", getsol(rank(k)), strfmt(DUR(getsol(rank(k))),8),
strfmt(getsol(clean(k)),9))
end-model
|
(!******************************************************
CP Example Problems
===================
file b5paint3_ka.mos
````````````````````
Planning of paint production
(See "Applications of optimization with Xpress-MP",
Section 7.5 Paint production)
- Formulation using 'cycle' constraint -
(c) 2008 Artelys S.A. and Fair Isaac Corporation
Creation: 2006, rev. Mar. 2013
*******************************************************!)
model "B-5 Paint production (CP)"
uses "kalis"
setparam("KALIS_DEFAULT_LB", 0)
declarations
NJ = 5 ! Number of paint batches (=jobs)
JOBS=0..NJ-1
DUR: array(JOBS) of integer ! Durations of jobs
CLEAN: array(JOBS,JOBS) of integer ! Cleaning times between jobs
CB: array(JOBS) of integer ! Cleaning times after a batch
succ: array(JOBS) of cpvar ! Successor of a batch
cleanTime,cycleTime: cpvar ! Durations of cleaning / complete cycle
end-declarations
initializations from 'Data/b5paint.dat'
DUR CLEAN
end-initializations
forall(j in JOBS) do
0 <= succ(j); succ(j) <= NJ-1; succ(j) <> j
end-do
! Assign values to 'succ' variables as to obtain a single cycle
! 'cleanTime' is the sum of the cleaning times
cycle(succ, cleanTime, CLEAN)
! Objective: minimize the duration of a production cycle
cycleTime = cleanTime +sum(j in JOBS) DUR(j)
! Solve the problem
if not cp_minimize(cycleTime) then
writeln("Problem is infeasible")
exit(1)
end-if
cp_show_stats
! Solution printing
writeln("Minimum cycle time: ", getsol(cycleTime))
writeln("Sequence of batches:\nBatch Duration Cleaning")
first:=1
repeat
writeln(" ", first, strfmt(DUR(first),8),
strfmt(CLEAN(first,getsol(succ(first))),9) )
first:=getsol(succ(first))
until (first=1)
end-model
|
(!******************************************************
Mosel Example Problems
======================
file b5paint4_ka.mos
```````````````````
Planning of paint production
- Alternative formulation using disjunctions
between tasks -
*** This model cannot be run with a Community Licence
for the provided data instance ***
(c) 2008 Artelys S.A. and Fair Isaac Corporation
*******************************************************!)
model "B-5 Paint production (CP)"
uses "kalis"
declarations
NJ = 5 ! Number of paint batches (=jobs)
JOBS=1..NJ
DUR: array(JOBS) of integer ! Durations of jobs
CLEAN: array(JOBS,JOBS) of integer ! Cleaning times between jobs
task: array(JOBS) of cptask
res: cpresource
firstjob,lastjob,cleanlf,finish: cpvar
L: cpvarlist
cycleTime: cpvar ! Objective variable
Strategy: array(range) of cpbranching
end-declarations
initializations from 'Data/b5paint.dat'
DUR CLEAN
end-initializations
! Setting up the resource (formulation of the disjunction of tasks)
set_resource_attributes(res, KALIS_UNARY_RESOURCE, 1)
! Setting up the tasks
forall(j in JOBS) getstart(task(j)) >= 1 ! Start times
forall(j in JOBS) set_task_attributes(task(j), DUR(j), res) ! Dur.s + disj.
forall(j,k in JOBS) setsetuptime(task(j), task(k), CLEAN(j,k), CLEAN(k,j))
! Cleaning times between batches
! Cleaning time at end of cycle (between last and first jobs)
setdomain(firstjob, JOBS); setdomain(lastjob, JOBS)
firstjob <> lastjob
forall(j in JOBS) equiv(getend(task(j))=getmakespan, lastjob=j)
forall(j in JOBS) equiv(getstart(task(j))=1, firstjob=j)
cleanlf = element(CLEAN, lastjob, firstjob)
forall(j in JOBS) L += getend(task(j))
finish = maximum(L)
! Objective: minimize the duration of a production cycle
cycleTime = finish - 1 + cleanlf
! Solve the problem
if cp_schedule(cycleTime) = 0 then
writeln("Problem is infeasible")
exit(1)
end-if
cp_show_stats
! Solution printing
declarations
SUCC: array(JOBS) of integer
end-declarations
forall(j in JOBS)
forall(k in JOBS)
if getsol(getstart(task(k))) = getsol(getend(task(j)))+CLEAN(j,k) then
SUCC(j):= k
break
end-if
writeln("Minimum cycle time: ", getsol(cycleTime))
writeln("Sequence of batches:\nBatch Start Duration Cleaning")
forall(k in JOBS)
writeln(" ", k, strfmt(getsol(getstart(task(k))),7), strfmt(DUR((k)),8),
strfmt(if(SUCC(k)>0, CLEAN(k,SUCC(k)), getsol(cleanlf)),9))
end-model
|