liquid_feedback_core

changeset 142:54ac8c473263

Use an improved definition for "disqualified" initiatives

"initiative"."disqualified" is TRUE, if the initiative may not win, because it either (a) has no better rank than the status quo, or (b) because there exists a better ranked initiative X, which directly beats this initiative, and either more voters prefer X to this initiative than voters preferring X to the status quo or less voters prefer this initiative to X than voters preferring the status quo to X
author jbe
date Wed Jun 01 16:58:00 2011 +0200 (2011-06-01)
parents f21a0b10f8ed
children 9d78380d1974
files core.sql
line diff
     1.1 --- a/core.sql	Sun May 29 20:44:07 2011 +0200
     1.2 +++ b/core.sql	Wed Jun 01 16:58:00 2011 +0200
     1.3 @@ -584,8 +584,8 @@
     1.4  COMMENT ON COLUMN "initiative"."unfavored"            IS 'TRUE, if initiative has a schulze-ranking worse than the status quo (without tie-breaking)';
     1.5  COMMENT ON COLUMN "initiative"."preliminary_rank"     IS 'Schulze-Ranking without tie-breaking';
     1.6  COMMENT ON COLUMN "initiative"."final_rank"           IS 'Schulze-Ranking after tie-breaking';
     1.7 -COMMENT ON COLUMN "initiative"."disqualified"         IS 'TRUE, if initiative may not win, because it is directly beaten with a simple majority by a better ranked initiative or by a better ranked status quo (without tie-breaking)';
     1.8 -COMMENT ON COLUMN "initiative"."winner"               IS 'TRUE, if initiative is final winner (best ranked initiative being "attainable", "favored", and not "disqualified")';
     1.9 +COMMENT ON COLUMN "initiative"."disqualified"         IS 'TRUE, if initiative may not win, because it either (a) has no better rank than the status quo, or (b) because there exists a better ranked initiative X, which directly beats this initiative, and either more voters prefer X to this initiative than voters preferring X to the status quo or less voters prefer this initiative to X than voters preferring the status quo to X';
    1.10 +COMMENT ON COLUMN "initiative"."winner"               IS 'TRUE, if initiative is final winner (best ranked initiative being "attainable" and not "disqualified")';
    1.11  
    1.12  
    1.13  CREATE TABLE "battle" (
    1.14 @@ -3813,7 +3813,7 @@
    1.15              "favored"          = "rank_ary"["i"] < "rank_ary"["dimension_v"],
    1.16              "unfavored"        = "rank_ary"["i"] > "rank_ary"["dimension_v"],
    1.17              "preliminary_rank" = "rank_ary"["i"],
    1.18 -            "disqualified"     = FALSE,
    1.19 +            "disqualified"     = "rank_ary"["i"] >= "rank_ary"["dimension_v"],
    1.20              "winner"           = FALSE
    1.21              WHERE "id" = "initiative_id_v";
    1.22            "i" := "i" + 1;
    1.23 @@ -3835,34 +3835,25 @@
    1.24            FROM (
    1.25              SELECT "losing_initiative"."id" AS "initiative_id"
    1.26              FROM "initiative" "losing_initiative"
    1.27 -            JOIN "battle_participant" "winning_participant"
    1.28 -              ON "winning_participant"."issue_id" = "issue_id_p"
    1.29 -            LEFT JOIN "initiative" "winning_initiative"
    1.30 -              ON "winning_initiative"."id" = "winning_participant"."id"
    1.31 -            -- NOTE: winner may be status quo:
    1.32 -            -- "losing_initiative"."id" is always NOTNULL
    1.33 -            -- while "winning_initiative"."id" may be NULL
    1.34 +            JOIN "initiative" "winning_initiative"
    1.35 +              ON "winning_initiative"."issue_id" = "issue_id_p"
    1.36 +              AND "winning_initiative"."admitted"
    1.37              JOIN "battle" "battle_win"
    1.38                ON "battle_win"."issue_id" = "issue_id_p"
    1.39 -              AND (
    1.40 -                "battle_win"."winning_initiative_id" = "winning_initiative"."id" OR
    1.41 -                ( "battle_win"."winning_initiative_id" ISNULL AND
    1.42 -                  "winning_initiative"."id" ISNULL ) )
    1.43 +              AND "battle_win"."winning_initiative_id" = "winning_initiative"."id"
    1.44                AND "battle_win"."losing_initiative_id" = "losing_initiative"."id"
    1.45              JOIN "battle" "battle_lose"
    1.46                ON "battle_lose"."issue_id" = "issue_id_p"
    1.47 -              AND (
    1.48 -                "battle_lose"."losing_initiative_id" = "winning_initiative"."id" OR
    1.49 -                ( "battle_lose"."losing_initiative_id" ISNULL AND
    1.50 -                  "winning_initiative"."id" ISNULL ) )
    1.51 +              AND "battle_lose"."losing_initiative_id" = "winning_initiative"."id"
    1.52                AND "battle_lose"."winning_initiative_id" = "losing_initiative"."id"
    1.53              WHERE "losing_initiative"."issue_id" = "issue_id_p"
    1.54              AND "losing_initiative"."admitted"
    1.55 +            AND "winning_initiative"."preliminary_rank" <
    1.56 +                "losing_initiative"."preliminary_rank"
    1.57 +            AND "battle_win"."count" > "battle_lose"."count"
    1.58              AND (
    1.59 -              ("winning_initiative"."id" ISNULL AND "losing_initiative"."unfavored") OR
    1.60 -              ( "winning_initiative"."preliminary_rank" <
    1.61 -                "losing_initiative"."preliminary_rank" ) )
    1.62 -            AND "battle_win"."count" > "battle_lose"."count"
    1.63 +              "battle_win"."count" > "winning_initiative"."positive_votes" OR
    1.64 +              "battle_lose"."count" < "losing_initiative"."negative_votes" )
    1.65            ) AS "subquery"
    1.66            WHERE "id" = "subquery"."initiative_id";
    1.67          -- calculate final ranks (start counting with 1, no equal ranks):
    1.68 @@ -3882,7 +3873,7 @@
    1.69              SELECT "id" AS "initiative_id"
    1.70              FROM "initiative"
    1.71              WHERE "issue_id" = "issue_id_p"
    1.72 -            AND "attainable" AND "favored" AND NOT "disqualified"
    1.73 +            AND "attainable" AND NOT "disqualified"
    1.74              ORDER BY "final_rank"
    1.75              LIMIT 1
    1.76            ) AS "subquery"

Impressum / About Us