Decision Optimization

View Only

how to solve a model

• 1.  how to solve a model

Posted Fri March 27, 2020 05:45 AM

Originally posted by: Zgefine

Hi everyone,

I am trying to code following IP model in ILOG CP optimizer?  I coded IP model with CPLEX optimization but i couldn't write its constraint programming version. Can anyone suggest me how to code for this case?

IP model with CPLEX optimization;

// sets
int V=...;  //# of demand locations
int D=...;   // # of potential facility locations
int N=...; // # of  vehicles
range I=1..V;  // set of all demand locations
range J=1..D;  //set of all potential facility locations
range K=1..N;    // set of vehicles

// parameters
int B=...;    // capacity of each vehicle
float t[i][j]= ...; //capacity constraint
float Cap=...;        //capacity of each located facility
float demand[I]=...;     // demand for resource at location i

//decision variables

dvar boolean X[I][J][K];   //1, if customer i served by the kth vehicle of facility j; 0, otherwise
dvar boolean Y[J];         //1, if the facility is located at j;0 , ow.
dvar boolean Z[J][K];      //1, if the kth vehicle is assigned to facility j; 0, ow.

// objective function

maximize sum(i in I, j in J, k in K) demand[i]*X[i][j][k];

//constraints

subject to{
forall(i in I)
sum(j in J, k in K) (X[i][j][k])<=1;
forall(j in J, k in K)
sum(i in I) (b[i][j]*X[i][j][k])<=B*Z[j][k];
forall(j in J)
sum(i in I, k in K) (demand[i]*X[i][j][k])<=cap
forall(j in J, k in K)
Z[j][k]<=Y[j];

}

#DecisionOptimization
#OPLusingCPOptimizer

• 2.  Re: maximum coverage facility location problem

Posted Fri March 27, 2020 12:49 PM

Originally posted by: GGR

Hi

Modeling in constraint programming needs to use Cp Optimizer language algebra and in particular the global constraints and other algebraic facilities. I suppose you have access to the documentation. You may have access to the concepts page in the user manual.

To do this it would be preferable to have a "textual" description of your problem

Reading your model , it looks like to a an allocation problem mix . I suspect you may need  a distribute constraint (count expression) (const. 5) and all different constraints (const. 6) (note I may be wrong)

I will try to express the model from my understanding (sorry if I eventually mistaken). For sake of simplicity I suppose facility location j is j.

//I,J,K are integer that index demands, location and drone from 1 to max. take value 0 if demands or drone and unassigned. table w is modified accordingly w[0] = 0

int var F_d[I in 1...I] in 0 ...J; //Demand I facility are Integer Variable in 1...V

int var K_d[I in 1...I] in 0...K // Demand i Drone

int var F[k in 1...k] in 0...J // Drone facility

maximize sum (I in 1...I) w[F_d] // element expression

//const 1 useless (variable domain)

//const. 2   the number of facilities located to be less than or equal to p
sum(j in J) ( count(all (I in 1...I), j) = 0) >= J-p ;// at most p used (count > 0)

//const. 3    battery range constraints on all the drones
forall(j in 1...J)

sum(I in 1.. I) b_j[F_d] <= B*sum (k in 1..K) ( F[k] > 0) ; \\ b_j energy used by a demand at location j (null for location 0)

//const. 4    the demand served by each located facility to be less than or equal to the capacity of the facility
forall(j in 1..J)
sum(i in 1..I) w_i[j]*(F_d[I] == j) <= U;

//const. 5     Vehicle are assigned only to located facilites
forall(k in1..K, I in 1..I)

(K_d[i] == k) == (F[k] == F_d[I]);

/const. 6   useless

Hope that helps

#DecisionOptimization
#OPLusingCPOptimizer