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

Last change on this file since 2385 was 2385, checked in by unxusr, 4 months ago

formatting

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