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

Last change on this file since 1878 was 1878, checked in by forrest, 7 years ago

minor changes to implement Aboca

File size: 4.6 KB
Line 
1/* $Id: AbcWarmStart.cpp 1515 2011-12-10 23:38:04Z lou $ */
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#if CLP_HAS_ABC
7#if defined(_MSC_VER)
8// Turn off compiler warning about long names
9#  pragma warning(disable:4786)
10#endif
11
12#include "CoinUtilsConfig.h"
13#include <cassert>
14
15#include "AbcWarmStart.hpp"
16#include "CoinHelperFunctions.hpp"
17#include <cmath>
18#include <iostream>
19
20//#############################################################################
21
22void 
23AbcWarmStart::setSize(int ns, int na) 
24{
25  CoinWarmStartBasis::setSize(ns,na);
26  delete [] extraInformation_;
27  extraInformation_=NULL;
28  typeExtraInformation_=0;
29}
30
31void 
32AbcWarmStart::assignBasisStatus(int ns, int na, char*& sStat, 
33                                char*& aStat) 
34{
35  CoinWarmStartBasis::assignBasisStatus(ns,na,sStat,aStat);
36  delete [] extraInformation_;
37  extraInformation_=NULL;
38  typeExtraInformation_=0;
39}
40AbcWarmStart::AbcWarmStart(AbcSimplex * model,int type) :
41  CoinWarmStartBasis(model->numberColumns(),model->numberRows(),
42#ifdef CLP_WARMSTART
43                     reinterpret_cast<const char *>(model->statusArray()),
44                     reinterpret_cast<const char *>(model->statusArray()+model->numberColumns())
45#else
46                     reinterpret_cast<const char *>(model->statusArray()+model->maximumAbcNumberRows()),
47                     reinterpret_cast<const char *>(model->statusArray())
48#endif
49                     ),
50  typeExtraInformation_(type),
51  lengthExtraInformation_(0),
52  extraInformation_(NULL),
53  model_(model),
54  organizer_(NULL),
55  previousBasis_(NULL),
56  nextBasis_(NULL),
57  stamp_(-1),
58  numberValidRows_(0)
59{
60  assert (!typeExtraInformation_);
61}
62
63AbcWarmStart::AbcWarmStart(const AbcWarmStart& rhs) :
64  CoinWarmStartBasis(rhs),
65  typeExtraInformation_(rhs.typeExtraInformation_),
66  lengthExtraInformation_(rhs.lengthExtraInformation_),
67  extraInformation_(NULL),
68  model_(rhs.model_),
69  organizer_(rhs.organizer_),
70  previousBasis_(NULL),
71  nextBasis_(NULL),
72  stamp_(-1),
73  numberValidRows_(0)
74{
75  if (typeExtraInformation_)
76    extraInformation_=CoinCopyOfArray(rhs.extraInformation_,lengthExtraInformation_);
77}
78
79AbcWarmStart& 
80AbcWarmStart::operator=(const AbcWarmStart& rhs)
81{
82  if (this != &rhs) {
83    CoinWarmStartBasis::operator=(rhs);
84    delete [] extraInformation_;
85    extraInformation_=NULL;
86    typeExtraInformation_ = rhs.typeExtraInformation_;
87    lengthExtraInformation_ = rhs.lengthExtraInformation_;
88    model_ = rhs.model_;
89    organizer_ = rhs.organizer_;
90    previousBasis_ = NULL;
91    nextBasis_ = NULL;
92    stamp_ = -1;
93    numberValidRows_ = 0;
94    if (typeExtraInformation_)
95      extraInformation_=CoinCopyOfArray(rhs.extraInformation_,lengthExtraInformation_);
96  }
97  return *this;
98}
99
100// Resizes
101void 
102AbcWarmStart::resize (int newNumberRows, int newNumberColumns)
103{
104  if (newNumberRows==numArtificial_&&newNumberColumns==numStructural_)
105    return;
106  CoinWarmStartBasis::resize(newNumberRows,newNumberColumns);
107  delete [] extraInformation_;
108  extraInformation_=NULL;
109  typeExtraInformation_=0;
110}
111
112/*
113  compressRows takes an ascending list of target indices without duplicates
114  and removes them, compressing the artificialStatus_ array in place. It will
115  fail spectacularly if the indices are not sorted. Use deleteRows if you
116  need to preprocess the target indices to satisfy the conditions.
117*/
118void AbcWarmStart::compressRows (int tgtCnt, const int *tgts)
119{
120  if (!tgtCnt)
121    return;
122  CoinWarmStartBasis::compressRows(tgtCnt,tgts);
123  delete [] extraInformation_;
124  extraInformation_=NULL;
125  typeExtraInformation_=0;
126} 
127
128/*
129  deleteRows takes an unordered list of target indices with duplicates and
130  removes them from the basis. The strategy is to preprocesses the list into
131  an ascending list without duplicates, suitable for compressRows.
132*/
133void 
134AbcWarmStart::deleteRows (int rawTgtCnt, const int *rawTgts)
135{
136  if (rawTgtCnt <= 0) return ;
137  CoinWarmStartBasis::deleteRows(rawTgtCnt,rawTgts);
138  delete [] extraInformation_;
139  extraInformation_=NULL;
140  typeExtraInformation_=0;
141}
142// Deletes columns
143void 
144AbcWarmStart::deleteColumns(int number, const int * which)
145{
146  CoinWarmStartBasis::deleteColumns(number,which);
147  delete [] extraInformation_;
148  extraInformation_=NULL;
149  typeExtraInformation_=0;
150}
151AbcWarmStart::AbcWarmStart() :
152  CoinWarmStartBasis(),
153  typeExtraInformation_(0),
154  lengthExtraInformation_(0),
155  extraInformation_(NULL),
156  model_(NULL),
157  organizer_(NULL),
158  previousBasis_(NULL),
159  nextBasis_(NULL),
160  stamp_(-1),
161  numberValidRows_(0)
162{
163}
164AbcWarmStart::~AbcWarmStart()
165{
166  delete[] extraInformation_;
167}
168#endif
Note: See TracBrowser for help on using the repository browser.