0

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]);
 }

  • Your question is well detailed. To make answering easier please format your code so the reader don't need to struggle with the formatting. also try to put each calculation step in an own variable for better readability. – finder2 Nov 29 '19 at 15:15
  • Well asked, but is this java related? – Karol Dowbecki Nov 29 '19 at 16:16
  • @KarolDowbecki yes! cplex runs on java – Beatriz Estevens Nov 29 '19 at 16:28
  • @BeatrizEstevens CPLEX is native program with Java JNI bindings, as per docs "At execution time, the same classpath setting is needed. Additionally, since CPLEXis implemented via JNI". Most likely your problem is not related to bindings. – Karol Dowbecki Nov 29 '19 at 16:44

1 Answers1

0

I am not clear about the meaning of your decision variables, so I cannot give a detailed answer.

A general approach to extend the model is this:

  • Create a new decision variable IsUsed that is 1 for each reactor if and only if the respective reactor is used.
  • Add a constraint that says that if IsUsed is 0 for a reactor then the number of tasks performed on this reactor is 0.
  • Add to the objective function a term IsUsed * Cost for each reactor that models that fixed cost for opening a reactor.
  • For initial stock you can multiply the initial stock by IsUsed for each reactor. Then the initial stock is 0 if the reactor is not used and the orignal initial stock if the reactor is used.
Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22