// The contents of this file are subject to the BOINC Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations // under the License. // // The Original Code is the Berkeley Open Infrastructure for Network Computing. // // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 // University of California at Berkeley. All Rights Reserved. // // Contributor(s): // using namespace std; #include #include "boinc_db.h" #include "config.h" #include "parse.h" #include "sched_util.h" extern CONFIG config; // get the name of a result's (first) output file // int get_output_file_path(RESULT& result, char* path) { char buf[256]; bool flag; flag = parse_str(result.xml_doc_in, "", buf, sizeof(buf)); if (!flag) return -1; sprintf(path, "%s/%s", config.upload_dir, buf); return 0; } // crude example of a validation function. // See if there's a strict majority under equality. // int check_set(vector& results, int& canonicalid, double& credit) { int i, j, n, neq=0, retval, ilow, ihigh, canonical; char* files[100]; char path[256]; bool found; double c, low=0.0, high=0.0; canonical = 0; n = results.size(); // read the result files into malloc'd memory buffers // for (i=0; i n/2) { found = true; canonical = i; canonicalid = results[i].id; break; } } // if we have a canonical result, flag all matching results as valid // Also find the low and high claimed credits // ilow = ihigh = -1; for (i=0; i high) { high = c; ihigh = i; } } } else { results[i].validate_state = VALIDATE_STATE_INVALID; } } // if we have a canonical result, compute a canonical credit as follows: // - if N==1, give that credit // - if N==2, give min credit // - if N>2, toss out min and max, give average of rest // if (neq == 1) { credit = low; } else if (neq == 2) { credit = low; } else { double sum = 0; for (i=0; i