Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

CP objective function for parallel machines

  • 1.  CP objective function for parallel machines

    Posted Wed February 18, 2009 08:22 PM

    Originally posted by: SystemAdmin


    [lalehkian said:]

    Hi,
    I'm trying to solve a problem with single task jobs on parallel machines with release and due date constraints. I want to minimize cost of  jobs assignment to the machines,  it seems there is something wrong in the code that I have written for the objective function. Would you please help me in this regard. My code is as follows: 
    using CP;

    // Number of Machines (Packing + Manufacturing)
    int nbMachines = ...;
    range Machines = 1..nbMachines;s
    // Number of Jobs
    int nbJobs = ...;
    range Jobs = 1..nbJobs;
    int duration[Jobs][Machines] = ...;
    int cost[Jobs][Machines]=...;
    int release[Jobs] = ...;
    int due[Jobs] = ...;

    dvar interval acts[j in Jobs] in release[j]..due[j];
    dvar interval actsOnRes[j in Jobs][m in Machines] optional size duration[j][m];

    dvar int assign[Jobs] in 1..nbMachines;
    minimize sum (j in Jobs) cost[j , assign[j]];

    constraints {
    forall(j in Jobs)
      alternative (acts[j], all(m in Machines) actsOnRes[j][m]);
     
    forall(m in Machines) 
      noOverlap(all(j in Jobs) actsOnRes[j][m]);

    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: CP objective function for parallel machines

    Posted Wed February 25, 2009 11:57 AM

    Originally posted by: SystemAdmin


    [pvilim said:]

    Hello.

    The trouble here is that the variables [tt]assign[j][/tt] are not used in any constraint, therefore CP-Optimizer can choose any value for them. For your simple example it is not actually necessary to create [tt]assign[j][/tt] variables, the expression to minimize can be directly created using [tt]presenceOf[/tt] constraint. When [tt]presenceOf[/tt] is used as an expression it has value 1 if the interval is present and 0 otherwise. Here is a full working model:
    [tt]
    using CP;

    // Number of Machines (Packing + Manufacturing)
    int nbMachines = ...;
    range Machines = 1..nbMachines;
    // Number of Jobs
    int nbJobs = ...;
    range Jobs = 1..nbJobs;
    int duration[Jobs][Machines] = ...;
    int cost[Jobs][Machines]=...;
    int release[Jobs] = ...;
    int due[Jobs] = ...;

    dvar interval acts[j in Jobs] in release[j]..due[j];
    dvar interval actsOnRes[j in Jobs][m in Machines] optional size duration[j][m];

    minimize sum (j in Jobs, m in Machines) (presenceOf(actsOnRes[j][m])*cost[j][m]);

    constraints {
    forall(j in Jobs)
      alternative (acts[j], all(m in Machines) actsOnRes[j][m]);
     
    forall(m in Machines) 
      noOverlap(all(j in Jobs) actsOnRes[j][m]);
    }
    [/tt]

    Petr
    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: CP objective function for parallel machines

    Posted Thu February 26, 2009 03:11 PM

    Originally posted by: SystemAdmin


    [lalehkian said:]

    Dear Petr,

    Thank you very much indeed. You are right, I had used the function of " presenceOf " in the constraints with the same objective function and the problem was removed.

    Regards
    Laleh
    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: CP objective function for parallel machines

    Posted Tue November 10, 2009 04:40 PM

    Originally posted by: SystemAdmin


    [Jobs said:]

    Thank you





    :) :) :)


    ____________
    [URL=http://www.jobsuche-international.de]Jobs[/URL]
    #CPOptimizer
    #DecisionOptimization