Originally posted by: Thomas_321
Hello,
I do have a problem with the second decision variable of my model. I also asked the question in the "CPLEX Optimizers" Forum but they suggested to ask here. I hope you guys can help. (https://www.ibm.com/developerworks/community/forums/html/topic?id=e5026e71-abf5-42ce-86d9-f56946dc58ea&ps=25#repliesPg=0)
The optimization problem:
I have Product Categories (lets start with 2) containing Products. Each Product can be bought from One of the Two Suppliers therefore I have Two Prices for each product. I want to minimize my total costs taking into account the two constraints:
-
60% of the total cost has to be purchased from supplier 1.
-
60% of the total cost of one product category has to be purchased from supplier 1.
My Code:
// Sets
{string} A = ...; // Product categories
{string} B = ...; // Products
// Parameters
float c1[B] = ...; // Product price supplier 1
float c2[B] = ...; // Product price supplier 2
float rate = ...; // Percentage rate purchased from supplier 1
float m = 10000; // Big number
// Decision variables
dvar boolean x[B];
dvar boolean y[A];
// decision expression
dexpr float test = sum (b in B)(c1[b]*x[b]+(1-x[b])*c2[b]); // Minimizing total cost
// objective funtion
minimize test;
// Constraints
subject to{
sum (b in B)c1[b]*x[b] >= rate * sum(b in B)(c1[b]*x[b]+(1-x[b])*c2[b]); // Percentage of total cost purchased from S1
forall (a in A)
sum (b in B) sum (b in B)c1[b]*x[b] >= rate * sum(b in B)(c1[b]*x[b]+(1-x[b])*c2[b])-(1-y[a])*m; // Percentage of total cost of a product category purchased from S1
sum (a in A) y[a] >=1; // Number of product categories which need to reach the percentage rate
}
The Problem is the following:
The decision variable y[a] should turn 1 if the 60% of the total cost of a product category is purchased from S1 (supplier1) but it doesn´t.
As seen below the buying rate for product category A is 38% but y[a] ==1 although the buying rate for product category B is 96% and y[a]==0.
I attached my model and the data.
Thank you, I appreciate the help!
#DecisionOptimization#OPLusingCPLEXOptimizer