void LinuxDiskDriveProvider::enumerateInstances( const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler ) { DiskDriveData diskdriveData; MediaAccessDeviceInformation *curDiskDrive; handler.processing(); curDiskDrive = diskdriveData.GetFirstDiskDrive(); while (curDiskDrive) { handler.deliver(build_instance(DISKDRIVECLASSNAME, curDiskDrive)); delete curDiskDrive; curDiskDrive = diskdriveData.GetNextDiskDrive(); } diskdriveData.EndGetDiskDrive(); handler.complete(); }
void tst_sat_local_search(char ** argv, int argc, int& i) { if (argc < i + 2) { std::cout << "require dimacs file name\n"; return; } reslimit limit; params_ref params; sat::solver solver(params, limit); sat::local_search local_search; local_search.import(solver, true); char const* file_name = argv[i + 1]; ++i; int cutoff_time = 1; int v; while (i + 1 < argc) { std::cout << argv[i + 1] << "\n"; // set other ad hoc parameters. if (argv[i + 1][0] == '-' && i + 2 < argc) { switch (argv[i + 1][1]) { case 's': // seed v = atoi(argv[i + 2]); local_search.config().set_random_seed(v); break; case 't': // cutoff_time v = atoi(argv[i + 2]); cutoff_time = v; break; case 'b': // best_known_value v = atoi(argv[i + 2]); local_search.config().set_best_known_value(v); break; default: ++i; v = -1; break; } } ++i; } if (!build_instance(file_name, solver, local_search)) { return; } //std::cout << "local instance built\n"; // set up cancellation/timeout environment. cancel_eh<reslimit> eh(local_search.rlimit()); scoped_ctrl_c ctrlc(eh, false, true); scoped_timer timer(cutoff_time*1000, &eh); local_search.check(); }
void LinuxNetworkAdapterProvider::getInstance(const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { Array<CIMKeyBinding> keys = ref.getKeyBindings(); Uint32 i; NetworkAdapterData* located_interface; String unique_name; CIMName className; enum network_provider_types classType; className = ref.getClassName(); if (className.equal("Linux_EthernetAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_ETHERNET; } else if (className.equal("Linux_NetworkAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_OTHER; } else { throw CIMNotSupportedException(className.getString() + "::getInstance"); } for (i = 0; i < keys.size(); i++) if (keys[i].getName() == CIMName("Name")) unique_name = keys[i].getValue(); handler.processing(); located_interface = LocateInterface(unique_name); if (located_interface != NULL && interface_is_my_type(classType,located_interface)) { CIMInstance instance = build_instance(className, classType, located_interface); handler.deliver(instance); } delete located_interface; handler.complete(); return; }
void LinuxNetworkAdapterProvider::enumerateInstances( const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { int i; NetworkAdapterData *iface; vector<String> adapter_names; CIMName className; enum network_provider_types classType; className = ref.getClassName(); if (className.equal("Linux_EthernetAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_ETHERNET; } else if (className.equal("Linux_NetworkAdapter")) { classType = NETWORK_ADAPTER_PROVIDER_OTHER; } else { throw CIMNotSupportedException(className.getString() + "::enumerateInstances"); } adapter_names = NetworkAdapterData::list_all_adapters(); handler.processing(); for (i = 0; i < (int) adapter_names.size(); i++) { iface = LocateInterface(adapter_names[i]); if (iface != NULL && interface_is_my_type(classType, iface)) handler.deliver(build_instance(className, classType, iface)); delete iface; } handler.complete(); }
void LinuxDiskDriveProvider::getInstance(const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { DiskDriveData diskdriveData; MediaAccessDeviceInformation *curDiskDrive; Array<CIMKeyBinding> keys = ref.getKeyBindings(); Uint32 i; String nameString; handler.processing(); /* Get the diskdrive that was requested */ i = 0; while (i < keys.size()) { if (keys[i].getName() == CIMName("Name")) nameString = keys[i].getValue(); i++; } if (nameString != String::EMPTY) { curDiskDrive = diskdriveData.GetDiskDrive(nameString); if (curDiskDrive!=NULL) { CIMInstance instance = build_instance(DISKDRIVECLASSNAME, curDiskDrive); handler.deliver(instance); delete curDiskDrive; } } handler.complete(); return; }
/* * Call solver on file given as an argument */ int main(int argc, char *argv[]) { int resu; if (argc != 2) { fprintf(stderr, "Usage: %s <input file>\n", argv[0]); exit(1); } resu = build_instance(argv[1], &solver); if (resu < 0) { exit(2); } construction_time = get_cpu_time(); print_problem_size(stdout, &solver, argv[1], construction_time); init_handler(); sat_solve(&solver, NULL, true); search_time = get_cpu_time() - construction_time; print_results(&solver, construction_time, search_time); delete_smt_core(&solver); return 0; }
int main(int argc, char* argv[]) { int seed,i; //cout<<"c This is NuMVC, a local search solver for the Minimum Vertex Cover (and also Maximum Independent Set) problem."<<endl; if(build_instance(argv[1])!=1){ cout<<"can't open instance file"<<endl; return -1; } optimal_size=0; i=2; //sscanf(argv[i++],"%d",&cand_count);//if you want to stop the algorithm only cutoff time is reached, set optimal_size to 0. //sscanf(argv[i++],"%d",&edge_cand); sscanf(argv[i++],"%d",&seed); sscanf(argv[i++],"%d",&cutoff_time); srand(seed); //cout<<seed<<' '; //cout<<argv[1]<<' '; times(&start); start_time = start.tms_utime + start.tms_stime; init_sol(); #ifdef individual_analysis_on_init_sls_mode times(&finish); init_time = double(finish.tms_utime - start.tms_utime + finish.tms_stime - start.tms_stime) / sysconf(_SC_CLK_TCK); init_time = round(init_time * 100)/100.0; #endif //if(c_size + uncov_stack_fill_pointer > optimal_size ) //{ //cout<<"c Start local search..."<<endl; cover_LS(); //} #ifdef individual_analysis_on_init_sls_mode times(&finish); sls_time = double(finish.tms_utime - start.tms_utime + finish.tms_stime - start.tms_stime) / sysconf(_SC_CLK_TCK) - init_time; sls_step_speed_per_ms = double(step) * 0.001 / sls_time; #endif //check solution if(check_solution()==1) { cout << "o " << best_c_size << endl; //cout << best_c_size << ' '; //print_mvc_solution(); cout << "c searchSteps " << best_step << endl; //printf("%ld ", best_step); cout << "c solveTime " << best_comp_time << endl; //cout << "c stepVelocity(/0.001ms) " << (long double)(best_step) / (best_comp_time * 1000000) << endl; /*cout<<"c Best found vertex cover size = "<<best_c_size<<endl; print_solution(); cout<<"c searchSteps = "<<best_step<<endl; cout<<"c solveTime = "<<best_comp_time<<endl;*/ //cout<<best_c_size<<' '<<best_comp_time<<' '<<best_step<<endl; #ifdef individual_analysis_on_init_sls_mode //cout<<"c initTime " << init_time << endl; //cout<<"c slsTime " << sls_time << endl; cout<<"c stepSpeed(/ms) "<< sls_step_speed_per_ms << endl; #endif } else { cout<<"the solution is wrong."<<endl; //print_solution(); } free_memory(); return 0; }
inline void operator()() { build_instance(); }