liquid_feedback_core
changeset 429:a16072fc288a
Re-added experimental "no_reverse_beat_path" feature for next minor version (provides backward compatibility)
author | jbe |
---|---|
date | Thu May 22 05:13:22 2014 +0200 (2014-05-22) |
parents | d0b4fa073ad3 |
children | 3031c1973748 |
files | core.sql test.sql |
line diff
1.1 --- a/core.sql Thu May 22 04:35:26 2014 +0200 1.2 +++ b/core.sql Thu May 22 05:13:22 2014 +0200 1.3 @@ -386,6 +386,7 @@ 1.4 "indirect_majority_strict" BOOLEAN NOT NULL DEFAULT TRUE, 1.5 "indirect_majority_positive" INT4 NOT NULL DEFAULT 0, 1.6 "indirect_majority_non_negative" INT4 NOT NULL DEFAULT 0, 1.7 + "no_reverse_beat_path" BOOLEAN NOT NULL DEFAULT FALSE, 1.8 "no_multistage_majority" BOOLEAN NOT NULL DEFAULT FALSE, 1.9 CONSTRAINT "timing" CHECK ( 1.10 ( "polling" = FALSE AND 1.11 @@ -399,7 +400,10 @@ 1.12 "verification_time" ISNULL AND "voting_time" ISNULL ) ), 1.13 CONSTRAINT "issue_quorum_if_and_only_if_not_polling" CHECK ( 1.14 "polling" = "issue_quorum_num" ISNULL AND 1.15 - "polling" = "issue_quorum_den" ISNULL ) ); 1.16 + "polling" = "issue_quorum_den" ISNULL ), 1.17 + CONSTRAINT "no_reverse_beat_path_requires_tuple_defeat_strength" CHECK ( 1.18 + "defeat_strength" = 'tuple'::"defeat_strength" OR 1.19 + "no_reverse_beat_path" = FALSE ) ); 1.20 CREATE INDEX "policy_active_idx" ON "policy" ("active"); 1.21 1.22 COMMENT ON TABLE "policy" IS 'Policies for a particular proceeding type (timelimits, quorum)'; 1.23 @@ -427,7 +431,8 @@ 1.24 COMMENT ON COLUMN "policy"."indirect_majority_strict" IS 'If TRUE, then the indirect majority must be strictly greater than "indirect_majority_num"/"indirect_majority_den", otherwise it may also be equal.'; 1.25 COMMENT ON COLUMN "policy"."indirect_majority_positive" IS 'Absolute number of votes in favor of the winner neccessary in a beat path to the status quo for an initaitive to be attainable as winner'; 1.26 COMMENT ON COLUMN "policy"."indirect_majority_non_negative" IS 'Absolute number of sum of votes in favor and abstentions in a beat path to the status quo for an initiative to be attainable as winner'; 1.27 -COMMENT ON COLUMN "policy"."no_multistage_majority" IS 'EXPERIMENTAL FEATURE: Causes initiatives with "multistage_majority" flag to not be "eligible", thus disallowing them to be winner. See comment on column "initiative"."multistage_majority". This disqualifies initiatives which could cause an instable result. An instable result in this meaning is a result such that repeating the ballot with same preferences but with the winner of the first ballot as status quo would lead to a different winner in the second ballot.'; 1.28 +COMMENT ON COLUMN "policy"."no_reverse_beat_path" IS 'EXPERIMENTAL FEATURE: Causes initiatives with "reverse_beat_path" flag to not be "eligible", thus disallowing them to be winner. See comment on column "initiative"."reverse_beat_path". This option ensures both that a winning initiative is never tied in a (weak) condorcet paradox with the status quo and a winning initiative always beats the status quo directly with a simple majority.'; 1.29 +COMMENT ON COLUMN "policy"."no_multistage_majority" IS 'EXPERIMENTAL FEATURE: Causes initiatives with "multistage_majority" flag to not be "eligible", thus disallowing them to be winner. See comment on column "initiative"."multistage_majority". This disqualifies initiatives which could cause an instable result. An instable result in this meaning is a result such that repeating the ballot with same preferences but with the winner of the first ballot as status quo would lead to a different winner in the second ballot. If there are no direct majorities required for the winner, or if in direct comparison only simple majorities are required and "no_reverse_beat_path" is true, then results are always stable and this flag does not have any effect on the winner (but still affects the "eligible" flag of an "initiative").'; 1.30 1.31 1.32 CREATE TABLE "unit" ( 1.33 @@ -667,6 +672,7 @@ 1.34 "schulze_rank" INT4, 1.35 "better_than_status_quo" BOOLEAN, 1.36 "worse_than_status_quo" BOOLEAN, 1.37 + "reverse_beat_path" BOOLEAN, 1.38 "multistage_majority" BOOLEAN, 1.39 "eligible" BOOLEAN, 1.40 "winner" BOOLEAN, 1.41 @@ -685,7 +691,7 @@ 1.42 "direct_majority" ISNULL AND "indirect_majority" ISNULL AND 1.43 "schulze_rank" ISNULL AND 1.44 "better_than_status_quo" ISNULL AND "worse_than_status_quo" ISNULL AND 1.45 - "multistage_majority" ISNULL AND 1.46 + "reverse_beat_path" ISNULL AND "multistage_majority" ISNULL AND 1.47 "eligible" ISNULL AND "winner" ISNULL AND "rank" ISNULL ) ), 1.48 CONSTRAINT "better_excludes_worse" CHECK (NOT ("better_than_status_quo" AND "worse_than_status_quo")), 1.49 CONSTRAINT "minimum_requirement_to_be_eligible" CHECK ( 1.50 @@ -725,8 +731,9 @@ 1.51 COMMENT ON COLUMN "initiative"."schulze_rank" IS 'Schulze-Ranking'; 1.52 COMMENT ON COLUMN "initiative"."better_than_status_quo" IS 'TRUE, if initiative has a schulze-ranking better than the status quo'; 1.53 COMMENT ON COLUMN "initiative"."worse_than_status_quo" IS 'TRUE, if initiative has a schulze-ranking worse than the status quo (DEPRECATED, since schulze-ranking is unique per issue; use "better_than_status_quo"=FALSE)'; 1.54 +COMMENT ON COLUMN "initiative"."reverse_beat_path" IS 'TRUE, if there is a beat path (may include ties) from this initiative to the status quo; set to NULL if "policy"."defeat_strength" is set to ''simple'''; 1.55 COMMENT ON COLUMN "initiative"."multistage_majority" IS 'TRUE, if either (a) this initiative has no better rank than the status quo, or (b) 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.56 -COMMENT ON COLUMN "initiative"."eligible" IS 'Initiative has a "direct_majority" and an "indirect_majority", is "better_than_status_quo" and depending on selected policy the initiative has no "multistage_majority"'; 1.57 +COMMENT ON COLUMN "initiative"."eligible" IS 'Initiative has a "direct_majority" and an "indirect_majority", is "better_than_status_quo" and depending on selected policy the initiative has no "reverse_beat_path" or "multistage_majority"'; 1.58 COMMENT ON COLUMN "initiative"."winner" IS 'Winner is the "eligible" initiative with best "schulze_rank"'; 1.59 COMMENT ON COLUMN "initiative"."rank" IS 'Unique ranking for all "admitted" initiatives per issue; lower rank is better; a winner always has rank 1, but rank 1 does not imply that an initiative is winner; initiatives with "direct_majority" AND "indirect_majority" always have a better (lower) rank than other initiatives'; 1.60 1.61 @@ -4195,6 +4202,9 @@ 1.62 "better_than_status_quo" = "rank_ary"["i"] < "rank_ary"[1], 1.63 "worse_than_status_quo" = "rank_ary"["i"] > "rank_ary"[1], 1.64 "multistage_majority" = "rank_ary"["i"] >= "rank_ary"[1], 1.65 + "reverse_beat_path" = CASE WHEN "policy_row"."defeat_strength" = 'simple'::"defeat_strength" 1.66 + THEN NULL 1.67 + ELSE "matrix_p"[1]["i"]."primary" >= 0 END, 1.68 "eligible" = FALSE, 1.69 "winner" = FALSE, 1.70 "rank" = NULL -- NOTE: in cases of manual reset of issue state 1.71 @@ -4273,7 +4283,10 @@ 1.72 AND "initiative"."better_than_status_quo" 1.73 AND ( 1.74 "policy_row"."no_multistage_majority" = FALSE OR 1.75 - "initiative"."multistage_majority" = FALSE ); 1.76 + "initiative"."multistage_majority" = FALSE ) 1.77 + AND ( 1.78 + "policy_row"."no_reverse_beat_path" = FALSE OR 1.79 + coalesce("initiative"."reverse_beat_path", FALSE) = FALSE ); 1.80 -- mark final winner: 1.81 UPDATE "initiative" SET "winner" = TRUE 1.82 FROM (
2.1 --- a/test.sql Thu May 22 04:35:26 2014 +0200 2.2 +++ b/test.sql Thu May 22 05:13:22 2014 +0200 2.3 @@ -44,7 +44,7 @@ 2.4 "issue_quorum_num", "issue_quorum_den", 2.5 "initiative_quorum_num", "initiative_quorum_den", 2.6 "direct_majority_num", "direct_majority_den", "direct_majority_strict", 2.7 - "no_multistage_majority" 2.8 + "no_reverse_beat_path", "no_multistage_majority" 2.9 ) VALUES ( 2.10 1, 2.11 'Default policy', 2.12 @@ -52,7 +52,7 @@ 2.13 25, 100, 2.14 20, 100, 2.15 1, 2, TRUE, 2.16 - FALSE ); 2.17 + TRUE, FALSE ); 2.18 2.19 CREATE FUNCTION "time_warp"() RETURNS VOID 2.20 LANGUAGE 'plpgsql' VOLATILE AS $$