void ifaGroup::learnMaxAbilities() { int maxAbilities = 0; Eigen::ArrayXi loadings(itemDims); loadings.setZero(); for (int cx = 0; cx < numItems(); cx++) { for (int dx=0; dx < itemDims; ++dx) { if (getItemParam(cx)[dx] != 0) loadings[dx] += 1; } } maxAbilities = (loadings != 0).count(); if (itemDims != maxAbilities) { for (int lx=0; lx < itemDims; ++lx) { if (loadings[lx] == 0) mxThrow("Factor %d does not load on any items", 1+lx); } } }
void ifaGroup::buildRowSkip() { rowSkip.assign(rowMap.size(), false); if (itemDims == 0) return; // Rows with no information about an ability will obtain the // prior distribution as an ability estimate. This will // throw off multigroup latent distribution estimates. for (size_t rx=0; rx < rowMap.size(); rx++) { bool hasNA = false; std::vector<int> contribution(itemDims); for (int ix=0; ix < numItems(); ix++) { int pick = dataColumn(ix)[ rowMap[rx] ]; if (pick == NA_INTEGER) { hasNA = true; continue; } const double *ispec = spec[ix]; int dims = ispec[RPF_ISpecDims]; double *iparam = getItemParam(ix); for (int dx=0; dx < dims; dx++) { // assume factor loadings are the first item parameters if (iparam[dx] == 0) continue; contribution[dx] += 1; } } if (!hasNA) continue; if (minItemsPerScore == NA_INTEGER) { mxThrow("You have missing data. You must set minItemsPerScore"); } for (int ax=0; ax < itemDims; ++ax) { if (contribution[ax] < minItemsPerScore) { // We could compute the other scores, but estimation of the // latent distribution is in the hot code path. We can reconsider // this choice when we try generating scores instead of the // score distribution. rowSkip[rx] = true; } } } }
Bscript::BObjectImp* UOExecutorModule::mf_PromptInput() { Mobile::Character* chr; Items::Item* item; const Bscript::String* prompt; if ( !getCharacterParam( exec, 0, chr ) || !getItemParam( exec, 1, item ) || !exec.getStringParam( 2, prompt ) ) { return new Bscript::BError( "Invalid parameter" ); } if ( chr->client == nullptr ) { return new Bscript::BError( "No client attached" ); } if ( chr->has_active_prompt() != false ) { return new Bscript::BError( "Another script has an active prompt" ); } if ( !uoexec.suspend() ) { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" << "\tCall to function UO::RequestInput():\n" << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } Core::send_sysmessage( chr->client, prompt->data() ); chr->client->gd->prompt_uoemod = this; prompt_chr = chr; Core::send_prompt( chr->client, ctBEu32( item->serial ) ); return new Bscript::BLong( 0 ); }
BObjectImp* UBoatExecutorModule::mf_BoatFromItem() { Item* item = NULL; if (getItemParam( exec, 0, item )) { if (item->ismulti()) { UMulti* multi = static_cast<UMulti*>(item); UBoat* boat = multi->as_boat(); if (boat != NULL) return boat->make_ref(); else return new BError( "Multi wasn't a boat" ); } else { return new BError( "Item wasn't a multi" ); } } else { return new BError( "Invalid parameter type." ); } }