0
votes

I used IBM ILOG CPLEX Optimization Studio to run a MILProblem, but got an error with massy code. The file editor didn't alert any errors until I pushed the run button.

The error is

ÔËÐÐÅäÖá°option 1¡±²»´æÔڡ£          unknown OPL

As such an error, I really don't know how to google it. Here is the .mod and .dat file.

.mod file

    {string} prd = ...;
int NP = ...;//number of periods
range T = 0..NP;
int Inventory[prd] = ...;
int purchase[prd] = ...;

int sl = ...;
int sm = ...;
float cl = ...;
float cm = ...;
float hR = ...;
float hI = ...;
float cB = ...;
int demand[prd][1..NP] = ...;
int buy[prd][T] = ...;
int inv[prd][T] = ...;
int u[prd] = ...;
int lb = ...;
int ubl = ...;
int ubm = ...;

dvar int+ Y[prd][T];
dvar int+ X[prd][T];
dvar int+ raw[prd][T];
dvar int+ backlog[prd][T];
dvar boolean L[prd][T];
dvar boolean M[prd][T];


minimize
    sum(p in prd, t in T)
        (sl*L[p][t] + sm*M[p][t] + cl*Y[p][t] + cm*X[p][t] + 
        hR*raw[p][t] + hI*inv[p][t] + cB*backlog[p][t]);

subject to {
    forall(p in prd, t in T)
        ctraw:
            raw[p][t] + (X[p][t] + Y[p][t])*u[p] == buy[p][t] + raw[p][t-1] ;
    forall(p in prd, t in T)
        ctInventory:
            inv[p][t] + buy[p][t-1] + demand[p][t] == X[p][t] + Y[p][t] + inv[p][t-1] + buy[p][t] ;
    forall(p in prd, t in T)
      ctYub:
        Y[p][t] <= ubl*L[p][t];
    forall(p in prd, t in T)
      ctYlb:
        Y[p][t] >= lb*L[p][t];
    forall(p in prd, t in T)
      ctXub:
        X[p][t] <= ubm*M[p][t];
    forall(p in prd, t in T)
      ctYcapacity:
        sum(p in prd)
          Y[p][t] <= ubl;
    forall(p in prd, t in T)
      ctXcapacity:
        sum(p in prd)
            X[p][t] <= ubm;
    forall( p in prd )
      ctInitialInventory:
        inv[p][0] == Inventory[p]; inv[prd][0]
    forall( p in prd )
      ctInitialBuy:
        buy[p][0] == purchase[p];
};

.dat file

    prd = {A B C D E F G H I};
NP = 52;
demand = #[
...
]#;

buy = #[
...
]#;

Inventory = #[0 0 0 0 0 0 0 0 0]#;
purchase = #[2900 500 2400 900 500 30 800 20 150]#;
u = #[0.09 0.09 0.09 0.09 0.09 0.05 0.09 0.09 0.09]#;
sl = 1500;
sm = 500;
cl = 0.225;
cm = 0.5;
hR = 0.05;
hI = 0.01;
cB = 0.1;
lb = 1000;
ubl = 8000;
ubm = 2500;
2
If I just paste that code into the editor, it highlights an error immediately. What is the extra code on the end of line 61 supposed to be? Is that just a typo while pasting your code here? - TimChippingtonDerrick
It is a typo. But even if I remove the code after the semicolon ; I got the same error - Yihang Zhu

2 Answers

0
votes

.dat

demand = [];
buy = [];
inv=[];

and .mod

you also need some fixes.

For example try

forall(p in prd, t in T:t-1 in T) 

when you need to use t-1.

regards

0
votes

If you are using a Chinese version Studio, try to set everything into English including the file names, the configuration names and the directory. There are several encoding problems in the studio.