Esempio n. 1
0
int Preferences::set_p3(float v){
cout<<" p3: e2="<<o_transitions[SEEDL][VEG]<<" e3=" <<o_transitions[SEEDL][GEN]<<endl;
    float p1=get_p1(),p3=v,p2=get_p2();
    if (p3*(1-p3)<=0) return -1;//0<p<1
    float e2=p1*p2*(1-p3);float e3=p1*p2*p3;
    o_transitions[SEEDL][VEG]=e2;o_transitions[SEEDL][GEN]=e3;
cout<<"new p3: e2="<<o_transitions[SEEDL][VEG]<<" e3=" <<o_transitions[SEEDL][GEN]<<endl;
    return 0;
}
Esempio n. 2
0
void Preferences::changeOTransition(state from,state to,float min,float max,float value){
  cout<<from<<";"<<to<<": "<<getOTransition(from,to)<<"--> change "<<value;
  if (from==SEEDL&&to>SEEDL){//sum of all estab must be less than one
    if (to==JUV) {set_p1(get_p1()+value);}
    else if (to==VEG) {set_p2(get_p2()+value);}
    else {set_p3(get_p3()+value);}
  }
  else if(from==JUV&&to>JUV){
    if (to==VEG) {set_gr1(get_gr1()+value);}
    else  {set_gr2(get_gr2()+value);}
  }
  else{
     float new_val=o_transitions[from][to]+value;
     if  (new_val<=min||new_val>=max) return;
     o_transitions[from][to]=new_val;
     cout<<">"<<new_val<<endl;
  }
    }
Esempio n. 3
0
/**
  Function sets single object transition rates.
  The value is reduced if establishment or growth of a state would exceed 1.
  \date 24.04.08
  \date 10.10.08
  changed, such as unvalid values are ignored, not recalculated
  \param from the stage of origin
  \param to the stage to go to
  \param value the new value
*/
void  Preferences::setOTransition(state from,state to,float value){
  cout<<from<<";"<<to<<": "<<getOTransition(from,to)<<"-->"<<value;
  if (from==SEEDL&&to>SEEDL){//sum of all estab must be less than one
    float diff=getOTransition(from,to)-value;
    if (to==JUV) {set_p1(get_p1()+diff);}
    else if (to==VEG) {set_p2(get_p2()+diff);}
    else {set_p3(get_p3()+diff);}
  }
  else if(from==JUV&&to>JUV){
    float diff=getOTransition(from,to)-value;
    if (to==VEG) {set_gr1(get_gr1()+value);}
    else  {set_gr2(get_gr2()+value);}
  }
  else{
     o_transitions[from][to]=std::max((float)0.0,value);
     cout<<">"<<value<<endl;
  }
}
Esempio n. 4
0
/* Builds a WPS PIN from the key tables */
char *build_wps_pin()
{
        char *key = NULL, *pin = NULL;
        int pin_len = PIN_SIZE + 1;

        pin = malloc(pin_len);
        key = malloc(pin_len);
        if(pin && key)
        {
                memset(key, 0, pin_len);
                memset(pin, 0, pin_len);

                /* Generate a 7-digit pin from the given key index values */
                snprintf(key, pin_len, "%s%s", get_p1(get_p1_index()), get_p2(get_p2_index()));

                /* Generate and append the pin checksum digit */
                snprintf(pin, pin_len, "%s%d", key, wps_pin_checksum(atoi(key)));

                free(key);
        }

        return pin;
}
Esempio n. 5
0
float Preferences::get_p3()const{
        float e3=getOTransition(SEEDL,GEN);
        return e3/(get_p1()*get_p2());
}