I'm working on a project on cplex and this is the case:
- it's a chemical plant where's produced and sold 2 final products
- there are 3 reactors and each reactor can perform different tasks, one at a time
- the objective function maximizes the total profit
- the solutions present the value calculated for this objF and also shows the sequence of activation of each reactor, and the the profit from each cycle
Problem: Now I've been given the choice to add one more reactor (and it can be any of the 3, each with different prices) or not buy one at all.
The objective remains the same: to maximize the revenue, and I can't seem to put this decision into code, so I can obtain the best case scenario result, because:
- profit and cost (of renewable resources (reactants)) depend on r produced and t time
- the InitialStock depends on the amount of reactors as well, so it will depend on the decision of how many reactors are running, and this depends on the max revenue of each case
- this is my first project :S
// Data Declaration
int MaxTime = ...;
range Time = 0..MaxTime;
{int} Tasks = ...;
{string} nrenuableR=...;
{string} renuableR=...;
{string} renuableRusedbyT[Tasks]=...;
{string} Resources= nrenuableR union renuableR;
int procTime[Tasks]= ...;
int minbatchsize[renuableR][Tasks] =...;
int maxbatchsize [renuableR][Tasks] =...;
int MaxAmountStock_nR[nrenuableR]=...;
int maxRenuableR[renuableR][Time] =...;
int InitialStock[Resources]=...;
int Profit[nrenuableR]=...;
float nRcosts[nrenuableR]=...;
int MaxTheta = ...;
range Theta=0..MaxTheta;
float Mu[Tasks][Resources][Theta] = ...;
float Nu[Tasks][Resources][Theta] = ...;
//Decision Variables
dvar boolean N[Tasks][Time];
dvar float+ Csi[Tasks][Time];
dvar int+ R[Resources][Time];
//Objective Function
dexpr float ObjFunction = sum (r in nrenuableR)(R[r][MaxTime] - InitialStock[r])*(Profit[r] - nRcosts[r]);
maximize ObjFunction;
//Contraints
subject to {
//Resources Capacity
forall (r in renuableR) forall(t in Time) R[r][t] <= maxRenuableR[r][t];
forall (r in nrenuableR) forall (t in Time) R[r][t] <= MaxAmountStock_nR[r];
//Batch Size + linking constraints
forall (k in Tasks, r in renuableRusedbyT[k], t in Time) minbatchsize[r][k] * N[k][t] <= Csi[k][t];
forall (k in Tasks, r in renuableRusedbyT[k], t in Time) maxbatchsize[r][k]*N[k][t] >= Csi[k][t];
//Resource Balance
forall(r in Resources) R[r][0] == InitialStock[r] + sum(k in Tasks) (Mu[k][r][0] * N[k][0] + Nu[k][r][0] * Csi[k][0]);
forall(r in Resources,t in Time: t>0) R[r][t] == R[r][t-1] + sum(k in Tasks,theta in Theta: t - theta >=0) (Mu[k][r][theta] * N[k][t - theta] + Nu[k][r][theta] * Csi[k][t - theta]);
}