void PLCP::write(const string & filename){ Archiver arch; arch.add_sp_mat("P",P); arch.add_sp_mat("U",U); arch.add_vec("q",q); arch.write(filename); }
void DefaultStrategos::Archive( Archiver &arc ) { Strategos::Archive( arc ); arc.ArchiveFloat( &_checkYawMin ); arc.ArchiveFloat( &_checkYawMax ); arc.ArchiveFloat( &_checkInConeDistMax ); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); Archiver w; w.show(); return a.exec(); }
// // Name: Archive() // Parameters: Archiver &arc // Description: Archives Class Data // void CombatSubsystem::Archive(Archiver& arc) { _activeWeapon.Archive(arc); arc.ArchiveFloat(&_nextTimeTracedToTarget); arc.ArchiveFloat(&_traceInterval); arc.ArchiveBool(&_canShootTarget); arc.ArchiveFloat(&_yawDiff); }
inline void dfunction_t::Archive( Archiver &arc ) { Class::Archive( arc ); arc.ArchiveInteger( &eventnum ); arc.ArchiveInteger( &first_statement ); arc.ArchiveInteger( &parm_start ); arc.ArchiveInteger( &parm_total ); arc.ArchiveInteger( &locals ); arc.ArchiveInteger( &profile ); arc.ArchiveString( &s_name ); arc.ArchiveString( &s_file ); arc.ArchiveInteger( &numparms ); arc.ArchiveInteger( &minparms ); if ( arc.Loading() ) { memset( &parm_size, 0, sizeof( parm_size[0] ) * MAX_PARMS ); memset( &parm_type, 0, sizeof( parm_type[0] ) * MAX_PARMS ); } arc.ArchiveRaw( parm_size, sizeof( parm_size[0] ) * numparms ); arc.ArchiveRaw( parm_type, sizeof( parm_type[0] ) * numparms ); }
Archiver* Archiver::create() { Archiver *ref = new (std::nothrow) Archiver(); if (ref) { ref->autorelease(); return ref; } else { CC_SAFE_DELETE(ref); return nullptr; } }
int main(int argc, char *argv[]) { cout << "If you want to compress the file enter -zip" << endl << "If you want to uncompress the file enter -unzip" << endl << "Enter your choice:"; string command; cin >> command; if (command == "-zip") { cout << "Enter path of the origin..." << endl << "Enter the path:"; string pathOfOrigin; cin >> pathOfOrigin; string pathOfArchive = pathOfOrigin + ".myzip"; Archiver arch; arch.compress(pathOfOrigin, pathOfArchive); cout << "Done!" << endl; }
inline void Talk::Archive(Archiver& arc) { Behavior::Archive(arc); arc.ArchiveObject(&turnto); arc.ArchiveSafePointer(&ent_listening); arc.ArchiveSafePointer(&last_headwatch_target); arc.ArchiveFloat(&original_yaw); arc.ArchiveFloat(&yaw); arc.ArchiveInteger(&mode); arc.ArchiveBoolean(&move_allowed); arc.ArchiveBool(&animDone); arc.ArchiveString(&oldAnimName); }
inline void WatchEntity::Archive(Archiver& arc) { Behavior::Archive(arc); // Archive Parameters arc.ArchiveFloat(&_time); arc.ArchiveFloat(&_turnspeed); arc.ArchiveFloat(&_oldTurnSpeed); arc.ArchiveString(&_anim); arc.ArchiveSafePointer(&_ent); arc.ArchiveUnsigned(&_waitForAnim); arc.ArchiveString(&_holdAnim); arc.ArchiveBool(&_forcePlayer); // Archive Member Vars arc.ArchiveUnsigned(&_state); arc.ArchiveUnsigned(&_animDone); }
//! Run through the data void dsp::LoadToFold::finish () try { if (phased_filterbank) { cerr << "Calling PhaseLockedFilterbank::normalize_output" << endl; phased_filterbank -> normalize_output (); } SingleThread::finish(); if (!output_subints()) { if (!unloader.size()) throw Error (InvalidState, "dsp::LoadToFold::finish", "no unloader"); for (unsigned i=0; i<fold.size(); i++) { Archiver* archiver = dynamic_cast<Archiver*>( unloader[0].get() ); if (!archiver) throw Error (InvalidState, "dsp::LoadToFold::finish", "unloader is not an archiver (single integration)"); /* In multi-threaded applications, the thread that calls the finish method may not be the thread that called the prepare method. */ if (Operation::verbose) cerr << "Creating archive " << i+1 << endl; if (phased_filterbank) archiver->unload( phased_filterbank->get_output() ); else archiver->unload( fold[i]->get_result() ); } } } catch (Error& error) { throw error += "dsp::LoadToFold::finish"; }
// // Name: Archive() // Parameters: Archiver &arc -- The archiver object // Description: Archives the class // void SensoryPerception::Archive ( Archiver &arc ) { arc.ArchiveInteger ( &_stimuli ); arc.ArchiveInteger ( &_permanent_stimuli ); arc.ArchiveVector ( &_noise_position ); arc.ArchiveInteger ( &_last_soundType ); arc.ArchiveFloat ( &_noise_time ); arc.ArchiveFloat ( &_fov ); arc.ArchiveFloat ( &_fovdot ); arc.ArchiveFloat ( &_vision_distance ); arc.ArchiveFloat ( &_nextSenseTime ); arc.ArchiveInteger( &_lineOfSight.entNum ); arc.ArchiveFloat( &_lineOfSight.time ); arc.ArchiveBoolean( &_lineOfSight.inLineOfSight ); }
inline void def_t::Archive( Archiver &arc ) { Class::Archive( arc ); arc.ArchiveObjectPointer( ( Class ** )&type ); arc.ArchiveString( &name ); // arc.ArchiveObjectPointer( ( Class ** )&next ); arc.ArchiveInteger( &ofs ); arc.ArchiveInteger( &localofs ); arc.ArchiveObjectPointer( ( Class ** )&scope ); arc.ArchiveInteger( &initialized ); arc.ArchiveBool( &caseSensitive ); arc.ArchiveBool( &_onDefList ); //arc.ArchiveObjectPointer( ( Class ** )&type ); }
//-------------------------------------------------------------- // Name: Archive() // Class: PostureController // // Description: Archives the class // // Parameters: Archiver &arc // // Returns: None //-------------------------------------------------------------- void PostureController::Archive( Archiver &arc ) { arc.ArchiveString( &_postureStateMap_Name ); arc.ArchiveString( &_currentPostureState_Name ); arc.ArchiveString( &_requestedPostureState_Name ); arc.ArchiveSafePointer ( &_requestor ); if ( !arc.Saving() ) { if ( _postureStateMap_Name.length() ) { Event *event; event = new Event( EV_Actor_SetPostureStateMap ); event->AddString( _postureStateMap_Name ); event->AddInteger( 1 ); act->ProcessEvent ( event ); _currentPostureState = _postureStateMap->FindState( _currentPostureState_Name.c_str() ); _requestedPostureState = _postureStateMap->FindState(_requestedPostureState_Name.c_str() ); } } }
inline void Work::Archive(Archiver& arc) { Behavior::Archive(arc); // Archive Parameters arc.ArchiveString(&_gotoWorkAnimName); arc.ArchiveFloat(&_maxDistance); // Archive Components arc.ArchiveObject(&_gotoHelperNode); // Archive Member Vars arc.ArchiveSafePointer(&_node); arc.ArchiveUnsigned(&_state); arc.ArchiveBool(&_animDone); arc.ArchiveFloat(&_endTime); arc.ArchiveObjectPointer((Class**)&_self); }
inline void WatchEntityEX::Archive(Archiver& arc) { Behavior::Archive(arc); // Archive Parameters arc.ArchiveString(&_stance); arc.ArchiveString(&_shuffleAnim); arc.ArchiveString(&_torsoAnim); arc.ArchiveSafePointer(&_ent); // Archive Components arc.ArchiveObject(&_rotateToEntity); // Archive Member Vars arc.ArchiveUnsigned(&_state); arc.ArchiveFloat(&_time); arc.ArchiveFloat(&_turnspeed); }
void Entity::Archive( Archiver &arc ) { SimpleEntity::Archive( arc ); arc.ArchiveBoolean( &fShader ); if( fShader ) { arc.ArchiveString( &shader ); if( arc.Loading() ) { customshader = cgi.R_RegisterShader( shader ); } } arc.ArchiveBoolean( &canThink ); arc.ArchiveFloat( &scale ); arc.ArchiveInteger( &entnum ); arc.ArchiveInteger( &renderFx ); arc.ArchiveString( &model ); }
void createStaticLibrary(CCompiler<Base>& compiler, Archiver& ar, bool posIndepCode) { // backup output format so that it can be restored OStreamConfigRestore coutb(std::cout); this->modelLibraryHelper_->startingJob("", JobTimer::STATIC_MODEL_LIBRARY); const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels(); try { for (const auto& p : models) { const std::map<std::string, std::string>& modelSources = this->getSources(*p.second); this->modelLibraryHelper_->startingJob("", JobTimer::COMPILING_FOR_MODEL); compiler.compileSources(modelSources, posIndepCode, this->modelLibraryHelper_); this->modelLibraryHelper_->finishedJob(); } const std::map<std::string, std::string>& sources = this->getLibrarySources(); compiler.compileSources(sources, posIndepCode, this->modelLibraryHelper_); const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources(); compiler.compileSources(customSource, posIndepCode, this->modelLibraryHelper_); std::string libname = _libraryName; if (_customLibExtension != nullptr) libname += *_customLibExtension; else libname += system::SystemInfo<>::STATIC_LIB_EXTENSION; ar.create(libname, compiler.getObjectFiles(), this->modelLibraryHelper_); } catch (...) { compiler.cleanup(); throw; } compiler.cleanup(); this->modelLibraryHelper_->finishedJob(); }
void Level::Archive( Archiver &arc ) { int num; int i; Class::Archive( arc ); if ( arc.Saving() ) { SafePtr<Earthquake> ent; num = _earthquakes.NumObjects(); arc.ArchiveInteger( &num ); for ( i = 1 ; i <= num ; i++ ) { ent = _earthquakes.ObjectAt( i ); arc.ArchiveSafePointer( &ent ); } } else { SafePtr<Earthquake> ent; SafePtr<Earthquake> *entityPointer; arc.ArchiveInteger( &num ); _earthquakes.ClearObjectList(); _earthquakes.Resize( num ); for ( i = 1 ; i <= num ; i++ ) { _earthquakes.AddObject( ent ); entityPointer = &_earthquakes.ObjectAt( i ); arc.ArchiveSafePointer( entityPointer ); } } arc.ArchiveInteger( &_totalEnemiesSpawned ); // Don't archive these //const char *current_map; //const char *current_entities; //int spawn_entnum; arc.ArchiveInteger( ¤tInstanceNumber ); //int spawnflags; arc.ArchiveInteger( &framenum ); arc.ArchiveInteger( &inttime ); arc.ArchiveFloat( &time ); arc.ArchiveFloat( &timeInLevel ); arc.ArchiveFloat( &frametime ); arc.ArchiveFloat( &fixedframetime ); arc.ArchiveInteger( &startTime ); arc.ArchiveString( &level_name ); arc.ArchiveString( &mapname ); arc.ArchiveString( &spawnpoint ); arc.ArchiveString( &nextmap ); arc.ArchiveBoolean( &restart ); arc.ArchiveBoolean( &started ); arc.ArchiveBoolean( &playerfrozen ); arc.ArchiveFloat( &intermissiontime ); arc.ArchiveInteger( &exitintermission ); arc.ArchiveFloat( &intermission_advancetime ); arc.ArchiveBool( &_showIntermission ); arc.ArchiveBool( &_saveOrientation ); // Don't archive //gentity_s *next_edict; arc.ArchiveInteger( &total_secrets ); arc.ArchiveInteger( &found_secrets ); arc.ArchiveInteger( &total_specialItems ); arc.ArchiveInteger( &found_specialItems ); arc.ArchiveString( &game_script ); // Don't archive //trace_t impact_trace; arc.ArchiveBoolean( &cinematic ); arc.ArchiveBoolean( &ai_on ); arc.ArchiveBoolean( &mission_failed ); arc.ArchiveBoolean( &died_already ); arc.ArchiveBoolean( &near_exit ); arc.ArchiveVector( &water_color ); arc.ArchiveFloat( &water_alpha ); arc.ArchiveVector( &slime_color ); arc.ArchiveFloat( &slime_alpha ); arc.ArchiveVector( &lava_color ); arc.ArchiveFloat( &lava_alpha ); arc.ArchiveString( ¤t_soundtrack ); arc.ArchiveString( &saved_soundtrack ); arc.ArchiveObjectPointer( ( Class ** )&consoleThread ); arc.ArchiveVector( &m_fade_color ); arc.ArchiveFloat( &m_fade_alpha ); arc.ArchiveFloat( &m_fade_time ); arc.ArchiveFloat( & m_fade_time_start ); ArchiveEnum( m_fade_type, fadetype_t ); ArchiveEnum( m_fade_style, fadestyle_t ); arc.ArchiveFloat( &m_letterbox_fraction ); arc.ArchiveFloat( &m_letterbox_time ); arc.ArchiveFloat( &m_letterbox_time_start ); ArchiveEnum( m_letterbox_dir, letterboxdir_t ); arc.ArchiveBool( &_cleanup ); arc.ArchiveString( &_playerDeathThread ); arc.ArchiveObjectPointer( ( Class ** )&hNodeController ); // Don't archive, will already be setup from camera code // Container<Camera *> automatic_cameras; arc.ArchiveVector( & m_intermission_origin ); arc.ArchiveVector( & m_intermission_angle ); if ( arc.Loading() ) { str temp_soundtrack; // Change the sound track to the one just loaded temp_soundtrack = saved_soundtrack; ChangeSoundtrack( current_soundtrack.c_str() ); saved_soundtrack = temp_soundtrack; // not archived since we can't save mid-frame next_edict = NULL; // not archived since we can't save mid-frame memset( &impact_trace, 0, sizeof( impact_trace ) ); loadLevelStrings(); } }
void Personality::Archive( Archiver &arc ) { int i; int j; int num; str packageName; BehaviorPackageType_t *package; PackageTendency_t *tendency; PackageTendency_t tempTendency; Tendency_t tempGeneralTendency; Tendency_t *generalTendency; tempTendency.packageIndex = 0; tempTendency.tendency = 0.0f; tempTendency.lastTendencyCheck = 0.0f; arc.ArchiveFloat( &_aggressiveness ); arc.ArchiveFloat( &_talkiness ); arc.ArchiveFloat( &_anger ); arc.ArchiveFloat( &_fear ); if ( arc.Saving() ) { num = _PackageTendencies.NumObjects(); arc.ArchiveInteger( &num ); for ( i = 1 ; i <= num ; i++ ) { tendency = &_PackageTendencies.ObjectAt( i ); package = PackageList.ObjectAt( tendency->packageIndex ); arc.ArchiveString( &package->packageName ); arc.ArchiveFloat( &tendency->tendency ); arc.ArchiveFloat( &tendency->lastTendencyCheck ); } } else { arc.ArchiveInteger( &num ); _PackageTendencies.ClearObjectList(); _PackageTendencies.Resize( num ); for ( i = 1 ; i <= num ; i++ ) { _PackageTendencies.AddObject( tempTendency ); tendency = &_PackageTendencies.ObjectAt( i ); arc.ArchiveString( &packageName ); // Find index tendency->packageIndex = -1; for ( j = 1 ; j <= PackageList.NumObjects() ; j++ ) { package = PackageList.ObjectAt( j ); if ( stricmp( packageName.c_str() , package->packageName.c_str() ) == 0 ) { tendency->packageIndex = j; break; } } assert( tendency->packageIndex != -1 ); arc.ArchiveFloat( &tendency->tendency ); arc.ArchiveFloat( &tendency->lastTendencyCheck ); } } if ( arc.Saving() ) { num = _Tendencies.NumObjects(); arc.ArchiveInteger( &num ); for ( i = 1 ; i <= num ; i++ ) { generalTendency = &_Tendencies.ObjectAt( i ); arc.ArchiveString( &generalTendency->tendencyName ); arc.ArchiveFloat( &generalTendency->tendencyValue ); } } else { arc.ArchiveInteger( &num ); _Tendencies.ClearObjectList(); _Tendencies.Resize( num ); for ( i = 1 ; i <= num ; i++ ) { _Tendencies.AddObject( tempGeneralTendency ); generalTendency = &_Tendencies.ObjectAt( i ); arc.ArchiveString( &generalTendency->tendencyName ); arc.ArchiveFloat( &generalTendency->tendencyValue ); } } }
inline void type_t::Archive( Archiver &arc ) { int i; Class::Archive( arc ); ArchiveEnum( type, etype_t ); if ( arc.Loading() ) { bool onList; arc.ArchiveBool( &onList ); if ( !onList ) { def = new def_t; arc.ArchiveObject( ( Class * )def ); } else { arc.ArchiveObjectPointer( ( Class ** )&def ); } } else { arc.ArchiveBool( &def->_onDefList ); if ( !def->_onDefList ) { arc.ArchiveObject( ( Class * )def ); } else { arc.ArchiveObjectPointer( ( Class ** )&def ); } } /* if ( arc.Loading() ) def = new def_t; arc.ArchiveObject( ( Class * )def ); */ arc.ArchiveObjectPointer( ( Class ** )&def ); arc.ArchiveObjectPointer( ( Class ** )&aux_type ); arc.ArchiveInteger( &num_parms ); arc.ArchiveInteger( &min_parms ); for ( i = 0; i < num_parms; i++ ) arc.ArchiveObjectPointer( ( Class ** )&parm_types[i] ); }
int main(int argc, char** argv) { po::variables_map var_map = read_command_line(argc,argv); string mesh_file = var_map["infile_base"].as<string>() + ".tri"; // Read in the CGAL mesh TriMesh mesh; cout << "Reading in cgal mesh file [" << mesh_file << ']' << endl; mesh.read_cgal(mesh_file); mesh.freeze(); uint V = mesh.number_of_vertices(); uint N = mesh.number_of_all_nodes(); assert(N == V+1); uint F = mesh.number_of_faces(); cout << "Mesh stats:" << "\n\tNumber of vertices: " << V << "\n\tNumber of faces: " << F << endl; Points centers = mesh.get_cell_centers(); // Find boundary from the mesh and create the simulator object mat bbox = mesh.find_bounding_box(); vec lb = bbox.col(0); vec ub = bbox.col(1); cout << "\tLower bound:" << lb.t() << "\tUpper bound:" << ub.t(); // Read in solution information string soln_file = var_map["infile_base"].as<string>() + ".sol"; cout << "Reading in LCP solution file [" << soln_file << ']' << endl; Unarchiver sol_unarch(soln_file); vec p = sol_unarch.load_vec("p"); string lcp_file = var_map["infile_base"].as<string>() + ".lcp"; Unarchiver lcp_unarch(lcp_file); vec q = lcp_unarch.load_vec("q"); Archiver arch; // Make sure that the primal information makes sense assert(0 == p.n_elem % V); uint A = p.n_elem / V; assert(A == 3); cout << "Blocking primal solution..." << "\n\tLength of primal solution: " << p.n_elem << "\n\tRatio of primal length to vertex number: " << A << endl; mat P = reshape(p,size(V,A)); P = join_vert(P,datum::inf * ones<rowvec>(3)); // Pad vec value = P.col(0); mat flows = P.tail_cols(2); mat Q = reshape(q,size(V,A)); Q = join_vert(Q,datum::inf * ones<rowvec>(3)); // Pad vec recon_b = mesh.interpolate(centers, conv_to<vec>::from(Q.col(1))); vec recon_c = mesh.interpolate(centers, conv_to<vec>::from(Q.col(2))); arch.add_vec("recon_b",recon_b); arch.add_vec("recon_c",recon_c); vec area = mesh.cell_area(); arch.add_vec("area",area); // True values vec sq_dist = sum(pow(centers,2),1); vec b = sq_dist; vec c = max(zeros<vec>(F),1 - sq_dist); vec x = arma::min(b,c); assert(all(x >= 0)); assert(F == x.n_elem); uvec pi = arma::index_min(join_horiz(b,c),1); assert(F == pi.n_elem); arch.add_uvec("pi",pi); // Approx policy assert(2 == flows.n_cols); mat interp_flows = mesh.interpolate(centers,flows); uvec flow_pi = arma::index_max(interp_flows,1); arch.add_uvec("flow_pi",flow_pi); assert(F == flow_pi.n_elem); uvec diff = zeros<uvec>(F); diff(find(flow_pi != pi)).fill(1); arch.add_uvec("policy_diff",diff); // Approx value vec interp_value = mesh.interpolate(centers,value); assert(F == interp_value.n_elem); vec res = abs(x - interp_value); arch.add_vec("residual",res); vec heuristic = res; heuristic(find(flow_pi != pi)) *= 4; arch.add_vec("heuristic",heuristic); double quant = 0.9; cout << "Quantile:" << quant << endl; double cutoff = quantile(heuristic,quant); cout << "\t Cutoff: " << cutoff << "\n\t Max:" << max(heuristic) << "\n\t Min:" << min(heuristic) << endl; // Split the cells if they have a large heuristic_1 or // policies disagree on them. TriMesh new_mesh(mesh); Point center; uint new_nodes = 0; for(uint f = 0; f < F; f++){ if(area(f) < 2e-4){ continue; } if(new_nodes > 200) break; if(heuristic(f) > cutoff){ center = convert(mesh.center_of_face(f)); new_mesh.insert(center); new_nodes++; } } cout << "Added " << new_nodes << " new nodes..." << endl; cout << "Refining..." << endl; new_mesh.refine(0.125,1.0); new_mesh.lloyd(10); //new_mesh.insert(Point(0,0)); new_mesh.freeze(); // Write out all the information string out_file_base = var_map["outfile_base"].as<string>(); arch.write(out_file_base + ".stats"); cout << "Writing..." << "\n\tCGAL mesh file: " << out_file_base << ".tri" << "\n\tShewchuk node file: " << out_file_base << ".node" << "\n\tShewchuk ele file: " << out_file_base << ".ele" << endl; new_mesh.write_cgal(out_file_base + ".tri"); new_mesh.write_shewchuk(out_file_base); }
void SolverResult::write(const string & filename) const{ Archiver arch; arch.add_vec("p",p); arch.add_vec("d",d); arch.write(filename); }
inline void Program::Archive( Archiver &arc ) { int i, num; type_t *curtype, *newtype; def_t *curdef, *newdef; Class::Archive( arc ); /* // Force all of the defs to have indexes forceDefSave = &def_void; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); forceDefSave = &def_string; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); forceDefSave = &def_float; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); forceDefSave = &def_vector; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); forceDefSave = &def_entity; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); forceDefSave = &def_function; arc.ArchiveObjectPointer( ( Class ** )&forceDefSave ); // Force all of the types to have indexes forceTypeSave = &type_void; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); forceTypeSave = &type_string; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); forceTypeSave = &type_float; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); forceTypeSave = &type_vector; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); forceTypeSave = &type_entity; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); forceTypeSave = &type_function; arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); */ // NOTE: must archive global data for pointer fixups arc.ArchiveObject( &def_void ); arc.ArchiveObject( &def_string ); arc.ArchiveObject( &def_float ); arc.ArchiveObject( &def_vector ); arc.ArchiveObject( &def_entity ); arc.ArchiveObject( &def_function ); arc.ArchiveObject( &def_ret ); arc.ArchiveObject( &junkdef ); arc.ArchiveObject( &type_void ); arc.ArchiveObject( &type_string ); arc.ArchiveObject( &type_float ); arc.ArchiveObject( &type_vector ); arc.ArchiveObject( &type_entity ); arc.ArchiveObject( &type_function ); arc.ArchiveInteger( &numpr_globals ); if ( arc.Loading() ) { memset( pr_globals, 0, sizeof( pr_globals[0] ) * MAX_REGS ); } arc.ArchiveRaw( pr_globals, sizeof( pr_globals[0] ) * numpr_globals ); arc.ArchiveInteger( &locals_start ); arc.ArchiveInteger( &locals_end ); for ( i = 0; i < MAX_STRINGS; i++ ) { arc.ArchiveBool( &strings[i].inuse ); if ( strings[i].inuse ) { arc.ArchiveString( &strings[i].s ); } else { strings[i].s = ""; } } arc.ArchiveInteger( &numstatements ); arc.ArchiveRaw( statements, sizeof( statements[0] ) * numstatements ); arc.ArchiveInteger( &numfunctions ); for ( i = 0; i < numfunctions; i++ ) arc.ArchiveObject( ( Class * )&functions[i] ); // archive types if ( arc.Saving() ) { for ( curtype = types, num = 0; curtype; curtype = curtype->next ) { num++; } // Don't count type_function num--; } arc.ArchiveInteger( &num ); if ( arc.Saving() ) { for ( curtype = types; curtype; curtype = curtype->next ) { // Skip type_function (we archive it seperately above) if ( curtype == &type_function ) continue; arc.ArchiveObject( ( Class * )curtype ); } } else { curtype = types; for ( i = 0; i < num; i++ ) { newtype = new type_t; arc.ArchiveObject( ( Class * )newtype ); newtype->next = NULL; curtype->next = newtype; curtype = newtype; } } // archive defs if ( arc.Saving() ) { for ( curdef = def_head.next, num = 0; curdef; curdef = curdef->next ) num++; } arc.ArchiveInteger( &num ); if ( arc.Saving() ) { for ( curdef = def_head.next; curdef; curdef = curdef->next ) arc.ArchiveObject( ( Class * )curdef ); } else { def_tail = &def_head; curdef = def_tail; for ( i = 0; i < num; i++ ) { newdef = new def_t; arc.ArchiveObject( ( Class * )newdef ); newdef->next = NULL; curdef->next = newdef; curdef = newdef; } } arc.ArchiveInteger( &pr_error_count ); filenames.Archive( arc ); arc.ArchiveString( &s_file ); if ( arc.Loading() ) { memset( pr_global_defs, 0, sizeof( pr_global_defs ) ); } for ( i = 0; i < numpr_globals; i++ ) { arc.ArchiveObjectPointer( ( Class ** )&pr_global_defs[i] ); } }
void World::Archive( Archiver &arc ) { int i; int num; TargetList *tempTargetList; Entity::Archive( arc ); if ( arc.Loading() ) { FreeTargetList(); } if ( arc.Saving() ) num = targetList.NumObjects(); arc.ArchiveInteger( &num ); for ( i = 1; i <= num; i++ ) { if ( arc.Saving() ) { tempTargetList = targetList.ObjectAt( i ); } else { tempTargetList = new TargetList; targetList.AddObject( tempTargetList ); } arc.ArchiveObject( ( Class * )tempTargetList ); } _brokenThings.Archive( arc ); _availableViewModes.Archive( arc ); arc.ArchiveBoolean( &world_dying ); arc.ArchiveString( &skipthread ); arc.ArchiveFloat( &farplane_distance ); arc.ArchiveVector( &farplane_color ); arc.ArchiveBoolean( &farplane_cull ); arc.ArchiveBoolean( &farplane_fog ); arc.ArchiveBoolean( &terrain_global ); arc.ArchiveFloat( &terrain_global_min ); arc.ArchiveFloat( &entity_fade_dist ); for( i = 0 ; i < MAX_LIGHTING_GROUPS ; i++ ) dynamic_lights[ i ].Archive( arc ); wind.Archive( arc ); weather.Archive( arc ); arc.ArchiveFloat( &time_scale ); arc.ArchiveFloat( &sky_alpha ); arc.ArchiveBoolean( &sky_portal ); for ( i = 0 ; i < WORLD_PHYSICS_TOTAL_NUMBER ; i++ ) { arc.ArchiveFloat( &_physicsInfo[ i ] ); } arc.ArchiveBool( &_canShakeCamera ); if ( arc.Loading() ) { UpdateConfigStrings(); UpdateFog(); UpdateTerrain(); UpdateSky(); UpdateDynamicLights(); UpdateWindDirection(); UpdateWindIntensity(); UpdateWeather(); UpdateTimeScale(); } // Archive groupcoordinator (not part of world but this is a good place) if ( arc.Loading() ) { if ( groupcoordinator ) delete groupcoordinator; groupcoordinator = new GroupCoordinator; } groupcoordinator->Archive( arc ); }
//////////////////////////////////////////////////////////// // MAIN FUNCTION /////////////////////////////////////////// //////////////////////////////////////////////////////////// int main(int argc, char** argv) { po::variables_map var_map = read_command_line(argc,argv); arma_rng::set_seed_random(); // Read in the CGAL mesh TriMesh mesh; string file_base = var_map["outfile_base"].as<string>(); double edge_length = var_map["edge_length"].as<double>(); generate_minop_mesh(mesh,file_base,edge_length); mesh.freeze(); // Stats uint N = mesh.number_of_vertices(); uint F = mesh.number_of_faces(); cout << "Mesh stats:" << "\n\tNumber of vertices: " << N << "\n\tNumber of faces: " << F << endl; // Build value basis uint num_value_basis = 25; uint num_flow_basis = 10; Points points = mesh.get_spatial_nodes(); cout << "Generating Radial Fourier basis for value..." << endl; mat value_basis = make_radial_fourier_basis(points, num_value_basis, (double)num_value_basis); cout << "\tOrthogonalizing..." << endl; value_basis = orth(value_basis); cout << "Generating Voronoi basis for flow..." << endl; sp_mat sp_value_basis = sp_mat(value_basis); Points centers = 2 * randu(10,2) - 1; mat flow_basis = make_voronoi_basis(points, centers); cout << "\tOrthogonalizing..." << endl; flow_basis = orth(flow_basis); sp_mat sp_flow_basis = sp_mat(flow_basis); cout << "Building LCP..." << endl; vec ref_weights = ones<vec>(N) / (double)N; LCP ref_lcp; vec ans; build_minop_lcp(mesh,ref_weights,ref_lcp,ans); assert(N == ans.n_elem); cout << "Building PLCP..." << endl; block_sp_vec D = {sp_value_basis, sp_flow_basis, sp_flow_basis}; sp_mat P = block_diag(D); double regularizer = 1e-12; sp_mat U = P.t() * (ref_lcp.M + regularizer*speye(size(ref_lcp.M))); vec q = P *(P.t() * ref_lcp.q); assert(3*N == P.n_rows); assert(3*N == q.n_rows); bvec free_vars = zeros<bvec>(3*N); free_vars.head(N).fill(1); PLCP ref_plcp = PLCP(P,U,q,free_vars); ref_plcp.write(file_base + ".plcp"); ProjectiveSolver psolver; psolver.comp_thresh = 1e-12; psolver.max_iter = 250; psolver.aug_rel_scale = 5; psolver.verbose = false; psolver.initial_sigma = 0.3; cout << "Starting reference solve..." << endl; SolverResult ref_sol = psolver.aug_solve(ref_plcp); cout << "\tDone." << endl; cout << "Reference solution error: " << norm(ans - ref_sol.p.head(N)) << endl; assert(ALMOST_ZERO > norm(ref_sol.d.head(N))); // Essentially zero ref_sol.write(file_base + ".sol"); psolver.comp_thresh = 1e-8; // Exactish vec twiddle = vec(N); for(uint i = 0; i < N; i++){ cout << "Component: " << i << endl; LCP twiddle_lcp; vec et = zeros<vec>(N); et(i) += 1.0 / (double) N; assert(size(ref_weights) == size(et)); build_minop_lcp(mesh,ref_weights + et,twiddle_lcp,ans); vec twiddle_q = P *(P.t() * twiddle_lcp.q); PLCP twiddle_plcp = PLCP(P,U,twiddle_q,free_vars); SolverResult twiddle_sol = psolver.aug_solve(twiddle_plcp); twiddle(i) = twiddle_sol.p(i) - ref_sol.p(i); } uint R = 75; mat jitter = mat(N,R); mat noise = mat(N,R); for(uint i = 0; i < R; i++){ cout << "Jitter round: " << i << endl; LCP jitter_lcp; noise.col(i) = max(1e-4*ones<vec>(N), 0.075 * randn<vec>(N)); build_minop_lcp(mesh,ref_weights + noise.col(i),jitter_lcp,ans); vec jitter_q = P *(P.t() * jitter_lcp.q); PLCP jitter_plcp = PLCP(P,U,jitter_q,free_vars); SolverResult jitter_sol = psolver.aug_solve(jitter_plcp); jitter.col(i) = (jitter_sol.p.head(N) - ref_sol.p.head(N)); } Archiver arch; arch.add_vec("p",ref_sol.p.head(N)); arch.add_vec("twiddle",twiddle); arch.add_mat("jitter",jitter); arch.add_mat("noise",noise); arch.add_sp_mat("flow_basis",sp_flow_basis); arch.write(file_base + ".exp_res"); }
void Strategos::Archive( Archiver &arc ) { arc.ArchiveFloat( &_sightBasedHate ); arc.ArchiveFloat( &_nextEvaluateTime ); arc.ArchiveFloat( &_evaluateInterval ); }
int main(int argc, char** argv) { arma_rng::set_seed_random(); // Set up 2D space cout << "Generating initial mesh..." << endl; TriMesh mesh = generate_initial_mesh(); Points points = mesh.get_spatial_nodes(); uint N = points.n_rows; assert(N == mesh.number_of_spatial_nodes()); assert(N > 0); DoubleIntegratorSimulator di = build_di_simulator(); uint A = di.num_actions(); assert(A >= 2); // Reference blocks cout << "Building LCP blocks..." << endl; vector<sp_mat> blocks = di.lcp_blocks(&mesh,GAMMA); assert(A == blocks.size()); assert(size(N,N) == size(blocks.at(0))); // Build smoother cout << "Building smoother matrix..." << endl; sp_mat smoother = gaussian_smoother(points,SMOOTH_BW,SMOOTH_THRESH); assert(size(N,N) == size(smoother)); // Build and pertrub the q cout << "Building RHS Q..." << endl; mat Q = di.q_mat(&mesh); bvec free_vars = zeros<bvec>((A+1)*N); free_vars.head(N).fill(1); cout << "Making value basis..." << endl; sp_mat value_basis = make_value_basis(points); cout << "Building reference approximate PLCP..." << endl; PLCP ref_plcp = approx_lcp(value_basis,smoother,blocks,Q,free_vars); ProjectiveSolver psolver = ProjectiveSolver(); psolver.comp_thresh = 1e-8; psolver.initial_sigma = 0.25; psolver.verbose = false; psolver.iter_verbose = false; cout << "Starting reference augmented PLCP solve..." << endl; SolverResult ref_sol = psolver.aug_solve(ref_plcp); mat ref_P = reshape(ref_sol.p,N,A+1); vec ref_V = ref_P.col(0); vec ref_res = bellman_residual_at_nodes(&mesh,&di,ref_V,GAMMA); vec ref_res_norm = vec{norm(ref_res,1),norm(ref_res,2),norm(ref_res,"inf")}; ////////////////////////// // SETUP FOR EXPERIMENT // ////////////////////////// vec bandwidths = logspace<vec>(-3,1,NUM_BW); // 0.01 to 1 uint num_points = bandwidths.n_elem; mat res_diff = mat(num_points,3); for(uint i = 0; i < num_points; i++){ cout << "Running " << i << "/" << num_points << endl; mat new_vects = mat(N,2); new_vects.col(0) = gaussian(points,NEW_CENTER,bandwidths(i)); new_vects.col(1) = gaussian(points,-NEW_CENTER,bandwidths(i)); sp_mat new_basis = sp_mat(orth(join_horiz(mat(value_basis), new_vects))); PLCP plcp = approx_lcp(new_basis,smoother, blocks,Q,free_vars); SolverResult sol = psolver.aug_solve(plcp); // Interpret results mat P = reshape(sol.p,N,A+1); vec V = P.col(0); vec res = bellman_residual_at_nodes(&mesh,&di,V,GAMMA); vec res_norm = vec{norm(res,1),norm(res,2),norm(res,"inf")}; res_diff.row(i) = (res_norm - ref_res_norm).t(); } mesh.write_cgal("test.mesh"); Archiver arch = Archiver(); arch.add_vec("ref_res",ref_res); arch.add_mat("res_diff",res_diff); arch.add_mat("bandwidths",bandwidths); arch.write("test.data"); }
bool KrArchiverResultTable::addRow(SearchObject* search, QGridLayout* grid) { Archiver* arch = dynamic_cast<Archiver*>(search); // Name column _label = new KUrlLabel(arch->getWebsite(), arch->getSearchName(), this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); grid->addWidget(_label, _numRows, 0); connect(_label, SIGNAL(leftClickedUrl(const QString&)), SLOT(website(const QString&))); // Found column _label = new QLabel(arch->getPath(), this); _label->setContentsMargins(5, 5, 5, 5); grid->addWidget(_label, _numRows, 1); // Packing column _label = new QLabel(this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); if (arch->getIsPacker() && arch->getFound()) { _label->setText(i18n("enabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "darkgreen"); _label->setPalette(pal); } else if (arch->getIsPacker() && !arch->getFound()) { _label->setText(i18n("disabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "red"); _label->setPalette(pal); } else _label->setText(""); grid->addWidget(_label, _numRows, 2); // Unpacking column _label = new QLabel(this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); if (arch->getIsUnpacker() && arch->getFound()) { _label->setText(i18n("enabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "darkgreen"); _label->setPalette(pal); } else if (arch->getIsUnpacker() && !arch->getFound()) { _label->setText(i18n("disabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "red"); _label->setPalette(pal); } else _label->setText(""); grid->addWidget(_label, _numRows, 3); // Note column _label = new QLabel(arch->getNote(), this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); _label->setWordWrap(true); // wrap words grid->addWidget(_label, _numRows, 4); // Apply shared design elements adjustRow(_grid); // Ensure the last column takes more space _label->setMinimumWidth(300); ++_numRows; return true; }
KrArchiverResultTable::KrArchiverResultTable(QWidget* parent) : KrResultTable(parent) { _supported = KRarcHandler::supportedPackers(); // get list of available packers Archiver* tar = new Archiver("tar", "http://www.gnu.org", PS("tar"), true, true); Archiver* gzip = new Archiver("gzip", "http://www.gnu.org", PS("gzip"), true, true); Archiver* bzip2 = new Archiver("bzip2", "http://www.gnu.org", PS("bzip2"), true, true); Archiver* lzma = new Archiver("lzma", "http://tukaani.org/lzma", PS("lzma"), true, true); Archiver* xz = new Archiver("xz", "http://tukaani.org/xz", PS("xz"), true, true); Archiver* lha = new Archiver("lha", "http://www.gnu.org", PS("lha"), true, true); Archiver* zip = new Archiver("zip", "http://www.info-zip.org", PS("zip"), true, false); Archiver* unzip = new Archiver("unzip", "http://www.info-zip.org", PS("unzip"), false, true); Archiver* arj = new Archiver("arj", "http://www.arjsoftware.com", PS("arj"), true, true); Archiver* unarj = new Archiver("unarj", "http://www.arjsoftware.com", PS("unarj"), false, true); Archiver* unace = new Archiver("unace", "http://www.winace.com", PS("unace"), false, true); Archiver* rar = new Archiver("rar", "http://www.rarsoft.com", PS("rar"), true, true); Archiver* unrar = new Archiver("unrar", "http://www.rarsoft.com", PS("unrar"), false, true); Archiver* rpm = new Archiver("rpm", "http://www.gnu.org", PS("rpm"), false, true); Archiver* dpkg = new Archiver("dpkg", "http://www.dpkg.org", PS("dpkg"), false, true); Archiver* _7z = new Archiver("7z", "http://www.7-zip.org", PS("7z"), true, true); // Special case: arj can unpack, but unarj is preferred if (PS("arj") && PS("unarj")) arj->setIsUnpacker(false); if (PS("arj") && !PS("unarj")) unarj->setNote(i18n("unarj not found, but arj found, which will be used for unpacking")); // Special case: rar can unpack, but unrar is preferred if (PS("rar") && PS("unrar")) rar->setIsUnpacker(false); // Special case: rpm needs cpio for unpacking if (PS("rpm") && !PS("cpio")) rpm->setNote(i18n("rpm found, but cpio not found which is required for unpacking")); _tableHeaders.append(i18n("Name")); _tableHeaders.append(i18n("Found")); _tableHeaders.append(i18n("Packing")); _tableHeaders.append(i18n("Unpacking")); _tableHeaders.append(i18n("Note")); _numColumns = _tableHeaders.size(); _grid = initTable(); addRow(tar, _grid); addRow(gzip, _grid); addRow(bzip2, _grid); addRow(lzma, _grid); addRow(xz, _grid); addRow(lha, _grid); addRow(zip, _grid); addRow(unzip, _grid); addRow(arj, _grid); addRow(unarj, _grid); addRow(unace, _grid); addRow(rar, _grid); addRow(unrar, _grid); addRow(rpm, _grid); addRow(dpkg, _grid); addRow(_7z, _grid); delete tar; delete gzip; delete bzip2; delete lzma; delete xz; delete lha; delete zip; delete unzip; delete arj; delete unarj; delete unace; delete rar; delete unrar; delete rpm; delete dpkg; delete _7z; }
// // Name: DoArchive // Parameters: Archiver &arc // Actor *actor // Description: Sets the Actor pointer during archiving // void PackageManager::DoArchive( Archiver &arc , Actor *actor ) { int i; BehaviorPackageEntry_t *pEntry; BehaviorPackageType_t *package; int numPackages; str packageName; if ( actor ) act = actor; else gi.Error( ERR_FATAL, "PackageManager::DoArchive -- actor is NULL" ); if ( arc.Loading() ) { arc.ArchiveInteger( &numPackages ); for ( i = 1 ; i <= numPackages ; i++ ) { arc.ArchiveString( &packageName ); RegisterPackage( packageName ); // The package we just added should always be the last one pEntry = &_BehaviorPackages.ObjectAt( _BehaviorPackages.NumObjects() ); arc.ArchiveFloat( &pEntry->currentScore ); arc.ArchiveFloat( &pEntry->lastScore ); arc.ArchiveFloat( &pEntry->lastTimeExecuted ); arc.ArchiveFloat( &pEntry->priority ); } } else { numPackages = _BehaviorPackages.NumObjects(); arc.ArchiveInteger( &numPackages ); for ( i = 1 ; i <= _BehaviorPackages.NumObjects() ; i++ ) { pEntry = &_BehaviorPackages.ObjectAt( i ); package = PackageList.ObjectAt( pEntry->packageIndex ); arc.ArchiveString( &package->packageName ); arc.ArchiveFloat( &pEntry->currentScore ); arc.ArchiveFloat( &pEntry->lastScore ); arc.ArchiveFloat( &pEntry->lastTimeExecuted ); arc.ArchiveFloat( &pEntry->priority ); } } arc.ArchiveInteger( &_currentFVarIndex ); arc.ArchiveFloat( &_currentFVarLastExecuteTime ); arc.ArchiveInteger( &_currentPackageIndex ); }