Originally posted by: JJC_UAB
someone knows how to solve this (Define dvars ... and constraints)
using CP;
{string} ComputerTypes = ...;
{string} ActivityTypes = ...;
{string} ResourceTypes = ...;
// Production work orders
int requiredQuantities[ComputerTypes] = ...;
/*************************************************
* An activity consists of
* - an activity type,
* - a duration,
* - a unary resource requirement, and
* - a list of precedences.
*************************************************/
tuple ActivityData {
key string name;
int duration;
string requirement;
{string} precedences;
};
{ActivityData} activities[ComputerTypes] = ...;
/********************************************************
* Each particular activity for each computer consist of:
* - a defined activity
* - for a computer type
* - for each computer to be manufatured
********************************************************/
tuple ComputerActivityMatch {
ActivityData activity;
string computerType;
int computer;
};
// All activities that must get scheduled
{ComputerActivityMatch} allActivities = {<a,c,j> | c in ComputerTypes,
a in activities[c],
j in 1..requiredQuantities[c]};
// The activities which must precede an activity
{ComputerActivityMatch} precedences[a in allActivities] = { b | b in allActivities :
a.computerType == b.computerType &&
a.computer == b.computer &&
b.activity.name in a.activity.precedences };
/********************************************************
* Resource data consists of:
* - ResourceType
* - Number of available resorces of this type
*******************************************************/
tuple ResourceData {
key string resourceType;
int available;
}
// for describing each resource (machine)
tuple ResourceUnit{
string resourceType;
int unit;
}
/*************************************
* Reads the defined resource units
* for each resource type
*************************************/
{ResourceData} resources = ...;
{ResourceUnit} availableResources = {<r.resourceType, i> | r in resources, i in 1..r.available};
/**********************************************
* Represent the pairs activity<->resouce unit
**********************************************/
tuple JobAllocation {
ComputerActivityMatch job;
int machineId;
}
/*********************************************
* Define the domain for the different
* choices when assigning a job to a machine
*********************************************/
{JobAllocation} jobAllocations = {<job, unit> |
job in allActivities, r in resources, unit in 1..r.available : job.activity.requirement == r.resourceType};
dvar interval activity[a in allActivities] size a.activity.duration;
dvar interval jobAllocation ...; // complete the dvar declaration accordingly
dvar sequence resource[r in availableResources] ...; // complete the dvar declaration accordingly
// Constraints labels
constraint Precedence[allActivities,allActivities];
execute {
cp.param.FailLimit = 10000;
}
dexpr int makespan = // Complete makespan expression;
minimize makespan;
subject to {
// Remove symmetry
// Each activity is performed only once
// Resource Requirements
// Precedences
};
This is an extension of the problem https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/examples/html/opl/models/sched_flowshop2/sched_flowshop2.mod.html
#ConstraintProgramming-General#DecisionOptimization