<commit_before>#ifndef OPENGM_PERMUTABLE_LABEL_FUSION_MOVER_HXX
#define OPENGM_PERMUTABLE_LABEL_FUSION_MOVER_HXX


#include <opengm/inference/inference.hxx>
#include <opengm/inference/multicut.hxx>
#include <opengm/inference/dmc.hxx>
// FIXME
using namespace std;
#define Isinf Isinf2
#include <opengm/inference/cgc.hxx>

#include <opengm/graphicalmodel/graphicalmodel.hxx>
#include <opengm/graphicalmodel/space/simplediscretespace.hxx>
#include <opengm/functions/potts.hxx>


#ifndef NOVIGRA
#define WITH_BOOST_GRAPH
#include <vigra/adjacency_list_graph.hxx>
#include <vigra/merge_graph_adaptor.hxx>
#include <vigra/hierarchical_clustering.hxx>
#include <vigra/priority_queue.hxx>
#include <vigra/random.hxx>
#include <vigra/graph_algorithms.hxx>

#endif

namespace opengm{







    #ifndef NOVIGRA
    template<class GM, class ACC >
    class McClusterOp{
    public:
        typedef ACC AccumulationType;
        typedef GM GraphicalModelType;
        OPENGM_GM_TYPE_TYPEDEFS;

        typedef vigra::AdjacencyListGraph Graph;
        typedef vigra::MergeGraphAdaptor< Graph > MergeGraph;


        typedef typename MergeGraph::Edge Edge;
        typedef ValueType WeightType;
        typedef IndexType index_type;
        struct Parameter
        {



            Parameter(
                const float stopWeight = 0.0
            )
            :
                stopWeight_(stopWeight){
            }
            float stopWeight_;
        };


        McClusterOp(const Graph & graph , 
                    MergeGraph & mergegraph, 
                    const Parameter & param,
                    std::vector<ValueType> & weights
                   )
        :
            graph_(graph),
            mergeGraph_(mergegraph),
            pq_(graph.edgeNum()),
            param_(param),
            weights_(weights){

            for(size_t i=0; i<graph_.edgeNum(); ++i){
                size_t u = graph_.id(graph_.u(graph_.edgeFromId(i)));
                size_t v = graph_.id(graph_.v(graph_.edgeFromId(i)));
                pq_.push(i, weights_[i]);
            }
        }




        void reset(){
            pq_.reset();
        }



        Edge contractionEdge(){
            index_type minLabel = pq_.top();
            while(mergeGraph_.hasEdgeId(minLabel)==false){
                pq_.deleteItem(minLabel);
                minLabel = pq_.top();
            }
            return Edge(minLabel);
        }

        /// \brief get the edge weight of the edge which should be contracted next
        WeightType contractionWeight(){
            index_type minLabel = pq_.top();
            while(mergeGraph_.hasEdgeId(minLabel)==false){
                pq_.deleteItem(minLabel);
                minLabel = pq_.top();
            }
            return pq_.topPriority();

        }

        /// \brief get a reference to the merge
        MergeGraph & mergeGraph(){
            return mergeGraph_;
        }

        bool done()const{
            return pq_.topPriority()<=ValueType(param_.stopWeight_);
        }

        void mergeEdges(const Edge & a,const Edge & b){
            weights_[a.id()]+=weights_[b.id()];
            pq_.push(a.id(), weights_[a.id()]);
            pq_.deleteItem(b.id());
        }

        void eraseEdge(const Edge & edge){
            pq_.deleteItem(edge.id());
        }

        const Graph & graph_;
        MergeGraph & mergeGraph_;
        vigra::ChangeablePriorityQueue< ValueType ,std::greater<ValueType> > pq_;
        Parameter param_;
        std::vector<ValueType> & weights_;
    };


    #endif





template<class GM, class ACC>
class PermutableLabelFusionMove{

public:

    typedef GM GraphicalModelType;
    typedef ACC AccumulationType;
    OPENGM_GM_TYPE_TYPEDEFS;
    typedef std::map<UInt64Type, ValueType> MapType;
    typedef typename MapType::iterator MapIter;
    typedef typename MapType::const_iterator MapCIter;


    typedef PermutableLabelFusionMove<GM, ACC> SelfType;

    enum FusionSolver{
        DefaultSolver,
        MulticutSolver,
        MulticutNativeSolver,
        CgcSolver,
        HierachicalClusteringSolver,
        BaseSolver
    };

    struct Parameter{
        Parameter(
            const FusionSolver fusionSolver = SelfType::DefaultSolver,
            const bool planar = false,
            const std::string  workflow = std::string(),
            const int nThreads = -1,
            const bool decompose = false,
            const std::vector<bool> & allowCutsWithin  = std::vector<bool>()
        )
        : 
            fusionSolver_(fusionSolver),
            planar_(planar),
            workflow_(workflow),
            nThreads_(nThreads),
            decompose_(decompose),
            allowCutsWithin_(allowCutsWithin)
        {

        }
        FusionSolver fusionSolver_;
        bool planar_;
        std::string workflow_;
        int nThreads_;
        bool decompose_;
        std::vector<bool> allowCutsWithin_;
<commit_msg>one thread as default<commit_after>#ifndef OPENGM_PERMUTABLE_LABEL_FUSION_MOVER_HXX
#define OPENGM_PERMUTABLE_LABEL_FUSION_MOVER_HXX


#include <opengm/inference/inference.hxx>
#include <opengm/inference/multicut.hxx>
#include <opengm/inference/dmc.hxx>
// FIXME
using namespace std;
#define Isinf Isinf2
#include <opengm/inference/cgc.hxx>

#include <opengm/graphicalmodel/graphicalmodel.hxx>
#include <opengm/graphicalmodel/space/simplediscretespace.hxx>
#include <opengm/functions/potts.hxx>


#ifndef NOVIGRA
#define WITH_BOOST_GRAPH
#include <vigra/adjacency_list_graph.hxx>
#include <vigra/merge_graph_adaptor.hxx>
#include <vigra/hierarchical_clustering.hxx>
#include <vigra/priority_queue.hxx>
#include <vigra/random.hxx>
#include <vigra/graph_algorithms.hxx>

#endif

namespace opengm{







    #ifndef NOVIGRA
    template<class GM, class ACC >
    class McClusterOp{
    public:
        typedef ACC AccumulationType;
        typedef GM GraphicalModelType;
        OPENGM_GM_TYPE_TYPEDEFS;

        typedef vigra::AdjacencyListGraph Graph;
        typedef vigra::MergeGraphAdaptor< Graph > MergeGraph;


        typedef typename MergeGraph::Edge Edge;
        typedef ValueType WeightType;
        typedef IndexType index_type;
        struct Parameter
        {



            Parameter(
                const float stopWeight = 0.0
            )
            :
                stopWeight_(stopWeight){
            }
            float stopWeight_;
        };


        McClusterOp(const Graph & graph , 
                    MergeGraph & mergegraph, 
                    const Parameter & param,
                    std::vector<ValueType> & weights
                   )
        :
            graph_(graph),
            mergeGraph_(mergegraph),
            pq_(graph.edgeNum()),
            param_(param),
            weights_(weights){

            for(size_t i=0; i<graph_.edgeNum(); ++i){
                size_t u = graph_.id(graph_.u(graph_.edgeFromId(i)));
                size_t v = graph_.id(graph_.v(graph_.edgeFromId(i)));
                pq_.push(i, weights_[i]);
            }
        }




        void reset(){
            pq_.reset();
        }



        Edge contractionEdge(){
            index_type minLabel = pq_.top();
            while(mergeGraph_.hasEdgeId(minLabel)==false){
                pq_.deleteItem(minLabel);
                minLabel = pq_.top();
            }
            return Edge(minLabel);
        }

        /// \brief get the edge weight of the edge which should be contracted next
        WeightType contractionWeight(){
            index_type minLabel = pq_.top();
            while(mergeGraph_.hasEdgeId(minLabel)==false){
                pq_.deleteItem(minLabel);
                minLabel = pq_.top();
            }
            return pq_.topPriority();

        }

        /// \brief get a reference to the merge
        MergeGraph & mergeGraph(){
            return mergeGraph_;
        }

        bool done()const{
            return pq_.topPriority()<=ValueType(param_.stopWeight_);
        }

        void mergeEdges(const Edge & a,const Edge & b){
            weights_[a.id()]+=weights_[b.id()];
            pq_.push(a.id(), weights_[a.id()]);
            pq_.deleteItem(b.id());
        }

        void eraseEdge(const Edge & edge){
            pq_.deleteItem(edge.id());
        }

        const Graph & graph_;
        MergeGraph & mergeGraph_;
        vigra::ChangeablePriorityQueue< ValueType ,std::greater<ValueType> > pq_;
        Parameter param_;
        std::vector<ValueType> & weights_;
    };


    #endif





template<class GM, class ACC>
class PermutableLabelFusionMove{

public:

    typedef GM GraphicalModelType;
    typedef ACC AccumulationType;
    OPENGM_GM_TYPE_TYPEDEFS;
    typedef std::map<UInt64Type, ValueType> MapType;
    typedef typename MapType::iterator MapIter;
    typedef typename MapType::const_iterator MapCIter;


    typedef PermutableLabelFusionMove<GM, ACC> SelfType;

    enum FusionSolver{
        DefaultSolver,
        MulticutSolver,
        MulticutNativeSolver,
        CgcSolver,
        HierachicalClusteringSolver,
        BaseSolver
    };

    struct Parameter{
        Parameter(
            const FusionSolver fusionSolver = SelfType::DefaultSolver,
            const bool planar = false,
            const std::string  workflow = std::string(),
            const int nThreads = 1,
            const bool decompose = false,
            const std::vector<bool> & allowCutsWithin  = std::vector<bool>()
        )
        : 
            fusionSolver_(fusionSolver),
            planar_(planar),
            workflow_(workflow),
            nThreads_(nThreads),
            decompose_(decompose),
            allowCutsWithin_(allowCutsWithin)
        {

        }
        FusionSolver fusionSolver_;
        bool planar_;
        std::string workflow_;
        int nThreads_;
        bool decompose_;
        std::vector<bool> allowCutsWithin_;

{'fraction_non_alphanumeric': 0.0939929328621908, 'fraction_numerical': 0.0014134275618374558, 'mean_word_length': 2.021043000914913, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6275546', 'n_tokens_mistral': 3050, 'n_tokens_neox': 2844, 'n_words': 561}