opkg_build::opkg_build(QWidget *parent) : QWidget(parent), ui(new Ui::opkg_build) { ui->setupUi(this); ui->progressBar->hide(); QObject::connect(&build_thread_obj,SIGNAL(input_status(QString)),this,SLOT(on_input_statu(QString))); QObject::connect(&build_thread_obj,SIGNAL(change_statu_word(QString)),this,SLOT(on_change_statu_word(QString))); QObject::connect(&build_thread_obj,SIGNAL(change_progress(int)),this,SLOT(on_change_progress(int))); QObject::connect(&build_thread_obj,SIGNAL(done()),this,SLOT(on_done())); QObject::connect(this,SIGNAL(make_start(QString,QString,QString,QString,QString,QString)),&build_thread_obj,SIGNAL(build_start(QString,QString,QString,QString,QString,QString))); build_thread_obj.start(); }
PUBLIC float inverse_pf_fold(char *start, char *target) { double dist; int dang; dang=dangles; if (dangles!=0) dangles=2; update_fold_params(); /* make sure there is a valid pair matrix */ make_pairset(); make_start(start, target); fold_type=1; do_backtrack = 0; dist = adaptive_walk(start, target); dangles=dang; return (dist+final_cost); }
void opkg_build::on_Start_button_clicked() { if (ui->Input_line->text().isEmpty()|ui->Input_line->text().isNull()) { ui->status_text->append(tr("请输入 选择待打包的目录.")); return; } if (ui->Output_line->text().isEmpty()|ui->Output_line->text().isNull()) { ui->status_text->append(tr("请输入 保存离线包的目录.")); return; } QDir Idir(ui->Input_line->text()); if(!Idir.exists()) { ui->status_text->append(tr("待打包的目录不存在.")); return; } QDir Odir(ui->Output_line->text()); if(!Odir.exists()) { Odir.mkpath(ui->Output_line->text()); } if (ui->name->text().isEmpty()|ui->name->text().isNull()) { ui->status_text->append(tr("请输入 离线包名称.")); return; } if (ui->code_name->text().isEmpty()|ui->code_name->text().isNull()) { ui->status_text->append(tr("请输入 离线包标识码.")); return; } if (ui->welcome->text().isEmpty()|ui->welcome->text().isNull()) { ui->welcome->setText(""); } if (ui->publisher->text().isEmpty()|ui->publisher->text().isNull()) { ui->publisher->setText(""); } ui->progressBar->setValue(0); Q_EMIT make_start(QString(ui->Input_line->text().remove(QRegExp("[/\\\\]$"))+"/"),QString(ui->Output_line->text().remove(QRegExp("[/\\\\]$"))+"/"+ui->code_name->text()),ui->type->currentText().remove(QRegExp("\\(.*\\)")),ui->publisher->text(),ui->name->text(),ui->welcome->text()); disable_ui(); }
PUBLIC float inverse_fold(char *start, char *structure) { int i, j, jj, len, o; int *pt; char *string, *wstring, *wstruct, *aux; double dist=0; nc2 = j = o = fold_type = 0; len = strlen(structure); if (strlen(start)!=len) { fprintf(stderr, "%s\n%s\n", start, structure); nrerror("inverse_fold: start and structure have unequal length"); } string = (char *) space(len+1); wstring = (char *) space(len+1); wstruct = (char *) space(len+1); pt = (int *) space(sizeof(int)*(len+2)); pt[len] = len+1; aux = aux_struct(structure); strcpy(string, start); make_pairset(); make_start(string, structure); make_ptable(structure, pt); while (j<len) { while ((j<len)&&(structure[j]!=')')) { if (aux[j]=='[') o++; if (aux[j]==']') o--; j++; } i=j; while ((i>0) && structure[--i]!='('); if (structure[i]=='.') { /* no pair found -> open chain */ WALK(0,len-1); } if (aux[i]!='[') { i--; j++;} while (pt[j]==i) { backtrack_type='C'; if (aux[i]!='[') { while (aux[--i]!='['); while (aux[++j]!=']'); /* WALK(i,j); */ } WALK(i,j); o--; jj = j; i--; while (aux[++j]=='.'); while ((i>=0)&&(aux[i]=='.')) i--; if (pt[j]!=i) { backtrack_type = (o==0)? 'F' : 'M'; if (j-jj>8) { WALK((i+1),(jj)); } WALK((i+1), (j-1)); while ((i>=0) &&(aux[i]==']')) { i=pt[i]-1; while ((i>=0)&&(aux[i]=='.')) i--; WALK((i+1), (j-1)); } } } } adios: backtrack_type='F'; if ((dist>0)&&(inv_verbose)) printf("%s\n%s\n", wstring, wstruct); /*if ((dist==0)||(give_up==0))*/ strcpy(start, string); free(wstring); free(wstruct); free(string); free(aux); free(pt); /* if (dist>0) printf("%3d \n", nc2); */ return dist; }
Path Search::search() { expanded = 0; Node* cur; Path ans(cost_maps[0]); make_goal(goal); fringe.push(make_start(start)); double cur_f = -1; int iter = 0; while (! fringe.is_empty()) { iter++; cur = fringe.pop(); cur->set_state(CLOSED); /// printf("Pop "); /// cur->print(stdout); if (cur_f - cur->f > 1e-6 ) { fprintf(stderr, "f value of node being expanded decreased\n"); fprintf(stdout, "Node above has f-value lower than previously closed node (%.1lf < %.1lf)\n", cur->f, cur_f); } cur_f = cur->f; expanded++; // If we are done, construct the path if (cur->check_state(GOAL)) { do { ans.add_node(Node(cur)); cur = cur->prev; } while (cur != NULL); break; } // Consider neighbours Point next_pos(cur->pos); while (next_successor(cur->pos, next_pos)) { double cost = step_cost(cur->pos, next_pos); if (cost >= 0 && cost < HUGE_VAL) { double ncost = cur->g + cost; Node* next = get_node(next_pos); if (next->check_state(CLOSED)) { continue; } else if (next->check_state(FRINGE)) { if (ncost < next->g) { // update it next->g = ncost; next->f = next->g + next->h; next->prev = cur; fringe.update(next); } } else { next->h = heuristic(next_pos); next->g = ncost; next->f = next->g + next->h; next->prev = cur; /// printf("Push 0 "); /// next->print(stdout); fringe.push(next); } } } } /// for (int i = 0; i < levels; i++) { /// printf("level %d:\n", i); /// printf("Map Costs\n"); /// cost_maps[i]->print(stdout); /// printf("Path costs\n"); /// path_maps[i]->print(stdout); /// } /// ans.print(stdout); return ans; }