hello guys i have a problem with a warehouse location example

this is file.mod

//warehouses and stores//
int nbstore=...;
int nbwarehouse=...;
range warehouses=1..nbwarehouse;
range stores=1..nbstore;
// coûts unitaires//
int cost=[warehouses][stores]=...;
//coût location entrepôts//
int k[w]=...;
// capacités //
int cap[warehouses]=...;
// demande //
int Q[stores]=...;
// variables de décision//
dvar float q[w][s];
dvar boolean y[w];
// fonction objectif //
minimize sum(w in warehouses, s in stores)cost[w][s]*q[w,s]+sum(w in warehouses)y[w]*k[w];
// contraintes //
subject to {
forall(s in stores)
  sum(w in warehouses)q[w][s]==Q[s];
forall(w in warehouses)
  sum(s in stores)q[w][s]<=cap[w]*y[w];
}

and this is file.dat

nbwarehouse=5;
nbstore=7;
Q=[100,150,220,300,100,140,77];
cap=[700,300,200,400,330];
k=[70,300,120,88,30];
cost=[
[10,12,11,14,17]
[9,5,4,3,10]
[11,7,6,9,11]
[15,25,18,14,16]
[19,14,12,9,10]
];

it always has a problem in this line:

int cost=[warehouses][stores]=...; (unexpected [ expecting ; )

please help me thanks in advance

asked 06 Dec '14, 09:00

klandos's gravatar image

klandos
112
accept rate: 0%

edited 06 Dec '14, 09:30

fbahr's gravatar image

fbahr ♦
4.6k716

1

Just delete the = after cost:

int cost[warehouses][stores]=...;

(06 Dec '14, 09:32) fbahr ♦

Hello, many small errors. For example, instead of

int cost=[warehouses][stores]=...;

you should write

int cost[warehouses][stores]=...;

Let me fix your code.

.mod

int nbstore=...;
int nbwarehouse=...;
range warehouses=1..nbwarehouse;
range stores=1..nbstore;
// coûts unitaires//
int cost[warehouses][stores]=...;
//coût location entrepôts//
int k[warehouses]=...;
// capacités //
int cap[warehouses]=...;
// demande //
int Q[stores]=...;
// variables de décision //
dvar float q[warehouses][stores];
dvar boolean y[warehouses];
// fonction objectif //
minimize sum(w in warehouses, s in stores)cost[w][s]*q[w,s]+sum(w in warehouses)y[w]*k[w];
// contraintes //
subject to {
forall(s in stores)
  sum(w in warehouses)q[w][s]==Q[s];
forall(w in warehouses)
  sum(s in stores)q[w][s]<=cap[w]*y[w];
}

.dat

nbwarehouse=5;
nbstore=7;
Q=[100,150,220,300,100,140,77];
cap=[700,300,200,400,330];
k=[70,300,120,88,30];
cost=[
  [10,12,11,14,17],
  [9,5,4,3,10],
  [11,7,6,9,11],
  [15,25,18,14,16],
  [19,14,12,9,10]
];

regards

link

answered 06 Dec '14, 09:54

Alex%20Fleischer's gravatar image

Alex Fleischer
1564
accept rate: 11%

edited 06 Dec '14, 12:39

fbahr's gravatar image

fbahr ♦
4.6k716

thank you guys i corrected my code also the .dat file with this:

nbwarehouse=5;
nbstore=7;
Q=[100,150,220,300,100,140,77];
cap=[700,300,200,400,330];
k=[70,300,120,88,30];
cost=[
[10,15,17,20,22,23,29],
[10,7,9,13,10,21,23],
[16,14,12,11,12,15,17],
[19,17,15,11,12,14,16],
[26,120,17,15,13,9,4]
];

but when i excute it it says:

Found incumbent of value 16899.000000 after 0.00 sec. (0.01 ticks)
Duplicate columns q(2)(1) and q(2)(6) make problem unbounded.
Presolve time = 0.00 sec. (0.02 ticks)

NB: i'm a begineer in Cplex

(06 Dec '14, 11:26) klandos
1

Hi

you get this because your problem is unbounded.

But if you turn

dvar float q[warehouses][stores];

into

dvar float+ q[warehouses][stores];

then you should get a solution

Regards

PS: You also have a lot of information at https://www.ibm.com/developerworks/community/forums/html/category?id=33333333-0000-0000-0000-000000000260

(06 Dec '14, 12:42) Alex Fleischer

many thanks :)

(07 Dec '14, 05:24) klandos
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×191
×5
×1

Asked: 06 Dec '14, 09:00

Seen: 1,271 times

Last updated: 07 Dec '14, 10:02

OR-Exchange! Your site for questions, answers, and announcements about operations research.