0

I am a beginner of programming. I'm trying to practice run a simulation with CPLEX. Since I want to be a person who wants to work in an area in optimization. Therefore, I am trying to study some journals from different areas by myself. The attached image is the objective function and constraints. I made up the code written below. I am not sure I made it right or wrong.

enter image description here

//Data
{string} product = ...;
{string} interval = ...;
// Limit
float low[interval] = ...;
float upper[interval] = ...;
// Maximum demand
float A[product] = ...;
// Slope of demand function
float varphi[product][interval] = ...;
// Price
float p[product] = ...;
// Setup cost
float f[product] = ...;
// Inventory holding cost rate
float h[product][interval] = ...;
// Variable cost rate
float v[product][interval] = ...;
// Variables
dvar float+ X[product][interval];    enter code here
dvar float+ D[product][interval];
dvar float+ a[interval];
dvar float+ beta[product][interval];

// Objective
maximize sum(i in product, j in interval) p[i]*X[i][j]-f[i]*beta[i][j]-v[i][j]*X[i][j]-0.5*h[i][j]*X[i][j] - F;

// Constraint
subject to{
  forall(j in interval) sum(j in interval) a[j] == 1;
  forall(i in product, j in interval) beta[i][j] <= a[j];
  forall(i in product, j in interval) sum(i in product, j in interval) X[i][j] <= C;
  forall(i in product, j in interval) X[j][i] <= D[i][j]*beta[i][j];
  forall(j in interval) sum(i in product) beta[i][j] <= upper[j]*a[j];
  forall(j in interval) sum(i in product) beta[i][j] >= low[j]*a[j];
  forall(i in product, j in interval) D[i][j] = (A[i]-varphi[i][j]*p[i])*a[j];
}

I want to demonstrate how an iterative procedure may be applied to progressively narrow the interval of search to precisely determine the optimal number of products to produce in order to maximize profit. The journal explains as "The cost and revenue data for these smaller intervals are provided as new inputs to the model which then identifies one of these new intervals as best in the subsequent iteration. The procedure is repeated in successive iterations until the last interval has only one or two levels (i.e., numbers of products) from which the model is able to make a final choice of product variety. In order to save time when the marginal benefit from successive iterations is very small, we also terminate the process if the difference between the objective function values (profit) of successive iterations is below a small predetermined convergence parameter. The model determines which of the levels of the final interval is optimal and also identifies which particular products to produce and in what quantities.

The first stage of this process begins with 100 products (as before) and a configuration involving price structure 3 and cost structure 3 (please see Tables 2–5). The product variety range is divided into four intervals with interval boundaries shown in Table 1. The result from this stage is that the third interval is selected as optimal, with 75 products and their corresponding optimal production quantities identified. The data are shown in Table 9 and the results are provided in Table 12, Table 13 (which also provide results from subsequent stages)."

Tables are attached below.

enter image description here

enter image description here

enter image description here

enter image description here

Product is total 100. I have not decided the values of other parameters.

What I want to know is how to run the following iterative procedure?

When I run CPLEX, the objective function in the code keeps telling there is an error?

Thank you for your kind answers and you are the bests.

Regards,

1 Answers1

0
forall(j in interval) sum(j in interval) a[j] == 1;

Looks bad since you used j twice !

For errors you should share dat file so that Other users could try

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Then how should I revise the following code? The above code is the data file. For objective function maximize sum(i in product, j in interval) p[i]*X[i][j]-f[i]*beta[i][j]-v[i][j]*X[i][j]-0.5*h[i][j]*X[i][j] - F; f[i] has an error. forall(i in product, j in interval) sum(i in product, j in interval) X[i][j] <= C; "sum(i in product, j in interval) X[i][j] <= C;" has an error. – SangYeop Lee Jul 11 '21 at 07:03