1 #ifndef snap_cascdynetinf_h
2 #define snap_cascdynetinf_h
74 THitInfo(
const int& NodeId=-1,
const double& HitTime=0) : NId(NodeId), Tm(HitTime) { }
91 TCascade(
const int &model) : NIdHitH() { Model = model; }
92 TCascade(
const int &cid,
const int& model) : NIdHitH() { CId = cid; Model = model; }
97 int Len()
const {
return NIdHitH.
Len(); }
98 int LenBeforeT(
const double& T) {
int len = 0;
while (len < NIdHitH.
Len() && NIdHitH[len].Tm <= T) { len++; }
return len; }
99 int LenAfterT(
const double& T) {
int len = 0;
while (len < NIdHitH.
Len() && NIdHitH[NIdHitH.
Len()-1-len].Tm >= T) { len++; }
return len; }
112 return Len() < Cascade.
Len(); }
122 TNodeInfo(
const TStr& NodeNm,
const int& Volume) : Name(NodeNm), Vol(Volume) { }
126 return Vol < NodeInfo.
Vol; }
174 TNIBs(
TSIn& SIn) : CascH(SIn), NodeNmH(SIn), CascPerEdge(SIn), InferredNetwork(SIn) { Model =
EXP; }
187 void SetWindow(
const double& window) { Window = window; }
190 void SetDelta(
const double& delta) { Delta = delta; }
191 void SetK(
const double& k) { K = k; }
194 void SetGamma(
const double& gamma) { Gamma = gamma; }
195 void SetAging(
const double& aging) { Aging = aging; }
197 void SetMu(
const double& mu) { Mu = mu; }
237 void SG(
const int& NId,
const int& Iters,
const TFltV& Steps,
const TSampling& Sampling,
const TStr& ParamSampling=
TStr(
""),
const bool& PlotPerformance=
false);
238 void BSG(
const int& NId,
const int& Iters,
const TFltV& Steps,
const int& BatchLen,
const TSampling& Sampling,
const TStr& ParamSampling=
TStr(
""),
const bool& PlotPerformance=
false);
239 void FG(
const int& NId,
const int& Iters,
const TFltV& Steps);
245 void find_C(
int t,
TFltV &x,
TFltVV &C,
const int& k,
const double& s,
const double& gamma,
const double& T );
247 void LabelBurstAutomaton(
const int& SrcId,
const int& DstId,
TIntV &state_labels,
TFltV &state_times,
const bool& inferred=
false,
const int& k = 5,
const double& s = 2.0,
const double& gamma = 1.0,
const TSecTm& MinTime=
TSecTm(),
const TSecTm& MaxTime=
TSecTm() );
TSizeTy AddUnique(const TVal &Val)
Adds element Val to a vector only if the element Val is not already in the vector.
void BSG(const int &NId, const int &Iters, const TFltV &Steps, const int &BatchLen, const TSampling &Sampling, const TStr &ParamSampling=TStr(""), const bool &PlotPerformance=false)
void SaveGroundTruth(const TStr &OutFNm)
void Save(TSOut &SOut) const
void SaveInferred(const TStr &OutFNm, const TIntV &NIdV=TIntV())
void SortNodeNmByVol(const bool &asc=false)
void AddCasc(const TCascade &Cascade)
TNodeInfo GetNodeInfo(const int &NId) const
THitInfo(const int &NodeId=-1, const double &HitTime=0)
void SetK(const double &k)
bool operator<(const TCascade &Cascade) const
TIntIntPrH SampledCascadesH
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
void SaveGroundTruthPajek(const TStr &OutFNm, const double &Step)
void SetInitAlpha(const double &ia)
TCascade(const int &model)
void Save(TSOut &SOut) const
void Init(const TFltV &Steps)
THash< TInt, TCascade > CascH
THash< TInt, THitInfo >::TIter EndI() const
TStrFltFltHNEDNet Network
void SetMu(const double &mu)
TStrFltFltHNEDNet InferredNetwork
TCascade & GetCasc(int c)
void AddDomainNm(const TStr &Domain, const int &DomainId=-1)
void LoadInferredNodesTxt(TSIn &SIn)
void LoadCascadesTxt(TSIn &SIn)
THash< TInt, TNodeInfo > NodeNmH
bool IsDomainNm(const TStr &Domain) const
void Save(TSOut &SOut) const
TNodeInfo(const TStr &NodeNm, const int &Volume)
void AddCasc(const TStr &CascStr, const TModel &Model=EXP)
void LoadGroundTruthTxt(TSIn &SIn)
TPt< TStrFltFltHNEDNet > PStrFltFltHNEDNet
void AddKeyword(const int &KId)
THash< TInt, THitInfo > NIdHitH
void SetRegularizer(const TRegularizer ®)
void SetMinAlpha(const double &ma)
const TDat & GetDat(const TKey &Key) const
int LenAfterT(const double &T)
void SetDelta(const double &delta)
void GetInferredGraphAtT(const double &Step, PNGraph &GraphAtT)
bool operator<(const THitInfo &Hit) const
void SaveInferredPajek(const TStr &OutFNm, const double &Step, const TIntV &NIdV=TIntV())
TNodeEDatNet< TStr, TFltFltH > TStrFltFltHNEDNet
void Save(TSOut &SOut) const
TCascade(const int &cid, const int &model)
double GetTm(const int &NId) const
void DelKey(const TKey &Key)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
THash< TInt, TFltV > TIntFltVH
void Save(TSOut &SOut, const bool &IsSmall=false) const
void SG(const int &NId, const int &Iters, const TFltV &Steps, const TSampling &Sampling, const TStr &ParamSampling=TStr(""), const bool &PlotPerformance=false)
void LoadInferredTxt(TSIn &SIn)
void SetWindow(const double &window)
void SetAging(const double &aging)
void GenCascade(TCascade &C)
void Save(TSOut &SOut) const
void Save(TSOut &SOut) const
TPt< TStrFltNEDNet > PStrFltNEDNet
bool operator<(const TNodeInfo &NodeInfo) const
void ComputePerformanceNId(const int &NId, const int &Step, const TFltV &Steps)
void FG(const int &NId, const int &Iters, const TFltV &Steps)
void SaveSites(const TStr &OutFNm, const TIntFltVH &CascadesPerNode=TIntFltVH())
void SaveInferredEdges(const TStr &OutFNm)
void GetInferredNetworkAtT(const double &Step, PStrFltNEDNet &NetworkAtT)
bool IsNodeNm(const int &NId) const
void GetGroundTruthNetworkAtT(const double &Step, PStrFltNEDNet &NetworkAtT)
int GetCascadeId(const TStr &Cascade)
void SetTolerance(const double &tol)
TNodeEDatNet< TStr, TFlt > TStrFltNEDNet
void UpdateDiff(const TOptMethod &OptMethod, const int &NId, TCascade &Cascade, TIntPrV &AlphasToUpdate, const double &CurrentTime=TFlt::Mx)
void find_C(int t, TFltV &x, TFltVV &C, const int &k, const double &s, const double &gamma, const double &T)
THash< TInt, THitInfo >::TIter BegI() const
void LoadGroundTruthNodesTxt(TSIn &SIn)
void Add(const int &NId, const double &HitTm)
void LabelBurstAutomaton(const int &SrcId, const int &DstId, TIntV &state_labels, TFltV &state_times, const bool &inferred=false, const int &k=5, const double &s=2.0, const double &gamma=1.0, const TSecTm &MinTime=TSecTm(), const TSecTm &MaxTime=TSecTm())
void SetMaxAlpha(const double &ma)
void SetModel(const TModel &model)
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
int LenBeforeT(const double &T)
void SetTotalTime(const float &tt)
void SaveCascades(const TStr &OutFNm)
int GetNode(const int &i) const
void Save(TSOut &SOut) const
THash< TIntPr, TIntV > CascPerEdge
bool IsKey(const TKey &Key) const
TStr GetNodeNm(const int &NId) const
int GetDomainId(const TStr &Domain)
TDat & AddDat(const TKey &Key)
void SetGamma(const double &gamma)
void AddNodeNm(const int &NId, const TNodeInfo &Info)
THash< TInt, TIntFltH > DiffAlphas
void Save(TSOut &SOut) const
const TKey & GetKey(const int &KeyId) const
void GetGroundTruthGraphAtT(const double &Step, PNGraph &GraphAtT)
bool IsNode(const int &NId) const
void find_min_state(TFltVV &C, TIntV &states, const int &k, const double &s, const double &gamma, const double &T)
int GetNodes() const
Returns the number of nodes in the network.
TIntFltH TotalCascadesAlpha
void SortByDat(const bool &Asc=true)