/* (C) Copyright 2003 Jens Lysgaard. All rights reserved. */
/* OSI Certified Open Source Software */
/* This software is licensed under the Common Public License Version 1.0 */

#ifndef _H_CNSTRMGR
#define _H_CNSTRMGR

/* Definition of constants for identification of constraint types. */

#define CMGR_CT_MIN_ROUTES        101
#define CMGR_CT_NODE_DEGREE       102  /* Degree = 2 for each customer. */
#define CMGR_CT_CAP               103  /* Capacity constraint. */
#define CMGR_CT_GENCAP            104  /* Generalized capacity constraint. */
#define CMGR_CT_FCI               104  /* For public version. */
#define CMGR_CT_TWOMATCHING       105
#define CMGR_CT_COMB              106
#define CMGR_CT_STR_COMB          107  /* Strengthened comb. */
#define CMGR_CT_HYPOTOUR          108
#define CMGR_CT_EXT_HYPOTOUR      109
#define CMGR_CT_MSTAR             110  /* Homogeneous multistar. */
#define CMGR_CT_WMSTAR            111  /* Weak multistar. */
#define CMGR_CT_DJCUT             112  /* Disjunctive cut. */
#define CMGR_CT_GOMORY            113  /* By variable numbers */
#define CMGR_CT_TWOEDGES_HYPOTOUR 114  /* 2EH inequality */
#define CMGR_BT_CLIQUE_DOWN       201  /* x(S:S) <= RHS */
#define CMGR_BT_CLIQUE_UP         202  /* x(S:S) >= RHS */
#define CMGR_BT_STAR_DOWN         301  /* x(i:F) <=RHS */
#define CMGR_BT_STAR_UP           302  /* x(i:F) >=RHS */

#define CMGR_CT_SLB               401  /* x(F) >= RHS. Simple lower bound */

typedef struct
{
  int CType; /* Constraint Type. */
  int Key;
  int IntListSize;
  int *IntList;
  int ExtListSize;
  int *ExtList;
  int CListSize;
  int *CList;
  double *CoeffList;
  int A,B,L; /* For MSTARs: Lambda=L/B, Sigma=A/B. */
  double RHS;
  int BranchLevel;
  int GlobalNr;
} CnstrRecord;
typedef CnstrRecord *CnstrPointer;

typedef CnstrPointer *CnstrPointerList;

typedef struct
{
  CnstrPointerList CPL;
  int Dim; /* Vector is zero-based (0..Dim-1). */
  int Size;
} CnstrMgrRecord;
typedef CnstrMgrRecord *CnstrMgrPointer;


void CMGR_CreateCMgr(CnstrMgrPointer *CMP, int Dim);
void CMGR_FreeMemCMgr(CnstrMgrPointer *CMP);
void CMGR_AddCnstr(CnstrMgrPointer CMP,
                   int CType, int Key, int IntListSize, int *IntList,
                   double RHS);
void CMGR_AddBranchCnstr(CnstrMgrPointer CMP,
                         int CType, int Key, int IntListSize, int *IntList,
                         double RHS,
                         int BranchLevel);
void CMGR_AddExtCnstr(CnstrMgrPointer CMP,
                      int CType, int Key, int IntListSize, int *IntList,
                      int ExtListSize, int *ExtList,
                      double RHS);
void CMGR_AddExplicitCnstr(CnstrMgrPointer CMP,
                           int CType, int Key,
                           int ListSize,
                           int *IntList,
                           int *ExtList,
                           double *CoeffList,
                           double RHS);
void CMGR_AddGomoryCnstr(CnstrMgrPointer CMP,
                         int CType, int Key,
                         int ListSize,
                         int *IntList, /* Variable numbers */
                         double *CoeffList,
                         double RHS); /* >= RHS */
void CMGR_AppendCMP(CnstrMgrPointer Sink,
                    CnstrMgrPointer Source);
void CMGR_SearchCap(CnstrMgrPointer CMP,
                    int IntListSize, int *IntList,
                    char *CapExists);
void CMGR_AddMStar(CnstrMgrPointer CMP,
                   int CType, int Key, int IntListSize, int *IntList,
                   int ExtListSize, int *ExtList,
                   int A, int B, int L);
void CMGR_AddPartialMStar(CnstrMgrPointer CMP,
                          int CType, int Key,
                          int IntListSize, int *IntList,
                          int ExtListSize, int *ExtList,
                          int CListSize, int *CList,
                          int A, int B, int L);
void CMGR_MoveCnstr(CnstrMgrPointer SourcePtr,
                    CnstrMgrPointer SinkPtr,
                    int SourceIndex,
                    int SinkIndex);
void CMGR_ClearCnstr(CnstrMgrPointer SourcePtr,
                     int Index);
void CMGR_CompressCMP(CnstrMgrPointer CMP);
void CMGR_ChgRHS(CnstrMgrPointer CMP, int CnstrNr, double NewRHS);
void CMGR_SaveCMP(FILE *f, CnstrMgrPointer CMP,
                  char MatchType,
                  int CnstrType,
                  char WriteLabel,
                  int Label);
void CMGR_WriteCMP(CnstrMgrPointer CMP, int MinCNr);

#endif

