Originally posted by: Mohamed Awad
Dear Phillipe,
Thank you for your kind reply and sorry for my late response as I was trying to adjust your model on a different case. In my case, I have two managers and there is a transition time based on the house category and who is the manager (i.e. the transition time in the case of the same house category and the same manager is zero). In addition, if any manager finishes 4 houses, he takes 20 days of vacation. I am attaching the code i am working on for which, I have the following questions/problems:
- In your solution, the size of every house is the same. In my case, the size is not constant so, I couldn't give a size for dvar interval campaign as you did. How can I solve this problem.
- The no of campaigns is considered for the houses in parallel not to the ones in series. How can I specify it to consider the sum of the houses of the same category that are in series.
- When I changed:
{triplet} transitionCategory = {<i,j, ((item(manCat,i).cat)==(item(manCat,j).cat)?0:10)> | i in manCatTypes,j in manCatTypes};
to:
{triplet} transitionCategory = {<i,j, ((item(manCat,i).cat)==(item(manCat,j).cat)?0:5)> | i in manCatTypes,j in manCatTypes};
I had the following error:
Exception in presolve: Transition matrix for state function does not satisfy the triangle inequality (path 1->0->1). What does the error mean.
The code is sent below and I attached the .dat file. I really appreciate your kind support.
Best regards,
Mohamed
The code:
// --------------------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
// Copyright IBM Corporation 1998, 2013. All Rights Reserved.
//
// Note to U.S. Government Users Restricted Rights:
// Use, duplication or disclosure restricted by GSA ADP Schedule
// Contract with IBM Corp.
// --------------------------------------------------------------------------
using CP;
int NbHouses = ...;
range Houses = 1..NbHouses;
{string} TaskNames = ...;
{string} ManNames = ...;
int Duration [t in TaskNames] = ...;
string Worker [t in TaskNames] = ...;
int k=4; // when this number was 2, it doesn't work as it counted the two batches in parallel not the ones in series
// I made K two times of max campaign number and it worked in case of one type "1".
int n = 9;
int Dcamp=20;
int T[h in 1..n] = ...; // Type of house
//--------------------------------------------------------
//--------------------------------------------------------
tuple Precedence {
string pre;
string post;
};
{Precedence} Precedences = ...;
int ReleaseDate[Houses] = ...;
int DueDate [Houses] = ...;
float Weight [Houses] = ...;
dvar interval houses[h in Houses] in ReleaseDate[h]..(maxint div 2)-1;
dvar interval itvs [h in Houses][t in TaskNames] size Duration[t];
dvar interval campaign [h in Houses] size 31..10000; // it requires a size. I gave it the size of house as it is constact..What will I do if it is variable??!!
dvar interval wtasks [h in Houses][m in ManNames] optional;
dvar sequence Mangs [m in ManNames] in all (h in Houses) wtasks[h][m] types all(h in 1..n) T[h];
cumulFunction campsize = sum(h in 1..n) pulse(campaign[h],1);
tuple triplet {int loc1; int loc2; int value; };
tuple ManCategory {string mang; int cat;};
{ManCategory} manCat={<m,c> | m in ManNames, c in 1..n};
{int} manCatTypes = {ord (manCat,mc)| mc in manCat};
{triplet} transitionMang = {<i,j, ((item(manCat,i).mang)==(item(manCat,j).mang)?0:10)> | i in manCatTypes,j in manCatTypes};
{triplet} transitionCategory = {<i,j, ((item(manCat,i).cat)==(item(manCat,j).cat)?0:5)> | i in manCatTypes,j in manCatTypes};
{triplet} transitionTimes = {<i,j, (tm.value + tc.value)> | i in manCatTypes,j in manCatTypes ,tm in transitionMang,
tc in transitionCategory : i==tm.loc1 && i==tc.loc1 && j==tm.loc2 && j==tc.loc2 && i!=j};
{triplet} transitionCamp = {<i,j,Dcamp> | i in manCatTypes,j in manCatTypes : i==j} union transitionTimes;
stateFunction type4 with transitionCamp;
execute {
cp.param.FailLimit = 20000;
}
minimize max(h in Houses,t in TaskNames ) endOf(itvs[h][t]);
subject to {
forall(h in Houses)
alternative(houses[h], all(m in ManNames) wtasks[h][m]);
forall (h in Houses)
forall (p in Precedences)
endBeforeStart(itvs[h][p.pre] , itvs[h][p.post]);
forall (h in Houses)
span(houses[h], all (t in TaskNames) itvs[h][t]);
forall (m in ManNames)
noOverlap (Mangs[m], transitionTimes);
forall(h in 1..n) {
startAtStart(houses[h], campaign[h]);
alwaysEqual(type4, campaign[h], T[h], 0, 1);
}
campsize <= k;
}
#DecisionOptimization#OPLusingCPOptimizer