#ifndef _GREEDY_H
#define	_GREEDY_H

#include "scpview.h"
#include "siman_solver.h"
#include "ilist.h"

#ifdef	__cplusplus
extern "C" {
#endif

#define GREEDY_OK 0
#define GREEDY_ERROR -1

/**\defgroup GREEDY Simple Chvatal's and Balas-Ho greedy algorithms for SCP
   @{
 */    

typedef struct _GreedySolver GreedySolver;


/**\brief Greedy algorithm*/
struct _GreedySolver {
    
    /** \brief View to the underlying problem*/
    SCPView* problemView;
    
    /**\brief Column mask that indices what columns are selected to
     * form the cover*/
    unsigned char* columnMask;
    
    /** \brief Mask of rows that indicates what rows are covered by selected columns*/
    unsigned char* rowMask;
    
};

/** \brief Create new Greedy algorithm
 *  \param p View to the undelrying problem that will be solved
 *  \return New Greedy algorithm
 */
GreedySolver* greedy_solver_new(SCPView* p);

/** \brief Initialize the Greedy algorithm
 *  \param columnMask Column mask representing partial solution or NULL
 */
 void greedy_solver_initialize(GreedySolver* s,unsigned char* columnMask);

/** \brief Solve the problem using Chvatal's algorithm
    \param saSolver Pointer to Simulated annealing. Used when Simulated annealing
 *   performs morphing. Can be set to NULL
 */

void greedy_solver_solve_chvatal(GreedySolver* s,SimanSolver* saSolver);

/** \brief Solve the problem using Balas-Ho algorithm
 *  \param saSolver Pointer to Simulated annealing. Used when Simulated annealing
 *   performs morphing
 */
void greedy_solver_solve_balasho(GreedySolver* s,SimanSolver* saSolver);


/** \brief Reinitialize Greedy algorithm. Used after morphing*/
void greedy_solver_reinitialize(GreedySolver* s);

/** \brief Remove rows from list of rows that are covered by specified column
 *  \param rowList List of rows
 *  \param column Index of column
 */
void greedy_solver_remove_covered_rows(GreedySolver* gs,IList* rowList,int column);

/** \brief Delete the Greedy algorithm*/
void greedy_solver_delete(GreedySolver* s);

/** \brief Print state of the Greedy algorithm*/
void greedy_solver_print(GreedySolver* s);




#ifdef	__cplusplus
}
#endif

#endif	/* _GREEDY_H */

/**@}*/

