Results 1 to 6 of 6

Thread: RAC badges

  1. #1
    Advisor - Stateside Division
    Bok's Avatar
    Join Date
    October 14th, 2010
    Location
    Wake Forest, NC
    Posts
    1,211

    RAC badges

    Hoping someone can give a little help with the algorithm that BOINc is using for the RAC badges (which I dislike anyway!)

    This is what i posted over at the Convector pages, but have not had a response.

    Can you give more explanation of the various levels of badges? I see 1%, 2%, 7%,25% and a broken image for 40% ?

    also, I'm trying to calculate the badges myself with my database over at Free-DC, but I don;t seem to be getting quite the same results.

    for the top 1% my calculation shows the top 6 should be getting the 1% badge, this is the way I'm calculating it, might just be difference between real time here and using the xml data in my database.

    Top 1% is ((#users with RAC >1) * 1/100) + 0.5

    This comes out to 601 * 1/100 + 0.5 = 6.51 so any user with an RAC rank higher than this should have the 1% badge which is the top 6.

    userid 1807 is 7th in RAC rank but appears to have the 1% badge.

    I kind of guessed at the calculation so it may well be incorrect, but it seems to work with the data over at NFS@Home

    I looked at the source code a little for BOINC to help and it does seem to only use users with a RAC > 1.

    Thanks

    Bok

  2. #2
    Platinum Member
    John P. Myers's Avatar
    Join Date
    January 13th, 2011
    Location
    Jackson, TN
    Posts
    4,502

    Re: RAC badges

    Perhaps they are figuring it using RAC >= 1 or RAC > 0?


  3. #3
    Advisor - Stateside Division
    Bok's Avatar
    Join Date
    October 14th, 2010
    Location
    Wake Forest, NC
    Posts
    1,211

    Re: RAC badges

    I thought that too, but >= 1 still gives top6 only in the 1% and >0 gives 14.

    Pretty sure they are using the base code, so perhaps I'm just not understanding it. I couldn't find the actual code that does it in the BOINC git repository, just the function that called it.

  4. #4
    Advisor - Stateside Division
    Bok's Avatar
    Join Date
    October 14th, 2010
    Location
    Wake Forest, NC
    Posts
    1,211

    Re: RAC badges

    Luckily I found out that Collatz is doing it, so I tested my algorithm with theirs, figured Slicker would have it right and mine matches correctly.

    So conclusion is that Convector have it different somehow or have just coded it wrongly..

  5. #5
    Gold Member
    Slicker's Avatar
    Join Date
    October 25th, 2010
    Location
    South of Cheeseland
    Posts
    1,253

    Re: RAC badges

    #!/usr/bin/env php
    <?php
    // This file is part of BOINC.
    // http://boinc.berkeley.edu
    // Copyright (C) 2013 University of California
    //
    // BOINC is free software; you can redistribute it and/or modify it
    // under the terms of the GNU Lesser General Public License
    // as published by the Free Software Foundation,
    // either version 3 of the License, or (at your option) any later version.
    //
    // BOINC is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    // See the GNU Lesser General Public License for more details.
    //
    // You should have received a copy of the GNU Lesser General Public License
    // along with BOINC. If not, see <http://www.gnu.org/licenses/>.


    // Assign badges based on RAC percentile.
    // Customize this to grant other types of badges


    require_once("../inc/util_ops.inc");


    // thresholds for the various badges
    // (i.e. gold badge is for top 1% of active users/teams)
    //
    $badge_pctiles = array(1, 5, 25);
    $badge_images = array("pct_1.png", "pct_5.png", "pct_25.png");


    // get the records for percentile badges; create them if needed
    //
    function get_pct_badges($badge_name_prefix, $badge_pctiles, $badge_images) {
    $badges = array();
    for ($i=0; $i<3; $i++) {
    $badges[$i] = get_badge($badge_name_prefix."_".$i, "Top ".$badge_pctiles[$i]."% in average credit", $badge_images[$i]);
    }
    return $badges;
    }
    // get the RAC percentiles from the database
    //
    function get_percentiles($is_user, $badge_pctiles) {
    $percentiles = array();
    for ($i=0; $i<3; $i++) {
    if ($is_user) {
    $percentiles[$i] = BoincUser:ercentile("expavg_credit", "expavg_credit>1", 100-$badge_pctiles[$i]);
    } else {
    $percentiles[$i] = BoincTeam:ercentile("expavg_credit", "expavg_credit>1", 100-$badge_pctiles[$i]);
    }
    if ($percentiles[$i] === false) {
    die("Can't get percentiles\n");
    }
    }
    return $percentiles;
    }


    // decide which badge to assign, if any.
    // Unassign other badges.
    //
    function assign_pct_badge($is_user, $item, $percentiles, $badges) {
    for ($i=0; $i<3; $i++) {
    if ($item->expavg_credit >= $percentiles[$i]) {
    assign_badge($is_user, $item, $badges[$i]);
    unassign_badges($is_user, $item, $badges, $i);
    return;
    }
    unassign_badges($is_user, $item, $badges, -1);
    }


    // Scan through all the users/teams, 1000 at a time,
    // and assign/unassign RAC badges
    //
    function assign_badges($is_user, $badge_pctiles, $badge_images) {
    $kind = $is_user?"user":"team";
    $badges = get_pct_badges($kind."_pct", $badge_pctiles, $badge_images);
    $pctiles = get_percentiles($is_user, $badge_pctiles);
    echo "thresholds for $kind badges: $pctiles[0] $pctiles[1] $pctiles[2]\n";


    $n = 0;
    $maxid = $is_user?BoincUser::max("id"):BoincTeam::max("id") ;
    while ($n <= $maxid) {
    $m = $n + 1000;
    if ($is_user) {
    $items = BoincUser::enum_fields("id, expavg_credit", "id>=$n and id<$m and total_credit>0");
    } else {
    $items = BoincTeam::enum_fields("id, expavg_credit", "id>=$n and id<$m and total_credit>0");
    }
    foreach ($items as $item) {
    assign_pct_badge($is_user, $item, $pctiles, $badges);


    // ... assign other types of badges
    }
    $n = $m;
    }
    }


    assign_badges(true, $badge_pctiles, $badge_images);
    assign_badges(false, $badge_pctiles, $badge_images);


    ?>



    That's the source, but the MySQL table contains a field named "sql_rule" which I believe the project admin can override in order to change the way it awards badges. DA, of course, wants everyone that already has badges to change the his version. So far, no one has. Maybe it is because that with his scheme, you may have a badge one day but it can get taken away from you the next. That isn't right! If you earned it, it should be yours forever.

    Anyway, collatz didn't change his code. My guess is that Convector did. Maybe they removed the code that clears the badges before re-assigning so that if you earned it at any time you get to keep it. I have considered doing that.
    Spring 2008 Race: (1st Place)

  6. #6
    Advisor - Stateside Division
    Bok's Avatar
    Join Date
    October 14th, 2010
    Location
    Wake Forest, NC
    Posts
    1,211

    Re: RAC badges

    Right, I'd seen that bit of the code, but not the BoincUser:ercentile part, so wasn't sure of that was doing something different.

    Good point that he may have taken away the delete, it looks horribly inefficient they way it's coded anyway going through everyone, but if they do that then without an export of the badges there would be no way for me to figure them out with the data in my tables and I hate scraping pages...

    mine is a little easier, though I was a little lazy on some parts of it, like using the fetchrow_array on a single column, but wth..

    Code:
    sub pctbadges {
    
     ($proj, $subproj, $pct, $pct2,$badge) = @_;
      print "proj is $proj, lowerbound is $lowerbound, upperbound is $upperbound, badge is $badge...\n";
      $sql = "select (count(*) * $pct/100) + 0.5 from dcfree.boinc_user where proj = '$proj' and metric2 > 1";
      $query = $dbh->prepare($sql);
      $query->execute;
      $racpercentile1 = $query->fetchrow_array;
      print "racpercentile = $racpercentile1, subproj is $subproj\n";
      $sql = "select (count(*) * $pct2/100) + 0.5 from dcfree.boinc_user where proj = '$proj' and metric2 > 1";
      $query = $dbh->prepare($sql);
      $query->execute;
      $racpercentile2 = $query->fetchrow_array;
      print "racpercentile = $racpercentile2, subproj is $subproj\n";
      $query->finish;
      $sql = "delete from static.boinc_badges where proj = '$proj' and subproj='$subproj'";
      $query = $dbh->prepare($sql);
      $query->execute;
      $query->finish;
      $sql = "insert into static.boinc_badges (select '$proj','$subproj',id,cpid,'$badge' from dcfree.boinc_user where proj = '$proj' and racrank0 < $racpercentile1 and racrank0 > $racpercentile2)";
      $query = $dbh->prepare($sql);
      $query->execute;
      $query->finish;
    }
    It seems to work for your project though so the badges are displaying



    Quote Originally Posted by Slicker View Post

    That's the source, but the MySQL table contains a field named "sql_rule" which I believe the project admin can override in order to change the way it awards badges. DA, of course, wants everyone that already has badges to change the his version. So far, no one has. Maybe it is because that with his scheme, you may have a badge one day but it can get taken away from you the next. That isn't right! If you earned it, it should be yours forever.

    Anyway, collatz didn't change his code. My guess is that Convector did. Maybe they removed the code that clears the badges before re-assigning so that if you earned it at any time you get to keep it. I have considered doing that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •