#ifndef _EI_SIMPLEX_H
#define	_EI_SIMPLEX_H

#include <glpk.h>
#include "scpview.h"

#ifdef	__cplusplus
extern "C" {
#endif

#define EI_SIMPLEX_OPTIMUM 0
#define EI_SIMPLEX_INFEAS 1
#define EI_SIMPLEX_OVERRUN 2
#define EI_SIMPLEX_FAILURE 3

/** \defgroup EISIMPLEX Externally implemented Simplex method
 *  @{
 */

typedef struct _EISimplex EISimplex;

struct _EISimplex {

    glp_prob* lp_problem;
    SCPView* problemView;
    
};

/** \brief Create new externally implemented simplex method*/
EISimplex* ei_simplex_new();
/** \brief Delete externally implemented simplex method*/
void ei_simplex_delete(EISimplex* sx);
/** \brief Formulate set covering problem for externally implemented simplex method
 *  \param view View to the underlying SCP
 *  \param withObjective Whether to set objective funtion or not
 */
void ei_simplex_formulate_scp(EISimplex* sx,SCPView* view,int withObjective);
/** \brief Solve SCP using simplex method
 *  \param itrLimit Limit of iterations of simplex method
 */
int ei_simplex_solve_scp(EISimplex* sx,SCPView* view,int itrLimit);
/** \brief Calculate lexicographically minimal solution to the SCP
 *  \param view View to the underliyng SCP
 *  \param maxCost Maximum cost of the solution
 *  \param auxCols Number of auxiliary columns in auxiliary simplex table
 *   row used by group testing heuristic
 */
int ei_simplex_solve_lexmin(EISimplex* sx,SCPView* view,int maxCost,int auxCols);

/** \brief Get RHS for specified column
 *  \param column Index of column
 *  \param val There will be the RHS placed
 */
void ei_simplex_get_rhs(EISimplex* sx,int column,double* val);

/** \brief Get cost of recently found solution
 *  \return cost
 */
double ei_simplex_get_cost(EISimplex* sx);


#ifdef	__cplusplus
}
#endif

#endif	/* _EI_SIMPLEX_H */

/**@}*/

