File: CbcGenParamUtils.cpp

package info (click to toggle)
coinor-cbc 2.9.9+repack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,848 kB
  • ctags: 5,787
  • sloc: cpp: 104,337; sh: 8,921; xml: 2,950; makefile: 520; ansic: 491; awk: 197
file content (1504 lines) | stat: -rw-r--r-- 56,079 bytes parent folder | download | duplicates (3)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
/*
  Copyright (C) 2007, Lou Hafer, International Business Machines Corporation
  and others.  All Rights Reserved.

  This code is licensed under the terms of the Eclipse Public License (EPL).

  $Id: CbcGenParamUtils.cpp 1899 2013-04-09 18:12:08Z stefan $
*/
/*
  This file is part of cbc-generic.
*/

#if defined(_MSC_VER)
// Turn off compiler warning about long names
#  pragma warning(disable:4786)
#endif

#include <string>
#include <cassert>

#include "CoinFileIO.hpp"

#include "CoinFinite.hpp"
#include "CoinParam.hpp"

#include "CbcModel.hpp"

#include "CbcGenParam.hpp"
#include "CbcGenCtlBlk.hpp"

/*! \file CbcGenParamUtils
    \brief Implementation functions for CbcGenParam parameters.
*/

namespace {

char svnid[] = "$Id: CbcGenParamUtils.cpp 1899 2013-04-09 18:12:08Z stefan $" ;

}

namespace CbcGenSolvers {
void setupSolverParam(CbcGenParam &solverParam) ;
}

namespace CbcGenParamUtils {

/*
  Function to add cbc-generic control parameters to the cbc-generic parameter
  vector. Were needed, defaults are drawn from ctlBlk-> This function is a
  friend of CbcGenCtlBlk.
*/

void addCbcGenParams (int &numberParameters, CoinParamVec &parameters,
                      CbcGenCtlBlk *ctlBlk)

{
    CbcGenParam *param ;
    std::string empty = "" ;

    param = new CbcGenParam(CbcGenParam::GENERALQUERY, "?",
                            "Print a list of commands", false) ;
    param->setPushFunc(doHelpParam) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::FULLGENERALQUERY, "???",
                            "Print a list with *all* commands, even those hidden with `?'", false) ;
    param->setPushFunc(doHelpParam) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::PRINTVERSION,
                            "version", "Print version") ;
    param->setPushFunc(doVersionParam) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    /*
      Built into CoinParam parsing. No additional actions required. doNothingParam
      simply prevents them from being reported as unimplemented.
    */
    param = new CbcGenParam(CbcGenParam::STDIN, "-",
                            "Switch to interactive command line mode", false) ;
    param->setPushFunc(doNothingParam) ;
    parameters.push_back(param) ;
    param = new CbcGenParam(CbcGenParam::STDIN, "stdin",
                            "Switch to interactive command line mode", false) ;
    param->setPushFunc(doNothingParam) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::BAB,
                            "branch!AndCut", "Do Branch and Cut") ;
    param->setPushFunc(doBaCParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This does branch and cut. There are many parameters which can affect the performance.  First just try with default settings and look carefully at the log file.  Did cuts help?  Did they take too long?  Look at output to see which cuts were effective and then do some tuning.  You will see that the options for cuts are off, on, root and ifmove.  Off is obvious, on means that this cut generator will be tried in the branch and cut tree (you can fine tune using 'depth').  Root means just at the root node while 'ifmove' means that cuts will be used in the tree if they look as if they are doing some good and moving the objective value.  If pre-processing reduced the size of the problem or strengthened many coefficients then it is probably wise to leave it on.  Switch off heuristics which did not provide solutions.  The other major area to look at is the search.  Hopefully good solutions were obtained fairly early in the search so the important point is to select the best variable to branch on.  See whether strong branching did a good job - or did it just take a lot of iterations.  Adjust the strongBranching and trustPseudoCosts parameters."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::CPP,
                            "cpp!Generate", "Generates C++ code", -1, 50000) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "Once you like what the stand-alone solver does then this allows you to generate user_driver.cpp which approximates the code.  0 gives simplest driver, 1 generates saves and restores, 2 generates saves and restores even for variables at default value. 4 bit in cbc generates size dependent code rather than computed values."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::CLIQUECUTS,
                            "clique!Cuts", "Whether to use clique cuts", "off",
                            ctlBlk->clique_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on clique cuts (either at root or in entire tree). See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::CUTDEPTH,
                            "cutD!epth", "Depth in tree at which to do cuts",
                            -1, 999999, ctlBlk->cutDepth_) ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenIntParam) ;
    param->setLongHelp(
        "Cut generators may be off, on only at the root, on if they look useful, and on at some interval.  If they are done every node then that is that, but it may be worth doing them every so often.  The original method was every so many nodes but it is more logical to do it whenever depth in tree is a multiple of K.  This option does that and defaults to -1 (off)."
    ) ;
    parameters.push_back(param) ;


    param = new CbcGenParam(CbcGenParam::CUTSTRATEGY,
                            "cuts!OnOff", "Switches all cuts on or off", "off", 0) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This can be used to switch on or off all cuts (apart from Reduce and Split).  Then you can set individual ones off or on.  See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::COMBINE,
                            "combine!Solutions",
                            "Whether to use combine solution heuristic", "off",
                            ctlBlk->combine_.action_) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This switches on a heuristic which does branch and cut on the problem given by just using variables which have appeared in one or more solutions. It is obviously only tried after two or more solutions."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::COSTSTRATEGY,
                            "cost!Strategy", "Whether to use costs or column order as priorities",
                            "off", 0) ;
    param->appendKwd("pri!orities") ;
    param->appendKwd("column!Order") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This orders the variables in order of their absolute costs - with largest cost ones being branched on first.  This primitive strategy can be surprisingly effective.  The column order option is obviously not on costs but it's easy to implement."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::DEBUG,
                            "debug!In", "Read/write valid solution from/to file", "", false) ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(doDebugParam) ;
    param->setLongHelp(
        "This will read a solution file from the given file name.  It will use the default directory given by 'directory'.  A name of '$' will use the previous value for the name.  This is initialized to '', i.e. it must be set.\n\nIf set to create it will create a file called debug.file after B&C search; if set to createAfterPre it will create the file before undoing preprocessing.\n\nThe idea is that if you suspect a bad cut generator and you did not use preprocessing you can do a good run with debug set to 'create' and then switch on the cuts you suspect and re-run with debug set to 'debug.file'  Similarly if you do use preprocessing, but use createAfterPre.  The create case has the same effect as saveSolution."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::DIRECTORY,
                            "directory", "Set Default directory for import etc.",
                            ctlBlk->dfltDirectory_) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This sets the directory which import, export, saveModel, restoreModel etc. will use. It is initialized to the current directory."
    ) ;
    param->setPushFunc(pushCbcGenStrParam) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::EXIT, "end", "Stops execution") ;
    param->setPushFunc(doExitParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This stops execution; end, exit, quit and stop are synonyms."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::ERRORSALLOWED,
                            "error!sAllowed", "Whether to allow import errors", "off", 0) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "The default is not to use any model which had errors when reading the mps file.  Setting this to 'on' will allow all errors from which the code can recover simply by ignoring the error.  There are some errors from which the code can not recover, e.g., no ENDATA.  This has to be set before import, i.e., -errorsAllowed on -import xxxxxx.mps."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::EXIT, "exit", "Stops execution") ;
    param->setPushFunc(doExitParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This stops execution; end, exit, quit and stop are synonyms."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::EXPORT,
                            "export", "Export model as mps file",
                            std::string("default.mps")) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This will write an MPS format file to the given file name.  It will use the default directory given by 'directory'.  A name of '$' will use the previous value for the name.  This is initialized to 'default.mps'."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::DJFIX, "fix!OnDj",
                            "Try heuristic that fixes variables based on reduced costs",
                            -1.0e20, 1.0e20, ctlBlk->djFix_.threshold_) ;
    param->setPushFunc(pushCbcGenDblParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "If set, integer variables with reduced costs greater than the specified value will be fixed before branch and bound - use with extreme caution!"
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::FPUMP,
                            "feas!ibilityPump", "Whether to try Feasibility Pump", "off",
                            ctlBlk->fpump_.action_) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This switches on feasibility pump heuristic at root. This is due to Fischetti and Lodi and uses a sequence of LPs to try and get an integer feasible solution.  Some fine tuning is available by passFeasibilityPump."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::FPUMPITS,
                            "passF!easibilityPump", "How many passes in feasibility pump",
                            0, 10000, ctlBlk->fpump_.iters_) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This fine tunes the Feasibility Pump heuristic by doing more or fewer passes."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::FLOWCUTS,
                            "flow!CoverCuts", "Whether to use Flow Cover cuts", "off",
                            ctlBlk->flow_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on flow cover cuts (either at root or in entire tree).  See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::GOMORYCUTS, "gomory!Cuts",
                            "Whether to use Gomory cuts", "off",
                            ctlBlk->gomory_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "The original cuts - beware of imitations!  Having gone out of favor, they are now more fashionable as LP solvers are more robust and they interact well with other cuts.  They will almost always give cuts (although in this executable they are limited as to number of variables in cut).  However the cuts may be dense so it is worth experimenting. See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::GREEDY,
                            "greedy!Heuristic", "Whether to use a greedy heuristic", "off",
                            ctlBlk->greedyCover_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "Switches on a pair of greedy heuristic which will try and obtain a solution.  It may just fix a percentage of variables and then try a small branch and cut run."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::HEURISTICSTRATEGY,
                            "heur!isticsOnOff", "Switches most heuristics on or off", "off", 0) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This can be used to switch on or off all heuristics.  Then you can set individual ones off or on.  CbcTreeLocal is not included as it dramatically alters search."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::KNAPSACKCUTS,
                            "knapsack!Cuts", "Whether to use Knapsack cuts", "off",
                            ctlBlk->knapsack_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on knapsack cuts (either at root or in entire tree). See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    /*
      param = new CbcGenParam(CbcGenParam::LANDPCUTS,
    	"lift!AndProjectCuts","Whether to use lift-and-project cuts","off",
    	ctlBlk->landp_.action_) ;
      param->appendKwd("on") ;
      param->appendKwd("root") ;
      param->appendKwd("ifmove") ;
      param->appendKwd("forceOn") ;
      param->setObj(ctlBlk) ;
      param->setLongHelp(
    	"This switches on lift-and-project cuts (either at root or in entire tree). See branchAndCut for information on options."
    	) ;
      parameters.push_back(param) ;
    */

    param = new CbcGenParam(CbcGenParam::LOCALTREE,
                            "local!TreeSearch", "Whether to use local tree search", "off",
                            ctlBlk->localTree_.action_) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This switches on a local search algorithm when a solution is found.  This is from Fischetti and Lodi and is not really a heuristic although it can be used as one. When used from this program it has limited functionality.  It is not controlled by heuristicsOnOff."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::LOGLEVEL,
                            "log!Level", "Level of detail in cbc-generic output.",
                            -1, 999999, ctlBlk->logLvl_) ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenIntParam) ;
    param->setLongHelp(
        "If set to 0 then there should be no output in normal circumstances. A value of 1 is probably the best value for most uses, while 2 and 3 give more information."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::MIXEDCUTS,
                            "mixed!IntegerRoundingCuts",
                            "Whether to use Mixed Integer Rounding cuts", "off",
                            ctlBlk->mir_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on mixed integer rounding cuts (either at root or in entire tree).  See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::USESOLUTION,
                            "force!Solution",
                            "Whether to use given solution as crash for BAB", "off", 0) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "If on then tries to branch to solution given by AMPL or priorities file."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::HELP, "help",
                            "Print out version, non-standard options and some help") ;
    param->setPushFunc(doHelpParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This prints out some help to get a user started. If you're seeing this message, you should be past that stage."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::IMPORT,
                            "import", "Import model from mps file",
                            ctlBlk->lastMpsIn_) ;
    param->setPushFunc(doImportParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This will read an MPS format file from the given file name.  It will use the default directory given by 'directory'.  A name of '$' will use the previous value for the name.  This is initialized to '', i.e., it must be set.  If you have libgz then it can read compressed files 'xxxxxxxx.gz'."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::SOLVECONTINUOUS, "initialS!olve",
                            "Solve to continuous optimum") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This just solves the problem to the continuous optimum, without adding any cuts."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::MESSAGES, "mess!ages",
                            "Controls whether standardised message prefix is printed", "off", 0) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "By default, messages have a standard prefix, such as:\n   Clp0005 2261  Objective 109.024 Primal infeas 944413 (758)\nbut this program turns this off to make it look more friendly.  It can be useful to turn them back on if you want to be able to 'grep' for particular messages or if you intend to override the behavior of a particular message."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::MIPLIB,
                            "miplib", "Do some of miplib test set") ;
    parameters.push_back(param) ;


    param = new CbcGenParam(CbcGenParam::OUTDUPROWS,
                            "outDup!licates",
                            "Takes duplicate rows, etc., out of the integer model", false) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::OUTPUTFORMAT,
                            "output!Format", "Which output format to use", 1, 6, 2) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "Normally export will be done using normal representation for numbers and two values per line.  You may want to do just one per line (for grep or suchlike) and you may wish to save with absolute accuracy using a coded version of the IEEE value. A value of 2 is normal. Otherwise, odd values give one value per line, even values two.  Values of 1 and 2 give normal format, 3 and 4 give greater precision, 5 and 6 give IEEE values.  When exporting a basis, 1 does not save values, 2 saves values, 3 saves with greater accuracy and 4 saves in IEEE format."
    ) ;
    parameters.push_back(param) ;

    /*
      In order for initialisation to work properly, the order of the keywords here
      must match the order of the enum IPPControl in CbcGenCtlBlk.hpp.
    */
    param = new CbcGenParam(CbcGenParam::PREPROCESS,
                            "preprocess", "Whether to use integer preprocessing", "off",
                            ctlBlk->preProcess_) ;
    param->appendKwd("on") ;
    param->appendKwd("save") ;
    param->appendKwd("equal") ;
    param->appendKwd("sos") ;
    param->appendKwd("trysos") ;
    param->appendKwd("equalall") ;
    param->appendKwd("strategy") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenKwdParam) ;
    param->setLongHelp(
        "This tries to reduce size of the model in a similar way to presolve and it also tries to strengthen the model. This can be very useful and is worth trying.  save option saves on file presolved.mps.  equal will turn <= cliques into ==.  sos will create sos sets if all 0-1 in sets (well one extra is allowed) and no overlaps.  trysos is same but allows any number extra. equalall will turn all valid inequalities into equalities with integer slacks. strategy is as on but uses CbcStrategy."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::PRINTOPTIONS,
                            "pO!ptions", "Dubious print options", 0, COIN_INT_MAX, 0, false) ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenIntParam) ;
    param->setLongHelp(
        "If this is greater than 0 then presolve will give more information and branch and cut will give statistics"
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::PROBINGCUTS,
                            "probing!Cuts", "Whether to use Probing cuts", "off",
                            ctlBlk->probing_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->appendKwd("forceOnBut") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on probing cuts (either at root or in entire tree). See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::INTPRINT,
                            "printi!ngOptions", "Print options", "normal", 0) ;
    param->appendKwd("integer") ;
    param->appendKwd("special") ;
    param->appendKwd("rows") ;
    param->appendKwd("all") ;
    param->setPushFunc(pushCbcGenKwdParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This changes the amount and format of printing a solution:\nnormal - nonzero column variables \ninteger - nonzero integer column variables\nspecial - in format suitable for OsiRowCutDebugger\nrows - nonzero column variables and row activities\nall - all column variables and row activities.\n\nFor non-integer problems 'integer' and 'special' act like 'normal'.  Also see printMask for controlling output."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::PRINTMASK,
                            "printM!ask",
                            "Control printing of solution with a regular expression", empty) ;
    param->setPushFunc(doPrintMaskParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "If set then only those names which match mask are printed in a solution. '?' matches any character and '*' matches any set of characters.  The default is '' (unset) so all variables are printed. This is only active if model has names."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::PRIORITYIN,
                            "prio!rityIn", "Import priorities etc from file", empty) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This will read a file with priorities from the given file name.  It will use the default directory given by 'directory'.  A name of '$' will use the previous value for the name.  This is initialized to '', i.e. it must be set.  This can not read from compressed files. File is in csv format with allowed headings - name, number, priority, direction, up, down, solution.  Exactly one of name and number must be given."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::REDSPLITCUTS,
                            "reduce!AndSplitCuts",
                            "Whether to use Reduce-and-Split cuts", "off",
                            ctlBlk->redSplit_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on reduce and split cuts (either at root or in entire tree). See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::ROUNDING,
                            "round!ingHeuristic", "Whether to use Rounding heuristic", "off",
                            ctlBlk->rounding_.action_) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This switches on a simple (but effective) rounding heuristic at each node of tree."
    ) ;
    parameters.push_back(param) ;


    param = new CbcGenParam(CbcGenParam::EXIT, "quit", "Stops execution") ;
    param->setPushFunc(doExitParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This stops execution; end, exit, quit and stop are synonyms."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::DUMMY,
                            "sleep", "for debug", 0, 9999, 0, false) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "If passed to solver from ampl, then ampl will wait so that you can copy .nl file for debug."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::SOLUTION,
                            "solu!tion", "Prints solution to file",
                            std::string("stdout")) ;
    param->setPushFunc(doSolutionParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This will write a primitive solution file to the given file name.  It will use the default directory given by 'directory'.  A name of '$' will use the previous value for the name.  This is initialized to 'stdout'.  The amount of output can be varied using printi!ngOptions or printMask."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam ;
    CbcGenSolvers::setupSolverParam(*param) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::SOS,
                            "sos!Options", "Whether to use SOS from AMPL", "off", 0) ;
    param->appendKwd("on") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "Normally if AMPL says there are SOS variables they should be used, but sometimes they should be turned off - this does so."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::EXIT, "stop", "Stops execution") ;
    param->setPushFunc(doExitParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This stops execution; end, exit, quit and stop are synonyms."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::STRENGTHEN,
                            "strengthen", "Create strengthened problem") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This creates a new problem by applying the root node cuts. All tight constraints will be in resulting problem."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::TIGHTENFACTOR, "tighten!Factor",
                            "Tighten bounds using value times largest activity at continuous solution",
                            1.0, 1.0e20) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This sleazy trick can help on some problems."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::TWOMIRCUTS,
                            "two!MirCuts",
                            "Whether to use Two phase Mixed Integer Rounding cuts", "off",
                            ctlBlk->twomir_.action_) ;
    param->appendKwd("on") ;
    param->appendKwd("root") ;
    param->appendKwd("ifmove") ;
    param->appendKwd("forceOn") ;
    param->setObj(ctlBlk) ;
    param->setPushFunc(pushCbcGenCutParam) ;
    param->setLongHelp(
        "This switches on two phase mixed integer rounding cuts (either at root or in entire tree). See branchAndCut for information on options."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::UNITTEST, "unitTest", "Do unit test") ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "This exercises the unit test."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::USERCBC,
                            "userCbc", "Hand coded Cbc stuff", 0, COIN_INT_MAX, 0, false) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "There are times (e.g., when using AMPL interface) when you may wish to do something unusual.  Look for USERCBC in main driver and modify sample code."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::VERBOSE,
                            "verbose", "Switches on longer help on single ?",
                            0, 15, ctlBlk->verbose_, false) ;
    param->setPushFunc(pushCbcGenIntParam) ;
    param->setObj(ctlBlk) ;
    param->setLongHelp(
        "Set to 1 to get short help with ? list, 2 to get long help."
    ) ;
    parameters.push_back(param) ;

    param = new CbcGenParam(CbcGenParam::SHOWUNIMP,
                            "unimp!lemented", "Report unimplemented commands.", false) ;
    param->setPushFunc(doUnimplementedParam) ;
    param->setObj(ctlBlk) ;
    parameters.push_back(param) ;

    numberParameters = parameters.size() ;
    assert (((unsigned) numberParameters) <= parameters.capacity()) ;

    return ;
}


void loadGenParamObj (const CoinParamVec paramVec, int first, int last,
                      CbcGenCtlBlk *ctlBlk)

{
    int i ;
    /*
      Load the cbc-generic object into the parameters
    */
    for (i = first ; i <= last ; i++) {
        CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(paramVec[i]) ;
        assert (genParam != 0) ;
        genParam->setObj(ctlBlk) ;
    }

    return ;
}


/* Functions to implement  cbc-generic (CbcGenParam) parameters */

/*
  Maintainer's utility, scan the parameters and report the ones that are
  unimplemented (i.e., have no pushFunc).
*/

int doUnimplementedParam (CoinParam *param)

{
    assert (param != 0) ;

    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;

    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    assert (ctlBlk->paramVec_ != 0) ;
    CoinParamVec &paramVec = *ctlBlk->paramVec_ ;

    int unimpCnt = 0 ;
    int maxAcross = 5 ;
    for (unsigned i = 0 ; i < paramVec.size() ; i++) {
        CoinParam *param = paramVec[i] ;
        if (param->pushFunc() == 0) {
            if (unimpCnt % maxAcross == 0) {
                std::cout << std::endl ;
            } else {
                std::cout << " " ;
            }
            std::cout << param->name() ;
            unimpCnt++ ;
        }
    }
    if (unimpCnt % maxAcross != 1) {
        std::cout << std::endl ;
    }
    std::cout << unimpCnt << " unimplemented parameters." << std::endl ;

    return (0) ;
}


/*
  Noop function. Mainly to eliminate commands from the list returned by
  doUnimplmentedParam.
*/

int doNothingParam (CoinParam *param)
{
    return (0) ;
}

/*
  Function to terminate command parsing by returning -1.
*/

int doExitParam (CoinParam *param)

{
    return (-1) ;
}

/*
  Function to print the current version.
*/

int doVersionParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    std::cout << "cbc-generic version " << ctlBlk->version_ << std::endl ;
    std::cout
        << "cbc-generic is experimental software. If you want a stable MIP "
        << "solver, please" << std::endl
        << "use cbc. If you discover bugs while using cbc-generic "
        << "please specify" << std::endl
        << "cbc-generic in the ticket description or email subject line."
        << std::endl ;

    return (0) ;
}

/*
  Function to handle help (HELP), `?' (GENERALQUERY), and `???'
  (FULLGENERALQUERY).
*/

int doHelpParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;

    int verbose = ctlBlk->verbose_ ;
    bool shortHelp = ((verbose & 0x01) ? true : false) ;
    bool longHelp = ((verbose & 0x02) ? true : false) ;
    bool hidden = ((verbose & 0x08) ? true : false) ;

    CoinParamVec *paramVec = ctlBlk->paramVec_ ;
    assert (paramVec != 0) ;
    /*
      Tune up the initial settings. FULLGENERALQUERY will print normally hidden
      params, and a request for long help overrules a request for short help.
    */
    if (code == CbcGenParam::FULLGENERALQUERY) {
        hidden = true ;
    }
    if (longHelp) {
        shortHelp = false ;
    }

    CoinParamUtils::printGenericHelp() ;

    std::cout << "\nAvailable commands are:" ;
    std::string pfx("  ") ;
    CoinParamUtils::printHelp(*paramVec, 0, paramVec->size() - 1, pfx,
                              shortHelp, longHelp, hidden) ;

    return (0) ;
}

/*
  Function to push a double-valued parameter.
*/

int pushCbcGenDblParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    double val = genParam->dblVal() ;
    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;

    int retval = 0 ;
    /*
      Figure out what we're doing and set the relevant field.
    */
    switch (code) {
    case CbcGenParam::DJFIX: {
        ctlBlk->djFix_.action_ = true ;
        ctlBlk->djFix_.threshold_ = val ;
        break ;
    }
    default: {
        std::cerr << "pushCbcGenDbl: no equivalent CbcGenCtlBlk field for "
                  << "parameter code `" << code << "'." << std::endl ;
        retval = -1 ;
        break ;
    }
    }

    return (retval) ;
}

/*
  Function to push an integer-valued parameter.
*/

int pushCbcGenIntParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    int val = genParam->intVal() ;
    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;

    int retval = 0 ;
    /*
      Figure out what we're doing and set the relevant field.
    */
    switch (code) {
    case CbcGenParam::CUTDEPTH: {
        ctlBlk->setCutDepth(val) ;
        break ;
    }
    case CbcGenParam::LOGLEVEL: {
        ctlBlk->setLogLevel(val) ;
        break ;
    }
    case CbcGenParam::PRINTOPTIONS: {
        ctlBlk->printOpt_ = val ;
        break ;
    }
    case CbcGenParam::VERBOSE: {
        ctlBlk->verbose_ = val ;
        break ;
    }
    default: {
        std::cerr << "pushCbcGenInt: no equivalent CbcGenCtlBlk field for "
                  << "parameter code `" << code << "'." << std::endl ;
        retval = -1 ;
        break ;
    }
    }

    return (retval) ;
}


/*
  Function to push a keyword-valued parameter. This is the catch-all function
  for keyword parameters that don't belong to any other useful grouping.
*/

int pushCbcGenKwdParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    std::string str = genParam->kwdVal() ;
    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;

    int retval = 0 ;
    /*
      Figure out what we're doing and set the relevant field.
    */
    switch (code) {
    case CbcGenParam::PREPROCESS: {
        if (str == "off") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPOff) ;
        } else if (str == "on") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPOn) ;
        } else if (str == "save") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPSave) ;
        } else if (str == "equal") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPEqual) ;
        } else if (str == "sos") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPSOS) ;
        } else if (str == "trysos") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPTrySOS) ;
        } else if (str == "equalall") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPEqualAll) ;
        } else if (str == "strategy") {
            ctlBlk->setIPPAction(CbcGenCtlBlk::IPPStrategy) ;
        } else {
            std::cerr
                << "pushCbcGenKwdParam(PREPROCESS): unrecognised keyword `"
                << str << "'." << std::endl ;
            retval = -1 ;
        }
        break ;
    }
    case CbcGenParam::COSTSTRATEGY: {
        if (str == "off") {
            ctlBlk->priorityAction_ = CbcGenCtlBlk::BPOff ;
        } else if (str == "priorities") {
            ctlBlk->priorityAction_ = CbcGenCtlBlk::BPCost ;
        }
        if (str == "columnOrder") {
            ctlBlk->priorityAction_ = CbcGenCtlBlk::BPOrder ;
        } else {
            std::cerr
                << "pushCbcGenKwdParam(COSTSTRATEGY): unrecognised keyword `"
                << str << "'." << std::endl ;
            retval = -1 ;
        }
        break ;
    }
    case CbcGenParam::INTPRINT: {
        if (str == "normal") {
            ctlBlk->printMode_ = 0 ;
        } else if (str == "integer") {
            ctlBlk->printMode_ = 1 ;
        } else if (str == "special") {
            ctlBlk->printMode_ = 2 ;
        } else if (str == "rows") {
            ctlBlk->printMode_ = 3 ;
        } else if (str == "all") {
            ctlBlk->printMode_ = 4 ;
        } else {
            std::cerr
                << "pushCbcGenKwdParam(INTPRINT): unrecognised keyword `"
                << str << "'." << std::endl ;
            retval = -1 ;
        }
        break ;
    }
    default: {
        std::cerr
            << "pushCbcGenKwdParam: unrecognised parameter code `"
            << code << "'." << std::endl ;
        retval = -1 ;
        break ;
    }
    }

    return (retval) ;
}

/*
  Function to push a string-valued parameter
*/

int pushCbcGenStrParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    std::string str = genParam->strVal() ;
    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;

    int retval = 0 ;
    /*
      Figure out what we're doing and set the relevant field.
    */
    switch (code) {
    case CbcGenParam::DIRECTORY: {
        char dirSep = CoinFindDirSeparator() ;
        if (str[str.length()-1] != dirSep) {
            str += dirSep ;
        }
        ctlBlk->dfltDirectory_ = str ;
        break ;
    }
    default: {
        std::cerr << "pushCbcGenStr: no equivalent CbcGenCtlBlk field for "
                  << "parameter code `" << code << "'." << std::endl ;
        retval = -1 ;
        break ;
    }
    }

    return (retval) ;
}

/*
  The various parameters to control cut generators can be
  grouped, as they all use the same set of keywords.
*/
int pushCbcGenCutParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;

    std::string str = genParam->kwdVal() ;
    CbcGenParam::CbcGenParamCode code = genParam->paramCode() ;
    /*
      Setup to return nonfatal/fatal error (1/-1) by default, so that all we need
      to do is correct to 0 (no error) if we're successful.
    */
    int retval ;
    if (CoinParamUtils::isInteractive()) {
        retval = 1 ;
    } else {
        retval = -1 ;
    }
    /*
      First translate the keyword into the correct CGControl enum value.
    */
    CbcGenCtlBlk::CGControl action ;
    if (str == "off") {
        action = CbcGenCtlBlk::CGOff ;
    } else if (str == "on") {
        action = CbcGenCtlBlk::CGOn ;
    } else if (str == "root") {
        action = CbcGenCtlBlk::CGRoot ;
    } else if (str == "ifmove") {
        action = CbcGenCtlBlk::CGIfMove ;
    } else if (str == "forceOn") {
        action = CbcGenCtlBlk::CGForceOn ;
    } else if (str == "forceOnBut") {
        action = CbcGenCtlBlk::CGForceBut ;
    } else {
        std::cerr
            << "pushCbcGenCutParam: unrecognised keyword `"
            << str << "'." << std::endl ;
        return (retval) ;
    }
    /*
      Validate the parameter code and set a variable to separate cuts from
      heuristics.
    */
    bool isCut = false ;
    bool isHeuristic = false ;
    switch (code) {
    case CbcGenParam::CLIQUECUTS:
    case CbcGenParam::FLOWCUTS:
    case CbcGenParam::GOMORYCUTS:
    case CbcGenParam::KNAPSACKCUTS:
    case CbcGenParam::MIXEDCUTS:
    case CbcGenParam::PROBINGCUTS:
    case CbcGenParam::REDSPLITCUTS:
    case CbcGenParam::TWOMIRCUTS:
    case CbcGenParam::CUTSTRATEGY: {
        isCut = true ;
        break ;
    }
    case CbcGenParam::COMBINE:
    case CbcGenParam::FPUMP:
    case CbcGenParam::ROUNDING:
    case CbcGenParam::LOCALTREE:
    case CbcGenParam::HEURISTICSTRATEGY: {
        isHeuristic = true ;
        break ;
    }
    default: {
        std::cerr
            << "pushCbcGenCutParam: unrecognised parameter code `"
            << code << "'." << std::endl ;
        return (retval) ;
    }
    }
    /*
      See if the action is valid for the specified type. Heuristics are on or
      off; cuts can be any of the other codes. Only probing can use forceOnBut.
    */
    if (isHeuristic) {
        if (!(action == CbcGenCtlBlk::CGOff || action == CbcGenCtlBlk::CGOn)) {
            std::cerr
                << "pushCbcGenCutParam: only on or off is valid for a heuristic."
                << std::endl ;
            return (retval) ;
        }
    } else if (isCut) {
        if (action == CbcGenCtlBlk::CGForceBut &&
                code != CbcGenParam::PROBINGCUTS) {
            std::cerr
                << "pushCbcGenCutParam: forceOnBut is valid only for probing."
                << std::endl ;
            return (retval) ;
        }
    }
    /*
      We've done the basic checks; go ahead and set the relevant field in the
      control block. We shouldn't need the default case, but some compilers will
      complain if it's missing.
    */
    switch (code) {
    case CbcGenParam::CLIQUECUTS: {
        ctlBlk->setCliqueAction(action) ;
        break ;
    }
    case CbcGenParam::FLOWCUTS: {
        ctlBlk->setFlowAction(action) ;
        break ;
    }
    case CbcGenParam::GOMORYCUTS: {
        ctlBlk->setGomoryAction(action) ;
        break ;
    }
    case CbcGenParam::KNAPSACKCUTS: {
        ctlBlk->setKnapsackAction(action) ;
        break ;
    }
    case CbcGenParam::MIXEDCUTS: {
        ctlBlk->setMirAction(action) ;
        break ;
    }
    case CbcGenParam::PROBINGCUTS: {
        ctlBlk->setProbingAction(action) ;
        break ;
    }
    case CbcGenParam::REDSPLITCUTS: {
        ctlBlk->setRedSplitAction(action) ;
        break ;
    }
    case CbcGenParam::TWOMIRCUTS: {
        ctlBlk->setTwomirAction(action) ;
        break ;
    }
    case CbcGenParam::CUTSTRATEGY: {
        ctlBlk->setCliqueAction(action) ;
        ctlBlk->setFlowAction(action) ;
        ctlBlk->setGomoryAction(action) ;
        ctlBlk->setKnapsackAction(action) ;
        ctlBlk->setMirAction(action) ;
        ctlBlk->setProbingAction(action) ;
        ctlBlk->setRedSplitAction(action) ;
        ctlBlk->setTwomirAction(action) ;
        break ;
    }
    case CbcGenParam::COMBINE: {
        ctlBlk->setCombineAction(action) ;
        break ;
    }
    case CbcGenParam::FPUMP: {
        ctlBlk->setFPumpAction(action) ;
        break ;
    }
    case CbcGenParam::GREEDY: {
        ctlBlk->setGreedyCoverAction(action) ;
        ctlBlk->setGreedyEqualityAction(action) ;
        break ;
    }
    case CbcGenParam::LOCALTREE: {
        ctlBlk->setTreeLocalAction(action) ;
        break ;
    }
    case CbcGenParam::ROUNDING: {
        ctlBlk->setRoundingAction(action) ;
        break ;
    }
    case CbcGenParam::HEURISTICSTRATEGY: {
        ctlBlk->setCombineAction(action) ;
        ctlBlk->setFPumpAction(action) ;
        ctlBlk->setGreedyCoverAction(action) ;
        ctlBlk->setRoundingAction(action) ;
        ctlBlk->setTreeLocalAction(action) ;
        break ;
    }
    default: {
        std::cerr
            << "pushCbcGenCutParam: internal confusion!" << std::endl ;
        return (-1) ;
    }
    }

    return (0) ;
}

/*
  This routine imports a new constraint system into the solver.
*/

int doImportParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;
    /*
      Setup to return nonfatal/fatal error (1/-1) by default, so that all we need
      to do is correct to 0 (no error) if we're successful.
    */
    int retval ;
    if (CoinParamUtils::isInteractive()) {
        retval = 1 ;
    } else {
        retval = -1 ;
    }
    /*
      Figure out where we're going to acquire this new model. As special cases,
      `$' says `use the previous input source' and `-' says `use stdin'.
    */
    std::string field = genParam->strVal() ;
    std::string fileName ;
    if (field == "$") {
        fileName = ctlBlk->lastMpsIn_ ;
        field = fileName ;
    } else if (field == "-") {
        fileName = "stdin" ;
        field = fileName ;
    } else {
        fileName = field ;
    }
    /*
      See if we can open a file. fileCoinReadable understands a fair bit about
      platforms and compressed files and will try variations of the file name
      (see the doxygen doc'n for details). The file name returned in field wil
      be the one that actually worked.
    */
    bool canOpen = fileCoinReadable(fileName, ctlBlk->dfltDirectory_) ;
    if (canOpen == false) {
        std::cout
            << "Unable to open file `" << fileName
            << "', original name '" << genParam->strVal() << "'." << std::endl ;
        return (retval) ;
    }
    /*
      We can find the file. Record the name. This requires a little finesse: what
      we want is the base file name (and extension(s), if present) but not the
      prefix, unless it's an absolute path.
    */
    if (!fileAbsPath(fileName)) {
        std::string::size_type pos = fileName.rfind(field) ;
        ctlBlk->lastMpsIn_ = fileName.substr(pos) ;
    } else {
        ctlBlk->lastMpsIn_ = fileName ;
    }
    /*
      Try to read the file. Standard OSI doesn't support the Clp extensions for
      keepImportNames and allowImportErrors. It should at least support
      keepImportNames. Status will be zero for a successful read.
    */
    OsiSolverInterface *lpSolver = ctlBlk->model_->solver() ;
    int status = lpSolver->readMps(fileName.c_str(), "") ;
    if (status) {
        std::cout
            << "There were " << status << " errors on input." << std::endl ;
        return (retval) ;
    }
    /*
      We have a model! Return success.
    */
    ctlBlk->goodModel_ = true ;

    return (0) ;
}


/*
  This routine imports a debug file into the solver, or arranges for its
  creation. Import works in the standard way, using the file name provided
  with the command.

  As special cases, if the file name is `create' or `createAfterPre', the
  action here sets up to cause a debug file containing the solution to be
  dumped after branch-and-cut is completed.  `createAfterPre' will dump the
  solution before undoing the presolve transforms.  `create' will dump the
  solution after integer presolve is backed out.
*/

int doDebugParam (CoinParam *param)

{
    assert (param != 0) ;
    CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ;
    assert (genParam != 0) ;
    CbcGenCtlBlk *ctlBlk = genParam->obj() ;
    assert (ctlBlk != 0) ;
    /*
      Setup to return nonfatal/fatal error (1/-1) by default, so that all we need
      to do is correct to 0 (no error) if we're successful.
    */
    int retval ;
    if (CoinParamUtils::isInteractive()) {
        retval = 1 ;
    } else {
        retval = -1 ;
    }
    /*
       If the file name is `create' or `createAfterPre', we're just setting up to
       make a debug file the next time we do branch-and-cut.
    */
    std::string field = genParam->strVal() ;
    if (field == "create" || field == "createAfterPre") {
        ctlBlk->debugCreate_ = field ;
        return (0) ;
    }
    /*
      Figure out where we're going to acquire the debug file. As special cases,
      `$' says `use the previous input source' and `-' says `use stdin'.
    */
    std::string fileName ;
    if (field == "$") {
        fileName = ctlBlk->debugFile_ ;
        field = fileName ;
    } else if (field == "-") {
        fileName = "stdin" ;
        field = fileName ;
    } else {
        fileName = field ;
    }
    /*
      See if we can open a file. fileCoinReadable understands a fair bit about
      platforms and compressed files and will try variations of the file name
      (see the doxygen doc'n for details). The file name returned in field wil be
      the one that actually worked. No default prefix --- a debug file is assumed
      to always be in the current directory.
    */
    bool canOpen = fileCoinReadable(fileName, ctlBlk->dfltDirectory_) ;
    if (canOpen == false) {
        std::cout
            << "Unable to open file `" << fileName
            << "', original name '" << genParam->strVal() << "'." << std::endl ;
        return (retval) ;
    }
    /*
      We can find the file. Record the name. This requires a little finesse: what
      we want is the base file name (and extension(s), if present) but not the
      prefix, unless it's an absolute path.
    */
    if (!fileAbsPath(fileName)) {
        std::string::size_type pos = fileName.rfind(field) ;
        ctlBlk->lastMpsIn_ = fileName.substr(pos) ;
    } else {
        ctlBlk->lastMpsIn_ = fileName ;
    }
    /*
      Load the primal variable values into the debug solution vector.
    */
    int intUnused, numCols ;
    double dblUnused ;
    double *primals ;

    bool readOK = readSolution(fileName,
                               intUnused, numCols, dblUnused, 0, 0, &primals, 0) ;

    if (readOK) {
        if (ctlBlk->debugSol_.values_) {
            delete[] ctlBlk->debugSol_.values_ ;
        }
        ctlBlk->debugSol_.numCols_ = numCols ;
        ctlBlk->debugSol_.values_ = primals ;
        retval = 0 ;
    } else {
        if (primals) {
            delete[] primals ;
        }
    }

    return (retval) ;
}


/*
  Utility routine to save the current solution to a file. No formatting, and
  not intended to be portable in any way, shape, or form.
*/

void saveSolution (const OsiSolverInterface *osi, std::string fileName)

{
    FILE *fp = fopen(fileName.c_str(), "wb") ;

    if (fp) {
        int numberRows = osi->getNumRows() ;
        int numberColumns = osi->getNumCols() ;
        double objectiveValue = osi->getObjValue() ;

        fwrite(&numberRows, sizeof(int), 1, fp) ;
        fwrite(&numberColumns, sizeof(int), 1, fp) ;
        fwrite(&objectiveValue, sizeof(double), 1, fp) ;

        const double *primalRowSolution = osi->getRowActivity() ;
        const double *dualRowSolution = osi->getRowPrice() ;
        const double *primalColumnSolution = osi->getColSolution() ;
        const double *dualColumnSolution = osi->getReducedCost() ;

        fwrite(primalRowSolution, sizeof(double), numberRows, fp) ;
        fwrite(dualRowSolution, sizeof(double), numberRows, fp) ;
        fwrite(primalColumnSolution, sizeof(double), numberColumns, fp) ;
        fwrite(dualColumnSolution, sizeof(double), numberColumns, fp) ;

        fclose(fp) ;
    } else {
        std::cout
            << "saveSolution: Unable to open file `"
            << fileName << "'." << std::endl ;
    }

    return ;
}

/*
  Utility routine to read in a solution dump created by saveSolution. Generally
  we don't need all the info in this file, so the routine accepts a bunch of
  reference/pointer paramaters and fills in any that are non-null. It's the
  client's responsibility to dispose of space allocated for solution vectors.
  The parameters fileName, numRows, numCols, and objVal are mandatory. The rest
  can be null.
*/
bool readSolution (std::string fileName,
                   int &numRows, int &numCols, double &objVal,
                   double **rowActivity, double **dualVars,
                   double **primalVars, double **reducedCosts)

{
    FILE *fp = fopen(fileName.c_str(), "rb") ;
    bool retval = true ;

    numRows = -1 ;
    numCols = -1 ;
    objVal = 0 ;
    *rowActivity = 0 ;
    *dualVars = 0 ;
    *primalVars = 0 ;
    *reducedCosts = 0 ;

    if (fp) {
        fread(&numRows, sizeof(int), 1, fp) ;
        fread(&numCols, sizeof(int), 1, fp) ;
        fread(&objVal, sizeof(double), 1, fp) ;

        if (rowActivity != NULL) {
            *rowActivity = new double [numRows] ;
            fread(*rowActivity, sizeof(double), numRows, fp) ;
        } else {
            fseek(fp, numRows*sizeof(double), SEEK_CUR) ;
        }

        if (dualVars != NULL) {
            *dualVars = new double [numRows] ;
            fread(*dualVars, sizeof(double), numRows, fp) ;
        } else {
            fseek(fp, numRows*sizeof(double), SEEK_CUR) ;
        }

        if (primalVars != NULL) {
            *primalVars = new double [numCols] ;
            fread(*primalVars, sizeof(double), numCols, fp) ;
        } else {
            fseek(fp, numCols*sizeof(double), SEEK_CUR) ;
        }

        if (reducedCosts != NULL) {
            *reducedCosts = new double [numCols] ;
            fread(*reducedCosts, sizeof(double), numCols, fp) ;
        } else {
            fseek(fp, numCols*sizeof(double), SEEK_CUR) ;
        }

        fclose(fp) ;
    } else {
        std::cout
            << "readSolution: Unable to open file `"
            << fileName << "'." << std::endl ;
        retval = false ;
    }

    return (retval) ;
}


} // end namespace CbcGenParamUtils