source: trunk/Clp/src/AbcWarmStart.cpp @ 2030

Last change on this file since 2030 was 1910, checked in by stefan, 7 years ago
  • add configure option --enable-aboca={1,2,3,4,yes,no}
  • compile Aboca source only if --enable-aboca set (instead of compiling empty source files)
  • fix svn properties
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1/* $Id: AbcWarmStart.cpp 1910 2013-01-27 02:00:13Z forrest $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others, Copyright (C) 2012, FasterCoin.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#include "CoinPragma.hpp"
7#include "CoinUtilsConfig.h"
8#include <cassert>
9
10#include "AbcWarmStart.hpp"
11#include "CoinHelperFunctions.hpp"
12#include <cmath>
13#include <iostream>
14
15//#############################################################################
16
17void 
18AbcWarmStart::setSize(int ns, int na) 
19{
20  CoinWarmStartBasis::setSize(ns,na);
21  delete [] extraInformation_;
22  extraInformation_=NULL;
23  typeExtraInformation_=0;
24}
25
26void 
27AbcWarmStart::assignBasisStatus(int ns, int na, char*& sStat, 
28                                char*& aStat) 
29{
30  CoinWarmStartBasis::assignBasisStatus(ns,na,sStat,aStat);
31  delete [] extraInformation_;
32  extraInformation_=NULL;
33  typeExtraInformation_=0;
34}
35AbcWarmStart::AbcWarmStart(AbcSimplex * model,int type) :
36  CoinWarmStartBasis(model->numberColumns(),model->numberRows(),
37#ifdef CLP_WARMSTART
38                     reinterpret_cast<const char *>(model->statusArray()),
39                     reinterpret_cast<const char *>(model->statusArray()+model->numberColumns())
40#else
41                     reinterpret_cast<const char *>(model->statusArray()+model->maximumAbcNumberRows()),
42                     reinterpret_cast<const char *>(model->statusArray())
43#endif
44                     ),
45  typeExtraInformation_(type),
46  lengthExtraInformation_(0),
47  extraInformation_(NULL),
48  model_(model),
49  organizer_(NULL),
50  previousBasis_(NULL),
51  nextBasis_(NULL),
52  stamp_(-1),
53  numberValidRows_(0)
54{
55  assert (!typeExtraInformation_);
56}
57
58AbcWarmStart::AbcWarmStart(const AbcWarmStart& rhs) :
59  CoinWarmStartBasis(rhs),
60  typeExtraInformation_(rhs.typeExtraInformation_),
61  lengthExtraInformation_(rhs.lengthExtraInformation_),
62  extraInformation_(NULL),
63  model_(rhs.model_),
64  organizer_(rhs.organizer_),
65  previousBasis_(NULL),
66  nextBasis_(NULL),
67  stamp_(-1),
68  numberValidRows_(0)
69{
70  if (typeExtraInformation_)
71    extraInformation_=CoinCopyOfArray(rhs.extraInformation_,lengthExtraInformation_);
72}
73
74AbcWarmStart& 
75AbcWarmStart::operator=(const AbcWarmStart& rhs)
76{
77  if (this != &rhs) {
78    CoinWarmStartBasis::operator=(rhs);
79    delete [] extraInformation_;
80    extraInformation_=NULL;
81    typeExtraInformation_ = rhs.typeExtraInformation_;
82    lengthExtraInformation_ = rhs.lengthExtraInformation_;
83    model_ = rhs.model_;
84    organizer_ = rhs.organizer_;
85    previousBasis_ = NULL;
86    nextBasis_ = NULL;
87    stamp_ = -1;
88    numberValidRows_ = 0;
89    if (typeExtraInformation_)
90      extraInformation_=CoinCopyOfArray(rhs.extraInformation_,lengthExtraInformation_);
91  }
92  return *this;
93}
94
95// Resizes
96void 
97AbcWarmStart::resize (int newNumberRows, int newNumberColumns)
98{
99  if (newNumberRows==numArtificial_&&newNumberColumns==numStructural_)
100    return;
101  CoinWarmStartBasis::resize(newNumberRows,newNumberColumns);
102  delete [] extraInformation_;
103  extraInformation_=NULL;
104  typeExtraInformation_=0;
105}
106
107/*
108  compressRows takes an ascending list of target indices without duplicates
109  and removes them, compressing the artificialStatus_ array in place. It will
110  fail spectacularly if the indices are not sorted. Use deleteRows if you
111  need to preprocess the target indices to satisfy the conditions.
112*/
113void AbcWarmStart::compressRows (int tgtCnt, const int *tgts)
114{
115  if (!tgtCnt)
116    return;
117  CoinWarmStartBasis::compressRows(tgtCnt,tgts);
118  delete [] extraInformation_;
119  extraInformation_=NULL;
120  typeExtraInformation_=0;
121} 
122
123/*
124  deleteRows takes an unordered list of target indices with duplicates and
125  removes them from the basis. The strategy is to preprocesses the list into
126  an ascending list without duplicates, suitable for compressRows.
127*/
128void 
129AbcWarmStart::deleteRows (int rawTgtCnt, const int *rawTgts)
130{
131  if (rawTgtCnt <= 0) return ;
132  CoinWarmStartBasis::deleteRows(rawTgtCnt,rawTgts);
133  delete [] extraInformation_;
134  extraInformation_=NULL;
135  typeExtraInformation_=0;
136}
137// Deletes columns
138void 
139AbcWarmStart::deleteColumns(int number, const int * which)
140{
141  CoinWarmStartBasis::deleteColumns(number,which);
142  delete [] extraInformation_;
143  extraInformation_=NULL;
144  typeExtraInformation_=0;
145}
146AbcWarmStart::AbcWarmStart() :
147  CoinWarmStartBasis(),
148  typeExtraInformation_(0),
149  lengthExtraInformation_(0),
150  extraInformation_(NULL),
151  model_(NULL),
152  organizer_(NULL),
153  previousBasis_(NULL),
154  nextBasis_(NULL),
155  stamp_(-1),
156  numberValidRows_(0)
157{
158}
159AbcWarmStart::~AbcWarmStart()
160{
161  delete[] extraInformation_;
162}
Note: See TracBrowser for help on using the repository browser.