-
Notifications
You must be signed in to change notification settings - Fork 4
/
DDSIPmain.c
1158 lines (1075 loc) · 52.7 KB
/
DDSIPmain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Authors: Andreas M"arkert, Ralf Gollmer
Copyright to: University of Duisburg-Essen
Language: C
Description:
This file contains the main procedure of DDSIP --
a decomposition method for two-stage stochastic mixed-integer programs
based on the Lagrangian relaxation of nonanticipativity and on
branch-and-bound.
License:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <DDSIP.h>
#include <DDSIPconst.h>
#include <DDSIPversion.h>
#include <sys/resource.h>
#define CBFORALL 0
#define DELNODE1MULT
CPXENVptr DDSIP_env = NULL;
CPXLPptr DDSIP_lp = NULL;
FILE * DDSIP_outfile = NULL;
// These pointers have to be global if we want to use ConicBundle
para_t * DDSIP_param= NULL;
data_t * DDSIP_data = NULL;
bb_t * DDSIP_bb = NULL;
node_t ** DDSIP_node = NULL;
// Identifiers are DDSIP_unique within ... letters
const int DDSIP_unique = 6;
// Maximal number of parameters (in each CPLEX section)
const int DDSIP_maxparam = 64;
// Number of risk measures implemented
const int DDSIP_maxrisk = 7;
// Large values
const int DDSIP_bigint = 10000000; // Upper bound on integer parameters
const double DDSIP_bigvalue = 1.0e9; // Just to detect the print format
const double DDSIP_infty = CPX_INFBOUND; // is 1.0e20; -- Infinity
// Output directory
const char DDSIP_outdir[8] = "sipout";
// Output file
const char DDSIP_outfname[16] = "sipout/sip.out";
// More output is printed if desired
const char DDSIP_moreoutfname[16] = "sipout/more.out";
// Solution output file
const char DDSIP_solfname[32] = "sipout/solution.out";
// Recourse function to file
//const char DDSIP_recfunfname[32] = "sipout/recfun.out";
// Indicates user termination ('Control-C')
int DDSIP_killsignal = 0;
//==========================================================================
int
main (int argc, char * argv[])
{
// Temporary variables
struct stat filestat;
char astring[DDSIP_ln_fname];
int status = 0, cont, boundstat, comb, i;
// guarantee minimal stacksize limit
const rlim_t kStackSize = 128 * 1024 * 1024; // min stack size = 128 MB
struct rlimit rl;
int result;
unsigned long cur_limit;
double tmp_objval;
result = getrlimit(RLIMIT_STACK, &rl);
if (result == 0)
{
cur_limit = rl.rlim_cur;
printf ("original stacksize limit %lu\n", cur_limit);
if (rl.rlim_cur < kStackSize)
{
rl.rlim_cur = kStackSize;
result = setrlimit(RLIMIT_STACK, &rl);
if (result != 0)
{
fprintf(stderr, "setrlimit returned result = %d\n", result);
}
result = getrlimit(RLIMIT_STACK, &rl);
if (result == 0)
{
cur_limit = rl.rlim_cur;
printf ("changed stacksize limit %lu\n", cur_limit);
}
}
}
i = argc;
//
// Welcome
printf ("#######################################################################################\n");
printf ("######### D D S I P -- Dual Decomposition In Stochastic Integer Programming #########\n");
printf ("######### %-66s #########\n", DDSIP_version);
printf ("For copyright, license agreements, help, comments, requests, ... ");
printf ("see\n\thttp://www.uni-duisburg-essen.de/~hn215go/ddsip.shtml\n");
printf ("\thttp://www.github.com/RalfGollmer/ddsip\n");
/* printf (" Copyright (C) to University of Duisburg-Essen \n\n"); */
/* printf(" This program is free software; you can redistribute it and/or\n"); */
/* printf (" modify it under the terms of the GNU General Public License\n"); */
/* printf(" as published by the Free Software Foundation; either version 2\n"); */
/* printf (" of the License, or (at your option) any later version.\n\n"); */
/* printf (" This program is distributed in the hope that it will be useful,\n"); */
/* printf(" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); */
/* printf (" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); */
/* printf (" GNU General Public License for more details.\n\n"); */
/* printf (" You should have received a copy of the GNU General Public License\n"); */
/* printf(" along with this program; if not, write to the Free Software\n"); */
/* printf (" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"); */
/* printf ("==============================================================================\n\n"); */
// These four structures shall carry the whole problem data
DDSIP_param = NULL;
DDSIP_bb = NULL;
DDSIP_data = NULL;
DDSIP_node = NULL;
// In DDSIP some signals are handled seperatly
DDSIP_RegisterSignalHandlers ();
// Create output directory if it doesn't already exist
if (stat (DDSIP_outdir, &filestat) == -1)
{
sprintf (astring, "mkdir %s\n", DDSIP_outdir);
i = system (astring);
printf ("Creating subdirectory %s ...\n", DDSIP_outdir);
}
// remove possibly existing output file
sprintf (astring, "rm -f %s\n", DDSIP_outfname);
i = system (astring);
// Open output file
if ((DDSIP_outfile = fopen (DDSIP_outfname, "a")) == NULL)
{
fprintf (stderr, "ERROR: Cannot open '%s'. \n", DDSIP_outfname);
status = 107;
goto TERMINATE;
}
setbuf (DDSIP_outfile, 0);
fprintf (DDSIP_outfile, "%s\n", argv[0]);
fprintf (DDSIP_outfile, "DDSIP %s\n", DDSIP_version);
fprintf (DDSIP_outfile, "-----------------------------------------------------------\n");
fprintf (DDSIP_outfile, "current system time: ");
fflush (DDSIP_outfile);
#ifndef _WIN32
i = system ("date");
// Print time to output file
sprintf (astring, "date >> %s\n", DDSIP_outfname);
i = system (astring);
fprintf (DDSIP_outfile, "host : ");
sprintf (astring, "hostname >> %s; cat /proc/cpuinfo | sed '/processor.*: 0/,/^$/!d' |grep -E 'vendor|cpu |model|stepping|MHz|cache |cores' >> %s\n", DDSIP_outfname, DDSIP_outfname);
for (i = 0; i < 100; i++)
exp(1.11*(-i-2));
i = system (astring);
#else
sprintf (astring, "date /T >> %s & time /T >> %s\n", DDSIP_outfname,DDSIP_outfname);
i = system (astring);
#endif
fprintf (DDSIP_outfile, "-----------------------------------------------------------\n");
// Open cplex environment
DDSIP_env = CPXopenCPLEX (&status);
if (DDSIP_env == NULL)
{
fprintf (stderr, "ERROR: Failed to open cplex environment, CPLEX error code %d.\n",status);
fprintf (DDSIP_outfile, "ERROR: Failed to open cplex environment, CPLEX error code %d.\n",status);
return status;
}
sprintf (astring, "%s", CPXversion (DDSIP_env));
printf ("CPLEX version is %s\n", astring);
fprintf (DDSIP_outfile, "CPLEX version is %s\n", astring);
fprintf (DDSIP_outfile, "CB version is %s\n", CBV);
// Allocate the structures to hold the information on the problem
DDSIP_param = (para_t *) DDSIP_Alloc (sizeof (para_t), 1, "param(Main)");
DDSIP_bb = (bb_t *) DDSIP_Alloc (sizeof (bb_t), 1, "bb(Main)");
DDSIP_data = (data_t *) DDSIP_Alloc (sizeof (data_t), 1, "data(Main)");
// Read model (lp) file
if ((status = DDSIP_ReadModel ()))
goto TERMINATE;
// Read specification file
if ((status = DDSIP_ReadSpec ()))
goto TERMINATE;
// Set specified CPLEX parameters
if ((status = DDSIP_InitCpxPara ()))
goto TERMINATE;
// if a Benders annotation file is given, read it
if (DDSIP_param->annotationFile)
{
status = CPXreadcopyannotations (DDSIP_env, DDSIP_lp, DDSIP_param->annotationFile);
if ( status )
{
fprintf (stderr, "ERROR: Failed to read and copy the annotation data from file %s.\n", DDSIP_param->annotationFile);
fprintf (DDSIP_outfile, "ERROR: Failed to read and copy the annotation data from file %s.\n", DDSIP_param->annotationFile);
goto TERMINATE;
}
}
// data->cost contains: stoch. costs for all scenarios, followed by the original costs
DDSIP_data->cost =
(double *) DDSIP_Alloc (sizeof (double),
DDSIP_param->scenarios * DDSIP_param->stoccost + DDSIP_data->novar, "cost (ReadData)");
// Store original objective coefficients
status = CPXgetobj (DDSIP_env, DDSIP_lp, DDSIP_data->cost + DDSIP_param->scenarios * DDSIP_param->stoccost, 0, DDSIP_data->novar - 1);
if (status)
{
fprintf (stderr, "ERROR: Failed to get objective coefficients\n");
fprintf (DDSIP_outfile, "ERROR: Failed to get objective coefficients\n");
goto TERMINATE;
}
DDSIP_bb->moreoutfile = NULL;
if (DDSIP_param->outlev)
{
// Open debug output file
if ((DDSIP_bb->moreoutfile = fopen (DDSIP_moreoutfname, "a")) == NULL)
{
fprintf (stderr, "ERROR: Cannot open '%s'. \n", DDSIP_moreoutfname);
fprintf (DDSIP_outfile, "ERROR: Cannot open '%s'. \n", DDSIP_moreoutfname);
status = 109;
goto TERMINATE;
}
if (DDSIP_param->outlev > 10)
{
// Buffer size = 0
setbuf (stdout, 0);
if (DDSIP_param->outlev > 20)
setbuf (DDSIP_bb->moreoutfile, 0);
}
#ifndef _WIN32
// Print time to output file
sprintf (astring, "date > %s\n", DDSIP_moreoutfname);
i = system (astring);
#else
sprintf (astring, "date /T > %s & time /T >> %s\n", DDSIP_moreoutfname,DDSIP_moreoutfname);
i = system (astring);
#endif
fprintf (DDSIP_bb->moreoutfile, "--------------------------------------------------------------");
fprintf (DDSIP_bb->moreoutfile, "---------\nThis is an additional output file of DDSIP. The ");
fprintf (DDSIP_bb->moreoutfile, "actual amount of output\nis controlled by the parameter ");
fprintf (DDSIP_bb->moreoutfile, "OUTLEV in the specification file.\n---------");
fprintf (DDSIP_bb->moreoutfile, "--------------------------------------------------------------\n\n");
if (DDSIP_param->cb)
fprintf (DDSIP_bb->moreoutfile, "front node re-eval at nodes %d and %d.\n",
2*((DDSIP_param->cbContinuous + DDSIP_param->cbBreakIters)/2) + DDSIP_Imax (2, 2*(-DDSIP_param->cb/2-1)),
2*(DDSIP_param->cbContinuous + 2*(DDSIP_param->cbBreakIters/2) + 4)
);
}
DDSIP_node = (node_t **) DDSIP_Alloc (sizeof (node_t *), DDSIP_param->nodelim + 3, "node(Main)");
DDSIP_node[0] = (node_t *) DDSIP_Alloc (sizeof (node_t), 1, "node[0](Main)");
DDSIP_node[0]->first_sol = (double **) DDSIP_Alloc (sizeof (double *), DDSIP_param->scenarios, "node[0]->first_sol(Main)");
DDSIP_node[0]->cursubsol = (double *) DDSIP_Alloc (sizeof (double), DDSIP_param->scenarios, "node[0]->cursubsol(Main)");
DDSIP_node[0]->subbound = (double *) DDSIP_Alloc (sizeof (double), DDSIP_param->scenarios, "node[0]->subbound(Main)");
if (DDSIP_param->cb)
{
DDSIP_node[0]->scenBoundsNoLag = (double *) DDSIP_Alloc (sizeof (double), DDSIP_param->scenarios, "node[0]->scenBoundsNoLag(Main)");
DDSIP_node[0]->BoundNoLag = -DDSIP_infty;
}
DDSIP_node[0]->mipstatus = (int *) DDSIP_Alloc (sizeof (int), DDSIP_param->scenarios, "node[0]->mipstatus(Main)");
DDSIP_node[0]->ref_scenobj = (double *) DDSIP_Alloc (sizeof (double), DDSIP_param->scenarios, "node[0]->ref_scenobj(Main)");
// Prepare first and second stage variables
if ((status = DDSIP_InitStages ()))
{
fprintf (stderr, "ERROR: Failed to initialize stages\n");
fprintf (DDSIP_outfile, "ERROR: Failed to initialize stages\n");
goto TERMINATE;
}
// Read data file(s)
if ((status = DDSIP_ReadData ()))
goto TERMINATE;
// Read order file if specified
if (DDSIP_param->cpxorder)
{
status = CPXsetintparam (DDSIP_env, CPX_PARAM_MIPORDIND, 1);
if (status)
{
fprintf (stderr, "ERROR: Failed to set cplex parameter CPX_PARAM_MIPORDIND.\n");
return status;
}
if (DDSIP_ReadCPLEXOrder ())
goto TERMINATE;
}
// Detect first and second stage constraints
if ((status = DDSIP_DetectStageRows ()))
{
fprintf (stderr, "ERROR: Failed detection of row stages (BbInit)\n");
fprintf (DDSIP_outfile, "ERROR: Failed detection of row stages (BbInit)\n");
goto TERMINATE;
}
DDSIP_bb->DDSIP_step = solve;
#ifdef CONIC_BUNDLE
if (DDSIP_param->cb)
{
status = DDSIP_NonAnt ();
if (status)
goto TERMINATE;
}
#endif
if (DDSIP_param->outlev)
{
printf ("\t Total initialization time: %4.2f seconds.\n", DDSIP_GetCpuTime ());
fprintf (DDSIP_bb->moreoutfile, " Total initialization time: %4.2f seconds.\n", DDSIP_GetCpuTime ());
}
fprintf (DDSIP_outfile, " Total initialization time: %4.2f seconds.\n", DDSIP_GetCpuTime ());
#ifndef _WIN32
sprintf (astring, "grep 'MHz' /proc/cpuinfo|sort -k 4 -rn|head -1 >> %s\n", DDSIP_outfname);
i = system (astring);
#endif
// at the start there is no solution
status = CPXsetintparam (DDSIP_env, CPX_PARAM_ADVIND, 0);
if (status)
{
fprintf (stderr, "ERROR: Failed to set cplex parameter CPX_PARAM_ADVIND.\n");
fprintf (DDSIP_outfile, "ERROR: Failed to set cplex parameter CPX_PARAM_ADVIND.\n");
return status;
}
#ifndef NEOS
// Write deterministic equivalent (only expectation-based cases)
if (DDSIP_param->write_detequ)
DDSIP_DetEqu ();
#endif
if (DDSIP_param->riskmod < 0)
{
fprintf (stderr, " pure risk models are disabled for now, exiting.\n");
fprintf (DDSIP_outfile, " pure risk models are disabled for now, exiting.\n");
goto TERMINATE;
}
if (DDSIP_param->stoccost && DDSIP_param->riskmod)
{
fprintf (DDSIP_outfile, "XXX Error: Risk optimization not implemented for stochastic cost coefficients.\n");
fprintf (stderr, "XXX Error: Risk optimization not implemented for stochastic cost coefficients.\n");
goto TERMINATE;
}
// Read advanced starting info
if (DDSIP_param->advstart)
{
DDSIP_node[DDSIP_bb->curnode]->step = DDSIP_bb->DDSIP_step = adv;
if ((status = DDSIP_AdvStart ()))
goto TERMINATE;
// Solution provided?
if (DDSIP_param->advstart == 2)
{
DDSIP_bb->curnode = 0;
DDSIP_bb->sug[DDSIP_param->nodelim + 2] = (struct sug_l *)DDSIP_Alloc (sizeof (sug_t), 1, "sug[0](Advanced start solution)");
(DDSIP_bb->sug[DDSIP_param->nodelim + 2])->firstval =
(double *) DDSIP_Alloc (sizeof (double), DDSIP_bb->firstvar, "sug[0]->firstval(adv start)");
for (i = 0; i < (DDSIP_bb->firstvar); i++)
(DDSIP_bb->sug[DDSIP_param->nodelim + 2]->firstval)[i] = DDSIP_bb->adv_sol[i];
(DDSIP_bb->sug[DDSIP_param->nodelim + 2])->next = NULL;
if ((status = DDSIP_UpperBound (DDSIP_param->scenarios, 0)) && status < 100000)
goto TERMINATE;
}
// Only weak consistency check:
if ((DDSIP_node[0]->bound) > DDSIP_bb->bestvalue)
{
status = 121;
goto TERMINATE;
}
fprintf (DDSIP_outfile, "-----------------------------------------------------------\n\n");
}
// Solve EV and EEV if specified
if (DDSIP_param->expected)
{
DDSIP_node[DDSIP_bb->curnode]->step = DDSIP_bb->DDSIP_step = eev;
// status = 1 -> ExpValProb infeasible
if ((status = DDSIP_ExpValProb ()) == 1)
{
if (DDSIP_param->outlev)
fprintf (DDSIP_bb->moreoutfile, " exp. val. prob: INFEASIBLE\n");
fprintf (DDSIP_outfile, " exp. val. prob: INFEASIBLE\n");
}
if (!status)
{
DDSIP_bb->curnode = 0;
DDSIP_bb->sug[DDSIP_param->nodelim + 2] = (struct sug_l *)DDSIP_Alloc (sizeof (sug_t), 1, "sug[0](Advanced start solution)");
DDSIP_bb->sug[DDSIP_param->nodelim + 2]->firstval =
(double *) DDSIP_Alloc (sizeof (double), DDSIP_bb->firstvar, "sug[i]->firstval(Heuristic)");
for (i = 0; i < DDSIP_bb->firstvar; i++)
(DDSIP_bb->sug[DDSIP_param->nodelim + 2]->firstval)[i] = DDSIP_bb->adv_sol[i];
DDSIP_bb->sug[DDSIP_param->nodelim + 2]->next = NULL;
if ((status = DDSIP_UpperBound (DDSIP_param->scenarios, 0)) && status < 100000)
goto TERMINATE;
}
if (fabs (DDSIP_bb->expbest) < DDSIP_infty)
{
if (DDSIP_param->outlev)
printf ("\t\t EEV: %13.7f\n", DDSIP_bb->expbest);
fprintf (DDSIP_outfile, "-EEV: %13.7f\n", DDSIP_bb->expbest);
}
else
{
if (DDSIP_param->outlev)
printf ("\t\t EEV: No solution found.\n");
fprintf (DDSIP_outfile, "-EEV: No solution found.\n");
}
} // END if (EV)
// stop here if NODELIM is zero
if (!(DDSIP_param->nodelim))
goto TERMINATE;
// Print cplex log to debugfile
if (DDSIP_param->outlev > 51)
{
#ifdef CPLEX_12_8
if ((status = CPXsetlogfilename (DDSIP_env, DDSIP_moreoutfname, "a")))
goto TERMINATE;
#else
if ((status = CPXsetlogfile (DDSIP_env, DDSIP_bb->moreoutfile)))
goto TERMINATE;
#endif
}
// No of DDSIP iterations
DDSIP_bb->noiter = 0;
// cont = 1 if no stop criteria is fullfilled
cont = 1;
// comb tells in case of a combined heuristic, which one to apply (3 = RoundNear)
comb = 3;
if (!DDSIP_param->nodelim)
return 0;
if (DDSIP_param->outlev)
printf ("Starting branch-and-bound algorithm.\n");
fprintf (DDSIP_outfile, "----------------------------------------------------------------------------------------\n");
while (cont)
{
// the cuts from the root node are contained in every following node model, there is no need to check their violation
// for the scenario solutions. But the rounding heuristics could violate a cut, so keep them.
result = DDSIP_bb->cutNumber;
#ifdef CONIC_BUNDLE
#ifdef DEBUG
////////////////////////////////////////////
if (DDSIP_bb->curnode && DDSIP_param->outlev)
{
if((DDSIP_node[DDSIP_bb->curnode-1])->step == dual)
fprintf(DDSIP_bb->moreoutfile, "######## last node %d step=dual, leaf= %d, dualdescitcnt = %d, DDSIP_bb->cutoff= %d\n",DDSIP_bb->curnode-1,(DDSIP_node[DDSIP_bb->curnode-1])->leaf,DDSIP_bb->dualdescitcnt,DDSIP_bb->cutoff);
}
////////////////////////////////////////////
#endif
if (DDSIP_param->outlev > 20)
{
if (DDSIP_node[DDSIP_bb->curnode]->cbReturn32)
fprintf (DDSIP_bb->moreoutfile, "########## DDSIP_node[%d]->cbReturn32 = %d -> no ConicBundle\n", DDSIP_bb->curnode, DDSIP_node[DDSIP_bb->curnode]->cbReturn32);
}
// Dual method
if ((!DDSIP_node[DDSIP_bb->curnode]->cbReturn32) &&
((DDSIP_param->cb > 0 && (!(DDSIP_bb->curnode % abs(DDSIP_param->cb))) && (abs(DDSIP_param->riskmod) != 4 || DDSIP_bb->curnode)) ||
(DDSIP_param->cb < 0 && (DDSIP_bb->curnode || (!DDSIP_bb->curnode && DDSIP_param->cbrootitlim >= 0)) &&
(((DDSIP_node[DDSIP_bb->curnode]->depth <= DDSIP_param->cb_depth) && abs(DDSIP_param->riskmod) != 4) ||
(abs(DDSIP_param->riskmod) == 5 && DDSIP_node[DDSIP_bb->curnode]->depth == 8) ||
(DDSIP_bb->curnode > DDSIP_param->cbBreakIters &&
((!(DDSIP_bb->curnode % abs(DDSIP_param->cb))) ||
(!((DDSIP_bb->curnode+1) % -DDSIP_param->cb)) ||
(DDSIP_bb->curnode%200 > 199 - DDSIP_param->cbContinuous) ||
(DDSIP_bb->curnode <= DDSIP_param->cbContinuous + DDSIP_param->cbBreakIters) ||
((DDSIP_bb->curnode > 2*DDSIP_param->cbBreakIters) && (DDSIP_bb->curnode <= DDSIP_param->cbContinuous + 2*DDSIP_param->cbBreakIters)) ||
((DDSIP_bb->cutoff > 6) &&
(((DDSIP_bb->no_reduced_front < 51) && (DDSIP_bb->curnode % -DDSIP_param->cb) < DDSIP_param->cbContinuous)
|| (((DDSIP_node[DDSIP_bb->curnode-1])->step == dual) && (DDSIP_node[DDSIP_bb->curnode-1])->leaf /*&& (DDSIP_bb->dualdescitcnt < 11)*/)
)
)
)
) ||
(abs(DDSIP_param->riskmod) != 5 && DDSIP_bb->curnode <= DDSIP_param->cbBreakIters && DDSIP_bb->curnode > DDSIP_param->cbBreakIters*.48 &&
(CBFORALL || (DDSIP_node[DDSIP_bb->curnode]->numInheritedSols > (DDSIP_Imin(DDSIP_param->scenarios/20,2)+(DDSIP_param->scenarios+1)/2))))
)
)
)
)
{
DDSIP_bb->DDSIP_step = DDSIP_node[DDSIP_bb->curnode]->step = dual;
if ((status = DDSIP_DualOpt (0)))
{
if (!DDSIP_bb->curnode)
goto TERMINATE;
else
{
DDSIP_bb->skip = 1;
fprintf (DDSIP_outfile, "### return code of DualOpt is %d.\n", status);
if (status == 2 || DDSIP_bb->skip == 1)
DDSIP_node[DDSIP_bb->curnode]->bound = DDSIP_infty;
}
}
}
else
{
DDSIP_node[DDSIP_bb->curnode]->step = DDSIP_bb->DDSIP_step = solve;
// status=1 means there was no solution found to a scenario problem
if ((status = DDSIP_LowerBound (&tmp_objval, 0)))
goto TERMINATE;
}
#else
DDSIP_node[DDSIP_bb->curnode]->step = DDSIP_bb->DDSIP_step = solve;
// status=1 means there was no solution found to a subproblem
if ((status = DDSIP_LowerBound (&tmp_objval, 0)))
goto TERMINATE;
#endif
if (!DDSIP_bb->skip || DDSIP_bb->skip == -1 || DDSIP_bb->skip == -11)
{
double old_bound;
int cntr, maxCntr, nowAdded;
DDSIP_bb->cutAdded = DDSIP_bb->cutNumber - result;
nowAdded = DDSIP_bb->cutNumber;
DDSIP_EvaluateScenarioSolutions (&comb);
nowAdded = DDSIP_bb->cutNumber - nowAdded;
cntr = 0;
if (DDSIP_node[DDSIP_bb->curnode]->step != dual)
maxCntr = DDSIP_param->numberReinits;
else
maxCntr = 0;
old_bound = DDSIP_node[DDSIP_bb->curnode]->bound;
boundstat = DDSIP_Bound ();
if (!DDSIP_bb->curnode)
{
int cnt, j, noIncreaseCntr = 0;
double lhs;
cutpool_t *currentCut;
DDSIP_PrintState (DDSIP_bb->noiter);
if (nowAdded && DDSIP_param->outlev)
{
fprintf (DDSIP_outfile, " %6d%101d cuts (UB)\n", DDSIP_bb->curnode, nowAdded);
}
while ((DDSIP_bb->cutAdded || DDSIP_node[0]->step == dual) && cntr < maxCntr)
{
cntr++;
old_bound = DDSIP_node[0]->bound;
// Free the solutions from former LowerBound
for (i = 0; i < DDSIP_param->scenarios; i++)
{
if (((DDSIP_node[0])->first_sol)[i])
{
if (DDSIP_node[0]->step == solve)
{
currentCut = DDSIP_bb->cutpool;
while (currentCut)
{
lhs = 0.;
for (j = 0; j < DDSIP_bb->firstvar; j++)
{
lhs += (DDSIP_node[0])->first_sol[i][j] * currentCut->matval[j];
}
if (lhs < currentCut->rhs - 1.e-7)
{
#ifdef DEBUG
if (DDSIP_param->outlev > 50)
fprintf (DDSIP_bb->moreoutfile, "scen %d solution violates cut %d.\n", i+1, currentCut->number);
#endif
if ((cnt = (int) ((((DDSIP_node[0])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
for (j = i + 1; cnt && j < DDSIP_param->scenarios; j++)
{
{
if (((DDSIP_node[0])->first_sol)[j]
&& ((DDSIP_node[0])->first_sol)[i] == ((DDSIP_node[0])->first_sol)[j])
{
((DDSIP_node[0])->first_sol)[j] = NULL;
cnt--;
}
}
}
DDSIP_Free ((void **) &(((DDSIP_node[0])->first_sol)[i]));
break;
}
currentCut = currentCut->prev;
}
}
else
{
if ((cnt = (int) ((((DDSIP_node[0])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
for (j = i + 1; cnt && j < DDSIP_param->scenarios; j++)
{
{
if (((DDSIP_node[0])->first_sol)[j]
&& ((DDSIP_node[0])->first_sol)[i] == ((DDSIP_node[0])->first_sol)[j])
{
((DDSIP_node[0])->first_sol)[j] = NULL;
cnt--;
}
}
}
DDSIP_Free ((void **) &(((DDSIP_node[0])->first_sol)[i]));
}
}
}
result = DDSIP_bb->cutNumber;
DDSIP_node[0]->step = DDSIP_bb->DDSIP_step = solve;
// status=1 means there was no solution found to a scenario problem
#ifdef GREATERMIPGAP
if ((status = DDSIP_LowerBound (&tmp_objval, 1)))
goto TERMINATE;
#else
if ((status = DDSIP_LowerBound (&tmp_objval, 0)))
goto TERMINATE;
#endif
nowAdded = DDSIP_bb->cutAdded = DDSIP_bb->cutNumber - result;
DDSIP_EvaluateScenarioSolutions (&comb);
nowAdded = DDSIP_bb->cutAdded - nowAdded;
DDSIP_bb->bestbound = DDSIP_node[0]->bound;
DDSIP_bb->noiter++;
DDSIP_PrintState (1);
if (/*nowAdded &&*/ DDSIP_param->outlev)
{
fprintf (DDSIP_outfile, " %6d %82d. reinit: %8d cuts (UB)\n", 0, cntr, nowAdded);
}
if ((DDSIP_node[0]->bound - old_bound)/(fabs(old_bound) + 1e-16) < 1.e-10)
noIncreaseCntr++;
if (noIncreaseCntr > 2 ||
(DDSIP_bb->bestvalue - DDSIP_node[0]->bound)/(fabs(DDSIP_bb->bestvalue) + 1e-16) < 0.5*DDSIP_param->relgap)
break;
}
if (DDSIP_param->deleteRedundantCuts)
DDSIP_CheckRedundancy(1);
// #ifdef GREATERMIPGAP
// // in case the computations werde done with reduced accuracy, repeat
// DDSIP_bb->cutAdded = 1;
// while (DDSIP_bb->cutAdded && cntr < maxCntr)
// {
// cntr++;
// old_bound = DDSIP_node[0]->bound;
// // Free the solutions from former LowerBound
// for (i = 0; i < DDSIP_param->scenarios; i++)
// {
// if (((DDSIP_node[0])->first_sol)[i])
// {
// double gap;
// gap = 100.0*((DDSIP_node[DDSIP_bb->curnode]->cursubsol)[i]-(DDSIP_node[DDSIP_bb->curnode]->subbound)[i])/
// (fabs((DDSIP_node[DDSIP_bb->curnode]->cursubsol)[i])+1e-4);
// if (fabs(gap) < 1.e-10)
// {
// currentCut = DDSIP_bb->cutpool;
// while (currentCut)
// {
// lhs = 0.;
// for (j = 0; j < DDSIP_bb->firstvar; j++)
// {
// lhs += (DDSIP_node[0])->first_sol[i][j] * currentCut->matval[j];
// }
// if (lhs < currentCut->rhs - 1.e-7)
// {
// #ifdef DEBUG
// if (DDSIP_param->outlev > 50)
// fprintf (DDSIP_bb->moreoutfile, "scen %d solution violates cut %d.\n", i+1, currentCut->number);
// #endif
// if ((cnt = (int) ((((DDSIP_node[0])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
// for (j = i + 1; cnt && j < DDSIP_param->scenarios; j++)
// {
// {
// if (((DDSIP_node[0])->first_sol)[j]
// && ((DDSIP_node[0])->first_sol)[i] == ((DDSIP_node[0])->first_sol)[j])
// {
// ((DDSIP_node[0])->first_sol)[j] = NULL;
// cnt--;
// }
// }
// }
// DDSIP_Free ((void **) &(((DDSIP_node[0])->first_sol)[i]));
// break;
// }
// currentCut = currentCut->prev;
// }
// }
// else
// {
// if ((cnt = (int) ((((DDSIP_node[0])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
// for (j = i + 1; cnt && j < DDSIP_param->scenarios; j++)
// {
// {
// if (((DDSIP_node[0])->first_sol)[j]
// && ((DDSIP_node[0])->first_sol)[i] == ((DDSIP_node[0])->first_sol)[j])
// {
// ((DDSIP_node[0])->first_sol)[j] = NULL;
// cnt--;
// }
// }
// }
// DDSIP_Free ((void **) &(((DDSIP_node[0])->first_sol)[i]));
// }
// }
// }
// result = DDSIP_bb->cutNumber;
// DDSIP_node[0]->step = DDSIP_bb->DDSIP_step = solve;
// // status=1 means there was no solution found to a scenario problem
// if ((status = DDSIP_LowerBound (&tmp_objval, 0)))
// goto TERMINATE;
// nowAdded = DDSIP_bb->cutAdded = DDSIP_bb->cutNumber - result;
// DDSIP_EvaluateScenarioSolutions (&comb);
// nowAdded = DDSIP_bb->cutAdded - nowAdded;
// DDSIP_bb->bestbound = DDSIP_node[0]->bound;
// DDSIP_bb->noiter++;
// DDSIP_PrintState (1);
// if (/*nowAdded &&*/ DDSIP_param->outlev)
// {
// fprintf (DDSIP_outfile, " %6d %82d. reinit: %8d cuts (UB)\n", 0, cntr, nowAdded);
// }
// if ((DDSIP_node[0]->bound - old_bound)/(fabs(old_bound) + 1e-16) < 1.e-10)
// noIncreaseCntr++;
// if (noIncreaseCntr > 2 ||
// (DDSIP_bb->bestvalue - DDSIP_node[0]->bound)/(fabs(DDSIP_bb->bestvalue) + 1e-16) < 0.5*DDSIP_param->relgap)
// break;
// }
// #endif
for (i = 0; i < DDSIP_param->scenarios; i++)
{
tmp_objval = 100.0*((DDSIP_node[DDSIP_bb->curnode]->cursubsol)[i]-(DDSIP_node[DDSIP_bb->curnode]->subbound)[i])/
(fabs((DDSIP_node[DDSIP_bb->curnode]->cursubsol)[i])+1e-4);
if (tmp_objval > DDSIP_param->relgap)
{
(DDSIP_node[DDSIP_bb->curnode]->mipstatus)[i] = CPXMIP_NODE_LIM_FEAS;
}
}
}
else
{
// Print a line of output at the first, the last and each `ith' node
if (!DDSIP_bb->noiter || (!((DDSIP_bb->noiter + 1) % DDSIP_param->logfreq)) || (DDSIP_param->outlev && (DDSIP_node[DDSIP_bb->curnode])->step == dual))
DDSIP_PrintState (DDSIP_bb->noiter);
if (nowAdded && DDSIP_param->outlev > 1)
{
fprintf (DDSIP_outfile, " %6d%101d cuts (UB)\n", DDSIP_bb->curnode, nowAdded);
}
}
}
else
{
boundstat = DDSIP_Bound ();
// Print a line of output at the first, the last and each `ith' node
if (!DDSIP_bb->noiter || (!((DDSIP_bb->noiter + 1) % DDSIP_param->logfreq)) || (DDSIP_param->outlev && (DDSIP_node[DDSIP_bb->curnode])->step == dual))
DDSIP_PrintState (DDSIP_bb->noiter);
}
if (!DDSIP_bb->curnode)
{
DDSIP_bb->cutCntr0 = DDSIP_bb->cutNumber;
DDSIP_bb->correct_bounding = fabs(DDSIP_node[0]->bound)*5.e-10;
}
else if (DDSIP_param->alwaysBendersCuts)
{
if (DDSIP_bb->curnode == 11)
{
if (DDSIP_bb->cutCntr0 == DDSIP_bb->cutNumber)
{
if (DDSIP_param->outlev > 20)
fprintf (DDSIP_bb->moreoutfile, "### setting alwaysBendersCuts to 0\n");
DDSIP_param->alwaysBendersCuts = 0;
}
}
if (DDSIP_bb->curnode == 24)
{
if (DDSIP_bb->cutCntr0 == DDSIP_bb->cutNumber)
{
if (DDSIP_param->outlev > 20)
fprintf (DDSIP_bb->moreoutfile, "### setting alwaysBendersCuts to 0\n");
DDSIP_param->alwaysBendersCuts = 0;
}
else
DDSIP_bb->cutCntr0 = DDSIP_bb->cutNumber;
}
else if (DDSIP_bb->curnode == 49)
{
if (DDSIP_bb->cutCntr0 == DDSIP_bb->cutNumber)
{
if (DDSIP_param->outlev > 20)
fprintf (DDSIP_bb->moreoutfile, "### setting alwaysBendersCuts to 0\n");
DDSIP_param->alwaysBendersCuts = 0;
}
else
DDSIP_bb->cutCntr0 = DDSIP_bb->cutNumber;
}
else if (DDSIP_bb->curnode == 99)
{
if (DDSIP_bb->cutCntr0 == DDSIP_bb->cutNumber)
{
if (DDSIP_param->outlev > 20)
fprintf (DDSIP_bb->moreoutfile, "### setting alwaysBendersCuts to 0\n");
DDSIP_param->alwaysBendersCuts = 0;
}
}
}
DDSIP_bb->correct_bounding = fabs(DDSIP_bb->bestbound)*5.e-10;
if (DDSIP_param->cb && DDSIP_param->cb_depth>0 && DDSIP_param->cb_depth_iters && DDSIP_bb->curnode == 2 && DDSIP_node[1]->dual && DDSIP_node[2]->dual)
{
double old_objval, *save_dual;
int cnt = 0, k1;
for (k1 = 0; k1 < DDSIP_bb->dimdual; k1++)
{
if (DDSIP_node[2]->dual[k1] != DDSIP_node[1]->dual[k1])
{
cnt = 1;
break;
}
}
if (cnt)
{
save_dual = (double *) DDSIP_Alloc (sizeof (double), DDSIP_bb->dimdual + 3, "save_dual(DDSIP_main)");
memcpy (save_dual, DDSIP_node[1]->dual, sizeof (double) * DDSIP_bb->dimdual + 3);
memcpy (DDSIP_node[1]->dual, DDSIP_node[2]->dual, sizeof (double) * DDSIP_bb->dimdual + 3);
DDSIP_bb->curnode = 1;
status = DDSIP_SetBounds ();
if (status)
{
fprintf (stderr, "ERROR: Failed to add new bounds (Branch).\n");
return status;
}
DDSIP_bb->DDSIP_step = solve;
for (i = 0; i < DDSIP_param->scenarios; i++)
{
if ((DDSIP_node[DDSIP_bb->curnode]->first_sol)[i] != NULL)
{
if ((cnt = (int) ((((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
for (k1 = i + 1; cnt && k1 < DDSIP_param->scenarios; k1++)
{
if ((((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i]) == (((DDSIP_node[DDSIP_bb->curnode])->first_sol)[k1]))
{
((DDSIP_node[DDSIP_bb->curnode])->first_sol)[k1] = NULL;
cnt--;
}
}
DDSIP_Free ((void **) &(((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i]));
}
}
old_objval = DDSIP_node[1]->bound;
DDSIP_bb->dualObjVal = DDSIP_node[1]->bound;
DDSIP_LowerBound (&tmp_objval, 0);
if (DDSIP_param->outlev > 10)
fprintf (DDSIP_bb->moreoutfile, " ## re-eval node %d : %20.14g (new) - %20.14g (old) = %g\n", DDSIP_bb->curnode, tmp_objval, old_objval, tmp_objval - old_objval);
if (tmp_objval <= old_objval)
{
memcpy (DDSIP_node[1]->dual, save_dual, sizeof (double) * DDSIP_bb->dimdual + 3);
DDSIP_node[1]->bound = old_objval;
DDSIP_bb->DDSIP_step = DDSIP_node[1]->step = dual;
}
else
{
DDSIP_node[1]->bound = tmp_objval;
DDSIP_bb->DDSIP_step = DDSIP_node[1]->step = solve;
#ifdef DE1MULT
// delete node 1 multiplier from list
bbest_t * tmp_previous, * tmp_bestdual;
tmp_bestdual = DDSIP_bb->bestdual;
if (tmp_bestdual)
{
if (tmp_bestdual->node_nr == 1)
{
DDSIP_bb->bestdual = DDSIP_bb->bestdual->next;
DDSIP_bb->bestdual_cnt--;
if (DDSIP_param->outlev > 10)
fprintf (DDSIP_bb->moreoutfile, " ## delete entry from node %d from bestdual list, #entries: %d\n", tmp_bestdual->node_nr, DDSIP_bb->bestdual_cnt);
DDSIP_Free ((void **) &(tmp_bestdual->dual));
DDSIP_Free ((void **) &(tmp_bestdual));
}
else
{
while (tmp_bestdual)
{
tmp_previous = tmp_bestdual;
tmp_bestdual = tmp_bestdual->next;
if (tmp_bestdual && tmp_bestdual->node_nr == 1)
{
tmp_previous->next = tmp_bestdual->next;
DDSIP_bb->bestdual_cnt--;
if (DDSIP_param->outlev > 10)
fprintf (DDSIP_bb->moreoutfile, " ## delete entry from node %d from bestdual list, #entries: %d\n", tmp_bestdual->node_nr, DDSIP_bb->bestdual_cnt);
DDSIP_Free ((void **) &(tmp_bestdual->dual));
DDSIP_Free ((void **) &(tmp_bestdual));
break;
}
}
}
}
#endif
}
DDSIP_Free ((void **) &(save_dual));
boundstat = DDSIP_Bound ();
if (!DDSIP_bb->skip)
DDSIP_EvaluateScenarioSolutions (&comb);
DDSIP_PrintState (DDSIP_bb->noiter);
DDSIP_bb->curnode = 2;
}
}
// check if the bestdual multipliers improve bounds of the nodes in the front
if (DDSIP_param->cb < 0 && DDSIP_param->cb_checkBestdual && DDSIP_bb->bestdual_cnt &&
(DDSIP_bb->curnode == DDSIP_Imin (2*((DDSIP_param->cbContinuous + DDSIP_param->cbBreakIters)/2) + DDSIP_Imax (2, 2*(-DDSIP_param->cb/2-1)), DDSIP_param->dive_start - 7) ||
DDSIP_bb->curnode == DDSIP_Imax (2*(DDSIP_param->cbContinuous + 2*(DDSIP_param->cbBreakIters/2) + 4), 62) ||
DDSIP_bb->curnode == DDSIP_param->nodelim - 2
)
)
{
if (DDSIP_bb->bestdual_improvement > 0)
{
int ih, inode, nowAdded;
double * front_node_bound, least_bound = DDSIP_infty;
if (DDSIP_param->outlev > 20)
fprintf (DDSIP_bb->moreoutfile, " ## node %d, bestdual_improvement= %d, re-evaluation of front nodes with bestdual entries\n", DDSIP_bb->curnode, DDSIP_bb->bestdual_improvement);
// sort front nodes ascending wrt. bound
DDSIP_Free ((void **) &DDSIP_bb->front_nodes_sorted);
DDSIP_bb->front_nodes_sorted = (int *) DDSIP_Alloc(sizeof(int), DDSIP_bb->nofront, "DDSIP_bb->front_nodes_sorted(main)");
front_node_bound = (double *) DDSIP_Alloc(sizeof(double), DDSIP_bb->nonode, "front_node_bound(main)");
for (ih = 0; ih < DDSIP_bb->nofront; ih++)
{
DDSIP_bb->front_nodes_sorted[ih] = DDSIP_bb->front[ih];
front_node_bound[DDSIP_bb->front_nodes_sorted[ih]] = DDSIP_node[DDSIP_bb->front_nodes_sorted[ih]]->bound;
}
DDSIP_qsort_ins_A (front_node_bound, DDSIP_bb->front_nodes_sorted, 0, DDSIP_bb->nofront-1);
tmp_objval = DDSIP_node[DDSIP_bb->front_nodes_sorted[DDSIP_bb->nofront - 1]]->bound;
ih = DDSIP_bb->curnode;
for (inode = 0; inode < DDSIP_bb->nofront; inode++)
{
if (DDSIP_node[DDSIP_bb->front_nodes_sorted[inode]]->leaf)
continue;
DDSIP_bb->curnode = DDSIP_bb->front_nodes_sorted[inode];
if (DDSIP_node[DDSIP_bb->curnode]->bound > 0.30 * least_bound + 0.70 * tmp_objval)
{
break;
}
if (!DDSIP_node[DDSIP_bb->curnode]->leaf && DDSIP_node[DDSIP_bb->curnode]->solved)
{
double old_objval;
int cnt, k1;
nowAdded = DDSIP_bb->cutNumber;
status = DDSIP_SetBounds ();
if (status)
{
fprintf (stderr, "ERROR: Failed to add new bounds (main).\n");
return status;
}
for (i = 0; i < DDSIP_param->scenarios; i++)
{
if ((DDSIP_node[DDSIP_bb->curnode]->first_sol)[i] != NULL)
{
if ((cnt = (int) ((((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i])[DDSIP_bb->firstvar] - 0.9)))
for (k1 = i + 1; cnt && k1 < DDSIP_param->scenarios; k1++)
{
if ((((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i]) == (((DDSIP_node[DDSIP_bb->curnode])->first_sol)[k1]))
{
((DDSIP_node[DDSIP_bb->curnode])->first_sol)[k1] = NULL;
cnt--;
}
}
DDSIP_Free ((void **) &(((DDSIP_node[DDSIP_bb->curnode])->first_sol)[i]));
}
}
old_objval = DDSIP_node[DDSIP_bb->curnode]->bound;
DDSIP_bb->DDSIP_step = DDSIP_node[DDSIP_bb->curnode]->step = dual;
if ((status = DDSIP_DualOpt (1)))
{