source: branches/devel-1/ClpDualRowDantzig.cpp @ 2351

Last change on this file since 2351 was 19, checked in by ladanyi, 17 years ago

reordering Clp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7
8
9#include "ClpSimplex.hpp"
10#include "ClpDualRowDantzig.hpp"
11#include "CoinIndexedVector.hpp"
12
13//#############################################################################
14// Constructors / Destructor / Assignment
15//#############################################################################
16
17//-------------------------------------------------------------------
18// Default Constructor
19//-------------------------------------------------------------------
20ClpDualRowDantzig::ClpDualRowDantzig () 
21: ClpDualRowPivot()
22{
23  type_=1;
24}
25
26//-------------------------------------------------------------------
27// Copy constructor
28//-------------------------------------------------------------------
29ClpDualRowDantzig::ClpDualRowDantzig (const ClpDualRowDantzig & source) 
30: ClpDualRowPivot(source)
31{ 
32
33}
34
35//-------------------------------------------------------------------
36// Destructor
37//-------------------------------------------------------------------
38ClpDualRowDantzig::~ClpDualRowDantzig ()
39{
40
41}
42
43//----------------------------------------------------------------
44// Assignment operator
45//-------------------------------------------------------------------
46ClpDualRowDantzig &
47ClpDualRowDantzig::operator=(const ClpDualRowDantzig& rhs)
48{
49  if (this != &rhs) {
50    ClpDualRowPivot::operator=(rhs);
51  }
52  return *this;
53}
54
55// Returns pivot row, -1 if none
56int 
57ClpDualRowDantzig::pivotRow()
58{
59  assert(model_);
60  int iRow;
61  const int * pivotVariable = model_->pivotVariable();
62  double largest=model_->currentPrimalTolerance();
63  // we can't really trust infeasibilities if there is primal error
64  if (model_->largestPrimalError()>1.0e-8)
65    largest *= model_->largestPrimalError()/1.0e-8;
66  int chosenRow=-1;
67  for (iRow=0;iRow<model_->numberRows();iRow++) {
68    int iPivot=pivotVariable[iRow];
69    double value = model_->solution(iPivot);
70    double lower = model_->lower(iPivot);
71    double upper = model_->upper(iPivot);
72    if (max(value-upper,lower-value)>largest) {
73      int iSequence = pivotVariable[iRow];
74      if (!model_->flagged(iSequence)) {
75        chosenRow=iRow;
76        largest=max(value-upper,lower-value);
77      }
78    }
79  }
80  return chosenRow;
81}
82 
83/* Updates primal solution (and maybe list of candidates)
84   Uses input vector which it deletes
85   Computes change in objective function
86*/
87void 
88ClpDualRowDantzig::updatePrimalSolution(CoinIndexedVector * primalUpdate,
89                                        double primalRatio,
90                                        double & objectiveChange)
91{
92  double * work = primalUpdate->denseVector();
93  int number = primalUpdate->getNumElements();
94  int * which = primalUpdate->getIndices();
95  int i;
96  double changeObj=0.0;
97  const int * pivotVariable = model_->pivotVariable();
98  for (i=0;i<number;i++) {
99    int iRow=which[i];
100    int iPivot=pivotVariable[iRow];
101    double & value = model_->solutionAddress(iPivot);
102    double cost = model_->cost(iPivot);
103    double change = primalRatio*work[iRow];
104    value -= change;
105    changeObj -= change*cost;
106    work[iRow]=0.0;
107  }
108  primalUpdate->setNumElements(0);
109  objectiveChange += changeObj;
110}
111//-------------------------------------------------------------------
112// Clone
113//-------------------------------------------------------------------
114ClpDualRowPivot * ClpDualRowDantzig::clone(bool CopyData) const
115{
116  if (CopyData) {
117    return new ClpDualRowDantzig(*this);
118  } else {
119    return new ClpDualRowDantzig();
120  }
121}
122
Note: See TracBrowser for help on using the repository browser.