idxint scs_solve(Work * w, Data * d, Cone * k, Sol * sol, Info * info) { idxint i; timer solveTimer; struct residuals r; if (!d || !k || !sol || !info || !w || !d->b || !d->c) { scs_printf("ERROR: NULL input\n"); return FAILURE; } tic(&solveTimer); info->statusVal = 0; /* not yet converged */ updateWork(d, w, sol); if (d->VERBOSE) printHeader(d, w, k); /* scs: */ for (i = 0; i < d->MAX_ITERS; ++i) { memcpy(w->u_prev, w->u, (d->n + d->m + 1) * sizeof(pfloat)); if (projectLinSys(d, w, i) < 0) return failureDefaultReturn(d, w, sol, info, "error in projectLinSys"); if (projectCones(d, w, k, i) < 0) return failureDefaultReturn(d, w, sol, info, "error in projectCones"); updateDualVars(d, w); if ((info->statusVal = converged(d, w, &r, i)) != 0) break; if (i % PRINT_INTERVAL == 0) { if (d->VERBOSE) { printSummary(i, &r, &solveTimer); #ifdef EXTRAVERBOSE scs_printf("Norm u = %4f, ", calcNorm(w->u, d->n + d->m + 1)); scs_printf("Norm u_t = %4f, ", calcNorm(w->u_t, d->n + d->m + 1)); scs_printf("Norm v = %4f, ", calcNorm(w->v, d->n + d->m + 1)); scs_printf("tau = %4f, ", w->u[d->n + d->m]); scs_printf("kappa = %4f, ", w->v[d->n + d->m]); scs_printf("|u - u_prev| = %4f, ", calcNormDiff(w->u, w->u_prev, d->n + d->m + 1)); scs_printf("|u - u_t| = %4f\n", calcNormDiff(w->u, w->u_t, d->n + d->m + 1)); #endif } } } if (d->VERBOSE) { printSummary(i, &r, &solveTimer); } setSolution(d, w, sol, info); /* populate info */ info->iter = i; getInfo(d, w, sol, info); info->solveTime = tocq(&solveTimer); if (d->VERBOSE) printFooter(d, w, info); /* un-normalize sol, b, c but not A */ if (d->NORMALIZE) unNormalizeSolBC(d, w, sol); return info->statusVal; }
void GetBlockTemplateContext::queryWork() { // JSON-request creation char *request; { blktemplate_t *t = blktmpl_create(); json_t *jsonRequest = blktmpl_request_jansson(blktmpl_addcaps(t), 0); request = json_dumps(jsonRequest, JSON_INDENT(2)); json_delete(jsonRequest); blktmpl_free(t); } curl_slist *header = curl_slist_append(0, "User-Agent: xpmminer"); curl_slist_append(header, "Content-Type: application/json"); CURL *curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, _url); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_easy_setopt(curl, CURLOPT_USERNAME, _user); curl_easy_setopt(curl, CURLOPT_PASSWORD, _password); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request); while (1) { _response.clear(); if (curl_easy_perform(curl) != CURLE_OK) { logFormattedWrite(_log, "block receiving error!"); } else { updateWork(); } xsleep(_timeout); } }
void FlyServer::setWork(QString title, QTime endTime) { _work->setTitle(title); _work->setEndTime(endTime); emit updateWork(); }