/***********************************************************************//** * @brief Optimize function * * This code illustrates the optimization of a function. ***************************************************************************/ int main(void) { // Allocate logger GLog log; log.cout(true); // Allocate optimizer //GOptimizerLM opt(log); GOptimizerLM opt; // Allocate function parabola fct; // Allocate parameters and set initial value GOptimizerPars pars(1); pars[0]->value(1.5); // Optimize parameters opt.optimize(fct, pars); // Print derivatives std::cout << "Function value .....: " << fct.value() << std::endl; std::cout << "Parameter value ....: " << pars[0]->value() << std::endl; // Exit return 0; }
void ParameterFile::initializeEmpty(const std::vector<Location>& iLocations, int iNumTimes, int iNumParameters) { std::vector<float> params(iNumParameters, Util::MV); Parameters parameters(params); std::vector<Parameters> pars(iNumTimes, params); for(int i = 0; i < iLocations.size(); i++) { mParameters[iLocations[i]] = pars; } }
//-------------------------------------------------------------------------------- //This passes the files to server //-------------------------------------------------------------------------------- TInt RFileDesTransferSession::TransferFilesToServer() { TBuf<256> fname; const CFileTable& ftable = Backend()->FileTable(); CFileDescBase* fdesc = NULL; int count = ftable.GetFileCount(); TInt j; for (int i = count-1; i >=3; --i) { if (ftable.At(i, fdesc) == KErrNone) { j=fdesc->Type(); if((j==CFileDescBase::EFileDesc)||(j==CFileDescBase::EFileTempDesc)) { CFileDesc* fp = (CFileDesc*)(fdesc); if (fp) { TUint attr = fp->Attributes(); if (!(attr & KCloseonExec) && !(attr & KSpawnCloseInChild)) { fp->FileHandle().FullName(fname); TParsePtr pars(fname); if (pars.Path().FindC(_L("\\PRIVATE\\")) != 0) { (Backend()->iFs).ShareProtected(); fp->DoSync(); #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS) //The integer width is bigger for 64 bit sizes TBuf<140> params; #else TBuf<60> params; #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */ params.AppendNum(fp->Offset()); params.Append(' '); params.AppendNum(fp->Extent()); params.Append(' '); params.AppendNum(fp->FcntlFlag()); params.Append(' '); params.AppendNum(fp->Attributes()); params.Append(' '); params.AppendNum(fp->Pos()); params.Append(' '); params.AppendNum(fp->Ext()); params.Append(' '); params.AppendNum(fp->Size()); TIpcArgs args(i,¶ms); if((fp->FileHandle()).TransferToServer(args, 2,3) == KErrNone) SendReceive(ETransferFile, args); (Backend()->iFs).ShareAuto(); } } } } } } //for return KErrNone; }
status_t JordanCameraWrapper::setParameters(const CameraParameters& params) { CameraParameters pars(params.flatten()); int width, height; char buf[10]; bool isWide; /* * getInt returns -1 if the value isn't present and 0 on parse failure, * so if it's larger than 0, we can be sure the value was parsed properly */ mVideoMode = pars.getInt("cam-mode") > 0; pars.remove("cam-mode"); pars.getPreviewSize(&width, &height); isWide = width == 848 && height == 480; if (isWide && !mVideoMode) { pars.setPreviewFrameRate(24); } if (mCameraType == CAM_BAYER && mVideoMode) { pars.setPreviewFrameRate(24); } if (mCameraType == CAM_SOC) { /* * libsoccamera fails to turn flash on if 16:9 recording is enabled (no matter * whether it's photo or video recording), thus we do it ourselves in that case. * Luckily libsoccamera handles the automatic flash properly also in the 16:9 case. */ const char *flashMode = pars.get(CameraParameters::KEY_FLASH_MODE); if (flashMode != NULL) { if (isWide && mLastFlashMode != flashMode) { bool shouldBeOn = strcmp(flashMode, CameraParameters::FLASH_MODE_TORCH) == 0 || strcmp(flashMode, CameraParameters::FLASH_MODE_ON) == 0; setSocTorchMode(shouldBeOn); } mLastFlashMode = flashMode; } } float exposure = pars.getFloat(CameraParameters::KEY_EXPOSURE_COMPENSATION); /* exposure-compensation comes multiplied in the -9...9 range, while we need it in the -3...3 range -> adjust for that */ exposure /= 3; /* format the setting in a way the lib understands */ bool even = (exposure - round(exposure)) < 0.05; snprintf(buf, sizeof(buf), even ? "%.0f" : "%.2f", exposure); pars.set("mot-exposure-offset", buf); /* kill off the original setting */ pars.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); return mMotoInterface->setParameters(pars); }
void factor() /* 式の因子のコンパイル */ { int tIndex, i; KeyId k; if (token.kind==Id){ tIndex = searchT(token.u.id, varId); setIdKind(k=kindT(tIndex)); /* 印字のための情報のセット */ switch (k) { case varId: case parId: /* 変数名かパラメタ名 */ genCodeT(lod, tIndex); token = nextToken(); break; case constId: /* 定数名 */ genCodeV(lit, val(tIndex)); token = nextToken(); break; case funcId: /* 関数呼び出し */ token = nextToken(); if (token.kind==Lparen){ i=0; /* iは実引数の個数 */ token = nextToken(); if (token.kind != Rparen) { for (; ; ) { expression(); i++; /* 実引数のコンパイル */ if (token.kind==Comma){ /* 次がコンマなら実引数が続く */ token = nextToken(); continue; } token = checkGet(token, Rparen); break; } } else token = nextToken(); if (pars(tIndex) != i) errorMessage("\\#par"); /* pars(tIndex)は仮引数の個数 */ }else{ errorInsert(Lparen); errorInsert(Rparen); } genCodeT(cal, tIndex); /* call命令 */ break; } }else if (token.kind==Num){ /* 定数 */ genCodeV(lit, token.u.value); token = nextToken(); }else if (token.kind==Lparen){ /* 「(」「因子」「)」 */ token = nextToken(); expression(); token = checkGet(token, Rparen); } switch (token.kind){ /* 因子の後がまた因子ならエラー */ case Id: case Num: case Lparen: errorMissingOp(); factor(); default: return; } }
Flann1DSearcher<ScalarT>::Flann1DSearcher(std::vector<ScalarT> v) { v_ = v; FLANNMat mat = FLANNMat(v_.data(), v_.size(), 1); flann::KDTreeSingleIndexParams pars(15); flann_index_.reset(new FLANNIndex(mat, pars)); flann_index_->buildIndex(); }
PatternTransform * PatternTransformBuilder::build( const lspl::patterns::Alternative & alt, const std::string & source ) { lspl::patterns::PatternTransformParser pars(space); boost::ptr_vector<lspl::patterns::matchers::Matcher>* matchers=NULL; if(!boost::spirit::classic::parse( source.c_str(), pars[ var(matchers) = arg1 ], space_p ).full) { throw lspl::patterns::PatternBuildingException( source.c_str() ); } return new PatternTransform( space, matchers ); }
void C4ObjectMenu::OnSelectionChanged(int32_t iNewSelection) { // do selection callback if (UserMenu) { C4AulParSet pars(iNewSelection, ParentObject); if (eCallbackType == CB_Object && Object) Object->Call(PSF_MenuSelection, &pars); else if (eCallbackType == CB_Scenario) ::GameScript.Call(PSF_MenuSelection, &pars); } }
// Get the position of the convolution indexes for the given // convolution parameters. Returns true if the indexes were // newly added, returns false if the indexes for these // parameters were added by a previous call to this method. // Not thread safe! bool addIndexesForParameters(const Shape &imageShape, int Ni, int Sk, int Nld, int &position) { Pars pars(imageShape, Ni, Sk, Nld); PositionMap::iterator p = _positionMap.find(pars); if (p == _positionMap.end()) { int pos = _addConvolution(imageShape, Ni, Sk, Nld); _positionMap[pars] = pos; position = pos; return true; } position = p->second; return false; }
t_pars *recup_graph(char *file) { t_pars *parse; if (!(parse = malloc(sizeof(t_pars)))) return (NULL); if (!(parse->cas = malloc(sizeof(t_case)))) return (NULL); parse->cas->next = parse->cas; parse->cas->prev = parse->cas; pars(file, parse->cas, parse); return (parse); }
//Change the effect void EffectMgr::changeeffectrt(int _nefx, bool avoidSmash) { cleanup(); if(nefx == _nefx && efx != NULL) return; nefx = _nefx; memset(efxoutl, 0, synth.bufferbytes); memset(efxoutr, 0, synth.bufferbytes); memory.dealloc(efx); EffectParams pars(memory, insertion, efxoutl, efxoutr, 0, synth.samplerate, synth.buffersize); switch(nefx) { case 1: efx = memory.alloc<Reverb>(pars); break; case 2: efx = memory.alloc<Echo>(pars); break; case 3: efx = memory.alloc<Chorus>(pars); break; case 4: efx = memory.alloc<Phaser>(pars); break; case 5: efx = memory.alloc<Alienwah>(pars); break; case 6: efx = memory.alloc<Distorsion>(pars); break; case 7: efx = memory.alloc<EQ>(pars); break; case 8: efx = memory.alloc<DynamicFilter>(pars); break; //put more effect here default: efx = NULL; break; //no effect (thru) } if(efx) filterpars = efx->filterpars; if(!avoidSmash) for(int i=0; i<128; ++i) settings[i] = geteffectparrt(i); }
BOOL ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom) { // scripted jump? assert(cObj); C4AulParSet pars(C4VInt(fixtoi(xdir, 100)), C4VInt(fixtoi(ydir, 100)), C4VBool(fByCom)); if (!!cObj->Call(PSF_OnActionJump, &pars)) return TRUE; // hardcoded jump by action if (!cObj->SetActionByName("Jump")) return FALSE; cObj->xdir=xdir; cObj->ydir=ydir; cObj->Mobile=1; // unstick from ground, because jump command may be issued in an Action-callback, // where attach-values have already been determined for that frame cObj->Action.t_attach&=~CNAT_Bottom; return TRUE; }
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom) { // scripted jump? assert(cObj); C4AulParSet pars(fixtoi(xdir, 100), fixtoi(ydir, 100), fByCom); if (!!cObj->Call(PSF_OnActionJump, &pars)) return true; // hardcoded jump by action if (!cObj->SetActionByName("Jump")) return false; cObj->xdir=xdir; cObj->ydir=ydir; cObj->Mobile=true; // unstick from ground, because jump command may be issued in an Action-callback, // where attach-values have already been determined for that frame cObj->Action.t_attach&=~CNAT_Bottom; return true; }
status_t LibCameraWrapper::setParameters(const CameraParameters& params) { CameraParameters pars(params.flatten()); const char *flashMode = pars.get(CameraParameters::KEY_FLASH_MODE); if (flashMode != NULL) { if (mLastFlashMode != flashMode) { bool shouldBeOn = strcmp(flashMode, CameraParameters::FLASH_MODE_TORCH) == 0 || strcmp(flashMode, CameraParameters::FLASH_MODE_ON) == 0; setSocTorchMode(shouldBeOn); } mLastFlashMode = flashMode; } return mLibInterface->setParameters(pars); }
/***********************************************************************//** * @brief Read parameter cubes * * @param[in] hdu Response table HDU. * * @exception GCTAException::bad_rsp_table_format * Parameter vector of bad size encountered. * * Reads the parameter cubes from the response table. The method also sets * the data members m_npars (number of parameters) and m_nelements (number * of elements per parameter). * * This method sets the following members: * m_pars - Parameter values * m_nelements - Number of elements per parameter * * In case that the HDU pointer is not valid (NULL), this method clears the * axes boundaries and does nothing else. ***************************************************************************/ void GCTAResponseTable::read_pars(const GFitsTable& hdu) { // Clear parameter cubes m_pars.clear(); // Compute expected cube size m_nelements = axis(0); for (int i = 1; i < axes(); ++i) { m_nelements *= axis(i); } // Loop over all parameter cubes for (int i = 0; i < size(); ++i) { // Get pointer to table column const GFitsTableCol* col = hdu[m_colname_par[i]]; // Extract number of bins. Verify that the number of bins // corresponds to the expectation. int num = col->number(); if (num != m_nelements) { std::string message = "Parameter vector '"+m_colname_par[i]+ "' has wrong size "+gammalib::str(num)+ " (expected"+ gammalib::str(m_nelements)+")."; throw GCTAException::bad_rsp_table_format(G_READ_PARS, message); } // Initialise parameter cube std::vector<double> pars(num); // Copy parameter values for (int k = 0; k < num; ++k) { pars[k] = col->real(0,k); } // Push cube into storage m_pars.push_back(pars); } // endfor: looped over all parameter cubes // Return return; }
bool C4ObjectMenu::IsCloseDenied() { // abort if menu is permanented by script; stop endless recursive calls if user opens a new menu by CloseQuerying-flag if (UserMenu && !CloseQuerying) { CloseQuerying = true; bool fResult = false; C4AulParSet pars(Selection, ParentObject); if (eCallbackType == CB_Object) { if (Object) fResult = !!Object->Call(PSF_MenuQueryCancel, &pars); } else if (eCallbackType == CB_Scenario) fResult = !!::GameScript.Call(PSF_MenuQueryCancel, &pars); CloseQuerying = false; if (fResult) return true; } // close OK return false; }
void Snoss2D::snoss2Dbatch( DataStation& data_station) { //------------------------LOAD PARAMETRS FROM TXT-----------------------------// int index_S=0; string readPathParams= "params.txt"; fstream readParams(readPathParams.c_str()); string a; getline(gotoLine(readParams,9),a); stringstream pars (a); pars>>A1>>A2>>sigm>>B1>>B2>>SIcrit; //------------------------INITIALIZE SNOSS(precip,snow)-------------------------// int p=0; for(int i = 0;i<data_station.data_loaded.size();i++) { data_station.data_loaded[i]; } }
void Graph::sg_SIG() { if(dbg)Rprintf("Spheres-of-Influence:"); std::vector<double> pars(pp->size()); int i,j,dbg0=dbg; double dist; // find the nearest neighbour distance: for(i=0;i<pp->size();i++) { dist = MAX_DOUBLE; for(j=0;j<pp->size();j++) if(i!=j) dist = fmin(dist, pp->getDist(&i, &j)); pars.at(i)=dist; } dbg=0; par = pars; sg_markcross(); dbg=dbg0; if(dbg)Rprintf(" Ok."); }
void C4RoundResults::EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalList, int32_t iPlayerNumber) { // clear prev GoalList.Clear(); FulfilledGoalList.Clear(); // Items int32_t cnt; C4ID idGoal; for (cnt=0; (idGoal=::Objects.GetListID(C4D_Goal,cnt)); cnt++) { // determine if the goal is fulfilled - do the calls even if the menu is not to be opened to ensure synchronization bool fFulfilled = false;; C4Object *pObj = C4Id2Def(idGoal) ? ::Objects.Find(::Definitions.ID2Def(idGoal)) : NULL; if (pObj) { // Check fulfilled per player, this enables the possibility of rivalry. C4AulParSet pars(iPlayerNumber); fFulfilled = !!pObj->Call(PSF_IsFulfilled, &pars); } GoalList.SetIDCount(idGoal, cnt, true); if (fFulfilled) FulfilledGoalList.SetIDCount(idGoal, 1, true); } }
int main(int argc, char *argv[]) { int numPoints = 1; double qMax = 0.; // Sets format of output: 4 decimal places outputCharacteristics(6); void (*boundaryCondition)(MssmSoftsusy &, const DoubleVector &); if (argc !=1 ) { cerr << "GAUGE/GRAVITY" << endl; cerr << "SOFTSUSY" << VERSION << endl; cerr << "B.C. Allanach, Comput. Phys. Commun. 143 (2002) 305-331,"; cerr << " hep-ph/0104145\n"; cerr << "Low energy data in SOFTSUSY: MIXING=" << MIXING << " TOLERANCE=" << TOLERANCE << endl; cerr << "G_F=" << GMU << " GeV^2" << endl; } // RANDOM SEED ///////////////////// time_t seconds; time( &seconds); srand( (unsigned int) seconds ); //////////////////////////////////// double mgutGuess = 2.0e16, mbmb = MBOTTOM, mtau = MTAU; int sgnMu = 1; bool gaugeUnification = false, ewsbBCscale = false, altEwsb = false; bool flag = false; double M_moduli_start, M_moduli_end ; double M_gauge_start, M_gauge_end ; double M_mess_start, M_mess_end ; double M_moduli, M_gauge, M_mess ; double tanb_start, tanb_end ; double tanb = 10; DoubleVector pars(3); // My modification cout << "argc = " << argc << endl; cout << flush ; if(argc != 3 ) { errorCall() ; exit(-1) ; } /* if (!strcmp(argv[1], "g-gmsb")) { cout << "SOFTSUSY Gauge/Gravity calculation" << endl; cout << flush; */ if( argc == 3 ) { ifstream inputfile(argv[1]); ofstream outputfile(argv[2]); string varname; inputfile >> varname >> l1 ; cout << varname << endl; inputfile >> varname >> l2 ; inputfile >> varname >> l3 ; inputfile >> varname >> nQ ; inputfile >> varname >> nU ; inputfile >> varname >> nD ; inputfile >> varname >> nL ; inputfile >> varname >> nE ; inputfile >> varname >> nHu ; inputfile >> varname >> nHd ; inputfile >> varname >> N ; inputfile >> varname >> numscan; inputfile >> varname >> M_moduli_start ; inputfile >> varname >> M_moduli_end ; inputfile >> varname >> M_gauge_start ; inputfile >> varname >> M_gauge_end ; inputfile >> varname >> M_mess_start ; inputfile >> varname >> M_mess_end ; inputfile >> varname >> tanb_start ; inputfile >> varname >> tanb_end ; inputfile >> varname >> sgnMu ; inputfile.close(); cout << "l1 = " << l1 << endl << "l2 = " << l2 << endl << "l3 = " << l3 << endl << "nQ = " << nQ << endl << "nU = " << nU << endl << "nD = " << nD << endl << "nL = " << nL << endl << "nE = " << nE << endl << "nHu = " << nHu << endl << "nHd = " << nHd << endl << "N = " << N << endl << "numscan = " << numscan << endl << "M_moduli_start = " << M_moduli_start << endl << "M_moduli_end = " << M_moduli_end << endl << "M_gauge_start = " << M_gauge_start << endl << "M_gauge_end = " << M_gauge_end << endl << "M_mess_start = " << M_mess_start << endl << "M_mess_end = " << M_mess_end << endl << "tanb_start = " << tanb_start << endl << "tanb_end = " << tanb_end << endl << "sgnMu = " << sgnMu << endl; for( int i = 0 ; i < numscan ; i++ ) { QedQcd oneset0, oneset1, oneset2; M_moduli = randomgenerator( M_moduli_start, M_moduli_end ) ; M_gauge = randomgenerator( M_gauge_start, M_gauge_end ) ; M_mess = lograndomgenerator( M_mess_start, M_mess_end ) ; tanb = randomgenerator( tanb_start, tanb_end ) ; cout << i << "th run : " << endl ; cout << "M_moduli = " << M_moduli << endl << "M_gauge = " << M_gauge << endl << "M_mess = " << M_mess << endl << "tanb = " << tanb << endl ; mgutGuess = 2e16; gaugeUnification = false; pars.setEnd(3); pars(1) = M_moduli; pars(2) = M_gauge; pars(3) = M_mess; // r = &m; // if (flag) oneset0.calcPoleMb(); oneset0.toMz(); oneset1.toMz(); oneset2.toMz(); // ofstream rgefile; // rgefile.open("rge.dat"); // ofstream spectrumfile; // spectrumfile.open("spectrum.dat") ; // cout << "Here comes r1 " << endl; MssmSoftsusy r0 ; cout << "Starting" << endl; r0.N= 0 ; r0.Nflag = true; r0.beta2() ; r0.Nflag = false; double mgut = r0.lowOrg(gaugegravityBcs0, mgutGuess, pars, sgnMu, tanb, oneset0, gaugeUnification, ewsbBCscale); r0.runto( M_mess ); cout << "starting phase 2 " << endl; r0.N = N ; r0.Nflag = true; r0.beta2() ; r0.Nflag = false; r0.runto( mgutGuess ) ; global_g1 = r0.displayGaugeCoupling(1); global_g2 = r0.displayGaugeCoupling(2); global_g3 = r0.displayGaugeCoupling(3); MssmSoftsusy r1 ; //, r2;// MssmSoftsusy2 l; r1.N = N ; r1.Nflag = true; r1.beta2(); r1.Nflag = false ; mgut = r1.lowOrg(gaugegravityBcs1, mgutGuess, pars, sgnMu, tanb, oneset1, gaugeUnification, ewsbBCscale); cout << "Here comes r1" << endl; cout << r1 ; // RGRUN( rgefile, r1 , log(mgutGuess) / log(10) , log( M_mess) / log( 10 ) , 20 ) ; r1.runto( M_mess ); global_g1 = r1.displayGaugeCoupling(1); global_g2 = r1.displayGaugeCoupling(2); global_g3 = r1.displayGaugeCoupling(3); inter_gaugino1 = r1.displayGaugino(1); inter_gaugino2 = r1.displayGaugino(2); inter_gaugino3 = r1.displayGaugino(3); inter_massmQl = r1.displaySoftMassSquared(mQl) ; inter_massmUr = r1.displaySoftMassSquared(mUr) ; inter_massmDr = r1.displaySoftMassSquared(mDr) ; inter_massmLl = r1.displaySoftMassSquared(mLl) ; inter_massmEr = r1.displaySoftMassSquared(mEr) ; inter_massmHu = r1.displayMh2Squared(); inter_massmHd = r1.displayMh1Squared(); inter_A_HuQU(1,1) = r1.displaySoftA( UA, 1, 1); inter_A_HuQU(2,2) = r1.displaySoftA( UA, 2, 2); inter_A_HuQU(3,3) = r1.displaySoftA( UA, 3, 3); inter_A_HdQD(1,1) = r1.displaySoftA( DA, 1, 1); inter_A_HdQD(2,2) = r1.displaySoftA( DA, 2, 2); inter_A_HdQD(3,3) = r1.displaySoftA( DA, 3, 3); inter_A_HdLE(1,1) = r1.displaySoftA( EA, 1, 1); inter_A_HdLE(2,2) = r1.displaySoftA( EA, 2, 2); inter_A_HdLE(3,3) = r1.displaySoftA( EA, 3, 3); mgutGuess = M_mess ; cout << "Here comes r2" << endl; MssmSoftsusy r2 ; r2.N = 0; r2.Nflag = true; r2.beta2(); r2.Nflag = false ; mgut = r2.lowOrg(gaugegravityBcs2, mgutGuess, pars, sgnMu, tanb, oneset2, gaugeUnification, ewsbBCscale); // cout << r2 ; // RGRUN( rgefile, r2 , log(M_mess) / log(10), log(100) / log(10), 20 ) ; //rgefile.close(); //spectrumrecord( spectrumfile, r2 ) ; // spectrumfile.close(); cout << r2 ; // sPhysical p = r2.displayPhys() ; // cout << p ; ofstream tempfile("LesHouches.dat"); streambuf* strm_buffer = cout.rdbuf(); cout.rdbuf( tempfile.rdbuf() ) ; r2.lesHouchesAccordOutput("nonUniversal", pars, sgnMu, tanb, 0, 1, mbmb, mtau, MGUTSCALE , 0 ) ; cout << flush; cout.rdbuf(strm_buffer); tempfile.close(); if (r2.displayProblem().test()) { cout << "# SOFTSUSY problem with point: " << r2.displayProblem(); } if( checktheresult( r2 ) ) { ////////////////////////////////////////////////// // micrOmegas // ////////////////////////////////////////////////// double Xf, Omega, Omega2, bsg_value, bsmumu_value, gmuon_value; string mess; double mtop ; int err ; int fast = 1; double Beps = 1E-6 ; double cut = 0.01; err = readLesH("LesHouches.dat",1); // // printVar(stdout); // char messtemp[20]; err=sortOddParticles(messtemp); mess = messtemp; // HiggsMasses(stdout); // printMasses(stdout,1); Omega=darkOmega(&Xf,fast,Beps); o1Contents(stdout); printChannels(Xf,cut,Beps,1,stdout); bsg_value= bsgnlo_(); bsmumu_value = bsmumu_(); gmuon_value = gmuon_(); recordphysics( outputfile, r2, M_moduli, M_gauge, M_mess, tanb, bsg_value, gmuon_value, bsmumu_value, Omega ) ; } else { recordphysics( outputfile, r2, M_moduli, M_gauge, M_mess, tanb, 0, 0 , 0, 0 ) ; } } }
void C4Object::DoMovement() { int32_t iContact=0; bool fAnyContact=false; int iContacts = 0; BYTE fTurned=0,fRedirectYR=0,fNoAttach=0; // Restrictions if (Def->NoHorizontalMove) xdir=0; // Dig free target area C4PropList* pActionDef = GetAction(); if (pActionDef) if (pActionDef->GetPropertyInt(P_DigFree)) { int ctcox, ctcoy; // Shape size square if (pActionDef->GetPropertyInt(P_DigFree)==1) { ctcox=fixtoi(fix_x+xdir); ctcoy=fixtoi(fix_y+ydir); ::Landscape.DigFreeRect(ctcox+Shape.GetX(),ctcoy+Shape.GetY(),Shape.Wdt,Shape.Hgt,this); } // Free size round (variable size) else { ctcox=fixtoi(fix_x+xdir); ctcoy=fixtoi(fix_y+ydir); int32_t rad = pActionDef->GetPropertyInt(P_DigFree); if (Con<FullCon) rad = rad*6*Con/5/FullCon; ::Landscape.DigFree(ctcox,ctcoy-1,rad,this); } } // store previous movement and ocf C4Real oldxdir(xdir), oldydir(ydir); uint32_t old_ocf = OCF; bool fMoved = false; C4Real new_x = fix_x + xdir; C4Real new_y = fix_y + ydir; SideBounds(new_x); if (!Action.t_attach) // Unattached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = { // Horizontal movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Move to target while (fixtoi(new_x) != fixtoi(fix_x)) { // Next step int step = Sign(new_x - fix_x); uint32_t border_hack_contacts = 0; iContact=ContactCheck(GetX() + step, GetY(), &border_hack_contacts); if (iContact || border_hack_contacts) { fAnyContact=true; iContacts |= t_contact | border_hack_contacts; } if (iContact) { // Abort horizontal movement new_x = fix_x; // Vertical redirection (always) RedirectForce(xdir,ydir,-1); ApplyFriction(ydir,ContactVtxFriction(this)); } else // Free horizontal movement { DoMotion(step, 0); fMoved = true; } } // Vertical movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Movement target new_y = fix_y + ydir; // Movement bounds (vertical) VerticalBounds(new_y); // Move to target while (fixtoi(new_y) != fixtoi(fix_y)) { // Next step int step = Sign(new_y - fix_y); if ((iContact=ContactCheck(GetX(), GetY() + step, nullptr, ydir > 0))) { fAnyContact=true; iContacts |= t_contact; new_y = fix_y; // Vertical contact horizontal friction ApplyFriction(xdir,ContactVtxFriction(this)); // Redirection slide or rotate if (!ContactVtxCNAT(this,CNAT_Left)) RedirectForce(ydir,xdir,-1); else if (!ContactVtxCNAT(this,CNAT_Right)) RedirectForce(ydir,xdir,+1); else { // living things are always capable of keeping their rotation if (OCF & OCF_Rotate) if (iContact==1) if (!Alive) { RedirectForce(ydir,rdir,-ContactVtxWeight(this)); fRedirectYR=1; } ydir=0; } } else // Free vertical movement { DoMotion(0,step); fMoved = true; } } } if (Action.t_attach) // Attached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = { VerticalBounds(new_y); // Move to target do { // Set next step target int step_x = 0, step_y = 0; if (fixtoi(new_x) != GetX()) step_x = Sign(fixtoi(new_x) - GetX()); else if (fixtoi(new_y) != GetY()) step_y = Sign(fixtoi(new_y) - GetY()); int32_t ctx = GetX() + step_x; int32_t cty = GetY() + step_y; // Attachment check if (!Shape.Attach(ctx,cty,Action.t_attach)) fNoAttach=1; else { // Attachment change to ctx/cty overrides target if (ctx != GetX() + step_x) { xdir = Fix0; new_x = itofix(ctx); } if (cty != GetY() + step_y) { ydir = Fix0; new_y = itofix(cty); } } // Contact check & evaluation uint32_t border_hack_contacts = 0; iContact=ContactCheck(ctx,cty,&border_hack_contacts); if (iContact || border_hack_contacts) { fAnyContact=true; iContacts |= border_hack_contacts | t_contact; } if (iContact) { // Abort movement if (ctx != GetX()) { ctx = GetX(); new_x = fix_x; } if (cty != GetY()) { cty = GetY(); new_y = fix_y; } } DoMotion(ctx - GetX(), cty - GetY()); fMoved = true; } while (fixtoi(new_x) != GetX() || fixtoi(new_y) != GetY()); } if(fix_x != new_x || fix_y != new_y) { fMoved = true; if (pSolidMaskData) pSolidMaskData->Remove(true); fix_x = new_x; fix_y = new_y; } // Rotation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (OCF & OCF_Rotate && !!rdir) { C4Real target_r = fix_r + rdir * 5; // Rotation limit if (Def->Rotateable>1) { if (target_r > itofix(Def->Rotateable)) { target_r = itofix(Def->Rotateable); rdir=0; } if (target_r < itofix(-Def->Rotateable)) { target_r = itofix(-Def->Rotateable); rdir=0; } } int32_t ctx=GetX(); int32_t cty=GetY(); // Move to target while (fixtoi(fix_r) != fixtoi(target_r)) { // Save step undos C4Real lcobjr = fix_r; C4Shape lshape=Shape; // Try next step fix_r += Sign(target_r - fix_r); UpdateShape(); // attached rotation: rotate around attachment pos if (Action.t_attach && !fNoAttach) { // more accurately, attachment should be evaluated by a rotation around the attachment vertex // however, as long as this code is only used for some surfaces adjustment for large vehicles, // it's enough to assume rotation around the center ctx=GetX(); cty=GetY(); // evaluate attachment, but do not bother about attachment loss // that will then be done in next execution cycle Shape.Attach(ctx,cty,Action.t_attach); } // check for contact if ((iContact=ContactCheck(ctx,cty))) // Contact { fAnyContact=true; iContacts |= t_contact; // Undo step and abort movement Shape=lshape; target_r = fix_r = lcobjr; // last UpdateShape-call might have changed sector lists! UpdatePos(); // Redirect to GetY() if (iContact==1) if (!fRedirectYR) RedirectForce(rdir,ydir,-1); // Stop rotation rdir=0; } else { fTurned=1; if (ctx != GetX() || cty != GetY()) { fix_x = itofix(ctx); fix_y = itofix(cty); } } } // Circle bounds if (target_r < -FixHalfCircle) { target_r += FixFullCircle; } if (target_r > +FixHalfCircle) { target_r -= FixFullCircle; } fix_r = target_r; } // Reput solid mask if moved by motion if (fMoved || fTurned) UpdateSolidMask(true); // Misc checks =========================================================================================== // InLiquid check // this equals C4Object::UpdateLiquid, but the "fNoAttach=false;"-line if (IsInLiquidCheck()) // In Liquid { if (!InLiquid) // Enter liquid { if (OCF & OCF_HitSpeed2) if (Mass>3) Splash(GetX(),GetY()+1,std::min(Shape.Wdt*Shape.Hgt/10,20),this); fNoAttach=false; InLiquid=1; } } else // Out of liquid { if (InLiquid) // Leave liquid InLiquid=0; } // Contact Action if (fAnyContact) { t_contact = iContacts; ContactAction(); } // Attachment Loss Action if (fNoAttach) NoAttachAction(); // Movement Script Execution if (fAnyContact) { C4AulParSet pars(C4VInt(fixtoi(oldxdir, 100)), C4VInt(fixtoi(oldydir, 100))); if (old_ocf & OCF_HitSpeed1) Call(PSF_Hit, &pars); if (old_ocf & OCF_HitSpeed2) Call(PSF_Hit2, &pars); if (old_ocf & OCF_HitSpeed3) Call(PSF_Hit3, &pars); } // Rotation gfx if (fTurned) UpdateFace(true); else // pos changed? if (fMoved) UpdatePos(); }
Vector_double stf::deconvolve(const Vector_double& data, const Vector_double& templ, int SR, double hipass, double lopass, stfio::ProgressInfo& progDlg) { bool skipped = false; progDlg.Update( 0, "Starting deconvolution...", &skipped ); if (data.size()<=0 || templ.size() <=0 || templ.size() > data.size()) { std::out_of_range e("subscript out of range in stf::filter()"); throw e; } /* pad templ */ Vector_double templ_padded(data.size()); std::copy(templ.begin(), templ.end(), templ_padded.begin()); if (templ.size() < templ_padded.size()) { std::fill(templ_padded.begin()+templ.size(), templ_padded.end(), 0); } Vector_double data_return(data.size()); if (skipped) { data_return.resize(0); return data_return; } double *in_data, *in_templ_padded; //fftw_complex is a double[2]; hence, out is an array of //double[2] with out[n][0] being the real and out[n][1] being //the imaginary part. fftw_complex *out_data, *out_templ_padded; fftw_plan p_data, p_templ, p_inv; //memory allocation as suggested by fftw: in_data =(double *)fftw_malloc(sizeof(double) * data.size()); out_data = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * ((int)(data.size()/2)+1)); in_templ_padded =(double *)fftw_malloc(sizeof(double) * templ_padded.size()); out_templ_padded = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * ((int)(templ_padded.size()/2)+1)); std::copy(data.begin(), data.end(), &in_data[0]); std::copy(templ_padded.begin(), templ_padded.end(), &in_templ_padded[0]); //plan the ffts and execute them: p_data =fftw_plan_dft_r2c_1d((int)data.size(), in_data, out_data, FFTW_ESTIMATE); fftw_execute(p_data); p_templ =fftw_plan_dft_r2c_1d((int)templ_padded.size(), in_templ_padded, out_templ_padded, FFTW_ESTIMATE); fftw_execute(p_templ); double SI=1.0/SR; //the sampling interval progDlg.Update( 25, "Performing deconvolution...", &skipped ); if (skipped) { data_return.resize(0); return data_return; } Vector_double f_c(1); for (std::size_t n_point=0; n_point < (unsigned int)(data.size()/2)+1; ++n_point) { /* highpass filter */ double f = n_point / (data.size()*SI); double rslt_hi = 1.0; if (hipass > 0) { f_c[0] = hipass; rslt_hi = 1.0-fgaussColqu(f, f_c); } /* lowpass filter */ double rslt_lo = 1.0; if (lopass > 0) { f_c[0] = lopass; rslt_lo= fgaussColqu(f, f_c); } /* do the division in place */ double a = out_data[n_point][0]; double b = out_data[n_point][1]; double c = out_templ_padded[n_point][0]; double d = out_templ_padded[n_point][1]; double mag2 = c*c + d*d; out_data[n_point][0] = rslt_hi * rslt_lo * (a*c + b*d)/mag2; out_data[n_point][1] = rslt_hi * rslt_lo * (b*c - a*d)/mag2; } //do the reverse fft: p_inv = fftw_plan_dft_c2r_1d((int)data.size(),out_data, in_data, FFTW_ESTIMATE); fftw_execute(p_inv); //fill the return array, adding the offset, and scaling by data.size() //(because fftw computes an unnormalized transform): for (std::size_t n_point=0; n_point < data.size(); ++n_point) { data_return[n_point]= in_data[n_point]/data.size(); } fftw_destroy_plan(p_data); fftw_destroy_plan(p_templ); fftw_destroy_plan(p_inv); fftw_free(in_data); fftw_free(out_data); fftw_free(in_templ_padded); fftw_free(out_templ_padded); progDlg.Update( 50, "Computing data histogram...", &skipped ); if (skipped) { data_return.resize(0); return data_return; } int nbins = int(data_return.size()/500.0); std::map<double, int> histo = histogram(data_return, nbins); double max_value = -1; double max_time = 0; double maxhalf_time = 0; Vector_double histo_fit(0); for (std::map<double,int>::const_iterator it=histo.begin(); it != histo.end(); ++it) { if (it->second > max_value) { max_value = it->second; max_time = it->first; } histo_fit.push_back(it->second); #ifdef _STFDEBUG std::cout << it->first << "\t" << it->second << std::endl; #endif } for (std::map<double,int>::const_iterator it=histo.begin(); it != histo.end(); ++it) { if (it->second > 0.5*max_value) { maxhalf_time = it->first; break; } } maxhalf_time = fabs(max_time-maxhalf_time); progDlg.Update( 75, "Fitting Gaussian...", &skipped ); if (skipped) { data_return.resize(0); return data_return; } /* Fit Gaussian to histogram */ Vector_double opts = LM_default_opts(); std::string info; int warning; std::vector< stf::storedFunc > funcLib = stf::GetFuncLib(); double interval = (++histo.begin())->first-histo.begin()->first; /* Initial parameter guesses */ Vector_double pars(3); pars[0] = max_value; pars[1] = (max_time - histo.begin()->first); pars[2] = maxhalf_time *sqrt(2.0)/2.35482; #ifdef _STFDEBUG std::cout << "nbins: " << nbins << std::endl; std::cout << "initial values:" << std::endl; for (std::size_t np=0; np<pars.size(); ++np) { std::cout << pars[np] << std::endl; } #endif #ifdef _STFDEBUG double chisqr = #endif lmFit(histo_fit, interval, funcLib[funcLib.size()-1], opts, true, pars, info, warning ); #ifdef _STFDEBUG std::cout << chisqr << "\t" << interval << std::endl; std::cout << "final values:" << std::endl; for (std::size_t np=0; np<pars.size(); ++np) { std::cout << pars[np] << std::endl; } #endif double sigma = pars[2]/sqrt(2.0); /* return data in terms of sigma */ for (std::size_t n_point=0; n_point < data.size(); ++n_point) { data_return[n_point] /= sigma; } progDlg.Update( 100, "Done.", &skipped ); return data_return; }
int main() { /// Header cerr << "SOFTSUSY" << SOFTSUSY_VERSION << " Ben Allanach, Markus Bernhardt 2009\n"; cerr << "If you use SOFTSUSY, please refer to B.C. Allanach, "; cerr << "Comput. Phys. Commun. 143 (2002) 305, hep-ph/0104145;\n"; cerr << "For RPV aspects, B.C. Allanach and M.A. Bernhardt, "; cerr << "Comp. Phys. Commun. 181 (2010) 232, "; cerr << "arXiv:0903.1805.\n"; cerr << "For RPV neutrino masses, B.C. Allanach, M. Hanussek and S. Kom,\n"; cerr << "Comput. Phys. Commun. 183 (2012) 785, arXiv:1109.3735 [hep-ph]\n"; /// Sets up exception handling signal(SIGFPE, FPE_ExceptionHandler); /// MIXING=1: CKM-mixing in up-sector MIXING = 1; /// Apply SUSY breaking conditions at GUT scale, where g_1=g_2 bool gaugeUnification = true; /// Sets format of output: 3 decimal places outputCharacteristics(3); /// "try" catches errors in main program and prints them out try { QedQcd oneset; ///< See "lowe.h" for default parameter definitions oneset.toMz(); ///< Runs SM fermion masses to MZ /// Guess at GUT scale double mxGuess = 2.e16; /// Close to scenario IH S2 from arXiv:1106.4338 int sgnMu = 1; double tanb = 20., a0 = 924., m12 = 500., m0 = 100.; /// Define RpvNeutrino object RpvNeutrino kw; /// Set the CKM angles in Wolfenstein parameterisation double lambda = 0.2272, aCkm = 0.818, rhobar = 0.221, etabar = 0.34; kw.setAngles(lambda, aCkm, rhobar, etabar); /// Set the GUT scale RPV SUSY couplings kw.setLamPrime(1, 1, 1, 0.0395); kw.setLamPrime(2, 1, 1, -0.018); kw.setLamPrime(3, 1, 1, 0.019); kw.setLamPrime(1, 3, 3, 3.0e-5); kw.setLamPrime(2, 3, 3, 3.2e-5); kw.setLamPrime(3, 3, 3, -3.5e-5); /// Store inputs into one vector DoubleVector pars(3); pars(1) = m0; pars(2) = m12; pars(3) = a0; /// Outputs the RPV couplings required into the vector pars used by lowOrg kw.rpvDisplay(pars); /// Makes sure the neutrino mass ordering will be as expected in inverted /// hierarchy output. If required, must be set before lowOrg is called kw.setInvertedOutput(); /// Main driver routine: do the calculation double mgut = kw.lowOrg(rpvSugraBcs, mxGuess, pars, sgnMu, tanb, oneset, gaugeUnification); /// Output the results in SLHA2 format double qMax = 0.; char * modelIdent = (char *)"sugra"; int numPoints = 1; bool ewsbBCscale = false; kw.lesHouchesAccordOutput(cout, modelIdent, pars, sgnMu, tanb, qMax, numPoints, mgut, ewsbBCscale); } catch(const string & a) { cout << a; exit(-1); } catch(const char *a) { cout << a; exit(-1); } }
int main() { /// Sets up exception handling signal(SIGFPE, FPE_ExceptionHandler); bool gaugeUnification = true, ewsbBCscale = false; /// Do we include 2-loop RGEs of *all* scalar masses and A-terms, or only the /// scalar mass Higgs parameters? (Other quantities all 2-loop anyway): the /// default in SOFTSUSY 3 is to include all 2-loop terms, except for RPV, /// which is already slow and calculated to less accuracy than the R-parity /// conserving version bool INCLUDE_2_LOOP_SCALAR_CORRECTIONS = false; /// Sets format of output: 6 decimal places outputCharacteristics(6); /// Header cerr << "SOFTSUSY" << SOFTSUSY_VERSION << " Ben Allanach, Markus Bernhardt 2009\n"; cerr << "If you use SOFTSUSY, please refer to B.C. Allanach, "; cerr << "Comput. Phys. Commun. 143 (2002) 305, hep-ph/0104145;\n"; cerr << "For RPV aspects, B.C. Allanach and M.A. Bernhardt, "; cerr << "Comp. Phys. Commun. 181 (2010) 232, "; cerr << "arXiv:0903.1805.\n\n"; /// "try" catches errors in main program and prints them out try { /// Contains default quark and lepton masses and gauge coupling /// information QedQcd oneset; ///< See "lowe.h" for default parameter definitions oneset.toMz(); ///< Runs SM fermion masses to MZ /// Print out the Standard Model data being used, as well as quark mixing /// assumption and the numerical accuracy of the solution cerr << "Low energy data in SOFTSUSY: MIXING=" << MIXING << " TOLERANCE=" << TOLERANCE << endl << oneset << endl; /// set parameters double tanb = 10.; int sgnMu = 1; double mgutGuess = 2.e16; double a0 = -100.0, m12 = 250.0, m0 = 100.0; /// number of points for scan const int numPoints = 20; /// parameter region double Start = 0. , End = 0.144; DoubleVector pars(3); /// set basic entries in pars pars(1) = m0; pars(2) = m12; pars(3) = a0; cout << "l'_{331}(M_X) m_snutau # Problem flag" << endl; /// loop over parameter space region int ii; for (ii=0; ii<=numPoints; ii++){ double lambda = Start + ((End - Start) / double(numPoints) * double(ii)); /// define rpvSoftsusy object RpvSoftsusy kw; /// set lambda coupling at mgut kw.setLamPrime(3, 3, 1, lambda); /// output parameters into double vector pars used by lowOrg kw.rpvDisplay(pars); /// generate spectrum in RpvSoftsusy object kw kw.lowOrg(rpvSugraBcs, mgutGuess, pars, sgnMu, tanb, oneset, gaugeUnification, ewsbBCscale); /// outputs for this scan cout << lambda << " " << kw.displayPhys().msnu.display(3) << " # " << kw.displayProblem() << endl; } } catch(const string & a) { cout << a; exit(-1); } catch(const char *a) { printf(a); exit(-1); } }
status_t MotoCameraWrapper::setParameters(const CameraParameters& params) { CameraParameters pars(params.flatten()); String8 oldFlashMode = mFlashMode; String8 sceneMode; status_t retval; int width, height; char buf[10]; bool isWide; /* * getInt returns -1 if the value isn't present and 0 on parse failure, * so if it's larger than 0, we can be sure the value was parsed properly */ mVideoMode = pars.getInt("cam-mode") > 0; pars.remove("cam-mode"); pars.getPreviewSize(&width, &height); isWide = width == 848 && height == 480; if (isWide && !mVideoMode) pars.setPreviewFrameRate(24); if (mCameraType == DEFY_RED && mVideoMode) pars.setPreviewFrameRate(24); sceneMode = pars.get(CameraParameters::KEY_SCENE_MODE); if (sceneMode != CameraParameters::SCENE_MODE_AUTO) { /* The lib doesn't seem to update the flash mode correctly when a scene * mode is set, so we need to do it here. Also do focus mode, just do * be on the safe side. */ pars.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO); if (sceneMode == CameraParameters::SCENE_MODE_PORTRAIT || sceneMode == CameraParameters::SCENE_MODE_NIGHT_PORTRAIT) { pars.set(CameraParameters::KEY_FLASH_MODE, CameraParameters::FLASH_MODE_AUTO); } else { pars.set(CameraParameters::KEY_FLASH_MODE, CameraParameters::FLASH_MODE_OFF); } } mFlashMode = pars.get(CameraParameters::KEY_FLASH_MODE); float exposure = pars.getFloat(CameraParameters::KEY_EXPOSURE_COMPENSATION); /* Exposure-compensation comes multiplied in the -9...9 range, while * we need it in the -3...3 range -> adjust for that */ exposure /= 3; /* format the setting in a way the lib understands */ bool even = (exposure - round(exposure)) < 0.05; snprintf(buf, sizeof(buf), even ? "%.0f" : "%.2f", exposure); pars.set("mot-exposure-offset", buf); /* kill off the original setting */ pars.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); retval = mMotoInterface->setParameters(pars); if (oldFlashMode != mFlashMode) { toggleTorchIfNeeded(); } return retval; }
int main( int argc, char *argv[] ) { if ( argc < 3 ) { std::cout << "Usage: ./compileSHE <domain.pddl> <task.pddl>\n"; std::cout << "Writes domain file to standard output and instance file to standard error\n"; exit( 1 ); } d = new Domain( argv[1] ); ins = new Instance( *d, argv[2] ); // Generate dependency graph among actions and identify durations and depths graph g( d->actions.size() ); for ( unsigned i = 0; i < d->actions.size(); ++i ) { for ( unsigned j = 0; j < d->actions.size(); ++j ) if ( i != j ) detectDependency( i, j, g ); } g.computeDurations(); g.computeDepths(); // Identify contexts that are threatened by contents // RIGHT NOW PRE & EFF ASSUME POSITIVE PRECONDITIONS !!! int maxCount = 0; for ( unsigned i = 0; i < d->actions.size(); ++i ) { maxCount = MAX( maxCount, *g.depths[i].rbegin() ); for ( unsigned j = 0; j < get( i )->pre_o->conds.size(); ++j ) { Ground * pre = dynamic_cast< Ground * >( get( i )->pre_o->conds[j] ); if ( pre ) { int k = d->preds.index( pre->name ); if ( k >= 0 && isPre( i, k, g ) ) pres.insert( k ); } } } // Create classical domain cd = new Domain; cd->name = d->name; cd->equality = d->equality; cd->condeffects = cd->typed = true; cd->cons = d->cons || ( maxCount && pres.size() ) || g.subtractionPairs.size(); cd->equality = d->equality; // Add types cd->setTypes( d->copyTypes() ); if ( maxCount && pres.size() ) cd->createType( "COUNT" ); if ( g.subtractionPairs.size() ) cd->createType( "TIME" ); // Add constants StringVec counts; for ( int i = 0; maxCount && pres.size() && i <= maxCount; ++i ) { std::stringstream ss; ss << "COUNT" << i; counts.push_back( ss.str() ); cd->createConstant( counts[i], "COUNT" ); } StringVec times; for ( unsigned i = 0; g.subtractionPairs.size() && i < g.durationMap.size(); ++i ) { std::stringstream ss; ss << "TIME" << i; times.push_back( ss.str() ); cd->createConstant( times[i], "TIME" ); } // Add predicates for ( unsigned i = 0; i < d->preds.size(); ++i ) { StringVec pars = d->typeList( d->preds[i] ); cd->createPredicate( d->preds[i]->name, pars ); if ( pres.find( i ) != pres.end() ) { pars.push_back( "COUNT" ); cd->createPredicate( "COUNT-" + d->preds[i]->name, pars ); } } StringVec stacks( 1, "EMPTYSTACK" ); cd->createPredicate( stacks[0] ); for ( int i = 1; i <= maxCount; ++i ) { std::stringstream ss; ss << "STACK" << i; stacks.push_back( ss.str() ); cd->createPredicate( stacks[i] ); cd->createPredicate( stacks[i] + "-REMAINING", StringVec( 1, "TIME" ) ); cd->createPredicate( stacks[i] + "-INCREASE", StringVec( 1, "TIME" ) ); cd->createPredicate( stacks[i] + "-DECREASE" ); cd->createPredicate( stacks[i] + "-CONTINUE", StringVec( 1, "TIME" ) ); } for ( unsigned i = 0; i < d->actions.size(); ++i ) for ( IntSet::iterator j = g.depths[i].begin(); g.outgoing( i ) && j != g.depths[i].end(); ++j ) { std::stringstream ss; ss << "STACK" << *j + 1 << "-" << d->actions[i]->name; cd->createPredicate( ss.str(), d->typeList( d->actions[i] ) ); } if ( counts.size() ) cd->createPredicate( "CONSECUTIVE", StringVec( 2, "COUNT" ) ); if ( times.size() ) cd->createPredicate( "SUBTRACT", StringVec( 3, "TIME" ) ); // Currently does NOT add functions // for ( unsigned i = 0; i < d->funcs.size(); ++i ) // cd->createFunction( d->funcs[i]->name, d->funcs[i]->returnType, d->typeList( d->funcs[i] ) ); // Add actions for ( unsigned i = 0; i < d->actions.size(); ++i ) // DOES NOT CURRENTLY IMPLEMENT COUNT MECHANISM !!! for ( IntSet::iterator j = g.depths[i].begin(); j != g.depths[i].end(); ++j ) if ( g.outgoing( i ) ) { // Action is an envelope: compile into push and pop action // Push action std::string name = "PUSH-" + d->actions[i]->name; unsigned size = d->actions[i]->params.size(); Action * push = cd->createAction( name, d->typeList( d->actions[i] ) ); //std::cout << "Creating action " << name << "\n"; // ONLY DEALS WITH POSITIVE PRECONDITIONS HERE !!! cd->setPre( name, d->actions[i]->pre ); for ( unsigned k = 0; k < get( i )->pre_o->conds.size(); ++k ) { Ground * pre = dynamic_cast< Ground * >( get( i )->pre_o->conds[k] ); if ( pre && !includes( 0, pre, ( And * )get( i )->pre ) && !includes( 0, pre, ( And * )get( i )->eff ) ) cd->addPre( 0, name, pre->name, pre->params ); // if precon is not positive, just copy it if ( !pre ) ( ( And * )push->pre )->add( get( i )->pre_o->conds[k]->copy( *cd ) ); } cd->addPre( 0, name, stacks[*j] ); cd->setEff( name, d->actions[i]->eff ); cd->addEff( 1, name, stacks[*j] ); if ( *j ) cd->addEff( 0, name, stacks[*j] + "-INCREASE", IntVec( 1, cd->constantIndex( times[g.durationMap[d->actions[i]->duration()]], "TIME" ) ) ); else cd->addEff( 0, name, stacks[1] ); cd->addEff( 0, name, stacks[*j + 1] + "-" + d->actions[i]->name, incvec( 0, size ) ); cd->addEff( 0, name, stacks[*j + 1] + "-REMAINING", IntVec( 1, cd->constantIndex( times[g.durationMap[d->actions[i]->duration()]], "TIME" ) ) ); // Pop action name = "POP-" + d->actions[i]->name; cd->createAction( name, d->typeList( d->actions[i] ) ); //std::cout << "Creating action " << name << "\n"; // ONLY DEALS WITH POSITIVE PRECONDITIONS HERE !!! cd->setPre( name, get( i )->pre_e ); for ( unsigned k = 0; k < get( i )->pre_o->conds.size(); ++k ) { Ground * h = dynamic_cast< Ground * >( get( i )->pre_o->conds[k] ); if ( h && !includes( 0, h, get( i )->pre_e ) ) cd->addPre( 0, name, h->name, h->params ); } cd->addPre( 0, name, stacks[*j + 1] ); cd->addPre( 0, name, stacks[*j + 1] + "-" + d->actions[i]->name, incvec( 0, size ) ); cd->setEff( name, get( i )->eff_e ); cd->addEff( 0, name, stacks[*j + 1] + "-DECREASE" ); cd->addEff( 1, name, stacks[*j + 1] ); cd->addEff( 1, name, stacks[*j + 1] + "-" + d->actions[i]->name, incvec( 0, size ) ); } else { // Action is not an envelope: compile into compressed action std::string name = "DO-" + d->actions[i]->name; Action * doit = cd->createAction( name, d->typeList( d->actions[i] ) ); //std::cout << "Creating action " << name << "\n"; // ONLY DEALS WITH POSITIVE PRECONDITIONS HERE !!! cd->setPre( name, d->actions[i]->pre ); for ( unsigned k = 0; k < get( i )->pre_o->conds.size(); ++k ) { Ground * pre = dynamic_cast< Ground * >( get( i )->pre_o->conds[k] ); if ( pre && !includes( 0, pre, ( And * )get( i )->pre ) && !includes( 0, pre, ( And * )get( i )->eff ) ) cd->addPre( 0, name, pre->name, pre->params ); // if precon is not positive, just copy it if ( !pre ) ( ( And * )doit->pre )->add( get( i )->pre_o->conds[k]->copy( *cd ) ); } for ( unsigned k = 0; k < get( i )->pre_e->conds.size(); ++k ) { Ground * h = ( Ground * )get( i )->pre_e->conds[k]; if ( !includes( 0, h, ( And * )get( i )->pre ) && !includes( 0, h, ( And * )get( i )->eff ) ) cd->addPre( 0, name, h->name, h->params ); } cd->addPre( 0, name, stacks[*j] ); cd->setEff( name, get( i )->eff_e ); GroundVec add = get( i )->addEffects(); for ( unsigned k = 0; k < add.size(); ++k ) if ( !includes( 1, add[k], get( i )->eff_e ) ) cd->addEff( 0, name, add[k]->name, add[k]->params ); GroundVec del = get( i )->deleteEffects(); for ( unsigned k = 0; k < del.size(); ++k ) if ( !includes( 0, del[k], get( i )->eff_e ) ) cd->addEff( 1, name, del[k]->name, del[k]->params ); if ( *j ) { cd->addEff( 1, name, stacks[*j] ); cd->addEff( 0, name, stacks[*j] + "-CONTINUE", IntVec( 1, cd->constantIndex( times[g.durationMap[d->actions[i]->duration()]], "TIME" ) ) ); } } for ( int i = 1; i <= maxCount; ++i ) { if ( i < maxCount ) { // Increase action std::stringstream ss; ss << "INCREASE" << i; std::string name = ss.str(); cd->createAction( name, StringVec( 3, "TIME" ) ); cd->addPre( 0, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addPre( 0, name, stacks[i] + "-INCREASE", incvec( 2, 3 ) ); cd->addPre( 0, name, "SUBTRACT", incvec( 0, 3 ) ); cd->addEff( 0, name, stacks[i + 1] ); cd->addEff( 1, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addEff( 0, name, stacks[i] + "-REMAINING", incvec( 1, 2 ) ); cd->addEff( 1, name, stacks[i] + "-INCREASE", incvec( 2, 3 ) ); } // Decrease action std::stringstream ss; ss << "DECREASE" << i; std::string name = ss.str(); cd->createAction( name, StringVec( 1, "TIME" ) ); cd->addPre( 0, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addPre( 0, name, stacks[i] + "-DECREASE" ); cd->addEff( 0, name, stacks[i - 1] ); cd->addEff( 1, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addEff( 1, name, stacks[i] + "-DECREASE" ); // Continue action std::stringstream ss2; ss2 << "CONTINUE" << i; name = ss2.str(); cd->createAction( name, StringVec( 3, "TIME" ) ); cd->addPre( 0, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addPre( 0, name, stacks[i] + "-CONTINUE", incvec( 2, 3 ) ); cd->addPre( 0, name, "SUBTRACT", incvec( 0, 3 ) ); cd->addEff( 0, name, stacks[i] ); cd->addEff( 1, name, stacks[i] + "-REMAINING", incvec( 0, 1 ) ); cd->addEff( 0, name, stacks[i] + "-REMAINING", incvec( 1, 2 ) ); cd->addEff( 1, name, stacks[i] + "-CONTINUE", incvec( 2, 3 ) ); } cd->PDDLPrint( std::cout ); cins = new Instance( *cd ); cins->name = ins->name; // create initial state for ( unsigned i = 0; i < ins->init.size(); ++i ) if ( d->preds.index( ins->init[i]->name ) >= 0 ) cins->addInit( ins->init[i]->name, d->objectList( ins->init[i] ) ); cins->addInit( stacks[0] ); for ( unsigned i = 1; i < counts.size(); ++i ) { StringVec pars( 1, counts[i - 1] ); pars.push_back( counts[i] ); cins->addInit( "CONSECUTIVE", pars ); } for ( DoublePairSet::iterator i = g.subtractionPairs.begin(); i != g.subtractionPairs.end(); ++i ) { StringVec pars( 1, times[g.durationMap[i->first]] ); pars.push_back( times[g.durationMap[i->first - i->second]] ); pars.push_back( times[g.durationMap[i->second]] ); cins->addInit( "SUBTRACT", pars ); } // create goal state for ( unsigned i = 0; i < ins->goal.size(); ++i ) cins->addGoal( ins->goal[i]->name, d->objectList( ins->goal[i] ) ); cins->addGoal( stacks[0] ); cins->PDDLPrint( std::cerr ); delete cins; delete cd; delete ins; delete d; }
// read config and load it into our structs static void getcfg() { LocalConfig lcfg; if (! lcfg.read(localcfgfile)) { fatal("read %s failed", localcfgfile); } ownnodeid = lcfg._ownNodeId; debug("ownnodeid = %d", ownnodeid); InitConfigFileParser pars(initcfgfile); Config icfg; if (! pars.getConfig(icfg)) { fatal("parse %s failed", initcfgfile); } Properties* ccfg = icfg.getConfig(ownnodeid); if (ccfg == 0) { const char* err = "unknown error"; fatal("getConfig: %s", err); } ccfg->put("NodeId", ownnodeid); ccfg->put("NodeType", "MGM"); if (! ccfg->get("NoOfNodes", &Node::count)) { properr(ccfg, "NoOfNodes", -1); } debug("Node::count = %d", Node::count); Node::list = new Node[Node::count]; for (unsigned i = 0; i < Node::count; i++) { Node& node = Node::list[i]; const Properties* nodecfg; if (! ccfg->get("Node", 1+i, &nodecfg)) { properr(ccfg, "Node", 1+i); } const char* type; if (! nodecfg->get("Type", &type)) { properr(nodecfg, "Type"); } if (strcmp(type, "MGM") == 0) { node.type = Node::MGM; } else if (strcmp(type, "DB") == 0) { node.type = Node::DB; } else if (strcmp(type, "API") == 0) { node.type = Node::API; } else { fatal("prop %s_%d bad Type = %s", "Node", 1+i, type); } if (! nodecfg->get("NodeId", &node.id)) { properr(nodecfg, "NodeId"); } debug("node id=%d type=%d", node.id, node.type); } IPCConfig ipccfg(ccfg); if (ipccfg.init() != 0) { fatal("ipccfg init failed"); } if (! ccfg->get("NoOfConnections", &Conn::count)) { properr(ccfg, "NoOfConnections"); } debug("Conn::count = %d", Conn::count); Conn::list = new Conn[Conn::count]; for (unsigned i = 0; i < Conn::count; i++) { Conn& conn = Conn::list[i]; const Properties* conncfg; if (! ccfg->get("Connection", i, &conncfg)) { properr(ccfg, "Connection", i); } unsigned n; if (! conncfg->get("NodeId1", &n)) { properr(conncfg, "NodeId1"); } if ((conn.node[0] = Node::find(n)) == 0) { fatal("node %d not found", n); } if (! conncfg->get("NodeId2", &n)) { properr(conncfg, "NodeId2"); } if ((conn.node[1] = Node::find(n)) == 0) { fatal("node %d not found", n); } if (! conncfg->get("PortNumber", &conn.port)) { properr(conncfg, "PortNumber"); } conn.proxy = 0; const char* proxy; if (conncfg->get("Proxy", &proxy)) { conn.proxy = atoi(proxy); if (conn.proxy > 0) { Conn::proxycount++; } } sprintf(conn.info, "conn %d-%d", conn.node[0]->id, conn.node[1]->id); } }
int main() { /// Sets up exception handling signal(SIGFPE, FPE_ExceptionHandler); try { /// Sets format of output: 6 decimal places outputCharacteristics(6); cerr << "SOFTSUSY" << SOFTSUSY_VERSION << " test program, Ben Allanach 2002\n"; cerr << "If you use SOFTSUSY, please refer to B.C. Allanach,\n"; cerr << "Comput. Phys. Commun. 143 (2002) 305, hep-ph/0104145\n"; /// Parameters used: CMSSM parameters double m12 = 500., a0 = 0., mGutGuess = 2.0e16, tanb = 10.0, m0 = 125.; int sgnMu = 1; ///< sign of mu parameter int numPoints = 10; ///< number of scan points QedQcd oneset; ///< See "lowe.h" for default definitions parameters /// most important Standard Model inputs: you may change these and recompile double alphasMZ = 0.1187, mtop = 173.5, mbmb = 4.18; oneset.setAlpha(ALPHAS, alphasMZ); oneset.setPoleMt(mtop); oneset.setMbMb(mbmb); oneset.toMz(); ///< Runs SM fermion masses to MZ /// Print out the SM data being used, as well as quark mixing assumption and /// the numerical accuracy of the solution cout << "# Low energy data in SOFTSUSY: MIXING=" << MIXING << " TOLERANCE=" << TOLERANCE << endl << oneset << endl; /// Print out header line cout << "# tan beta mh mA mH0 mH+-\n"; int i; /// Set limits of tan beta scan double startTanb = 3.0, endTanb = 50.0; /// Cycle through different points in the scan for (i = 0; i<=numPoints; i++) { tanb = (endTanb - startTanb) / double(numPoints) * double(i) + startTanb; // set tan beta ready for the scan. /// Preparation for calculation: set up object and input parameters MssmSoftsusy r; DoubleVector pars(3); pars(1) = m0; pars(2) = m12; pars(3) = a0; bool uni = true; // MGUT defined by g1(MGUT)=g2(MGUT) /// Calculate the spectrum r.lowOrg(sugraBcs, mGutGuess, pars, sgnMu, tanb, oneset, uni); /// check the point in question is problem free: if so print the output if (!r.displayProblem().test()) cout << tanb << " " << r.displayPhys().mh0 << " " << r.displayPhys().mA0 << " " << r.displayPhys().mH0 << " " << r.displayPhys().mHpm << endl; else /// print out what the problem(s) is(are) cout << tanb << " " << r.displayProblem() << endl; } } catch(const string & a) { cout << a; } catch(const char * a) { cout << a; } catch(...) { cout << "Unknown type of exception caught.\n"; } exit(0); }