CoinUtils  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinPresolveMatrix.hpp
Go to the documentation of this file.
1 /* $Id: CoinPresolveMatrix.hpp 1581 2013-04-06 12:48:50Z stefan $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CoinPresolveMatrix_H
7 #define CoinPresolveMatrix_H
8 
9 #include "CoinPragma.hpp"
10 #include "CoinPackedMatrix.hpp"
11 #include "CoinMessage.hpp"
12 #include "CoinTime.hpp"
13 
14 #include <cmath>
15 #include <cassert>
16 #include <cfloat>
17 #include <cassert>
18 #include <cstdlib>
19 
20 #if PRESOLVE_DEBUG > 0
21 #include "CoinFinite.hpp"
22 #endif
23 
32 #if defined(_MSC_VER)
33 // Avoid MS Compiler problem in recognizing type to delete
34 // by casting to type.
35 // Is this still necessary? -- lh, 111202 --
36 #define deleteAction(array,type) delete [] ((type) array)
37 #else
38 #define deleteAction(array,type) delete [] array
39 #endif
40 
41 /*
42  Define PRESOLVE_DEBUG and PRESOLVE_CONSISTENCY on the configure command
43  line or in a Makefile! See comments in CoinPresolvePsdebug.hpp.
44 */
45 #if PRESOLVE_DEBUG > 0 || PRESOLVE_CONSISTENCY > 0
46 
47 #define PRESOLVE_STMT(s) s
48 
49 #define PRESOLVEASSERT(x) \
50  ((x) ? 1 : ((std::cerr << "FAILED ASSERTION at line " \
51  << __LINE__ << ": " #x "\n"), abort(), 0))
52 
53 inline void DIE(const char *s) { std::cout << s ; abort() ; }
54 
65 #define PRESENT_IN_REDUCED '\377'
66 
67 #else
68 
69 #define PRESOLVEASSERT(x) {}
70 #define PRESOLVE_STMT(s) {}
71 
72 inline void DIE(const char *) {}
73 
74 #endif
75 
76 /*
77  Unclear why these are separate from standard debug.
78 */
79 #ifndef PRESOLVE_DETAIL
80 #define PRESOLVE_DETAIL_PRINT(s) {}
81 #else
82 #define PRESOLVE_DETAIL_PRINT(s) s
83 #endif
84 
89 const double ZTOLDP = 1e-12 ;
94 const double ZTOLDP2 = 1e-10 ;
95 
97 #define PRESOLVE_INF COIN_DBL_MAX
98 #define PRESOLVE_SMALL_INF 1.0e20
100 #define PRESOLVEFINITE(n) (-PRESOLVE_INF < (n) && (n) < PRESOLVE_INF)
102 
103 
104 class CoinPostsolveMatrix ;
105 
156 {
157  public:
164  static void throwCoinError(const char *error, const char *ps_routine)
165  { throw CoinError(error, ps_routine, "CoinPresolve"); }
166 
172 
180  inline void setNext(const CoinPresolveAction *nextAction)
181  { next = nextAction;}
182 
187  virtual const char *name() const = 0;
188 
192  virtual void postsolve(CoinPostsolveMatrix *prob) const = 0;
193 
195  virtual ~CoinPresolveAction() {}
196 };
197 
198 /*
199  These are needed for OSI-aware constructors associated with
200  CoinPrePostsolveMatrix, CoinPresolveMatrix, and CoinPostsolveMatrix.
201 */
202 class ClpSimplex;
203 class OsiSolverInterface;
204 
205 /*
206  CoinWarmStartBasis is required for methods in CoinPrePostsolveMatrix
207  that accept/return a CoinWarmStartBasis object.
208 */
209 class CoinWarmStartBasis ;
210 
266 {
267  public:
268 
278  CoinPrePostsolveMatrix(int ncols_alloc, int nrows_alloc,
279  CoinBigIndex nelems_alloc) ;
280 
285  CoinPrePostsolveMatrix(const OsiSolverInterface * si,
286  int ncols_,
287  int nrows_,
289 
294  CoinPrePostsolveMatrix(const ClpSimplex * si,
295  int ncols_,
296  int nrows_,
297  CoinBigIndex nelems_,
298  double bulkRatio);
299 
303 
313  enum Status {
314  isFree = 0x00,
315  basic = 0x01,
316  atUpperBound = 0x02,
317  atLowerBound = 0x03,
318  superBasic = 0x04
319  };
320 
333 
335  inline void setRowStatus(int sequence, Status status)
336  {
337  unsigned char & st_byte = rowstat_[sequence];
338  st_byte = static_cast<unsigned char>(st_byte & (~7)) ;
339  st_byte = static_cast<unsigned char>(st_byte | status) ;
340  }
342  inline Status getRowStatus(int sequence) const
343  {return static_cast<Status> (rowstat_[sequence]&7);}
345  inline bool rowIsBasic(int sequence) const
346  {return (static_cast<Status> (rowstat_[sequence]&7)==basic);}
348  inline void setColumnStatus(int sequence, Status status)
349  {
350  unsigned char & st_byte = colstat_[sequence];
351  st_byte = static_cast<unsigned char>(st_byte & (~7)) ;
352  st_byte = static_cast<unsigned char>(st_byte | status) ;
353 
354 # ifdef PRESOLVE_DEBUG
355  switch (status)
356  { case isFree:
357  { if (clo_[sequence] > -PRESOLVE_INF || cup_[sequence] < PRESOLVE_INF)
358  { std::cout << "Bad status: Var " << sequence
359  << " isFree, lb = " << clo_[sequence]
360  << ", ub = " << cup_[sequence] << std::endl ; }
361  break ; }
362  case basic:
363  { break ; }
364  case atUpperBound:
365  { if (cup_[sequence] >= PRESOLVE_INF)
366  { std::cout << "Bad status: Var " << sequence
367  << " atUpperBound, lb = " << clo_[sequence]
368  << ", ub = " << cup_[sequence] << std::endl ; }
369  break ; }
370  case atLowerBound:
371  { if (clo_[sequence] <= -PRESOLVE_INF)
372  { std::cout << "Bad status: Var " << sequence
373  << " atLowerBound, lb = " << clo_[sequence]
374  << ", ub = " << cup_[sequence] << std::endl ; }
375  break ; }
376  case superBasic:
377  { if (clo_[sequence] <= -PRESOLVE_INF && cup_[sequence] >= PRESOLVE_INF)
378  { std::cout << "Bad status: Var " << sequence
379  << " superBasic, lb = " << clo_[sequence]
380  << ", ub = " << cup_[sequence] << std::endl ; }
381  break ; }
382  default:
383  { assert(false) ;
384  break ; } }
385 # endif
386  }
388  inline Status getColumnStatus(int sequence) const
389  {return static_cast<Status> (colstat_[sequence]&7);}
391  inline bool columnIsBasic(int sequence) const
392  {return (static_cast<Status> (colstat_[sequence]&7)==basic);}
396  void setRowStatusUsingValue(int iRow);
400  void setColumnStatusUsingValue(int iColumn);
402  void setStructuralStatus(const char *strucStatus, int lenParam) ;
404  void setArtificialStatus(const char *artifStatus, int lenParam) ;
406  void setStatus(const CoinWarmStartBasis *basis) ;
412  const char *columnStatusString(int j) const ;
416  const char *rowStatusString(int i) const ;
418 
426  void setObjOffset(double offset) ;
434  void setObjSense(double objSense) ;
436  void setPrimalTolerance(double primTol) ;
438  void setDualTolerance(double dualTol) ;
440  void setColLower(const double *colLower, int lenParam) ;
442  void setColUpper(const double *colUpper, int lenParam) ;
444  void setColSolution(const double *colSol, int lenParam) ;
446  void setCost(const double *cost, int lenParam) ;
448  void setReducedCost(const double *redCost, int lenParam) ;
450  void setRowLower(const double *rowLower, int lenParam) ;
452  void setRowUpper(const double *rowUpper, int lenParam) ;
454  void setRowPrice(const double *rowSol, int lenParam) ;
456  void setRowActivity(const double *rowAct, int lenParam) ;
458 
461  inline int getNumCols() const
463  { return (ncols_) ; }
465  inline int getNumRows() const
466  { return (nrows_) ; }
468  inline int getNumElems() const
469  { return (nelems_) ; }
471  inline const CoinBigIndex *getColStarts() const
472  { return (mcstrt_) ; }
474  inline const int *getColLengths() const
475  { return (hincol_) ; }
477  inline const int *getRowIndicesByCol() const
478  { return (hrow_) ; }
480  inline const double *getElementsByCol() const
481  { return (colels_) ; }
483  inline const double *getColLower() const
484  { return (clo_) ; }
486  inline const double *getColUpper() const
487  { return (cup_) ; }
489  inline const double *getCost() const
490  { return (cost_) ; }
492  inline const double *getRowLower() const
493  { return (rlo_) ; }
495  inline const double *getRowUpper() const
496  { return (rup_) ; }
498  inline const double *getColSolution() const
499  { return (sol_) ; }
501  inline const double *getRowActivity() const
502  { return (acts_) ; }
504  inline const double *getRowPrice() const
505  { return (rowduals_) ; }
507  inline const double *getReducedCost() const
508  { return (rcosts_) ; }
510  inline int countEmptyCols()
511  { int empty = 0 ;
512  for (int i = 0 ; i < ncols_ ; i++) if (hincol_[i] == 0) empty++ ;
513  return (empty) ; }
515 
516 
519  inline CoinMessageHandler *messageHandler() const
521  { return handler_; }
527  inline void setMessageHandler(CoinMessageHandler *handler)
528  { if (defaultHandler_ == true)
529  { delete handler_ ;
530  defaultHandler_ = false ; }
531  handler_ = handler ; }
533  inline CoinMessages messages() const
534  { return messages_; }
536 
546 
548  int ncols_;
550  int nrows_;
553 
555  int ncols0_;
557  int nrows0_ ;
570  double bulkRatio_;
572 
584  int *hincol_;
586  int *hrow_;
588  double *colels_;
589 
591  double *cost_;
594 
596  double *clo_;
598  double *cup_;
599 
601  double *rlo_;
603  double *rup_;
604 
619 
621  double ztolzb_;
623  double ztoldj_;
624 
630  double maxmin_;
632 
653  double *sol_;
659  double *rowduals_;
665  double *acts_;
671  double *rcosts_;
672 
679  unsigned char *colstat_;
680 
687  unsigned char *rowstat_;
689 
705 
706 };
707 
711 const char *statusName (CoinPrePostsolveMatrix::Status status) ;
712 
713 
739 { public:
740  int pre, suc;
741 } ;
742 
743 #define NO_LINK -66666666
744 
750 inline void PRESOLVE_REMOVE_LINK(presolvehlink *link, int i)
751 {
752  int ipre = link[i].pre;
753  int isuc = link[i].suc;
754  if (ipre >= 0) {
755  link[ipre].suc = isuc;
756  }
757  if (isuc >= 0) {
758  link[isuc].pre = ipre;
759  }
760  link[i].pre = NO_LINK, link[i].suc = NO_LINK;
761 }
762 
768 inline void PRESOLVE_INSERT_LINK(presolvehlink *link, int i, int j)
769 {
770  int isuc = link[j].suc;
771  link[j].suc = i;
772  link[i].pre = j;
773  if (isuc >= 0) {
774  link[isuc].pre = i;
775  }
776  link[i].suc = isuc;
777 }
778 
790 inline void PRESOLVE_MOVE_LINK(presolvehlink *link, int i, int j)
791 {
792  int ipre = link[i].pre;
793  int isuc = link[i].suc;
794  if (ipre >= 0) {
795  link[ipre].suc = j;
796  }
797  if (isuc >= 0) {
798  link[isuc].pre = j;
799  }
800  link[i].pre = NO_LINK, link[i].suc = NO_LINK;
801 }
802 
803 
836 {
837  public:
838 
845  CoinPresolveMatrix(int ncols_alloc, int nrows_alloc,
846  CoinBigIndex nelems_alloc) ;
847 
852  CoinPresolveMatrix(int ncols0,
853  double maxmin,
854  // end prepost members
855 
856  ClpSimplex * si,
857 
858  // rowrep
859  int nrows,
860  CoinBigIndex nelems,
861  bool doStatus,
862  double nonLinearVariable,
863  double bulkRatio);
864 
866  void update_model(ClpSimplex * si,
867  int nrows0,
868  int ncols0,
869  CoinBigIndex nelems0);
874  CoinPresolveMatrix(int ncols0,
875  double maxmin,
876  // end prepost members
877  OsiSolverInterface * si,
878  // rowrep
879  int nrows,
880  CoinBigIndex nelems,
881  bool doStatus,
882  double nonLinearVariable,
883  const char * prohibited,
884  const char * rowProhibited=NULL);
885 
887  void update_model(OsiSolverInterface * si,
888  int nrows0,
889  int ncols0,
890  CoinBigIndex nelems0);
891 
894 
900  friend void assignPresolveToPostsolve (CoinPresolveMatrix *&preObj) ;
901 
910  void setMatrix(const CoinPackedMatrix *mtx) ;
911 
913  inline int countEmptyRows()
914  { int empty = 0 ;
915  for (int i = 0 ; i < nrows_ ; i++) if (hinrow_[i] == 0) empty++ ;
916  return (empty) ; }
917 
923  inline void setVariableType(int i, int variableType)
924  { if (integerType_ == 0) integerType_ = new unsigned char [ncols0_] ;
925  integerType_[i] = static_cast<unsigned char>(variableType) ; }
926 
932  void setVariableType(const unsigned char *variableType, int lenParam) ;
933 
939  void setVariableType (bool allIntegers, int lenParam) ;
940 
942  inline void setAnyInteger (bool anyInteger = true)
943  { anyInteger_ = anyInteger ; }
945 
949 
951  inline const CoinBigIndex *getRowStarts() const
952  { return (mrstrt_) ; }
954  inline const int *getColIndicesByRow() const
955  { return (hcol_) ; }
957  inline const double *getElementsByRow() const
958  { return (rowels_) ; }
959 
965  inline bool isInteger (int i) const
966  { if (integerType_ == 0)
967  { return (anyInteger_) ; }
968  else
969  if (integerType_[i] == 1)
970  { return (true) ; }
971  else
972  { return (false) ; } }
973 
978  inline bool anyInteger () const
979  { return (anyInteger_) ; }
981  inline int presolveOptions() const
982  { return presolveOptions_;}
984  inline void setPresolveOptions(int value)
985  { presolveOptions_=value;}
987 
1000 
1002  double dobias_ ;
1003 
1005  inline void change_bias(double change_amount)
1006  {
1007  dobias_ += change_amount ;
1008  # if PRESOLVE_DEBUG > 2
1009  assert(fabs(change_amount)<1.0e50) ;
1010  if (change_amount)
1011  PRESOLVE_STMT(printf("changing bias by %g to %g\n",
1012  change_amount, dobias_)) ;
1013  # endif
1014  }
1015 
1027  int *hinrow_;
1029  double *rowels_;
1031  int *hcol_;
1033 
1035  unsigned char *integerType_;
1043  bool tuning_;
1045  void statistics();
1047  double startTime_;
1048 
1052  inline double feasibilityTolerance()
1053  { return (feasibilityTolerance_) ; }
1055  inline void setFeasibilityTolerance (double val)
1056  { feasibilityTolerance_ = val ; }
1057 
1063  int status_;
1065  inline int status()
1066  { return (status_) ; }
1068  inline void setStatus(int status)
1069  { status_ = (status&0x3) ; }
1070 
1078  int pass_;
1080  inline void setPass (int pass = 0)
1081  { pass_ = pass ; }
1082 
1089  inline void setMaximumSubstitutionLevel (int level)
1090  { maxSubstLevel_ = level ; }
1091 
1092 
1116  unsigned char * colChanged_;
1118  int * colsToDo_;
1125 
1135  unsigned char * rowChanged_;
1137  int * rowsToDo_;
1169 
1180  int *usefulRowInt_ ;
1189  double *randomNumber_ ;
1190 
1194  double *sumUp_ ;
1198  double *sumDown_ ;
1200 
1212  int recomputeSums(int whichRow) ;
1213 
1215  void initializeStuff() ;
1217  void deleteStuff() ;
1218 
1221 
1227  void initColsToDo () ;
1228 
1234  int stepColsToDo () ;
1235 
1237  inline int numberColsToDo()
1238  { return (numberColsToDo_) ; }
1239 
1241  inline bool colChanged(int i) const {
1242  return (colChanged_[i]&1)!=0;
1243  }
1245  inline void unsetColChanged(int i) {
1246  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] & (~1)) ;
1247  }
1249  inline void setColChanged(int i) {
1250  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] | (1)) ;
1251  }
1253  inline void addCol(int i) {
1254  if ((colChanged_[i]&1)==0) {
1255  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] | (1)) ;
1257  }
1258  }
1260  inline bool colProhibited(int i) const {
1261  return (colChanged_[i]&2)!=0;
1262  }
1269  inline bool colProhibited2(int i) const {
1270  if (!anyProhibited_)
1271  return false;
1272  else
1273  return (colChanged_[i]&2)!=0;
1274  }
1276  inline void setColProhibited(int i) {
1277  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] | (2)) ;
1278  }
1284  inline bool colUsed(int i) const {
1285  return (colChanged_[i]&4)!=0;
1286  }
1288  inline void setColUsed(int i) {
1289  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] | (4)) ;
1290  }
1292  inline void unsetColUsed(int i) {
1293  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] & (~4)) ;
1294  }
1296  inline bool colInfinite(int i) const {
1297  return (colChanged_[i]&8)!=0;
1298  }
1300  inline void unsetColInfinite(int i) {
1301  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] & (~8)) ;
1302  }
1304  inline void setColInfinite(int i) {
1305  colChanged_[i] = static_cast<unsigned char>(colChanged_[i] | (8)) ;
1306  }
1307 
1313  void initRowsToDo () ;
1314 
1320  int stepRowsToDo () ;
1321 
1323  inline int numberRowsToDo()
1324  { return (numberRowsToDo_) ; }
1325 
1327  inline bool rowChanged(int i) const {
1328  return (rowChanged_[i]&1)!=0;
1329  }
1331  inline void unsetRowChanged(int i) {
1332  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] & (~1)) ;
1333  }
1335  inline void setRowChanged(int i) {
1336  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] | (1)) ;
1337  }
1339  inline void addRow(int i) {
1340  if ((rowChanged_[i]&1)==0) {
1341  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] | (1)) ;
1343  }
1344  }
1346  inline bool rowProhibited(int i) const {
1347  return (rowChanged_[i]&2)!=0;
1348  }
1355  inline bool rowProhibited2(int i) const {
1356  if (!anyProhibited_)
1357  return false;
1358  else
1359  return (rowChanged_[i]&2)!=0;
1360  }
1362  inline void setRowProhibited(int i) {
1363  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] | (2)) ;
1364  }
1370  inline bool rowUsed(int i) const {
1371  return (rowChanged_[i]&4)!=0;
1372  }
1374  inline void setRowUsed(int i) {
1375  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] | (4)) ;
1376  }
1378  inline void unsetRowUsed(int i) {
1379  rowChanged_[i] = static_cast<unsigned char>(rowChanged_[i] & (~4)) ;
1380  }
1381 
1382 
1384  inline bool anyProhibited() const
1385  { return anyProhibited_;}
1387  inline void setAnyProhibited(bool val = true)
1388  { anyProhibited_ = val ; }
1390 
1391 };
1392 
1422 {
1423  public:
1424 
1431  CoinPostsolveMatrix(int ncols_alloc, int nrows_alloc,
1432  CoinBigIndex nelems_alloc) ;
1433 
1434 
1439  CoinPostsolveMatrix(ClpSimplex * si,
1440 
1441  int ncols0,
1442  int nrows0,
1443  CoinBigIndex nelems0,
1444 
1445  double maxmin_,
1446  // end prepost members
1447 
1448  double *sol,
1449  double *acts,
1450 
1451  unsigned char *colstat,
1452  unsigned char *rowstat);
1453 
1458  CoinPostsolveMatrix(OsiSolverInterface * si,
1459 
1460  int ncols0,
1461  int nrows0,
1462  CoinBigIndex nelems0,
1463 
1464  double maxmin_,
1465  // end prepost members
1466 
1467  double *sol,
1468  double *acts,
1469 
1470  unsigned char *colstat,
1471  unsigned char *rowstat);
1472 
1484 
1487 
1499 
1509 
1511 
1519  char *cdone_;
1520  char *rdone_;
1522 
1524  void check_nbasic();
1525 
1526 };
1527 
1528 
1535 
1540 void presolve_make_memlists(/*CoinBigIndex *starts,*/ int *lengths,
1541  presolvehlink *link, int n);
1542 
1550 bool presolve_expand_major(CoinBigIndex *majstrts, double *majels,
1551  int *minndxs, int *majlens,
1552  presolvehlink *majlinks, int nmaj, int k) ;
1553 
1559 inline bool presolve_expand_col(CoinBigIndex *mcstrt, double *colels,
1560  int *hrow, int *hincol,
1561  presolvehlink *clink, int ncols, int colx)
1562 { return presolve_expand_major(mcstrt,colels,
1563  hrow,hincol,clink,ncols,colx) ; }
1564 
1570 inline bool presolve_expand_row(CoinBigIndex *mrstrt, double *rowels,
1571  int *hcol, int *hinrow,
1572  presolvehlink *rlink, int nrows, int rowx)
1573 { return presolve_expand_major(mrstrt,rowels,
1574  hcol,hinrow,rlink,nrows,rowx) ; }
1575 
1576 
1586  CoinBigIndex ks, CoinBigIndex ke,
1587  const int *minndxs)
1588 { CoinBigIndex k ;
1589  for (k = ks ; k < ke ; k++)
1590 #ifndef NDEBUG
1591  { if (minndxs[k] == tgt)
1592  return (k) ; }
1593  DIE("FIND_MINOR") ;
1594 
1595  abort () ; return -1;
1596 #else
1597  { if (minndxs[k] == tgt)
1598  break ; }
1599  return (k) ;
1600 #endif
1601 }
1602 
1610  CoinBigIndex kce, const int *hrow)
1611 { return presolve_find_minor(row,kcs,kce,hrow) ; }
1612 
1620  CoinBigIndex kre, const int *hcol)
1621 { return presolve_find_minor(col,krs,kre,hcol) ; }
1622 
1623 
1633  const int *minndxs);
1634 
1642  CoinBigIndex kce, const int *hrow)
1643 { return presolve_find_minor1(row,kcs,kce,hrow) ; }
1644 
1652  CoinBigIndex kre, const int *hcol)
1653 { return presolve_find_minor1(col,krs,kre,hcol) ; }
1654 
1663 CoinBigIndex presolve_find_minor2(int tgt, CoinBigIndex ks, int majlen,
1664  const int *minndxs,
1665  const CoinBigIndex *majlinks) ;
1666 
1674 inline CoinBigIndex presolve_find_row2(int row, CoinBigIndex kcs, int collen,
1675  const int *hrow,
1676  const CoinBigIndex *clinks)
1677 { return presolve_find_minor2(row,kcs,collen,hrow,clinks) ; }
1678 
1687 CoinBigIndex presolve_find_minor3(int tgt, CoinBigIndex ks, int majlen,
1688  const int *minndxs,
1689  const CoinBigIndex *majlinks) ;
1690 
1698 inline CoinBigIndex presolve_find_row3(int row, CoinBigIndex kcs, int collen,
1699  const int *hrow,
1700  const CoinBigIndex *clinks)
1701 { return presolve_find_minor3(row,kcs,collen,hrow,clinks) ; }
1702 
1712 inline void presolve_delete_from_major(int majndx, int minndx,
1713  const CoinBigIndex *majstrts,
1714  int *majlens, int *minndxs, double *els)
1715 {
1716  const CoinBigIndex ks = majstrts[majndx] ;
1717  const CoinBigIndex ke = ks+majlens[majndx] ;
1718 
1719  const CoinBigIndex kmi = presolve_find_minor(minndx,ks,ke,minndxs) ;
1720 
1721  minndxs[kmi] = minndxs[ke-1] ;
1722  els[kmi] = els[ke-1] ;
1723  majlens[majndx]-- ;
1724 
1725  return ;
1726 }
1727 
1734 inline void presolve_delete_many_from_major(int majndx, char *marked,
1735  const CoinBigIndex *majstrts,
1736  int *majlens, int *minndxs, double *els)
1737 {
1738  const CoinBigIndex ks = majstrts[majndx] ;
1739  const CoinBigIndex ke = ks+majlens[majndx] ;
1740  CoinBigIndex put = ks ;
1741  for (CoinBigIndex k = ks ; k < ke ; k++) {
1742  int iMinor = minndxs[k] ;
1743  if (!marked[iMinor]) {
1744  minndxs[put] = iMinor ;
1745  els[put++] = els[k] ;
1746  } else {
1747  marked[iMinor] = 0 ;
1748  }
1749  }
1750  majlens[majndx] = put-ks ;
1751  return ;
1752 }
1753 
1764 inline void presolve_delete_from_col(int row, int col,
1765  const CoinBigIndex *mcstrt,
1766  int *hincol, int *hrow, double *colels)
1767 { presolve_delete_from_major(col,row,mcstrt,hincol,hrow,colels) ; }
1768 
1779 inline void presolve_delete_from_row(int row, int col,
1780  const CoinBigIndex *mrstrt,
1781  int *hinrow, int *hcol, double *rowels)
1782 { presolve_delete_from_major(row,col,mrstrt,hinrow,hcol,rowels) ; }
1783 
1794 void presolve_delete_from_major2 (int majndx, int minndx,
1795  CoinBigIndex *majstrts, int *majlens,
1796  int *minndxs, int *majlinks,
1797  CoinBigIndex *free_listp) ;
1798 
1809 inline void presolve_delete_from_col2(int row, int col, CoinBigIndex *mcstrt,
1810  int *hincol, int *hrow,
1811  int *clinks, CoinBigIndex *free_listp)
1812 { presolve_delete_from_major2(col,row,mcstrt,hincol,hrow,clinks,free_listp) ; }
1813 
1815 
1821 
1833 double *presolve_dupmajor(const double *elems, const int *indices,
1834  int length, CoinBigIndex offset, int tgt = -1);
1835 
1837 void coin_init_random_vec(double *work, int n);
1838 
1840 
1841 
1842 #endif