I have asked Chat GPT for the code below but it's not worked. Could you help me please
// Number of materials and time periods
int N = 2; // Number of materials
int T = 3; // Number of periods
// Input data
float p[N][T] = [ [10, 12, 15], [8, 9, 11] ]; // Unit cost of materials
float s[N][T] = [ [5, 5, 5], [3, 3, 3] ]; // Setup cost
float h[N][T] = [ [2, 2, 2], [1, 1, 1] ]; // Inventory holding cost
float d[N][T] = [ [20, 15, 10], [10, 5, 8] ]; // Production demand
float r[N] = [1, 1]; // Resource usage per material
float C[T] = [30, 25, 20]; // Maximum resource capacity per period
float M = 1000; // Large constant for linking constraints
// Decision variables
dvar float+ x[N][T]; // Quantity purchased of material i in period t
dvar float+ I[N][T]; // Inventory level of material i at the end of period t
dvar boolean Y[N][T]; // Binary variable: 1 if material i is purchased in period t, otherwise 0
// Objective function: Minimize total costs
minimize
sum(i in 0..N-1, t in 0..T-1) (p[i][t] * x[i][t] + s[i][t] * Y[i][t] + h[i][t] * I[i][t]);
// Constraints
subject to {
// 1. Balance supply and demand
forall(i in 0..N-1, t in 0..T-1) {
if (t == 0) // Initial period
x[i][t] - I[i][t] == d[i][t];
else // Subsequent periods
I[i][t-1] + x[i][t] - I[i][t] == d[i][t];
}
// 2. Resource capacity constraints
forall(t in 0..T-1)
sum(i in 0..N-1) r[i] * x[i][t] <= C[t];
// 3. Linking constraint between x and Y
forall(i in 0..N-1, t in 0..T-1)
x[i][t] <= M * Y[i][t];
}
------------------------------
Thuận Nguyễn
------------------------------