Skip to content
Snippets Groups Projects
CNDFS.h 2.02 KiB
Newer Older
//
// Created by ghofrane on 5/4/22.
//
#ifndef PMC_SOG_CNDFS_H
#define PMC_SOG_CNDFS_H
chihebabid's avatar
chihebabid committed
#include "../ModelCheckBaseMT.h"
#include <spot/tl/apcollect.hh>
chihebabid's avatar
chihebabid committed
#include <cstdint>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <spot/twa/twagraph.hh>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <atomic>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <thread>
#include <mutex>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <condition_variable>
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include "misc/SafeDequeue.h"
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
#include <spot/tl/contain.hh>
chihebabid's avatar
chihebabid committed
using namespace std;
typedef pair<struct myState_t *, int> coupleSuccessor;
static constexpr uint8_t MAX_THREADS = 64;

enum class SuccState {notyet,beingbuilt,built};
chihebabid's avatar
chihebabid committed
struct myState_t {
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    LDDState *left;
chihebabid's avatar
chihebabid committed
    const spot::twa_graph_state *right;
    vector<pair<struct myState_t *, int>> new_successors;
chihebabid's avatar
chihebabid committed
    bool isAcceptance {false};
    bool isConstructed {false};
chihebabid's avatar
chihebabid committed
    array<bool, MAX_THREADS> cyan {false};
    atomic<bool> blue{false};
    atomic<bool> red{false};
    SuccState succState {SuccState::notyet};
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
};
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed

class CNDFS {
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
private:
chihebabid's avatar
chihebabid committed
    ModelCheckBaseMT *mMcl;
chihebabid's avatar
chihebabid committed
    spot::twa_graph_ptr mAa;
chihebabid's avatar
chihebabid committed
    uint16_t mNbTh;
chihebabid's avatar
chihebabid committed
    atomic<uint8_t> mIdThread;
chihebabid's avatar
chihebabid committed
    std::thread *mlThread[MAX_THREADS];
    mutex mMutex,mMutexStatus;
    std::condition_variable mDataCondWait;
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    condition_variable cv;
chihebabid's avatar
chihebabid committed
    myState_t *mInitStatePtr;
    vector<myState_t *> mlBuiltStates;
    SafeDequeue<struct myState_t *> mSharedPoolTemp;
    static spot::bdd_dict_ptr *m_dict_ptr;
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    spot::language_containment_checker c;
chihebabid's avatar
chihebabid committed
    void getInitialState();
chihebabid's avatar
chihebabid committed

    void spawnThreads();

chihebabid's avatar
chihebabid committed
    static void threadHandler(void *context);
    void threadRun();
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    void computeSuccessors(myState_t *state, vector<spot::formula> ap_sog);
chihebabid's avatar
chihebabid committed

    myState_t *buildState(LDDState *left, spot::state *right, bool acc, bool constructed, bool cyan);
    myState_t* isStateBuilt(LDDState *sogState,spot::twa_graph_state *spotState);
chihebabid's avatar
chihebabid committed
    CNDFS(ModelCheckBaseMT *mcl, const spot::twa_graph_ptr &af, const uint16_t &nbTh);

    virtual ~CNDFS();
Ghofrane Amaimi's avatar
Ghofrane Amaimi committed
    void dfsBlue(myState_t *state, vector<myState_t *> &Rp, uint8_t idThread,vector<spot::formula> ap_sog);
chihebabid's avatar
chihebabid committed

    void dfsRed(myState_t *state, vector<myState_t *> &Rp, uint8_t idThread);

};

#endif //PMC_SOG_CNDFS_H