Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Scheduling of house building problem with different categories of houses

  • 1.  Scheduling of house building problem with different categories of houses

    Posted Wed July 03, 2019 11:38 AM

    Originally posted by: Mohamed Awad


    Hi,

    I am working on a task similar to house building tutorial. I would like to solve the same model "sched_sequence" but in case of having two categories of houses (A & B). For each category, different tasks are required. How could I modify the existing model to cover my case.

     

    Best regards,

    Mohamed


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Scheduling of house building problem with different categories of houses

    Posted Thu July 04, 2019 01:57 AM

    Hi,

    starting with sched_sequence you could try different kind of houses:

    .mod

     

    using CP;

    int NbHouses = ...;
    range Houses = 1..NbHouses;

    {string} WorkerNames = ...;  
    {string} TaskNames   = ...;
    {string} TaskNamesFast   = ...;

    int    Duration [t in TaskNames] = ...;
    int    DurationFast [t in TaskNamesFast] = ...;
    string Worker   [t in TaskNames] = ...;

    tuple Precedence {
       string pre;
       string post;
    };

    {Precedence} Precedences = ...;
    {Precedence} PrecedencesFast = ...;

    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 (h>=3)?Duration[t]:((t in TaskNamesFast?Duration[t]:0));

    dvar sequence workers[w in WorkerNames] in
        all(h in Houses, t in TaskNames: Worker[t]==w && ((h<=2)=>(t in TaskNamesFast))) itvs[h][t] types
        all(h in Houses, t in TaskNames: Worker[t]==w  && ((h<=2)=>(t in TaskNamesFast))) h;

    tuple triplet { int loc1; int loc2; int value; };
    {triplet} transitionTimes = { <i,j, ftoi(abs(i-j))> | i in Houses, j in Houses };

    execute {
      cp.param.FailLimit = 30000;
    }

    execute{
            cp.param.timeLimit=60;
    }

    minimize sum(h in Houses)
      (Weight[h] * maxl(0, endOf(houses[h])-DueDate[h]) + lengthOf(houses[h]));
    subject to {

     

      forall(h in Houses:h>=3)
        forall(p in Precedences)
          endBeforeStart(itvs[h][p.pre], itvs[h][p.post]);
          
      forall(h in Houses:h<=2)
        forall(p in PrecedencesFast)
          endBeforeStart(itvs[h][p.pre], itvs[h][p.post]);    
          
          
      forall(h in Houses:h>=3)
        span(houses[h], all(t in TaskNames) itvs[h][t]);
        
        forall(h in Houses:h<=2)
        span(houses[h], all(t in TaskNamesFast) itvs[h][t]);
        
        
      forall(w in WorkerNames)
        noOverlap(workers[w], transitionTimes);
    }

    .dat

    NbHouses = 5;

    WorkerNames = {"Joe", "Jim" };

    TaskNames = {
      "masonry",
      "carpentry",
      "plumbing",
      "ceiling",
      "roofing",
      "painting",
      "windows",
      "facade",
      "garden",
      "moving"
    };

    TaskNamesFast = {
      "masonry",
      "carpentry",
     
      "ceiling",
      "roofing",
     
      "windows",
      "facade",
     
      "moving"
    };

    Duration =  [
      35,
      15,
      40,
      15,
      05,
      10,
      05,
      10,
      05,
      05
    ];

    DurationFast =  [
      35,
      15,
     
      15,
      05,
     
      05,
      10,
     
      05
    ];

    Worker = #[
      "masonry"  : "Joe" ,
      "carpentry": "Joe" ,
      "plumbing" : "Jim" ,
      "ceiling"  : "Jim" ,
      "roofing"  : "Joe" ,
      "painting" : "Jim" ,
      "windows"  : "Jim" ,
      "facade"   : "Joe" ,
      "garden"   : "Joe" ,
      "moving"   : "Jim"
    ]#;

    ReleaseDate = [  0,     0,   151,    59,   243];
    DueDate     = [120,   212,   304,   181,   425];
    Weight      = [100.0, 100.0, 100.0, 200.0, 100.0];

    Precedences = {
      <"masonry",   "carpentry">,
      <"masonry",   "plumbing">,
      <"masonry",   "ceiling">,
      <"carpentry", "roofing">,
      <"ceiling",   "painting">,
      <"roofing",   "windows">,
      <"roofing",   "facade">,
      <"plumbing",  "facade">,
      <"roofing",   "garden">,
      <"plumbing",  "garden">,
      <"windows",   "moving">,
      <"facade",    "moving">,
      <"garden",    "moving">,
      <"painting",  "moving">
     };
     
     PrecedencesFast = {
      <"masonry",   "carpentry">,
     
      <"masonry",   "ceiling">,
      <"carpentry", "roofing">,
     
      <"roofing",   "windows">,
      <"roofing",   "facade">,
     
     
     
      <"windows",   "moving">,
      <"facade",    "moving">,
     
     
     };

     

    regards

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Scheduling of house building problem with different categories of houses

    Posted Thu July 04, 2019 05:47 AM

    Originally posted by: Mohamed Awad


    Dear Alex,

     

    I am really grateful for your kind help. I would like to ask how to use the house category name instead of using the house number. Also, I would be grateful if you could explain the following part of your code (the part after size):

    dvar interval itvs [h in Houses][t in TaskNames] size (h>=3)?Duration[t]:((t in TaskNamesFast?Duration[t]:0));

     

    Best regards,

    Mohamed


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Scheduling of house building problem with different categories of houses

    Posted Thu July 04, 2019 06:00 AM

    Hi,

    here houses have interger ids but if they had names it would be the same.

    dvar interval itvs [h in Houses][t in TaskNames] size (h>=3)?Duration[t]:((t in TaskNamesFast?Duration[t]:0));

    means that if the house is more than 3 the size of the itvs is Duration[t] else it is Duration[t] only if t is in the tasks to build a house very fast and else that s 0

    Remember that (condition)?value1:value2 is the ternary operator like in C

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Scheduling of house building problem with different categories of houses

    Posted Thu July 04, 2019 06:16 AM

    Originally posted by: Mohamed Awad


    Hi Alex,

     

    Thanks again for your great support. I have a final question to close my request. How the problem will look like if I have more than 2 categories of houses.

     

    Thanks a million

    Mohamed


    #DecisionOptimization
    #OPLusingCPOptimizer