Sure, I can help you write a GAMS (General Algebraic Modeling System) code for this linear programming problem. Here's how you can set it up:
* Sets and Parameters
SET i / 1*3 /; ! Set containing mine indices
ALIAS (i,j);
PARAMETER
P(i) Cost per tone extracted from mine i /1 50, 2 55, 3 62/
CAP(i) Capacity of mine i /1 120, 2 100, 3 140/;
SCALAR
Ash_limit /0.05/
Sulfur_limit/0.04/;
TABLE Demand(j,i) Customer demand coefficients
1 2 3
1 4 9 8
2 6 6 12
3 8 7 3
4 12 11 5;
PARAMETER
RHS_demand(j) Right-hand side of customer demand constraints
/1 80, 2 70, 3 60, 4 90/;
SCALAR
RHS_capacity(i);
RHS_capacity(i) = CAP(i);
PARAMETER
Ash_coeff(i) Ash content coefficients /1 0.08, 2 0.06, 3 0.04/
Sulfur_coeff(i) Sulfur content coefficients /1 0.05, 2 0.04, 3 0.03/;
* Variables
VARIABLES X(i) Number of tones extracted from mine i;
POSITIVE VARIABLES X(i);
VARIABLE
Z Objective function value;
* Objective Function
EQUATION obj;
obj.. Z =E= SUM(i, P(i) * X(i));
* Constraints
EQUATION
ash_content Ash content constraint,
sulfur_content Sulfur content constraint,
capacity(i) Capacity constraint,
customer_demand(j) Customer demand constraints;
ash_content..
SUM(i, Ash_coeff(i) * X(i)) / SUM(i, X(i)) =L= Ash_limit;
sulfur_content..
SUM(i, Sulfur_coeff(i) * X(i)) / SUM(i, X(i)) =L= Sulfur_limit;
capacity(i)..
X(i) =L= RHS_capacity(i);
customer_demand(j)..
SUM(i, Demand(j,i) * X(i)) =G= RHS_demand(j);
* Model definition
MODEL MinimizeCost /all/;
* Solve statement
SOLVE MinimizeCost USING LP MINIMIZING Z;
* Display results
DISPLAY X.l, Z.l;
Explanation:
-
Sets and Parameters:
- We define a set
i which represents the different mines.
- Parameters are defined to store cost, capacity, ash content coefficients, sulfur content coefficients, and demand coefficients.
-
Variables:
- The
X(i) variable represents the number of tones extracted from mine i.
Z is the objective function value which is to be minimized.
-
Objective Function:
- The function minimizes the total cost of tones extracted from all mines.
-
Constraints:
- The ash and sulfur content constraints are defined to ensure the mixture's content does not exceed specified limits.
- Capacity constraints ensure that the extraction does not exceed the capacity of each mine.
- Customer demand constraints ensure that the demand from each customer is satisfied.
-
Model Definition and Solving:
- The
MODEL statement names the model, and SOLVE statement with USING LP indicates that this is a linear programming problem. It aims to minimize the Z.
-
Display Results:
- Finally, we display the values of variables and the minimized cost.
This code formulates and solves the problem you described using GAMS. Make sure you have a working GAMS environment to run this code. Adjust paths or any initial settings specific to your setup if needed.