예제 #1
0
파일: SplitLP.cpp 프로젝트: kierzek/MUFINS
void SplitLP::minimiseInput(stomap* conv, strvec& txs){
    strvec externals = getExternals();
    stomap obj;
    int nblock = 0;

    stomap::iterator cend = conv->end();
    for (strvec::iterator it = externals.begin(); it != externals.end(); ++it){
        string tx = getTransporterName(*it, 1);
        if (tx.size() > 0){
            stomap::iterator ct = conv->find(*it);
            if (ct != cend && ct->second < 0){
                obj[tx] = 1;
            }
            else{
                block(tx, true);
                nblock++;
            }
        }
    }
    setObjective(&obj);
    Solve(true);
    conv->clear();
    getConversion(conv);
    cleanTmpRows(nblock);
}
예제 #2
0
파일: SplitLP.cpp 프로젝트: kierzek/MUFINS
void SplitLP::minExchangeSets(solvec& solutions, stomap* obj, int dir, long nmax){
    strvec externals = getExternals();
    strvec txs(externals.size());// - obj->size());
    strvec::iterator ti = txs.begin();
    stomap::iterator oend = obj->end();
    for (strvec::iterator it = externals.begin(); it != externals.end(); ++it){
        string xname = *it;
        string txname = getTransporterName(xname, dir);
        stomap::iterator jt = obj->find(xname);
        if (jt != oend){
            double coef = jt->second;
            coef /= this->vmax;
            fix(txname, coef, true, txname + "_mxs");
        }
        else if (dir > 0){
                fix(txname, 0, true);
        }
        *ti++ = get_opp_name(txname);
    }
    setObjDir(false);
    setLenObjective(txs, true);

    strvec itxs = get_int_names(txs);

    long i = 0;
    while(i < nmax){
        stomap conv;
        stomap sol;

        Solve(true);
        getConversion(&conv);

        if (!isSolved())
            break;

        getSolution(&sol, itxs, INT, false);

        if (!conv.empty()){
            i++;
            if (dir < 0){
                minimiseInput(&conv, txs);
                setLenObjective(txs, true);
            }
            solutions.push_back(conv);
        }

        if (i < nmax)
            cutSolution(&sol, true);
    }

//    cleanTmpRows();
}
예제 #3
0
/** Get the current voltage reading
 * Read the current differential and return it multiplied
 * by the constant for the current gain.  mV is returned to
 * increase the precision of the voltage
 *
 */
float ADS1115::getMilliVolts() {
  switch (pgaMode) {
    case ADS1115_PGA_6P144:
      return (getConversion() * ADS1115_MV_6P144);
      break;    
    case ADS1115_PGA_4P096:
      return (getConversion() * ADS1115_MV_4P096);
      break;             
    case ADS1115_PGA_2P048:    
      return (getConversion() * ADS1115_MV_2P048);
      break;       
    case ADS1115_PGA_1P024:     
      return (getConversion() * ADS1115_MV_1P024);
      break;       
    case ADS1115_PGA_0P512:      
      return (getConversion() * ADS1115_MV_0P512);
      break;       
    case ADS1115_PGA_0P256:           
    case ADS1115_PGA_0P256B:          
    case ADS1115_PGA_0P256C:      
      return (getConversion() * ADS1115_MV_0P256);
      break;       
  }
}
예제 #4
0
/** Get AIN3/GND differential.
 * This changes the MUX setting to AIN3/GND if necessary, triggers a new
 * measurement (also only if necessary), then gets the differential value
 * currently in the CONVERSION register.
 * @return 16-bit signed differential value
 * @see getConversion()
 */
int16_t ADS1115::getConversionP3GND() {
    if (muxMode != ADS1115_MUX_P3_NG) setMultiplexer(ADS1115_MUX_P3_NG);
    return getConversion();
}
예제 #5
0
/** Get AIN2/N3 differential.
 * This changes the MUX setting to AIN2/N3 if necessary, triggers a new
 * measurement (also only if necessary), then gets the differential value
 * currently in the CONVERSION register.
 * @return 16-bit signed differential value
 * @see getConversion()
 */
int16_t ADS1115::getConversionP2N3() {
    if (muxMode != ADS1115_MUX_P2_N3) setMultiplexer(ADS1115_MUX_P2_N3);
    return getConversion();
}
예제 #6
0
/** Get AIN0/N1 differential.
 * This changes the MUX setting to AIN0/N1 if necessary, triggers a new
 * measurement (also only if necessary), then gets the differential value
 * currently in the CONVERSION register.
 * @return 16-bit signed differential value
 * @see getConversion()
 */
int16_t ADS1115::getConversionP0N1() {
    if (muxMode != ADS1115_MUX_P0_N1) setMultiplexer(ADS1115_MUX_P0_N1);
    return getConversion();
}