# Decision Optimization

View Only

## number of active nodes as a constraint #### Olga Chukhno27 days ago #### ALEX FLEISCHER27 days ago #### Olga Chukhno26 days ago #### Paul Rubin27 days ago • #### 1.  number of active nodes as a constraint

Posted 27 days ago
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
------------------------------

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

Posted 27 days ago
Edited by ALEX FLEISCHER 27 days ago
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 27 days ago
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
------------------------------

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

Posted 26 days ago
Dear Alex,

Thank you a lot!!

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

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

Posted 26 days ago
Dear Paul,

Thank you for introducing this approach!

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