Decision Optimization

 View Only
  • 1.  number of active nodes as a constraint

    Posted Wed September 22, 2021 06:39 AM
    Hello!
    I need to use the number of active nodes as a constraint.
    The following expression works well:
    dexpr float AS[t in Slots]= (sum(w in Servers) ((sum(s in SVES) Assign[t][s][w]) >=1));
    Here, Assign is a boolean variable.

    However, when I try to do the following as a constraint:
    //forall (t in Slots) 1/(sum(w in Servers) ((sum(s in SVES) Assign[t][s][w]) >=1))<=1;


    it returns me an error.: 
    CPLEX(default) cannot extract expression

    How can I overcome this situation?


    ------------------------------
    Best regards,
    Olga
    ------------------------------

    #DecisionOptimization


  • 2.  RE: number of active nodes as a constraint

    Posted Wed September 22, 2021 07:25 AM
    Edited by System Fri January 20, 2023 04:44 PM
    Hi,

    you could try to use CP:

    using CP;

    range Slots=1..2;
    range Servers=1..2;
    range SVES=1..3;
    dvar boolean Assign[Slots][SVES][Servers];

    subject to {
    forall (t in Slots)
    1/(sum(w in Servers) ((sum(s in SVES) Assign[t][s][w]) >=1))<=1; }


    works fine


    Or you could write a linear constraint instead of the inverse:


    range Slots=1..2;
    range Servers=1..2;
    range SVES=1..3;

    dvar boolean Assign[Slots][SVES][Servers];

    subject to
    {

    forall (t in Slots)
    sum(w in Servers) ((sum(s in SVES) Assign[t][s][w]) >=1)>=1;

    }

    regards

    And yes Optimization can help IT



    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: number of active nodes as a constraint

    Posted Thu September 23, 2021 02:32 AM
    Dear Alex,

    Thank you a lot!!

    ------------------------------
    Best regards,
    Olga
    ------------------------------



  • 4.  RE: number of active nodes as a constraint

    IBM Champion
    Posted Wed September 22, 2021 06:16 PM
    Assuming that you are trying to enforce the constraint that for each value of t there exists a value of w such that Assign[t][s][w] is 1 for at least one value of s, you could do it in CPLEX as follows. Add a continuous variable y[t][w] with domain [0,1]. For each combination of t and w, add the constraint y[t][w] <= sum(s in SVES) Assign[t][s][w]. Finally, for each t add the constraint sum(w in Servers) y[t][w] >= 1.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 5.  RE: number of active nodes as a constraint

    Posted Thu September 23, 2021 02:38 AM
    Dear Paul, 

    Thank you for introducing this approach!

    ------------------------------
    Best regards,
    Olga
    ------------------------------