質問編集履歴
4
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,459 +9,3 @@
|
|
9
9
|
Cplexファイルの場所を入力し間違えたのかと何度もやってみましたが同じ結果です。
|
10
10
|
|
11
11
|
解決方法をご存知の方、教えて頂けませんか?
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
追記
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
```ここに言語を入力
|
28
|
-
|
29
|
-
package numberlink;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
import ilog.concert.IloException;
|
38
|
-
|
39
|
-
import ilog.concert.IloIntVar;
|
40
|
-
|
41
|
-
import ilog.concert.IloLinearNumExpr;
|
42
|
-
|
43
|
-
import ilog.cplex.IloCplex;
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
public class numberlink1 {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
public static void main(String[] args) {
|
56
|
-
|
57
|
-
try {
|
58
|
-
|
59
|
-
IloCplex numberlink = new IloCplex();
|
60
|
-
|
61
|
-
int row=4;
|
62
|
-
|
63
|
-
int column=4;
|
64
|
-
|
65
|
-
IloIntVar s[][] = new IloIntVar[row][column];
|
66
|
-
|
67
|
-
for(int i=1;i<=row-1;i++) {
|
68
|
-
|
69
|
-
for(int j=1;j<=column;j++) {
|
70
|
-
|
71
|
-
s[i][j] = numberlink.boolVar();
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
IloIntVar e[][] = new IloIntVar[row][column];
|
80
|
-
|
81
|
-
for(int i=1;i<=row;i++) {
|
82
|
-
|
83
|
-
for(int j=1;j<=column-1;j++) {
|
84
|
-
|
85
|
-
e[i][j] = numberlink.boolVar();
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
IloLinearNumExpr NumberMath = numberlink.linearNumExpr();
|
94
|
-
|
95
|
-
IloIntVar[][] x = new IloIntVar[row][column];
|
96
|
-
|
97
|
-
for(int i=1;i<=row;i++) {
|
98
|
-
|
99
|
-
for(int j=1;j<=column;j++) {
|
100
|
-
|
101
|
-
NumberMath.addTerm(1, x[i][j]);
|
102
|
-
|
103
|
-
numberlink.addLe(NumberMath,3);
|
104
|
-
|
105
|
-
numberlink.addGe(NumberMath, 1);
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
IloLinearNumExpr NumberMath1_a = numberlink.linearNumExpr();
|
114
|
-
|
115
|
-
NumberMath1_a.addTerm(1,x[1][1]);
|
116
|
-
|
117
|
-
numberlink.addEq(NumberMath1_a,1);
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
IloLinearNumExpr NumberMath1_b = numberlink.linearNumExpr();
|
122
|
-
|
123
|
-
NumberMath1_b.addTerm(1,x[2][3]);
|
124
|
-
|
125
|
-
numberlink.addEq(NumberMath1_b,1);
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
IloLinearNumExpr NumberMath2_a = numberlink.linearNumExpr();
|
132
|
-
|
133
|
-
NumberMath2_a.addTerm(1,x[1][4]);
|
134
|
-
|
135
|
-
numberlink.addEq(NumberMath2_a,2);
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
IloLinearNumExpr NumberMath2_b = numberlink.linearNumExpr();
|
140
|
-
|
141
|
-
NumberMath2_b.addTerm(1,x[3][2]);
|
142
|
-
|
143
|
-
numberlink.addEq(NumberMath2_b,2);
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
IloLinearNumExpr NumberMath3_a = numberlink.linearNumExpr();
|
150
|
-
|
151
|
-
NumberMath3_a.addTerm(1,x[2][2]);
|
152
|
-
|
153
|
-
numberlink.addEq(NumberMath3_a,3);
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
IloLinearNumExpr NumberMath3_b = numberlink.linearNumExpr();
|
158
|
-
|
159
|
-
NumberMath3_b.addTerm(1,x[4][4]);
|
160
|
-
|
161
|
-
numberlink.addEq(NumberMath3_b,3);
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
IloLinearNumExpr MathLine = numberlink.linearNumExpr();
|
172
|
-
|
173
|
-
for(int i=1;i<=row;i++) {
|
174
|
-
|
175
|
-
for(int j=1;j<=column;j++) {
|
176
|
-
|
177
|
-
MathLine.addTerm(1, s[i-1][j]);
|
178
|
-
|
179
|
-
MathLine.addTerm(1, s[i][j]);
|
180
|
-
|
181
|
-
MathLine.addTerm(1, e[i][j-1]);
|
182
|
-
|
183
|
-
MathLine.addTerm(1, e[i][j]);
|
184
|
-
|
185
|
-
if(i-1==0) {
|
186
|
-
|
187
|
-
MathLine.addTerm(-1, s[i-1][j]);
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
if(i==4) {
|
192
|
-
|
193
|
-
MathLine.addTerm(-1, s[i][j]);
|
194
|
-
|
195
|
-
}
|
196
|
-
|
197
|
-
if(j-1==0) {
|
198
|
-
|
199
|
-
MathLine.addTerm(-1, e[i][j-1]);
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
if(j==4) {
|
204
|
-
|
205
|
-
MathLine.addTerm(-1, e[i][j]);
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
if((i==1&&j==1)||(i==1&&j==4)||(i==2&&j==2)||(i==2&&j==3)||
|
210
|
-
|
211
|
-
(i==3&&j==2)||i==4&&j==4) {
|
212
|
-
|
213
|
-
numberlink.addEq(MathLine, 1);
|
214
|
-
|
215
|
-
}
|
216
|
-
|
217
|
-
else {numberlink.addGe(MathLine, 2);
|
218
|
-
|
219
|
-
numberlink.addLe(MathLine, 0);}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
IloLinearNumExpr IfsEq1_1 = numberlink.linearNumExpr();
|
230
|
-
|
231
|
-
IloLinearNumExpr IfsEq1_2 = numberlink.linearNumExpr();
|
232
|
-
|
233
|
-
for(int i=1;i<=row-1;i++) {
|
234
|
-
|
235
|
-
for(int j=1;j<=column;j++) {
|
236
|
-
|
237
|
-
IfsEq1_1.addTerm(3,s[i][j]);
|
238
|
-
|
239
|
-
IfsEq1_1.addTerm(-1,x[i][j]);
|
240
|
-
|
241
|
-
IfsEq1_1.addTerm(1,x[i+1][j]);
|
242
|
-
|
243
|
-
numberlink.addLe(IfsEq1_1,3);
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
IfsEq1_2.addTerm(3,s[i][j]);
|
248
|
-
|
249
|
-
IfsEq1_2.addTerm(1,x[i][j]);
|
250
|
-
|
251
|
-
IfsEq1_2.addTerm(-1,x[i+1][j]);
|
252
|
-
|
253
|
-
numberlink.addLe(IfsEq1_1,3);
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
IloLinearNumExpr IfeEq1_1 = numberlink.linearNumExpr();
|
262
|
-
|
263
|
-
IloLinearNumExpr IfeEq1_2 = numberlink.linearNumExpr();
|
264
|
-
|
265
|
-
for(int i=1;i<=row;i++) {
|
266
|
-
|
267
|
-
for(int j=1;j<=column-1;j++) {
|
268
|
-
|
269
|
-
IfeEq1_1.addTerm(3,e[i][j]);
|
270
|
-
|
271
|
-
IfeEq1_1.addTerm(-1,x[i][j]);
|
272
|
-
|
273
|
-
IfeEq1_1.addTerm(1,x[i+1][j]);
|
274
|
-
|
275
|
-
numberlink.addLe(IfeEq1_1,3);
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
IfeEq1_2.addTerm(3,e[i][j]);
|
280
|
-
|
281
|
-
IfeEq1_2.addTerm(1,x[i][j]);
|
282
|
-
|
283
|
-
IfeEq1_2.addTerm(-1,x[i+1][j]);
|
284
|
-
|
285
|
-
numberlink.addLe(IfeEq1_1,3);
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
}
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
IloLinearNumExpr AllLine = numberlink.linearNumExpr();
|
298
|
-
|
299
|
-
for(int i=1;i<=row;i++) {
|
300
|
-
|
301
|
-
for(int j=1;j<=column-1;j++) {
|
302
|
-
|
303
|
-
AllLine.addTerm(1,e[i][j]);
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
for(int i=1;i<=row-1;i++) {
|
310
|
-
|
311
|
-
for(int j=1;j<=column;j++) {
|
312
|
-
|
313
|
-
AllLine.addTerm(1,s[i][j]);
|
314
|
-
|
315
|
-
}
|
316
|
-
|
317
|
-
}
|
318
|
-
|
319
|
-
numberlink.addMinimize(AllLine);
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
if(numberlink.solve()) {
|
326
|
-
|
327
|
-
System.out.println("目的関数値は"+numberlink.getObjValue());
|
328
|
-
|
329
|
-
for(int i=1;i<=row;i++) {
|
330
|
-
|
331
|
-
for(int j=1;j<=column;j++) {
|
332
|
-
|
333
|
-
System.out.println(s[i][j]+"="+numberlink.getValue(s[i][j]));
|
334
|
-
|
335
|
-
System.out.println(e[i][j]+"="+numberlink.getValue(e[i][j]));
|
336
|
-
|
337
|
-
System.out.println(x[i][j]+"="+numberlink.getValue(x[i][j]));
|
338
|
-
|
339
|
-
}
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
}
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
catch(IloException e) {
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
```
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
実行構成のVM引数にCPLEXファイルの場所を入力した後実行すると
|
366
|
-
|
367
|
-
�G���[: ���C���E�N���X〇〇〇\Documents\IBM\ILOG\CPLEX_Studio127��������Ȃ����������[�h�ł��܂���ł���
|
368
|
-
|
369
|
-
というエラーが出ます。(〇〇〇にはユーザ名が入ります。)
|
370
|
-
|
371
|
-
よろしくお願いします。
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
追記2
|
382
|
-
|
383
|
-
以下のようなコードを入力し実行すると、エラーも出ず解が出力されました。
|
384
|
-
|
385
|
-
Cplexファイルの場所を実行構成に入力せずに実行し成功したので、元のコードのエラーの原因はコード内にあるのでしょうか...?
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
```ここに言語を入力
|
390
|
-
|
391
|
-
package testtt;
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
import ilog.concert.IloException;
|
396
|
-
|
397
|
-
import ilog.concert.IloLinearNumExpr;
|
398
|
-
|
399
|
-
import ilog.concert.IloNumVar;
|
400
|
-
|
401
|
-
import ilog.cplex.IloCplex;
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
public class test1{
|
406
|
-
|
407
|
-
static public void main(String[] args) {
|
408
|
-
|
409
|
-
try {
|
410
|
-
|
411
|
-
IloCplex cplex = new IloCplex();
|
412
|
-
|
413
|
-
// create model and solve it
|
414
|
-
|
415
|
-
IloNumVar x = cplex.numVar(0, Double.MAX_VALUE, "x");
|
416
|
-
|
417
|
-
IloNumVar y = cplex.numVar(0, Double.MAX_VALUE, "y");
|
418
|
-
|
419
|
-
IloLinearNumExpr objective = cplex.linearNumExpr();
|
420
|
-
|
421
|
-
objective.addTerm(0.12, x);
|
422
|
-
|
423
|
-
objective.addTerm(0.15, y);
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
cplex.addMinimize(objective);
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
cplex.addGe(cplex.sum(cplex.prod(60, x), cplex.prod(60, y)), 300);
|
432
|
-
|
433
|
-
cplex.addGe(cplex.sum(cplex.prod(12, x), cplex.prod(6, y)), 36);
|
434
|
-
|
435
|
-
cplex.addGe(cplex.sum(cplex.prod(10, x), cplex.prod(30, y)), 90);
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
if (cplex.solve()) {
|
440
|
-
|
441
|
-
System.out.println("obj = " + cplex.getObjValue());
|
442
|
-
|
443
|
-
System.out.println("x = " + cplex.getValue(x));
|
444
|
-
|
445
|
-
System.out.println("y = " + cplex.getValue(y));
|
446
|
-
|
447
|
-
} else {
|
448
|
-
|
449
|
-
System.out.println("Can not solve");
|
450
|
-
|
451
|
-
}
|
452
|
-
|
453
|
-
} catch (IloException e) {
|
454
|
-
|
455
|
-
System.err.println("Concert exception caught: " + e);
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
}
|
460
|
-
|
461
|
-
}
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
```
|
3
別のコードで試した結果
test
CHANGED
File without changes
|
test
CHANGED
@@ -369,3 +369,99 @@
|
|
369
369
|
というエラーが出ます。(〇〇〇にはユーザ名が入ります。)
|
370
370
|
|
371
371
|
よろしくお願いします。
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
追記2
|
382
|
+
|
383
|
+
以下のようなコードを入力し実行すると、エラーも出ず解が出力されました。
|
384
|
+
|
385
|
+
Cplexファイルの場所を実行構成に入力せずに実行し成功したので、元のコードのエラーの原因はコード内にあるのでしょうか...?
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
```ここに言語を入力
|
390
|
+
|
391
|
+
package testtt;
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
import ilog.concert.IloException;
|
396
|
+
|
397
|
+
import ilog.concert.IloLinearNumExpr;
|
398
|
+
|
399
|
+
import ilog.concert.IloNumVar;
|
400
|
+
|
401
|
+
import ilog.cplex.IloCplex;
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
public class test1{
|
406
|
+
|
407
|
+
static public void main(String[] args) {
|
408
|
+
|
409
|
+
try {
|
410
|
+
|
411
|
+
IloCplex cplex = new IloCplex();
|
412
|
+
|
413
|
+
// create model and solve it
|
414
|
+
|
415
|
+
IloNumVar x = cplex.numVar(0, Double.MAX_VALUE, "x");
|
416
|
+
|
417
|
+
IloNumVar y = cplex.numVar(0, Double.MAX_VALUE, "y");
|
418
|
+
|
419
|
+
IloLinearNumExpr objective = cplex.linearNumExpr();
|
420
|
+
|
421
|
+
objective.addTerm(0.12, x);
|
422
|
+
|
423
|
+
objective.addTerm(0.15, y);
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
cplex.addMinimize(objective);
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
cplex.addGe(cplex.sum(cplex.prod(60, x), cplex.prod(60, y)), 300);
|
432
|
+
|
433
|
+
cplex.addGe(cplex.sum(cplex.prod(12, x), cplex.prod(6, y)), 36);
|
434
|
+
|
435
|
+
cplex.addGe(cplex.sum(cplex.prod(10, x), cplex.prod(30, y)), 90);
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
if (cplex.solve()) {
|
440
|
+
|
441
|
+
System.out.println("obj = " + cplex.getObjValue());
|
442
|
+
|
443
|
+
System.out.println("x = " + cplex.getValue(x));
|
444
|
+
|
445
|
+
System.out.println("y = " + cplex.getValue(y));
|
446
|
+
|
447
|
+
} else {
|
448
|
+
|
449
|
+
System.out.println("Can not solve");
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
} catch (IloException e) {
|
454
|
+
|
455
|
+
System.err.println("Concert exception caught: " + e);
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
```
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -362,7 +362,7 @@
|
|
362
362
|
|
363
363
|
|
364
364
|
|
365
|
-
実行構成のVM引数にCPLEXファイルを入力した後実行すると
|
365
|
+
実行構成のVM引数にCPLEXファイルの場所を入力した後実行すると
|
366
366
|
|
367
367
|
�G���[: ���C���E�N���X〇〇〇\Documents\IBM\ILOG\CPLEX_Studio127��������Ȃ����������[�h�ł��܂���ł���
|
368
368
|
|
1
コード、エラー内容を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,363 @@
|
|
9
9
|
Cplexファイルの場所を入力し間違えたのかと何度もやってみましたが同じ結果です。
|
10
10
|
|
11
11
|
解決方法をご存知の方、教えて頂けませんか?
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
追記
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```ここに言語を入力
|
28
|
+
|
29
|
+
package numberlink;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
import ilog.concert.IloException;
|
38
|
+
|
39
|
+
import ilog.concert.IloIntVar;
|
40
|
+
|
41
|
+
import ilog.concert.IloLinearNumExpr;
|
42
|
+
|
43
|
+
import ilog.cplex.IloCplex;
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
public class numberlink1 {
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
public static void main(String[] args) {
|
56
|
+
|
57
|
+
try {
|
58
|
+
|
59
|
+
IloCplex numberlink = new IloCplex();
|
60
|
+
|
61
|
+
int row=4;
|
62
|
+
|
63
|
+
int column=4;
|
64
|
+
|
65
|
+
IloIntVar s[][] = new IloIntVar[row][column];
|
66
|
+
|
67
|
+
for(int i=1;i<=row-1;i++) {
|
68
|
+
|
69
|
+
for(int j=1;j<=column;j++) {
|
70
|
+
|
71
|
+
s[i][j] = numberlink.boolVar();
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
IloIntVar e[][] = new IloIntVar[row][column];
|
80
|
+
|
81
|
+
for(int i=1;i<=row;i++) {
|
82
|
+
|
83
|
+
for(int j=1;j<=column-1;j++) {
|
84
|
+
|
85
|
+
e[i][j] = numberlink.boolVar();
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
IloLinearNumExpr NumberMath = numberlink.linearNumExpr();
|
94
|
+
|
95
|
+
IloIntVar[][] x = new IloIntVar[row][column];
|
96
|
+
|
97
|
+
for(int i=1;i<=row;i++) {
|
98
|
+
|
99
|
+
for(int j=1;j<=column;j++) {
|
100
|
+
|
101
|
+
NumberMath.addTerm(1, x[i][j]);
|
102
|
+
|
103
|
+
numberlink.addLe(NumberMath,3);
|
104
|
+
|
105
|
+
numberlink.addGe(NumberMath, 1);
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
IloLinearNumExpr NumberMath1_a = numberlink.linearNumExpr();
|
114
|
+
|
115
|
+
NumberMath1_a.addTerm(1,x[1][1]);
|
116
|
+
|
117
|
+
numberlink.addEq(NumberMath1_a,1);
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
IloLinearNumExpr NumberMath1_b = numberlink.linearNumExpr();
|
122
|
+
|
123
|
+
NumberMath1_b.addTerm(1,x[2][3]);
|
124
|
+
|
125
|
+
numberlink.addEq(NumberMath1_b,1);
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
IloLinearNumExpr NumberMath2_a = numberlink.linearNumExpr();
|
132
|
+
|
133
|
+
NumberMath2_a.addTerm(1,x[1][4]);
|
134
|
+
|
135
|
+
numberlink.addEq(NumberMath2_a,2);
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
IloLinearNumExpr NumberMath2_b = numberlink.linearNumExpr();
|
140
|
+
|
141
|
+
NumberMath2_b.addTerm(1,x[3][2]);
|
142
|
+
|
143
|
+
numberlink.addEq(NumberMath2_b,2);
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
IloLinearNumExpr NumberMath3_a = numberlink.linearNumExpr();
|
150
|
+
|
151
|
+
NumberMath3_a.addTerm(1,x[2][2]);
|
152
|
+
|
153
|
+
numberlink.addEq(NumberMath3_a,3);
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
IloLinearNumExpr NumberMath3_b = numberlink.linearNumExpr();
|
158
|
+
|
159
|
+
NumberMath3_b.addTerm(1,x[4][4]);
|
160
|
+
|
161
|
+
numberlink.addEq(NumberMath3_b,3);
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
IloLinearNumExpr MathLine = numberlink.linearNumExpr();
|
172
|
+
|
173
|
+
for(int i=1;i<=row;i++) {
|
174
|
+
|
175
|
+
for(int j=1;j<=column;j++) {
|
176
|
+
|
177
|
+
MathLine.addTerm(1, s[i-1][j]);
|
178
|
+
|
179
|
+
MathLine.addTerm(1, s[i][j]);
|
180
|
+
|
181
|
+
MathLine.addTerm(1, e[i][j-1]);
|
182
|
+
|
183
|
+
MathLine.addTerm(1, e[i][j]);
|
184
|
+
|
185
|
+
if(i-1==0) {
|
186
|
+
|
187
|
+
MathLine.addTerm(-1, s[i-1][j]);
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
if(i==4) {
|
192
|
+
|
193
|
+
MathLine.addTerm(-1, s[i][j]);
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
if(j-1==0) {
|
198
|
+
|
199
|
+
MathLine.addTerm(-1, e[i][j-1]);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
if(j==4) {
|
204
|
+
|
205
|
+
MathLine.addTerm(-1, e[i][j]);
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
if((i==1&&j==1)||(i==1&&j==4)||(i==2&&j==2)||(i==2&&j==3)||
|
210
|
+
|
211
|
+
(i==3&&j==2)||i==4&&j==4) {
|
212
|
+
|
213
|
+
numberlink.addEq(MathLine, 1);
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
else {numberlink.addGe(MathLine, 2);
|
218
|
+
|
219
|
+
numberlink.addLe(MathLine, 0);}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
IloLinearNumExpr IfsEq1_1 = numberlink.linearNumExpr();
|
230
|
+
|
231
|
+
IloLinearNumExpr IfsEq1_2 = numberlink.linearNumExpr();
|
232
|
+
|
233
|
+
for(int i=1;i<=row-1;i++) {
|
234
|
+
|
235
|
+
for(int j=1;j<=column;j++) {
|
236
|
+
|
237
|
+
IfsEq1_1.addTerm(3,s[i][j]);
|
238
|
+
|
239
|
+
IfsEq1_1.addTerm(-1,x[i][j]);
|
240
|
+
|
241
|
+
IfsEq1_1.addTerm(1,x[i+1][j]);
|
242
|
+
|
243
|
+
numberlink.addLe(IfsEq1_1,3);
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
IfsEq1_2.addTerm(3,s[i][j]);
|
248
|
+
|
249
|
+
IfsEq1_2.addTerm(1,x[i][j]);
|
250
|
+
|
251
|
+
IfsEq1_2.addTerm(-1,x[i+1][j]);
|
252
|
+
|
253
|
+
numberlink.addLe(IfsEq1_1,3);
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
IloLinearNumExpr IfeEq1_1 = numberlink.linearNumExpr();
|
262
|
+
|
263
|
+
IloLinearNumExpr IfeEq1_2 = numberlink.linearNumExpr();
|
264
|
+
|
265
|
+
for(int i=1;i<=row;i++) {
|
266
|
+
|
267
|
+
for(int j=1;j<=column-1;j++) {
|
268
|
+
|
269
|
+
IfeEq1_1.addTerm(3,e[i][j]);
|
270
|
+
|
271
|
+
IfeEq1_1.addTerm(-1,x[i][j]);
|
272
|
+
|
273
|
+
IfeEq1_1.addTerm(1,x[i+1][j]);
|
274
|
+
|
275
|
+
numberlink.addLe(IfeEq1_1,3);
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
IfeEq1_2.addTerm(3,e[i][j]);
|
280
|
+
|
281
|
+
IfeEq1_2.addTerm(1,x[i][j]);
|
282
|
+
|
283
|
+
IfeEq1_2.addTerm(-1,x[i+1][j]);
|
284
|
+
|
285
|
+
numberlink.addLe(IfeEq1_1,3);
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
IloLinearNumExpr AllLine = numberlink.linearNumExpr();
|
298
|
+
|
299
|
+
for(int i=1;i<=row;i++) {
|
300
|
+
|
301
|
+
for(int j=1;j<=column-1;j++) {
|
302
|
+
|
303
|
+
AllLine.addTerm(1,e[i][j]);
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
for(int i=1;i<=row-1;i++) {
|
310
|
+
|
311
|
+
for(int j=1;j<=column;j++) {
|
312
|
+
|
313
|
+
AllLine.addTerm(1,s[i][j]);
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
numberlink.addMinimize(AllLine);
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
if(numberlink.solve()) {
|
326
|
+
|
327
|
+
System.out.println("目的関数値は"+numberlink.getObjValue());
|
328
|
+
|
329
|
+
for(int i=1;i<=row;i++) {
|
330
|
+
|
331
|
+
for(int j=1;j<=column;j++) {
|
332
|
+
|
333
|
+
System.out.println(s[i][j]+"="+numberlink.getValue(s[i][j]));
|
334
|
+
|
335
|
+
System.out.println(e[i][j]+"="+numberlink.getValue(e[i][j]));
|
336
|
+
|
337
|
+
System.out.println(x[i][j]+"="+numberlink.getValue(x[i][j]));
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
catch(IloException e) {
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
```
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
実行構成のVM引数にCPLEXファイルを入力した後実行すると
|
366
|
+
|
367
|
+
�G���[: ���C���E�N���X〇〇〇\Documents\IBM\ILOG\CPLEX_Studio127��������Ȃ����������[�h�ł��܂���ł���
|
368
|
+
|
369
|
+
というエラーが出ます。(〇〇〇にはユーザ名が入ります。)
|
370
|
+
|
371
|
+
よろしくお願いします。
|