void CLuaCFGMenu::UpdateSelection(const gchar *var) { gtk_widget_hide(m_pInputField); gtk_widget_hide(m_pComboBox); gtk_widget_hide(m_pDirInputBox); const SEntry *entry = GetVariables()[var]; switch (entry->type) { case TYPE_STRING: gtk_entry_set_text(GTK_ENTRY(m_pInputField), entry->val.c_str()); gtk_widget_show(m_pInputField); break; case TYPE_DIR: gtk_entry_set_text(GTK_ENTRY(m_pDirInput), entry->val.c_str()); gtk_widget_show(m_pDirInputBox); break; case TYPE_BOOL: case TYPE_LIST: SetComboBox(var); gtk_widget_show(m_pComboBox); break; } }
OptError CGProblem::CreateApplicationOptimizer(OptimizeClass* &objfcn, NLP0* &func) { OptError error; int numVar = GetNumVar(); VariableList* variables = GetVariables(); AppLauncher* launcher = GetAppLauncher(); USERFCN0APP userFcn = &(launcher->run_app); INITFCNAPP initFcn = &(launcher->init_app); if ((variables->upperExists()) || (variables->lowerExists()) || (variables->linearExists()) || (variables->nonlinearExists())) { cout << "CG does not support constraints." << endl; cout << "Constraints being ignored" << endl; } FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn, launcher); myFunc->setIsExpensive(true); func = myFunc; objfcn = new OptCG(myFunc); error.value = 0; error.msg = "Success"; return error; }
char *GetVariable(int sid, char *name) { struct variable *v; char buf[MAX_LINE_SIZE]; for (v = GetVariables(sid); v->name != NULL; v++) { if (strcmp(v->name, name)==0) { if (strcmp(v->longname, "Status")!=0) { /* syslog(LOG_INFO, "Get variables: %s %s\n", v->name, name, nvram_safe_get_x(svcLinks[sid].serviceId, name)); */ return(nvram_safe_get_x(svcLinks[sid].serviceId, name)); } else { strcpy(buf, nvram_safe_get_f(v->argv[0], v->argv[1])); /*syslog(LOG_INFO, "Get variables from file: %s %s %s\n", v->argv[0], v->argv[1], buf); */ return(buf); } } } return(""); }
const char *CLuaCFGMenu::CurSelection() { const char *item = static_cast<const char *>(m_pVarListView->data(m_pVarListView->value())); if (!item || !*item || !GetVariables()[item]) return NULL; return item; }
void NewtonProblem::SetParameters(OptimizeClass* objfcn) { Problem::SetParameters(objfcn); DOMElement* searchXML = GetParameterXML(); VariableList* variables = GetVariables(); string gradMult, searchSize, maxBack; OptNewtonLike * objfcnNewt = (OptNewtonLike *) objfcn; if(searchType_ == trustPDS) { objfcnNewt->setSearchStrategy(TrustPDS); gradMult = XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult"))); if (gradMult != "") objfcnNewt->setGradMult(atof(gradMult.c_str())); searchSize = XMLString::transcode(searchXML->getAttribute(XMLString::transcode("searchSize"))); if (searchSize != "") objfcnNewt->setSearchSize(atoi(searchSize.c_str())); } else if (searchType_ == lineSearch) { objfcnNewt->setSearchStrategy(LineSearch); maxBack = XMLString::transcode(searchXML->getAttribute(XMLString::transcode("maxBTIter"))); if (maxBack != "") objfcnNewt->setMaxBacktrackIter(atoi(maxBack.c_str())); } else if (searchType_ == trustRegion) { if ((variables->upperExists()) || (variables->lowerExists())) { cout << "Newton with Trust Region does not support bounds." << endl; cout << "Using Line Search instead." << endl; objfcnNewt->setSearchStrategy(LineSearch); } else { objfcnNewt->setSearchStrategy(TrustRegion); gradMult = XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult"))); if (gradMult != "") objfcnNewt->setGradMult(atof(gradMult.c_str())); } } else { cerr << "Unrecognized search strategy type" << endl; exit(1); } }
OptError NewtonProblem::CreateApplicationOptimizer(OptimizeClass * &objfcn, NLP0 * &func) { OptError error; int numVar = GetNumVar(); VariableList* variables = GetVariables(); CompoundConstraint* constraints = 0; AppLauncher * launcher = GetAppLauncher(); USERFCN0APP userFcn = &(launcher->run_app); INITFCNAPP initFcn = &(launcher->init_app); if(userFcn == NULL) { error.value = -4; error.msg = "Error loading user function"; return error; } else if(initFcn == NULL) { error.value = -4; error.msg = "Error loading init function"; return error; } if ((variables->linearExists()) || (variables->nonlinearExists())) { cout << "Newton does not support linear or nonlinear constraints." << endl; cout << "Linear and nonlinear constraints being ignored." << endl; } if ((variables->upperExists()) || (variables->lowerExists())) { constraints = new CompoundConstraint(Constraint(variables->GetBoundConstraints())); } FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn, launcher, constraints); myFunc->setIsExpensive(true); if(searchType_ == trustPDS) myFunc->setSpecOption(NoSpec); func = myFunc; if ((variables->upperExists()) || (variables->lowerExists())) { objfcn = new OptBCQNewton(myFunc); } else { objfcn = new OptQNewton(myFunc); } error.value = 0; error.msg = "Success"; return error; }
void QueryAttributes::PrintSelf(ostream &os) { os << "\n" << GetName().c_str() << ": "; os << "selected variables: "; stringVector &v = GetVariables(); for (size_t i = 0; i < v.size(); i++) os << v[i].c_str() << " "; os << "\n"; os << "Results: <" << resultsMessage.c_str() << ">\n"; }
void EvnVarList::InsertVariable(const wxString& setName, const wxString& name, const wxString& value) { wxString actualSetName; DoGetSetVariablesStr(setName, actualSetName); EnvMap set = GetVariables(actualSetName, false, wxEmptyString, wxEmptyString); if(!set.Contains(name)) { set.Put(name, value); } m_envVarSets[actualSetName] = set.String(); }
void CLuaCFGMenu::CoreUpdateLanguage() { GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(m_pVarListView))); GtkTreeIter it; if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &it)) { do { gchar *var; gtk_tree_model_get(GTK_TREE_MODEL(store), &it, COLUMN_VAR, &var, -1); gtk_list_store_set(store, &it, COLUMN_TITLE, GetTranslation(var), COLUMN_DESC, GetTranslation(GetVariables()[var]->desc.c_str()), -1); g_free(var); } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &it)); } gtk_label_set(GTK_LABEL(m_pDirButtonLabel), GetTranslation("Browse")); std::string sel = CurSelection(); if (!sel.empty() && ((GetVariables()[sel]->type == TYPE_BOOL) || (GetVariables()[sel]->type == TYPE_LIST))) SetComboBox(sel); }
void CLuaCFGMenu::CoreAddVar(const char *name) { GtkTreeIter iter; GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(m_pVarListView))); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, COLUMN_TITLE, GetTranslation(name), COLUMN_DESC, GetTranslation(GetVariables()[name]->desc.c_str()), COLUMN_VAR, name, -1); if (m_bInitSelection) { m_bInitSelection = false; GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pVarListView)); gtk_tree_selection_select_iter(selection, &iter); } }
void CLuaCFGMenu::UpdateSelection() { const char *var = CurSelection(); if (!var) return; m_pInputField->hide(); m_pChoiceMenu->hide(); m_pDirInput->hide(); m_pBrowseButton->hide(); const SEntry *entry = GetVariables()[var]; switch(entry->type) { case TYPE_STRING: m_pInputField->value(entry->val.c_str()); m_pInputField->show(); break; case TYPE_DIR: m_pDirInput->value(entry->val.c_str()); m_pDirInput->show(); m_pBrowseButton->show(); break; case TYPE_LIST: case TYPE_BOOL: { m_pChoiceMenu->clear(); TOptionsType::size_type cur = 0, n = 0; for (TOptionsType::const_iterator it=entry->options.begin(); it!=entry->options.end(); it++) { m_pChoiceMenu->add(GetTranslation(it->c_str())); if (!cur && (*it == entry->val)) cur = n; n++; } if (m_pChoiceMenu->size()) m_pChoiceMenu->value(SafeConvert<int>(cur)); m_pChoiceMenu->show(); break; } } }
void CLuaCFGMenu::SetComboBox(const std::string &var) { GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(m_pComboBox))); gtk_list_store_clear(store); SEntry *entry = GetVariables()[var]; GtkTreeIter iter; for (TOptionsType::iterator it=entry->options.begin(); it!=entry->options.end(); it++) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, GetTranslation(it->c_str()), -1); if (*it == entry->val) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(m_pComboBox), &iter); } }
struct variable *LookupGroupVariables(int sid, char *groupName) { struct variable *v; /* Find group */ for (v = GetVariables(sid); v->name != NULL; v++) { if (strcmp(v->name, groupName)==0) { break; } } if (v->name==NULL||v->argv[0]==NULL) return NULL; return(v); }
void GusdOBJ_usdcamera::Register(OP_OperatorTable* table) { OP_Operator* op = new OP_Operator("pixar::usdcamera", "USD Camera", creator, GetTemplates(), #if UT_MAJOR_VERSION_INT >= 16 SOP_TABLE_NAME, #endif /* min inputs*/ 0, /* max inputs*/ 1, GetVariables()); op->setIconName("pxh_gusdIcon.png"); op->setOpTabSubMenuPath( "Pixar" ); table->addOperator(op); table->setOpFirstName("pixar::usdcamera", "usdcam"); }
void Layout::SerializeTo(SerializerElement & element) const { element.SetAttribute( "name", GetName()); element.SetAttribute( "mangledName", GetMangledName()); element.SetAttribute( "r", (int)GetBackgroundColorRed() ); element.SetAttribute( "v", (int)GetBackgroundColorGreen() ); element.SetAttribute( "b", (int)GetBackgroundColorBlue() ); element.SetAttribute( "title", GetWindowDefaultTitle()); element.SetAttribute( "oglFOV", oglFOV ); element.SetAttribute( "oglZNear", oglZNear ); element.SetAttribute( "oglZFar", oglZFar ); element.SetAttribute( "standardSortMethod", standardSortMethod); element.SetAttribute( "stopSoundsOnStartup", stopSoundsOnStartup); element.SetAttribute( "disableInputWhenNotFocused", disableInputWhenNotFocused); #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI) GetAssociatedLayoutEditorCanvasOptions().SerializeTo(element.AddChild("uiSettings")); #endif ObjectGroup::SerializeTo(GetObjectGroups(), element.AddChild("objectsGroups")); GetVariables().SerializeTo(element.AddChild("variables")); GetInitialInstances().SerializeTo(element.AddChild("instances")); SerializeObjectsTo(element.AddChild("objects")); gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events")); SerializerElement & layersElement = element.AddChild("layers"); layersElement.ConsiderAsArrayOf("layer"); for ( std::size_t j = 0;j < GetLayersCount();++j ) GetLayer(j).SerializeTo(layersElement.AddChild("layer")); SerializerElement & behaviorDatasElement = element.AddChild("behaviorsSharedData"); behaviorDatasElement.ConsiderAsArrayOf("behaviorSharedData"); for (std::map<gd::String, std::shared_ptr<gd::BehaviorsSharedData> >::const_iterator it = behaviorsInitialSharedDatas.begin(); it != behaviorsInitialSharedDatas.end();++it) { SerializerElement & dataElement = behaviorDatasElement.AddChild("behaviorSharedData"); dataElement.SetAttribute("type", it->second->GetTypeName()); dataElement.SetAttribute("name", it->second->GetName()); it->second->SerializeTo(dataElement); } }
int CheckVariables(int sid, char *name, char *var) { struct variable *v; for (v = GetVariables(sid); v->name != NULL; v++) { syslog(LOG_INFO, "Check variables: %s %s\n", v->name, name); if (strcmp(v->name, name)==0) { if (v->validate!=NULL) { if ((v->validate(var, v))==UPNP_E_SUCCESS) return 1; else return 0; } else return 1; } } return 0; }
// called from 00C589E5, 00C58B61 BSScriptObject::~BSScriptObject() // 00C30E90 { if (flags & kFlag_HasVariables) { UInt32 numVars = classPtr->GetNumAllVariables(); BSScriptVariable *pVar = GetVariables(); while (numVars) { pVar->~BSScriptVariable(); --numVars; } } flags = 0; if (unk0C.GetFlag()) { InterlockedDecrement(unk0C); } }
void CLuaCFGMenu::CoreDelVar(const char *name) { const int size = m_pVarListView->size(); int index = -1; for (int i=1; i<=size; i++) { if (m_pVarListView->data(i) && !strcmp(static_cast<const char *>(m_pVarListView->data(i)), name)) { index = i; break; } } if (index != -1) { m_pVarListView->remove(index); TVarType &vars = GetVariables(); for (TVarType::iterator it=vars.begin(); it!=vars.end(); it++) SetVarColumnW(it->first.c_str()); UpdateSelection(); } }
OptError NewtonProblem::CreateFunctionOptimizer(OptimizeClass * &objfcn, NLP0 * &func) { OptError error; int numVar = GetNumVar(); int derivOrder = GetDerivOrder(); VariableList* variables = GetVariables(); CompoundConstraint* constraints = 0; if ((variables->linearExists()) || (variables->nonlinearExists())) { cout << "Newton does not support linear or nonlinear constraints." << endl; cout << "Linear and nonlinear constraints being ignored." << endl; } if ((variables->upperExists()) || (variables->lowerExists())) { constraints = new CompoundConstraint(Constraint(variables->GetBoundConstraints())); } if(derivOrder == 2) { USERFCN2 userFcn = GetUserFunction2(); INITFCN initFcn = GetInitFunction(); if(userFcn == NULL || initFcn == NULL) { error.value = -4; error.msg = "Error loading function"; return error; } NLF2 * myFunc = new NLF2(numVar, userFcn, initFcn, constraints); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); if ((variables->upperExists()) || (variables->lowerExists())) { objfcn = new OptBCNewton(myFunc); } else { objfcn = new OptNewton(myFunc); } func = myFunc; } else if(derivOrder == 1) { // construct a function with 1st derivative info USERFCN1 userFcn = GetUserFunction1(); INITFCN initFcn = GetInitFunction(); if(userFcn == NULL || initFcn == NULL) { error.value = -4; error.msg = "Error loading function"; return error; } NLF1 * myFunc = new NLF1(numVar, userFcn, initFcn, constraints); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); if ((variables->upperExists()) || (variables->lowerExists())) { objfcn = new OptBCQNewton(myFunc); } else { objfcn = new OptQNewton(myFunc); } func = myFunc; } else if(derivOrder == 0) { INITFCN initFcn = GetInitFunction(); USERFCN0 userFcn = GetUserFunction0(); if(userFcn == NULL) { error.value = -4; error.msg = "Error loading user function"; return error; } else if(initFcn == NULL) { error.value = -4; error.msg = "Error loading init function"; return error; } // construct a function with no derivative info // but use finite differences to approximate a first derivative FDNLF1 * myFunc = new FDNLF1(numVar, userFcn, initFcn, constraints); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); if(searchType_ == trustPDS) myFunc->setSpecOption(NoSpec); if ((variables->upperExists()) || (variables->lowerExists())) { objfcn = new OptBCQNewton(myFunc); } else { objfcn = new OptQNewton(myFunc); } func = myFunc; } error.value = 0; error.msg = "Success"; return error; }
CLuaCFGMenu::SEntry *CLuaCFGMenu::GetCurEntry() { return GetVariables()[m_pMenu->Value()]; }
void CLuaCFGMenu::CoreUpdateLanguage() { for (TVarType::iterator it=GetVariables().begin(); it!=GetVariables().end(); it++) m_pMenu->SetName(it->first, GetTranslation(it->first)); UpdateDesc(); }
Ptr<IValueReadonlyDictionary> WfRuntimeCallStackInfo::GetCapturedVariables() { return GetVariables(assembly->functions[functionIndex]->capturedVariableNames, captured, cachedCapturedVariables); }
OptError CGProblem::CreateFunctionOptimizer(OptimizeClass* &objfcn, NLP0* &func) { OptError error; int numVar = GetNumVar(); int derivOrder = GetDerivOrder(); VariableList* variables = GetVariables(); if ((variables->upperExists()) || (variables->lowerExists()) || (variables->linearExists()) || (variables->nonlinearExists())) { cout << "CG does not support constraints." << endl; cout << "Constraints being ignored." << endl; } // construct a function with 2nd derivative info if(derivOrder == 2) { USERFCN2 userFcn = GetUserFunction2(); INITFCN initFcn = GetInitFunction(); if(userFcn == NULL || initFcn == NULL) { error.value = -4; error.msg = "Error loading function"; return error; } NLF2* myFunc = new NLF2(numVar, userFcn, initFcn); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); func = myFunc; } else if(derivOrder == 1) { // construct a function with 1st derivative info USERFCN1 userFcn = GetUserFunction1(); INITFCN initFcn = GetInitFunction(); if(userFcn == NULL || initFcn == NULL) { error.value = -4; error.msg = "Error loading function"; return error; } NLF1* myFunc = new NLF1(numVar, userFcn, initFcn); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); func = myFunc; } else if(derivOrder == 0) { USERFCN0 userFcn = GetUserFunction0(); INITFCN initFcn = GetInitFunction(); if(userFcn == NULL || initFcn == NULL) { error.value = -4; error.msg = "Error loading function"; return error; } // construct a function with no derivative info // but use finite differences to approximate a first derivative FDNLF1* myFunc = new FDNLF1(numVar, userFcn, initFcn); myFunc->setIsExpensive(true); myFunc->setX(variables->GetInitialValues()); func = myFunc; } objfcn = new OptCG((NLP1 *)func); error.value = 0; error.msg = "Success"; return error; }
Ptr<IValueReadonlyDictionary> WfRuntimeCallStackInfo::GetLocalArguments() { return GetVariables(assembly->functions[functionIndex]->argumentNames, localVariables, cachedLocalArguments); }
globle int VariableAnalysis( void *theEnv, struct lhsParseNode *patternPtr) { int errorFlag = FALSE; struct nandFrame *theNandFrames = NULL, *tempNandPtr; int currentDepth = 1; /*======================================================*/ /* Loop through all of the CEs in the rule to determine */ /* which variables refer to other variables and whether */ /* any semantic errors exist when refering to variables */ /* (such as referring to a variable that was not */ /* previously bound). */ /*======================================================*/ while (patternPtr != NULL) { /*==================================*/ /* If the nand depth is increasing, */ /* create a new nand frame. */ /*==================================*/ while (patternPtr->beginNandDepth > currentDepth) { tempNandPtr = get_struct(theEnv,nandFrame); tempNandPtr->nandCE = patternPtr; tempNandPtr->depth = currentDepth; tempNandPtr->next = theNandFrames; theNandFrames = tempNandPtr; currentDepth++; } /*=========================================================*/ /* If a pattern CE is encountered, propagate any variables */ /* found in the pattern and note any illegal references to */ /* other variables. */ /*=========================================================*/ if (patternPtr->type == PATTERN_CE) { /*====================================================*/ /* Determine if the fact address associated with this */ /* pattern illegally refers to other variables. */ /*====================================================*/ if ((patternPtr->value != NULL) && (patternPtr->referringNode != NULL)) { errorFlag = TRUE; if (patternPtr->referringNode->index == -1) { PrintErrorID(theEnv,"ANALYSIS",1,TRUE); EnvPrintRouter(theEnv,WERROR,"Duplicate pattern-address ?"); EnvPrintRouter(theEnv,WERROR,ValueToString(patternPtr->value)); EnvPrintRouter(theEnv,WERROR," found in CE #"); PrintLongInteger(theEnv,WERROR,(long) patternPtr->whichCE); EnvPrintRouter(theEnv,WERROR,".\n"); } else { PrintErrorID(theEnv,"ANALYSIS",2,TRUE); EnvPrintRouter(theEnv,WERROR,"Pattern-address ?"); EnvPrintRouter(theEnv,WERROR,ValueToString(patternPtr->value)); EnvPrintRouter(theEnv,WERROR," used in CE #"); PrintLongInteger(theEnv,WERROR,(long) patternPtr->whichCE); EnvPrintRouter(theEnv,WERROR," was previously bound within a pattern CE.\n"); } } /*====================================================*/ /* Propagate the pattern and field location of bound */ /* variables found in this pattern to other variables */ /* in the same semantic scope as the bound variable. */ /*====================================================*/ if (GetVariables(theEnv,patternPtr,PATTERN_CE,theNandFrames)) { ReleaseNandFrames(theEnv,theNandFrames); return(TRUE); } /*==========================================================*/ /* Analyze any test CE that's been attached to the pattern. */ /*==========================================================*/ if (TestCEAnalysis(theEnv,patternPtr,patternPtr->expression,FALSE,&errorFlag,theNandFrames) == TRUE) { ReleaseNandFrames(theEnv,theNandFrames); return TRUE; } if (TestCEAnalysis(theEnv,patternPtr,patternPtr->secondaryExpression,TRUE,&errorFlag,theNandFrames) == TRUE) { ReleaseNandFrames(theEnv,theNandFrames); return TRUE; } } /*==============================================================*/ /* If a test CE is encountered, make sure that all references */ /* to variables have been previously bound. If they are bound */ /* then replace the references to variables with function calls */ /* to retrieve the variables. */ /*==============================================================*/ else if (patternPtr->type == TEST_CE) { if (TestCEAnalysis(theEnv,patternPtr,patternPtr->expression,FALSE,&errorFlag,theNandFrames) == TRUE) { ReleaseNandFrames(theEnv,theNandFrames); return TRUE; } } /*==================================*/ /* If the nand depth is decreasing, */ /* release the nand frames. */ /*==================================*/ while (patternPtr->endNandDepth < currentDepth) { tempNandPtr = theNandFrames->next; rtn_struct(theEnv,nandFrame,theNandFrames); theNandFrames = tempNandPtr; currentDepth--; } /*=====================================================*/ /* Move on to the next pattern in the LHS of the rule. */ /*=====================================================*/ patternPtr = patternPtr->bottom; } /*==========================================*/ /* Return the error status of the analysis. */ /*==========================================*/ return(errorFlag); }
Ptr<IValueReadonlyDictionary> WfRuntimeCallStackInfo::GetGlobalVariables() { return GetVariables(assembly->variableNames, global, cachedGlobalVariables); }
const char *CLuaCFGMenu::ColumnText(const char *var) { return CreateText("%s\t%s", GetTranslation(var), GetTranslation(GetVariables()[var]->desc.c_str())); }