Esempio n. 1
0
NFA Union (NFA nfa1, NFA nfa2 )
{
    int i, j, n1, n2, n, e1, e2;
    NFA     combined_NFA;
    Status  s;

    Edge    e;

    /* 得到两个NFA 边(Edge)数 和 顶点(Status)数 */
    n1 = Array_length (nfa1->statusArray);
    n2 = Array_length (nfa2->statusArray);
    e1 = Array_length (nfa1->edgeArray);
    e2 = Array_length (nfa2->edgeArray);

    n = n1 + n2 + 2;

    combined_NFA = malloc (sizeof (struct Automaton));
    assert(combined_NFA);

    combined_NFA->statusArray = allocStatusArray(n);


    /* 构造边集合, 即两个NFA的边数加上4条ε边 */
    n = e1 + e2 + 4;
    combined_NFA->edgeArray = allocEdgeArray(n); 

    /* 提取0号边 */
    e = Array_get (combined_NFA->edgeArray, 0);
    setEpsilon (e);
    link_Two_Status_In_Automaton (combined_NFA, 0, 1, 0);
    
    adjustStatusEdges (combined_NFA, nfa1, 1, 2);
     
    e = Array_get (combined_NFA->edgeArray, 1);
    setEpsilon (e);
    link_Two_Status_In_Automaton (combined_NFA, 0, n1+1, 1);

    adjustStatusEdges (combined_NFA, nfa2, n1+1, e1+2);

    setEpsilon (Array_get (combined_NFA->edgeArray, e1+e2+2));
    link_Two_Status_In_Automaton (combined_NFA, n1, n1+n2+1, e1+e2+2);

    setEpsilon (Array_get (combined_NFA->edgeArray, e1+e2+3));
    link_Two_Status_In_Automaton (combined_NFA, n1+n2, n1+n2+1, e1+e2+3);

    adjustStatusID (combined_NFA);
    ensureFinalStatus (combined_NFA->end);

    free_Automaton(nfa1);
    free_Automaton(nfa2);

    return combined_NFA ;
}
/// default constructor
GreedyHillClimbing::GreedyHillClimbing() {
    setEpsilon(0);
    disableMinEpsilonRate();
    disableMaxIter();
    disableMaxTime();
    GUM_CONSTRUCTOR(learning::GreedyHillClimbing);
}
Esempio n. 3
0
/*
 *  nfa1 G: n×e
 *  以下是 求nfa闭包
 *
                       e+2 号边
                 —————————————————————
                |                   |
                |                   |       
 *  (0号边)      —>    ------   —————— 
 *    ————————————>  |  nfa  | —————————————————
      |                ------        e+3号边    |
      |                                         v
    -----                                     -----
  | start | (0号顶点)                        | end | (n+1) 号顶点
    -----                                     -----
    |                                         |
     ———————————————————————————————————————————
                       1号边
    
    边顺序:     0号 
                1号  
                nfa中的e条边:    2, 3, ...  e
                e+2号边
                (e+3)号边

    顶点顺序:   start:  0号,  
                nfa中n个顶点:     1, 2, 3, ..., n
                end :   n+1


 */
NFA Closure(NFA nfa)
{
    NFA     newnfa;

    int n, e;

    newnfa = malloc (sizeof (struct Automaton));
    assert (newnfa);

    /* 构造边数组 */
    e = Array_length (nfa->edgeArray);
    newnfa->edgeArray = allocEdgeArray (e+4);
  
    // 得到nfa状态个数
    n = Array_length (nfa->statusArray);
    newnfa->statusArray = allocStatusArray (n+2);

    /* 提取0号边 */
    setEpsilon (Array_get (newnfa->edgeArray, 0));
    link_Two_Status_In_Automaton (newnfa, 0, 1, 0);

    /* 提取1号边 */
    setEpsilon (Array_get (newnfa->edgeArray, 1));
    link_Two_Status_In_Automaton (newnfa, 0, n+1, 1);

    /* 在newnfa中构造与nfa对应一样的图结构 */
    adjustStatusEdges (newnfa, nfa, 1, 2);

    /* 提取e+2号边 */
    setEpsilon (Array_get (newnfa->edgeArray, e+2));
    link_Two_Status_In_Automaton (newnfa, n, 1, e+2);

    /* 提取e+3号边 */
    setEpsilon (Array_get (newnfa->edgeArray, e+3));
    link_Two_Status_In_Automaton (newnfa, n, n+1, e+3);
    
    adjustStatusID (newnfa); 

    free_Automaton(nfa);
    
    return newnfa;
}
Esempio n. 4
0
NFA Link (NFA frontNFA, NFA toNFA )
{
    int i, j, numStatus ;
    int n1, n2, n;
    NFA combined_NFA;
    Edge bridge;
    Status s, s1, s2;

    
    combined_NFA = malloc (sizeof (struct Automaton));
    assert(combined_NFA);

    /* 构造combined_NFA所有状态 */
    n = Array_length (frontNFA->statusArray) + Array_length (toNFA->statusArray);
    
    combined_NFA->statusArray = allocStatusArray(n);
    
    adjustStatusID (combined_NFA);
    combined_NFA->start = Array_get(combined_NFA->statusArray, 0);
    combined_NFA->end = Array_get(combined_NFA->statusArray, n-1);
    ensureFinalStatus(combined_NFA->end);
    
    /* combined_NFA边集合 <=> 两个nfa以及连接它们的边ε*/
    n = Array_length(frontNFA->edgeArray) + Array_length(toNFA->edgeArray) + 1;
    
    combined_NFA->edgeArray = allocEdgeArray(n);
    
    adjustStatusEdges(combined_NFA, frontNFA, 0, 0);
    
    n1 = Array_length (frontNFA->statusArray);
    n2 = Array_length (toNFA->statusArray);
    /* 连结两个NFA图的边是epsilon edge */
    bridge = Array_get(combined_NFA->edgeArray, Array_length(frontNFA->edgeArray)); 
    setEpsilon (bridge);
    // 提取对应于frontNFA状态的最后一个状态
    s1 = Array_get (combined_NFA->statusArray, n1-1);
    s2 = Array_get (combined_NFA->statusArray, n1);
    link_Two_Status_In_Automaton (combined_NFA, n1-1, n1, Array_length(frontNFA->edgeArray));
    // linkTwoStatus_by_AnEdge (s1, s2, bridge);
     

    /* 根据已有的NFA, 确认combined_NFA中边和点之间的关系 */
    /* 已边数: frontNFA所有边以及bridge, 所以边计数从n开始*/
    n = Array_length (frontNFA->edgeArray) + 1;
    adjustStatusEdges (combined_NFA, toNFA, n1, n);

    free_Automaton(frontNFA);
    free_Automaton(toNFA);

    return combined_NFA ;
}
AdaptiveSO2CPGSynPlas::AdaptiveSO2CPGSynPlas(Neuron* perturbingNeuron)
: ExtendedSO2CPG(perturbingNeuron){
    setAlpha(1.01);
    setPhi(0.3);
    setMu(1.00);

    setGamma(0.02);
    setEpsilon(0.03);
    setBeta(0.00);

    // for a range of P from -1 to 1
    setBetaDynamics   (-1.0, 0.003, 0.0000);
    setGammaDynamics  (-1.0, 0.003, 1.0000);
    setEpsilonDynamics(0.04, 0.003, 0.0001);
}
Esempio n. 6
0
  gBathProperties::gBathProperties(Molecule* pMol)
    :m_Sigma(sigmaDefault),
    m_Epsilon(epsilonDefault),
    m_Sigma_chk(-1),
    m_Epsilon_chk(-1)
  {
    ErrorContext c(pMol->getName());
    m_host = pMol;
    PersistPtr pp = pMol->get_PersistentPointer();

    PersistPtr ppPropList = pp->XmlMoveTo("propertyList");
    if (!ppPropList)
      ppPropList = pp; //Be forgiving; we can get by without a propertyList element

    setSigma(ppPropList->XmlReadPropertyDouble("me:sigma"));
    setEpsilon(ppPropList->XmlReadPropertyDouble("me:epsilon"));
  }
void AdaptiveSO2CPGSynPlas::updateWeights() {
    const double& phi     = getPhi();
    const double& beta    = getBeta();
    const double& gamma   = getGamma();
    const double& epsilon = getEpsilon();
    const double& mu      = getMu();
    const double& F       = getOutput(2);
    const double& w01     = getWeight(0,1);
    const double& x       = getOutput(0);
    const double& y       = getOutput(1);
    const double& P       = getPerturbation();

    // general approach
    setPhi    ( phi     + mu * gamma * F * w01 * y );
    setBeta   ( beta    + betaHebbRate    * x * F - betaDecayRate    * (beta    - betaZero) );
    setGamma  ( gamma   + gammaHebbRate   * x * F - gammaDecayRate   * (gamma   - gammaZero) );
    setEpsilon( epsilon + epsilonHebbRate * F * P - epsilonDecayRate * (epsilon - epsilonZero) );

}
Esempio n. 8
0
 ValueIteration::ValueIteration(unsigned horizon, double epsilon, ValueFunction v) : horizon_(horizon), vParameter_(v),
                                                                                     S(0), A(0)
 {
     setEpsilon(epsilon);
 }
Esempio n. 9
0
 IncrementalPruning::IncrementalPruning(unsigned h, double e) : horizon_(h) {
     setEpsilon(e);
 }