Originally posted by: Thomas_321
Hello everyone,
I do have a tricky problem with an optimization problem I implemented into Cplex.
I do not have that much of experience in working with cplex, so I have reached my limits at that point and hope you can help me with this problem.
First the description of the problem:
I do have a certain number of products divided into 3 Product Categories A, B and C witch I can buy from 2 Suppliers S1 and S2 for certain prices.
I do also have a constraint that, I have to buy a certain percentage (e.g. 60%) of a certain number of product categories(e.g. 2) from supplier S1 (measured by the value of the prices).
So the first Problem is to minimize my total cost. (Decision variable x[B])
The second problem is to reach the minimum buying percentage rate for a certain number of product categories (e.g. 2). (Decision variable y[A])
(see the model below plus I attached the excel with the data)
My Problem is now the following:
y[A] should turn 1 when the buying rate of a certain product category reached the minimum percentage rate. The problem is it doesn´t.
I set the buying rate at 60% and y[A]>=3 to check the worst case szenario, for all 3 product categories y turns 1 but the actual buying rate for each category is below the 60%.
Can anybody help with this?
Thank you in advance for your time and effort!!!
Code:
// Sets
{string} A = ...; // Categories
{string} B = ...; // Products
// Parameters
float c1[B] = ...; // Product price supplier 1
float c2[B] = ...; // Product price supplier 2
float rate = ...; // Buying rate of supplier 1
float m = 10000;
// Decision variables
dvar boolean x[B];
dvar boolean y[A];
// decision expression
dexpr float test = sum (b in B)(x[b]*c1[b] +(1-x[b])*c2[b]);
// objective funtion
minimize test ;
// Constraints
subject to{
// Constraint to assure the rate is kept
forall (a in A)
sum (b in B) ( x[b] * c1[b] ) >= rate * sum (b in B)(x[b]*c1[b] +(1-x[b])*c2[b])-m*(1-y[a]);
sum (a in A) y[a] >= 3; // At least 3 product categories have to reach the minimum percentage rate
}
Data:
SheetConnection sheet ("D:/Test/Test.xlsx");
A from SheetRead (sheet,"Tabelle1!A5:A27"); // Product Categories
B from SheetRead (sheet,"Tabelle1!B5:B27"); // Products of the respective Product Categories
c1 from SheetRead (sheet,"Tabelle1!C5:C27"); //Price 1 for the Products
c2 from SheetRead (sheet,"Tabelle1!D5:D27"); // Price 2 for the Products
rate from SheetRead (sheet,"Tabelle1!I6"); //buying Rate
x to SheetWrite (sheet,"Tabelle1!E5:E27");
y to SheetWrite (sheet,"Tabelle1!J8:J10");
test to SheetWrite (sheet, "Tabelle1!I3");
I hope the information is enough.
#CPLEXOptimizers#DecisionOptimization