Originally posted by: cplex-newbie
Hi Daniel,
Thanks for the reply. I will go over the link which you sent.
I am using c++ for programming.
Problem I am trying to formulate.
Equation 1:
\sum_{k=2} \sum_{w} C_ij,k,w = 3 ∀(i, j) ∈ Z
Equation 2:
\sum_{(i,j)∈ Z } \sum_{k=2} C_ij,k,w * X_ij,k,l <= 1 ∀l ∈ L ∀w
Equation 3:
\sum_{(i,j)∈ Z } \sum_{k=2} C_ij,k,w <= 2*U^w ∀w
Equation 4:
V >= w*U^w ∀w
Objective : I want to minimize V.
Notation.
1) where C_ij,k,w is the binary decision variable indicating whether
there exists a lightpath on path P_ij,k which uses wavelength
w. Here I am trying to reach from node i to node j along the path
denoted by k.
2) Z is the set of all node pairs in the network.
3) The variable X_ij,k,l = 1 if P_ij,k uses link l and is 0 otherwise.
4) U^w is a binary variable which indicates whether wavelength w is used.
5) V is the number of wavelengths used.
Program :
For equation 1, I am using
for (i = 0; i < nbElements; i++) {
for(j = 0; j < nbElements; j++) {
con.add(IloRange(env, 3, 3);
varCount = 0;
for (k = 0; k < 2; k++) {
for(w = 0; w < 50; w++) {
var.add(IloNumVar(env));
con
conCount.setLinearCoef(var
varCount++, 1.0);
}
}
conCount++;
}
}
For equation 2, I am using
for (i = 0; i < nbElements; i++) {
for(j = 0; j < nbElements; j++) {
varCount = 0;
for (k = 0; k < K; k++) {
for(w = 0; w < W; w++) {
/* some more core over here */
con
conCount.setLinearCoef(var
varCount++, 1.0);
}
}
conCount++;
}
}
I am reusing the constriant from equation 1 in 2 and I am not adding this constriant again to the model.
Is this correct ?
For equation 3, I am using
for (i = 0; i < nbElements; i++) {
for(j = 0; j < nbElements; j++) {
for (k = 0; k < K; k++) {
for(w = 0; w < W; w++) {
//because P=|p| and there are two paths.
model.add(con
conCount <= 2*u_w[w]);
}
}
conCount++;
}
}
Is the model add function correct ?
For equation 4, I am using
for(w = 0; w < W; w++) {
model.add(w*u_w[w] <= V);
}
Is the model add function correct ?
Finally i am adding my objective function.
model.add(IloMinimize(env, V));
Is the model add function correct ?
Thanks,
Shireesh
#CPLEXOptimizers#DecisionOptimization