Ignore:
Timestamp:
Sep 21, 2006 11:29:23 AM (13 years ago)
Author:
pbonami
Message:

Can add linear cut to nonlinear formulation in Ipopt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/src/IpoptInterface/TMINLP.hpp

    r26 r44  
    5555  {
    5656  public:
    57     /**@name Constructors/Destructors */
    58     //@{
    59     TMINLP()
    60     {}
    61     ;
    62 
    63     /** Default destructor */
    64     virtual ~TMINLP()
    65     {}
    66     ;
    67     //@}
     57    friend class TMINLP2TNLP;
    6858
    6959    /** Class to store sos constraints for model */
     
    8979      /** @} */
    9080      /** default constructor. */
    91       SosInfo():num(0), types(NULL), priorities(NULL), numNz(0), starts(NULL),
    92              indices(NULL), weights(NULL)
    93       {}
     81      SosInfo();
    9482      /** Copy constructor.*/
    95       SosInfo(const SosInfo & source):num(source.num), types(NULL), priorities(NULL),
    96           numNz(source.numNz), starts(NULL),indices(NULL),
    97            weights(NULL)
    98       {
    99 
    100         if(num > 0) {
    101           assert(source.types!=NULL);
    102           assert(source.priorities!=NULL);
    103           assert(source.starts!=NULL);
    104           assert(source.indices!=NULL);
    105           assert(source.weights!=NULL);
    106           types = new char[num];
    107           priorities = new int[num];
    108           starts = new int[num + 1];
    109           indices = new int[numNz];
    110           weights = new double[numNz];
    111           for(int i = 0 ; i < num ; i++) {
    112             source.types[i] = types[i];
    113             source.priorities[i] = priorities[i];
    114             source.starts[i] = starts[i];
    115           }
    116           for(int i = 0 ; i < numNz ; i++) {
    117             source.indices[i] = indices[i];
    118             source.weights[i] = weights[i];
    119           }
    120         }
    121         else {
    122           assert(source.types==NULL);
    123           assert(source.priorities==NULL);
    124           assert(source.starts==NULL);
    125           assert(source.indices==NULL);
    126           assert(source.weights==NULL);
    127         }
    128 
    129       }
     83      SosInfo(const SosInfo & source);
     84     
    13085
    13186      /** destructor*/
     
    13792
    13893      /** Reset information */
    139       void gutsOfDestructor()
    140       {
    141         num = 0;
    142         numNz = 0;
    143         if(types) delete [] types;
    144         types = NULL;
    145         if(starts) delete [] starts;
    146         starts = NULL;
    147         if(indices) delete [] indices;
    148         indices = NULL;
    149         if(priorities) delete [] priorities;
    150         priorities = NULL;
    151         if(weights) delete [] weights;
    152         weights = NULL;
    153       }
     94      void gutsOfDestructor();
     95
    15496    };
    15597
     
    210152    };
    211153
     154    /**@name Constructors/Destructors */
     155    //@{
     156    TMINLP();
     157
     158    /** Default destructor */
     159    virtual ~TMINLP()
     160    {}
     161    //@}
     162;
     163
    212164    /**@name methods to gather information about the MINLP */
    213165    //@{
     
    294246    virtual const BranchingInfo * branchingInfo() const = 0;
    295247
    296     virtual const SosInfo * sosConstraints() const = 0;
     248    /** Add some linear cuts to the problem formulation */
     249   void addCuts(int numberCuts, const OsiRowCut ** cuts);
     250 
     251   /** Remove some cuts to the formulation */
     252   void removeCuts(int number ,const int * toRemove);
     253
     254   /** remove the last number cuts.*/
     255   void removeLastCuts(int number);
     256
     257   virtual const SosInfo * sosConstraints() const = 0;
    297258  private:
    298259    /**@name Default Compiler Generated Methods
     
    314275    //@}
    315276
    316 
     277      private:
     278  /** resize arrays for linear cuts */
     279  void resizeLinearCuts(int newNumberCuts, int newNnz);
     280  /** columnindices of linear cuts. */
     281   int * jCol_;
     282  /** rows indices of linear cuts. */
     283   int * iRow_;
     284  /** elements of linear cuts.*/
     285  double * elems_;
     286  /** lower bounds for linear cuts. */
     287  double * lower_;
     288  /** upper bounds for linear cuts. */
     289  double * upper_;
     290  /** number of linear cuts.*/
     291  int nLinearCuts_;
     292  /** number of non-zeroes in linear cuts*/
     293  int linearCutsNnz_;
     294  /** storage size for linear cuts number of cuts.*/
     295  int linearCutsCapacity_;
     296  /** storage size for linear cuts number of nnz.*/
     297  int linearCutsNnzCapacity_;
    317298  };
    318299
Note: See TracChangeset for help on using the changeset viewer.