From 07775d65c6844a56dea6ba0ecdf71d53f163a58a Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 06:25:19 +0100 Subject: [PATCH 01/28] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 600ec83..f2feefd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ Thumbs.db .cache-main .cache-tests docs/sphinx/build +.lake/ From b470da427e0a421175c3f1ebedc8411e961043d0 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 06:25:29 +0100 Subject: [PATCH 02/28] Update lean-toolchain --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 3cf5817..6cbcec4 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1,2 +1,2 @@ -leanprover/lean4:stable +leanprover/lean4:v4.5.0 From 8e0b001a97b53816dc77a882c6fe01076f4aaf5c Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 06:32:16 +0100 Subject: [PATCH 03/28] Add lakefile.lean --- lakefile.lean | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lakefile.lean diff --git a/lakefile.lean b/lakefile.lean new file mode 100644 index 0000000..ee7d5b4 --- /dev/null +++ b/lakefile.lean @@ -0,0 +1,13 @@ +import Lake +open Lake DSL + +package «soda» where + -- add package configuration options here + +lean_lib «Soda» where + -- add library configuration options here + +@[default_target] +lean_exe «tiles» where + root := `Soda.tiles.fairness.main.Main + From 14efcc73e31c02c22e65f327288cbbd2f214cc3f Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 07:16:05 +0100 Subject: [PATCH 04/28] Add lean-manifest.json --- lake-manifest.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lake-manifest.json diff --git a/lake-manifest.json b/lake-manifest.json new file mode 100644 index 0000000..b48d1ce --- /dev/null +++ b/lake-manifest.json @@ -0,0 +1,5 @@ +{"version": 7, + "packagesDir": ".lake/packages", + "packages": [], + "name": "soda", + "lakeDir": ".lake"} From ca08753c78c1980df823d7fcd75d3d0e92d143ab Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 06:32:26 +0100 Subject: [PATCH 05/28] Add Soda.lean --- Soda.lean | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Soda.lean diff --git a/Soda.lean b/Soda.lean new file mode 100644 index 0000000..f353e6c --- /dev/null +++ b/Soda.lean @@ -0,0 +1,4 @@ +-- This module serves as the root of the `Soda` library. +-- Import modules here that should be built as part of the library. +import «Soda».tiles.fairness.main.Main + From 5f9a96505e6dbd0fd54c643eae9d709d1ff5119d Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 07:13:00 +0100 Subject: [PATCH 06/28] Add script to translate files to Lean --- update.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 update.sh diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..b17e760 --- /dev/null +++ b/update.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# This script translates the Soda source files into Lean. +# +# 2024-02-18 + +oldIFS="$IFS" +IFS=$'\n' +# $IFS is the Internal Field Separator. +# Its default value is . +# This is changed to support spaces in file names. + + +pathToSodaDir="tiles/src/main/scala/soda/tiles/fairness" +pathToLeanDir="Soda/tiles/fairness" + + +# This translates all Soda files into Lean +packages=$(ls "${pathToSodaDir}") + +for package in ${packages}; do + files=$(ls "${pathToSodaDir}/${package}") + mkdir -p "${pathToLeanDir}/${package}" + + for file in ${files}; do + + if [ "${file: -5}" == ".soda" ]; then + fileName="${file%.*}" + soda lean "${pathToSodaDir}/${package}/${fileName}.soda" "${pathToLeanDir}/${package}/${fileName}.lean" + fi + + done + +done + + +IFS="$oldIFS" + From 783a7f660174e6b2d56fa6cbf8121b07a564bd5e Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 07:19:59 +0100 Subject: [PATCH 07/28] Add Main.lean --- Soda/tiles/fairness/main/Main.lean | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Soda/tiles/fairness/main/Main.lean diff --git a/Soda/tiles/fairness/main/Main.lean b/Soda/tiles/fairness/main/Main.lean new file mode 100644 index 0000000..d2e2e20 --- /dev/null +++ b/Soda/tiles/fairness/main/Main.lean @@ -0,0 +1,3 @@ + +def main : IO Unit := + IO.println s!"Under construction ..." From b94f140f28bab04711bbc337ace321fb7e812f0e Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 12:46:29 +0100 Subject: [PATCH 08/28] Use Scala 3.4.0 only (no Scala 2) --- .github/workflows/ci.yml | 5 +---- build.sbt | 13 +++---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 187209a..bb5c42c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,7 @@ jobs: - 17.0.9 - 21.0.1 scala: - - 2.11.12 - - 2.12.18 - - 2.13.12 - - 3.3.1 + - 3.4.0 steps: - name: Check out uses: actions/checkout@v4 diff --git a/build.sbt b/build.sbt index cb65de9..310238d 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,6 @@ import sbt.Keys.scalacOptions -lazy val scala2_11 = "2.11.12" - -lazy val scala2_12 = "2.12.18" - -lazy val scala2_13 = "2.13.12" - -lazy val scala3_3 = "3.3.1" +lazy val scala3_4 = "3.4.0" lazy val commonSettings = Seq( @@ -25,11 +19,10 @@ lazy val commonSettings = * Scala * [[https://www.scala-lang.org]] * [[https://github.com/scala/scala]] - * [[https://repo1.maven.org/maven2/org/scala-lang/scalap/]] * [[https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/]] */ - crossScalaVersions := Seq(scala2_11, scala2_12, scala2_13, scala3_3), - scalaVersion := scala3_3, + crossScalaVersions := Seq(scala3_4), + scalaVersion := scala3_4, /** * ScalaTest * [[https://www.scalatest.org]] From 2966e3719da1add6bb428d9405ca139bf53332df Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 16:33:19 +0100 Subject: [PATCH 09/28] Update build.sbt --- build.sbt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index 310238d..25a8c2f 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ lazy val commonSettings = organization := "se.umu.cs.tiles", version := "0.1.0", description := "Object-oriented functional language to describe, analyze, and model human-centered problems", - homepage := Some(url("https://julianmendez.github.io/soda/")), + homepage := Some(url("https://julianmendez.github.io/tiles/")), startYear := Some(2023), licenses := Seq("Apache License Version 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")), organizationName := "Umea University", @@ -29,7 +29,7 @@ lazy val commonSettings = * [[https://github.com/scalatest/scalatest]] * [[https://repo1.maven.org/maven2/org/scalatest/]] */ - libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.17" % "test", + libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.18" % "test", resolvers += Resolver.mavenLocal, publishTo := Some(Resolver.mavenLocal), publishMavenStyle := true, @@ -44,7 +44,7 @@ lazy val docs = .in(file("docs")) .settings(commonSettings) -lazy val tiles = +lazy val root = project .withId("tiles") .in(file("tiles")) @@ -53,14 +53,4 @@ lazy val tiles = assembly / assemblyJarName := "tiles-" + version.value + ".jar" ) -lazy val root = - project - .withId("soda") - .in(file(".")) - .aggregate(docs, tiles) - .dependsOn(docs, tiles) - .settings( - commonSettings, - assembly / assemblyJarName := "tiles-" + version.value + ".jar" - ) From edaca52f2cb06d67f61537f9a5be7f3243c903e7 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 16:34:04 +0100 Subject: [PATCH 10/28] Update build.properties and plugins.sbt --- project/build.properties | 2 +- project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index 28a421f..1a6f388 100644 --- a/project/build.properties +++ b/project/build.properties @@ -7,5 +7,5 @@ # [https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/] # [https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/] # -sbt.version=1.9.7 +sbt.version=1.9.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index bca0451..0ee148f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ * [[https://github.com/sbt/sbt-assembly]] * [[https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.12_1.0/]] */ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.3") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5") /** * scalastyle-sbt-plugin From 074b5e8077639b36f1ff24173a6cfdf488ad7b3a Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 16:46:59 +0100 Subject: [PATCH 11/28] Simplify Actor, Resource, and Context types --- .../soda/tiles/fairness/tool/Entity.soda | 36 ++---------- .../soda/tiles/fairness/tool/Package.scala | 58 ++----------------- .../soda/tiles/fairness/tile/Package.scala | 25 ++++---- .../soda/tiles/fairness/tile/Package.soda | 3 - .../ResourceAllocationScenarioExample.soda | 14 ++--- .../fairness/tile/ScoringScenarioExample.soda | 8 +-- 6 files changed, 30 insertions(+), 114 deletions(-) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda index 2447f9b..965e730 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda @@ -1,36 +1,14 @@ -class Actor - extends - Comparable [Actor] - - abstract - id : String +class Identifier = String - compareTo (other : Actor) : Int = - id .compareTo (other .id) - @override - toString : String = - id +class Actor = Identifier -end +class Resource = Identifier -class Resource - extends - Comparable [Resource] - abstract - id : String - - compareTo (other : Resource) : Int = - id .compareTo (other .id) - - @override - toString : String = - id - -end +class Context = Identifier class Measure @@ -86,9 +64,3 @@ class Outcome end -class Context - - abstract - -end - diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala index 1e2ccd8..8141284 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -8,51 +8,13 @@ package soda.tiles.fairness.tool -trait Actor - extends - Comparable [Actor] -{ - - def id : String - - def compareTo (other : Actor) : Int = - id .compareTo (other .id) +type Identifier = String - override - lazy val toString : String = - id +type Actor = Identifier -} +type Resource = Identifier -case class Actor_ (id : String) extends Actor - -object Actor { - def mk (id : String) : Actor = - Actor_ (id) -} - -trait Resource - extends - Comparable [Resource] -{ - - def id : String - - def compareTo (other : Resource) : Int = - id .compareTo (other .id) - - override - lazy val toString : String = - id - -} - -case class Resource_ (id : String) extends Resource - -object Resource { - def mk (id : String) : Resource = - Resource_ (id) -} +type Context = Identifier trait Measure extends @@ -125,20 +87,8 @@ object Outcome { Outcome_ (assignments) } -trait Context -{ - -} - -case class Context_ () extends Context - -object Context { - def mk : Context = - Context_ () -} - /** * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala index 3d45e74..95c239b 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -6,17 +6,14 @@ package soda.tiles.fairness.tile import org.scalatest.funsuite.AnyFunSuite import soda.tiles.fairness.tool.Actor -import soda.tiles.fairness.tool.Actor_ import soda.tiles.fairness.tool.Assignment import soda.tiles.fairness.tool.Assignment_ import soda.tiles.fairness.tool.Context -import soda.tiles.fairness.tool.Context_ import soda.tiles.fairness.tool.Measure import soda.tiles.fairness.tool.Measure_ import soda.tiles.fairness.tool.Outcome import soda.tiles.fairness.tool.Outcome_ import soda.tiles.fairness.tool.Resource -import soda.tiles.fairness.tool.Resource_ import soda.tiles.fairness.tool.TileMessage import soda.tiles.fairness.tool.TileMessage_ import soda.tiles.fairness.tool.TileMessageBuilder @@ -132,17 +129,17 @@ trait ResourceAllocationScenarioExample def measure_sum (a : Measure) (b : Measure) : Measure = Measure_ (a .value + b .value) - lazy val resource0 = Resource_ ("small box - 0.1 m") + lazy val resource0 = "small box - 0.1 m" - lazy val resource1 = Resource_ ("medium box - 0.2 m") + lazy val resource1 = "medium box - 0.2 m" - lazy val resource2 = Resource_ ("large box - 0.3 m") + lazy val resource2 = "large box - 0.3 m" - lazy val actor0 = Actor_ ("Anna A") + lazy val actor0 = "Anna A" - lazy val actor1 = Actor_ ("Bob B") + lazy val actor1 = "Bob B" - lazy val actor2 = Actor_ ("Charlie C") + lazy val actor2 = "Charlie C" lazy val actor_need_map : Map [Actor, Measure] = Seq ( Tuple2 [Actor, Measure] (actor0 , Measure_ (30) ) , @@ -162,7 +159,7 @@ trait ResourceAllocationScenarioExample def resource_height (resource : Resource) : Measure = resource_height_map .getOrElse (resource , Measure_ (-1) ) - lazy val context = Context_ () + lazy val context = "context" lazy val outcome0 : Outcome = Outcome_ ( @@ -232,11 +229,11 @@ trait ScoringScenarioExample "Alice", "Benjamin", "Charlotte", "Daniel", "Emily", "Fiona", "George", "Hannah", "Isaac", "James", "Kevin", "Lily", "Matthew", "Natalie", "Olivia", "Quinn", "Peter", "Rachel", "Sarah", "Timothy", "Ursula", "Victoria", "William", "Xavier", "Yasmine", "Zachary" - ) .map ( name => Actor_ (name) ) + ) - private lazy val _resource_zero : Resource = Resource_ ("0") + private lazy val _resource_zero : Resource = "0" - private lazy val _resource_one : Resource = Resource_ ("1") + private lazy val _resource_one : Resource = "1" private lazy val _measure_zero : Measure = Measure_ (0) @@ -357,7 +354,7 @@ trait ScoringScenarioExample ) _measure_zero else _measure_one - lazy val context = Context_ () + lazy val context = "context" lazy val initial_unbiased : TileMessage [Boolean] = TileMessageBuilder_ () .build (context) (unbiased_outcome) (true) diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda index a7e7182..40f73e4 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda @@ -7,17 +7,14 @@ package soda.tiles.fairness.tile import org.scalatest.funsuite.AnyFunSuite soda.tiles.fairness.tool.Actor - soda.tiles.fairness.tool.Actor_ soda.tiles.fairness.tool.Assignment soda.tiles.fairness.tool.Assignment_ soda.tiles.fairness.tool.Context - soda.tiles.fairness.tool.Context_ soda.tiles.fairness.tool.Measure soda.tiles.fairness.tool.Measure_ soda.tiles.fairness.tool.Outcome soda.tiles.fairness.tool.Outcome_ soda.tiles.fairness.tool.Resource - soda.tiles.fairness.tool.Resource_ soda.tiles.fairness.tool.TileMessage soda.tiles.fairness.tool.TileMessage_ soda.tiles.fairness.tool.TileMessageBuilder diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda index 6fe7fea..f839b6b 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda @@ -9,17 +9,17 @@ class ResourceAllocationScenarioExample measure_sum (a : Measure) (b : Measure) : Measure = Measure_ (a .value + b .value) - resource0 = Resource_ ("small box - 0.1 m") + resource0 = "small box - 0.1 m" - resource1 = Resource_ ("medium box - 0.2 m") + resource1 = "medium box - 0.2 m" - resource2 = Resource_ ("large box - 0.3 m") + resource2 = "large box - 0.3 m" - actor0 = Actor_ ("Anna A") + actor0 = "Anna A" - actor1 = Actor_ ("Bob B") + actor1 = "Bob B" - actor2 = Actor_ ("Charlie C") + actor2 = "Charlie C" actor_need_map : Map [Actor] [Measure] = Seq ( Tuple2 [Actor] [Measure] (actor0 , Measure_ (30) ) , @@ -39,7 +39,7 @@ class ResourceAllocationScenarioExample resource_height (resource : Resource) : Measure = resource_height_map .getOrElse (resource , Measure_ (-1) ) - context = Context_ () + context = "context" outcome0 : Outcome = Outcome_ ( diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda index 20de56d..8bda98a 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda @@ -8,11 +8,11 @@ class ScoringScenarioExample "Alice", "Benjamin", "Charlotte", "Daniel", "Emily", "Fiona", "George", "Hannah", "Isaac", "James", "Kevin", "Lily", "Matthew", "Natalie", "Olivia", "Quinn", "Peter", "Rachel", "Sarah", "Timothy", "Ursula", "Victoria", "William", "Xavier", "Yasmine", "Zachary" - ) .map (lambda name --> Actor_ (name) ) + ) - _resource_zero : Resource = Resource_ ("0") + _resource_zero : Resource = "0" - _resource_one : Resource = Resource_ ("1") + _resource_one : Resource = "1" _measure_zero : Measure = Measure_ (0) @@ -133,7 +133,7 @@ class ScoringScenarioExample then _measure_zero else _measure_one - context = Context_ () + context = "context" initial_unbiased : TileMessage [Boolean] = TileMessageBuilder_ () .build (context) (unbiased_outcome) (true) From 1e7d9eff74d829dff6e70c3cdddda38b9fc0cb84 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 17:40:26 +0100 Subject: [PATCH 12/28] Simplify Measure type --- .../soda/tiles/fairness/tile/AtLeastTile.soda | 4 +- .../tiles/fairness/tile/CorrelationTile.soda | 4 +- .../tiles/fairness/tile/DecisionTile.soda | 3 +- .../tiles/fairness/tile/FalsePosTile.soda | 4 +- .../soda/tiles/fairness/tile/Package.scala | 22 +++++---- .../soda/tiles/fairness/tile/Package.soda | 3 +- .../tiles/fairness/tile/PredictionPTile.soda | 2 +- .../fairness/tile/ReceivedSigmaPTile.soda | 2 +- .../soda/tiles/fairness/tool/Entity.soda | 38 +++++++++----- .../soda/tiles/fairness/tool/Package.scala | 49 +++++++++++++------ .../soda/tiles/fairness/tile/Package.scala | 40 +++++++++------ .../soda/tiles/fairness/tile/Package.soda | 1 - .../ResourceAllocationScenarioExample.soda | 25 ++++++---- .../fairness/tile/ScoringScenarioExample.soda | 8 +-- .../fairness/tile/UnbiasednessTileSpec.soda | 4 +- 15 files changed, 133 insertions(+), 76 deletions(-) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda index f749492..e2d8c42 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda @@ -7,7 +7,9 @@ class AtLeastTile : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( ( (message .contents) - .map (lambda pair --> (pair .fst .compareTo (pair .snd) >= 0 ) ) + .map (lambda pair --> + (Comparator_ () + .compareToMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall (lambda e --> e) ) ) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda index 6991b3e..e855f9a 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda @@ -3,7 +3,7 @@ class CorrelationTile abstract - _measure_zero = Measure_ (0) + _measure_zero : Measure = Some (0) _percentage_constant : Double = 100.0 @@ -16,7 +16,7 @@ class CorrelationTile else 1.0 to_measure (d : Double) : Measure = - Measure_ ( (d * _percentage_constant) .intValue) + Some ( (d * _percentage_constant) .intValue) get_fst_list (lists : Seq [TilePair [Measure] [Measure] ] ) : Seq [Double] = lists .map (lambda pair --> to_double (pair .fst) ) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda index c70ba4c..c14db89 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda @@ -5,7 +5,8 @@ class DecisionTile maximum_acceptable_bias_percentage : Measure to_boolean (m : Measure) : Boolean = - m .value <= maximum_acceptable_bias_percentage .value + ( Comparator_ () + .compareToMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda index cf43c80..48e4567 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda @@ -3,9 +3,9 @@ class FalsePosTile abstract - _measure_zero = Measure_ (0) + _measure_zero : Measure = Some (0) - _measure_one = Measure_ (1) + _measure_one : Measure = Some (1) sigma (m0 : Measure) (m1 : Measure) : Measure = if (m0 == _measure_one) and (m1 == _measure_zero) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala index 5cd816e..5940349 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -6,8 +6,9 @@ package soda.tiles.fairness.tile import soda.tiles.fairness.tool.Actor import soda.tiles.fairness.tool.Assignment +import soda.tiles.fairness.tool.Comparator +import soda.tiles.fairness.tool.Comparator_ import soda.tiles.fairness.tool.Measure -import soda.tiles.fairness.tool.Measure_ import soda.tiles.fairness.tool.Outcome import soda.tiles.fairness.tool.Pearson import soda.tiles.fairness.tool.Pearson_ @@ -147,7 +148,9 @@ trait AtLeastTile : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( ( (message .contents) - .map ( pair => (pair .fst .compareTo (pair .snd) >= 0 ) ) + .map ( pair => + (Comparator_ () + .compareToMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall ( e => e) ) ) @@ -188,7 +191,7 @@ trait CorrelationTile - private lazy val _measure_zero = Measure_ (0) + private lazy val _measure_zero : Measure = Some (0) private lazy val _percentage_constant : Double = 100.0 @@ -201,7 +204,7 @@ trait CorrelationTile else 1.0 def to_measure (d : Double) : Measure = - Measure_ ( (d * _percentage_constant) .intValue) + Some ( (d * _percentage_constant) .intValue) def get_fst_list (lists : Seq [TilePair [Measure, Measure] ] ) : Seq [Double] = lists .map ( pair => to_double (pair .fst) ) @@ -234,7 +237,8 @@ trait DecisionTile def maximum_acceptable_bias_percentage : Measure def to_boolean (m : Measure) : Boolean = - m .value <= maximum_acceptable_bias_percentage .value + ( Comparator_ () + .compareToMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 def apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( @@ -335,9 +339,9 @@ trait FalsePosTile - private lazy val _measure_zero = Measure_ (0) + private lazy val _measure_zero : Measure = Some (0) - private lazy val _measure_one = Measure_ (1) + private lazy val _measure_one : Measure = Some (1) def sigma (m0 : Measure) (m1 : Measure) : Measure = if ( (m0 == _measure_one) && (m1 == _measure_zero) @@ -381,7 +385,7 @@ trait PredictionPTile def p : Resource => Measure - private lazy val _measure_zero : Measure = Measure_ (0) + private lazy val _measure_zero : Measure = Some (0) def measure_or (m0 : Measure) (m1 : Measure) : Measure = if ( (m0 == _measure_zero) @@ -410,7 +414,7 @@ trait ReceivedSigmaPTile private def _sigma2 (m0 : Measure , m1 : Measure) : Measure = sigma (m0) (m1) - private lazy val _measure_zero : Measure = Measure_ (0) + private lazy val _measure_zero : Measure = Some (0) def get_assignment (assignments : Seq [Assignment] ) (a : Actor) : Option [Assignment] = assignments . find ( assignment => (assignment .actor) == a) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda index a4b25f7..77b96c8 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda @@ -7,8 +7,9 @@ package soda.tiles.fairness.tile import soda.tiles.fairness.tool.Actor soda.tiles.fairness.tool.Assignment + soda.tiles.fairness.tool.Comparator + soda.tiles.fairness.tool.Comparator_ soda.tiles.fairness.tool.Measure - soda.tiles.fairness.tool.Measure_ soda.tiles.fairness.tool.Outcome soda.tiles.fairness.tool.Pearson soda.tiles.fairness.tool.Pearson_ diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda index 6e7a7bc..5e85cfc 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda @@ -4,7 +4,7 @@ class PredictionPTile abstract p : Resource -> Measure - _measure_zero : Measure = Measure_ (0) + _measure_zero : Measure = Some (0) measure_or (m0 : Measure) (m1 : Measure) : Measure = if (m0 == _measure_zero) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda index 2e47dea..dbc99db 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda @@ -8,7 +8,7 @@ class ReceivedSigmaPTile _sigma2 (m0 : Measure , m1 : Measure) : Measure = sigma (m0) (m1) - _measure_zero : Measure = Measure_ (0) + _measure_zero : Measure = Some (0) get_assignment (assignments : Seq [Assignment] ) (a : Actor) : Option [Assignment] = assignments . find (lambda assignment --> (assignment .actor) == a) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda index 965e730..e61861c 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda @@ -11,23 +11,39 @@ class Resource = Identifier class Context = Identifier -class Measure - extends - Comparable [Measure] +class Measure = Option [Int] + + +class Comparator abstract - value : Int - minus_infinity = Int .MinValue + compareToIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = + identifier0 .compareTo (identifier1) - plus_infinity = Int .MaxValue + compareToActor (actor0 : Actor) (actor1 : Actor) : Int = + compareToIdentifier (actor0) (actor1) - compareTo (other : Measure) : Int = - value .compareTo (other .value) + compareToResource (resource0 : Resource) (resource1 : Resource) : Int = + compareToIdentifier (resource0) (resource1) - @override - toString : String = - value .toString + compareToContext (context0 : Context) (context1 : Context) : Int = + compareToIdentifier (context0) (context1) + + _compareNoneTo (measure : Measure) : Int = + match measure + case Some (value) ==> -1 + case None ==> 0 + + _compareSomeTo (value : Int) (measure : Measure) : Int = + match measure + case Some (other_value) ==> value - other_value + case None ==> 1 + + compareToMeasure (measure0 : Measure) (measure1 : Measure) : Int = + match measure0 + case Some (value) ==> _compareSomeTo (value) (measure1) + case None ==> _compareNoneTo (measure1) end diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala index 8141284..3acf6ac 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -16,31 +16,50 @@ type Resource = Identifier type Context = Identifier -trait Measure - extends - Comparable [Measure] +type Measure = Option [Int] + +trait Comparator { - def value : Int - lazy val minus_infinity = Int .MinValue - lazy val plus_infinity = Int .MaxValue + def compareToIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = + identifier0 .compareTo (identifier1) - def compareTo (other : Measure) : Int = - value .compareTo (other .value) + def compareToActor (actor0 : Actor) (actor1 : Actor) : Int = + compareToIdentifier (actor0) (actor1) - override - lazy val toString : String = - value .toString + def compareToResource (resource0 : Resource) (resource1 : Resource) : Int = + compareToIdentifier (resource0) (resource1) + + def compareToContext (context0 : Context) (context1 : Context) : Int = + compareToIdentifier (context0) (context1) + + private def _compareNoneTo (measure : Measure) : Int = + measure match { + case Some (value) => -1 + case None => 0 + } + + private def _compareSomeTo (value : Int) (measure : Measure) : Int = + measure match { + case Some (other_value) => value - other_value + case None => 1 + } + + def compareToMeasure (measure0 : Measure) (measure1 : Measure) : Int = + measure0 match { + case Some (value) => _compareSomeTo (value) (measure1) + case None => _compareNoneTo (measure1) + } } -case class Measure_ (value : Int) extends Measure +case class Comparator_ () extends Comparator -object Measure { - def mk (value : Int) : Measure = - Measure_ (value) +object Comparator { + def mk : Comparator = + Comparator_ () } trait Assignment diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala index 95c239b..d0a8c12 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -10,7 +10,6 @@ import soda.tiles.fairness.tool.Assignment import soda.tiles.fairness.tool.Assignment_ import soda.tiles.fairness.tool.Context import soda.tiles.fairness.tool.Measure -import soda.tiles.fairness.tool.Measure_ import soda.tiles.fairness.tool.Outcome import soda.tiles.fairness.tool.Outcome_ import soda.tiles.fairness.tool.Resource @@ -126,8 +125,17 @@ trait ResourceAllocationScenarioExample private def _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = Assignment_ (actor, resource) + private def _addValueTo (value : Int) (m : Measure) : Measure = + m match { + case Some (other_value) => Some (value + other_value) + case None => None + } + def measure_sum (a : Measure) (b : Measure) : Measure = - Measure_ (a .value + b .value) + a match { + case Some (value) => _addValueTo (value) (b) + case None => None + } lazy val resource0 = "small box - 0.1 m" @@ -142,22 +150,22 @@ trait ResourceAllocationScenarioExample lazy val actor2 = "Charlie C" lazy val actor_need_map : Map [Actor, Measure] = Seq ( - Tuple2 [Actor, Measure] (actor0 , Measure_ (30) ) , - Tuple2 [Actor, Measure] (actor1 , Measure_ (10) ) , - Tuple2 [Actor, Measure] (actor2 , Measure_ (0) ) + Tuple2 [Actor, Measure] (actor0 , Some (30) ) , + Tuple2 [Actor, Measure] (actor1 , Some (10) ) , + Tuple2 [Actor, Measure] (actor2 , Some (0) ) ) .toMap lazy val resource_height_map : Map [Resource, Measure] = Seq ( - Tuple2 [Resource, Measure] (resource0 , Measure_ (10) ) , - Tuple2 [Resource, Measure] (resource1 , Measure_ (20) ) , - Tuple2 [Resource, Measure] (resource2 , Measure_ (30) ) + Tuple2 [Resource, Measure] (resource0 , Some (10) ) , + Tuple2 [Resource, Measure] (resource1 , Some (20) ) , + Tuple2 [Resource, Measure] (resource2 , Some (30) ) ) .toMap def actor_need (actor : Actor) : Measure = - actor_need_map .getOrElse (actor , Measure_ (-1) ) + actor_need_map .getOrElse (actor , Some (-1) ) def resource_height (resource : Resource) : Measure = - resource_height_map .getOrElse (resource , Measure_ (-1) ) + resource_height_map .getOrElse (resource , Some (-1) ) lazy val context = "context" @@ -235,9 +243,9 @@ trait ScoringScenarioExample private lazy val _resource_one : Resource = "1" - private lazy val _measure_zero : Measure = Measure_ (0) + private lazy val _measure_zero : Measure = Some (0) - private lazy val _measure_one : Measure = Measure_ (1) + private lazy val _measure_one : Measure = Some (1) lazy val seed_protected_attribute : Long = 127 @@ -251,7 +259,7 @@ trait ScoringScenarioExample lazy val protected_attribute : Seq [Measure] = Random_ () .get_next_seq (seed_protected_attribute) (actors .length) - .map ( x => Measure_ ( as_protected_attribute (x .intValue) ) ) + .map ( x => Some ( as_protected_attribute (x .intValue) ) ) lazy val protected_attribute_map : Map [Actor, Measure] = actors @@ -296,7 +304,7 @@ trait ScoringScenarioExample lazy val prediction_bias_on_attribute : Int = 40 - lazy val maximum_acceptable_bias_percentage : Measure = Measure_ (30) + lazy val maximum_acceptable_bias_percentage : Measure = Some (30) lazy val result : Seq [Measure] = result_values .map ( x => make_binary_measure (x) ) @@ -415,7 +423,7 @@ case class UnbiasednessTileSpec () check ( obtained = get_coefficient (ex .initial_unbiased) .contents ) ( - expected = Measure_ (0) + expected = Some (0) ) ) @@ -423,7 +431,7 @@ case class UnbiasednessTileSpec () check ( obtained = get_coefficient (ex .initial_biased) .contents ) ( - expected = Measure_ (42) + expected = Some (42) ) ) diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda index 40f73e4..dd1604d 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda @@ -11,7 +11,6 @@ import soda.tiles.fairness.tool.Assignment_ soda.tiles.fairness.tool.Context soda.tiles.fairness.tool.Measure - soda.tiles.fairness.tool.Measure_ soda.tiles.fairness.tool.Outcome soda.tiles.fairness.tool.Outcome_ soda.tiles.fairness.tool.Resource diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda index f839b6b..f2d67d3 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda @@ -6,8 +6,15 @@ class ResourceAllocationScenarioExample _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = Assignment_ (actor) (resource) + _addValueTo (value : Int) (m : Measure) : Measure = + match m + case Some (other_value) ==> Some (value + other_value) + case None ==> None + measure_sum (a : Measure) (b : Measure) : Measure = - Measure_ (a .value + b .value) + match a + case Some (value) ==> _addValueTo (value) (b) + case None ==> None resource0 = "small box - 0.1 m" @@ -22,22 +29,22 @@ class ResourceAllocationScenarioExample actor2 = "Charlie C" actor_need_map : Map [Actor] [Measure] = Seq ( - Tuple2 [Actor] [Measure] (actor0 , Measure_ (30) ) , - Tuple2 [Actor] [Measure] (actor1 , Measure_ (10) ) , - Tuple2 [Actor] [Measure] (actor2 , Measure_ (0) ) + Tuple2 [Actor] [Measure] (actor0 , Some (30) ) , + Tuple2 [Actor] [Measure] (actor1 , Some (10) ) , + Tuple2 [Actor] [Measure] (actor2 , Some (0) ) ) .toMap resource_height_map : Map [Resource] [Measure] = Seq ( - Tuple2 [Resource] [Measure] (resource0 , Measure_ (10) ) , - Tuple2 [Resource] [Measure] (resource1 , Measure_ (20) ) , - Tuple2 [Resource] [Measure] (resource2 , Measure_ (30) ) + Tuple2 [Resource] [Measure] (resource0 , Some (10) ) , + Tuple2 [Resource] [Measure] (resource1 , Some (20) ) , + Tuple2 [Resource] [Measure] (resource2 , Some (30) ) ) .toMap actor_need (actor : Actor) : Measure = - actor_need_map .getOrElse (actor , Measure_ (-1) ) + actor_need_map .getOrElse (actor , Some (-1) ) resource_height (resource : Resource) : Measure = - resource_height_map .getOrElse (resource , Measure_ (-1) ) + resource_height_map .getOrElse (resource , Some (-1) ) context = "context" diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda index 8bda98a..1fcb055 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda @@ -14,9 +14,9 @@ class ScoringScenarioExample _resource_one : Resource = "1" - _measure_zero : Measure = Measure_ (0) + _measure_zero : Measure = Some (0) - _measure_one : Measure = Measure_ (1) + _measure_one : Measure = Some (1) seed_protected_attribute : Long = 127 @@ -30,7 +30,7 @@ class ScoringScenarioExample protected_attribute : Seq [Measure] = Random_ () .get_next_seq (seed_protected_attribute) (actors .length) - .map (lambda x --> Measure_ ( as_protected_attribute (x .intValue) ) ) + .map (lambda x --> Some ( as_protected_attribute (x .intValue) ) ) protected_attribute_map : Map [Actor] [Measure] = actors @@ -75,7 +75,7 @@ class ScoringScenarioExample prediction_bias_on_attribute : Int = 40 - maximum_acceptable_bias_percentage : Measure = Measure_ (30) + maximum_acceptable_bias_percentage : Measure = Some (30) result : Seq [Measure] = result_values .map (lambda x --> make_binary_measure (x) ) diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda index a96e23c..7aca290 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda @@ -42,7 +42,7 @@ class UnbiasednessTileSpec () check ( obtained := get_coefficient (ex .initial_unbiased) .contents ) ( - expected := Measure_ (0) + expected := Some (0) ) ) @@ -50,7 +50,7 @@ class UnbiasednessTileSpec () check ( obtained := get_coefficient (ex .initial_biased) .contents ) ( - expected := Measure_ (42) + expected := Some (42) ) ) From 7da744d80968f9392872be159a624a6413341618 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 17:42:37 +0100 Subject: [PATCH 13/28] Update build.sbt --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 25a8c2f..8bece44 100644 --- a/build.sbt +++ b/build.sbt @@ -47,7 +47,7 @@ lazy val docs = lazy val root = project .withId("tiles") - .in(file("tiles")) + .in(file(".")) .settings( commonSettings, assembly / assemblyJarName := "tiles-" + version.value + ".jar" From a4a9a97c8a10444e097c9b95184a2724927bf77c Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 18 Feb 2024 21:15:04 +0100 Subject: [PATCH 14/28] Update build.sbt --- build.sbt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8bece44..9291a27 100644 --- a/build.sbt +++ b/build.sbt @@ -44,13 +44,23 @@ lazy val docs = .in(file("docs")) .settings(commonSettings) +lazy val core = + project + .withId("tiles-core") + .in(file("tiles")) + .settings( + commonSettings, + assembly / assemblyJarName := "tiles-" + version.value + ".jar" + ) + lazy val root = project .withId("tiles") .in(file(".")) + .aggregate(docs, core) + .dependsOn(docs, core) .settings( commonSettings, assembly / assemblyJarName := "tiles-" + version.value + ".jar" ) - From 4df2554e7d37518c8e4c21a83c116ae466177633 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Tue, 20 Feb 2024 23:19:06 +0100 Subject: [PATCH 15/28] Add functions to compare the entities --- .../soda/tiles/fairness/tile/AtLeastTile.soda | 2 +- .../tiles/fairness/tile/DecisionTile.soda | 2 +- .../soda/tiles/fairness/tile/Package.scala | 4 +- .../soda/tiles/fairness/tool/Entity.soda | 87 ++++---- .../soda/tiles/fairness/tool/Package.scala | 211 +++++++++++++----- .../soda/tiles/fairness/tool/ScoringTool.soda | 5 + .../tiles/fairness/tool/StringComparator.soda | 64 ++++++ .../soda/tiles/fairness/tool/TileMessage.soda | 4 + .../soda/tiles/fairness/tool/Package.scala | 157 +++++++++++++ .../fairness/tool/StringComparatorSpec.soda | 156 +++++++++++++ 10 files changed, 588 insertions(+), 104 deletions(-) create mode 100644 tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda create mode 100644 tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda index e2d8c42..46ec522 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda @@ -9,7 +9,7 @@ class AtLeastTile ( (message .contents) .map (lambda pair --> (Comparator_ () - .compareToMeasure (pair .fst) (pair .snd) ) >= 0 ) + .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall (lambda e --> e) ) ) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda index c14db89..64d3334 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda @@ -6,7 +6,7 @@ class DecisionTile to_boolean (m : Measure) : Boolean = ( Comparator_ () - .compareToMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 + .compareMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala index 5940349..54173ff 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -150,7 +150,7 @@ trait AtLeastTile ( (message .contents) .map ( pair => (Comparator_ () - .compareToMeasure (pair .fst) (pair .snd) ) >= 0 ) + .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall ( e => e) ) ) @@ -238,7 +238,7 @@ trait DecisionTile def to_boolean (m : Measure) : Boolean = ( Comparator_ () - .compareToMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 + .compareMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 def apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = TileMessageBuilder_ () .build (message .context) (message .outcome) ( diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda index e61861c..bd62f56 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.StringComparator + + class Identifier = String @@ -14,69 +18,68 @@ class Context = Identifier class Measure = Option [Int] -class Comparator +class Assignment abstract + actor : Actor + resource : Resource - compareToIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = - identifier0 .compareTo (identifier1) +end - compareToActor (actor0 : Actor) (actor1 : Actor) : Int = - compareToIdentifier (actor0) (actor1) - compareToResource (resource0 : Resource) (resource1 : Resource) : Int = - compareToIdentifier (resource0) (resource1) +class Outcome - compareToContext (context0 : Context) (context1 : Context) : Int = - compareToIdentifier (context0) (context1) + abstract + assignments : Seq [Assignment] - _compareNoneTo (measure : Measure) : Int = - match measure - case Some (value) ==> -1 - case None ==> 0 +end - _compareSomeTo (value : Int) (measure : Measure) : Int = - match measure - case Some (other_value) ==> value - other_value - case None ==> 1 - compareToMeasure (measure0 : Measure) (measure1 : Measure) : Int = - match measure0 - case Some (value) ==> _compareSomeTo (value) (measure1) - case None ==> _compareNoneTo (measure1) +class Comparator -end + abstract + directive lean + def compareString (string0 : String) (string1 : String) : Int := + StringComparator.compare (string0) (string1) -class Assignment - extends - Comparable [Assignment] + directive scala + def compareString (string0 : String) (string1 : String) : Int = + StringComparator.mk.compare (string0) (string1) - abstract - actor : Actor - resource : Resource + compareIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = + compareString (identifier0) (identifier1) - compareTo (other : Assignment) : Int = - if actor == other .actor - then resource .compareTo (other .resource) - else actor .compareTo (other .actor) + compareActor (actor0 : Actor) (actor1 : Actor) : Int = + compareIdentifier (actor0) (actor1) - @override - toString : String = - "\u27E8" + actor + ", " + resource + "\u27E9" + compareResource (resource0 : Resource) (resource1 : Resource) : Int = + compareIdentifier (resource0) (resource1) -end + compareContext (context0 : Context) (context1 : Context) : Int = + compareIdentifier (context0) (context1) + _compareNone (measure : Measure) : Int = + match measure + case Some (value) ==> -1 + case None ==> 0 -class Outcome + _compareSome (value : Int) (measure : Measure) : Int = + match measure + case Some (other_value) ==> value - other_value + case None ==> 1 - abstract - assignments : Seq [Assignment] + compareMeasure (measure0 : Measure) (measure1 : Measure) : Int = + match measure0 + case Some (value) ==> _compareSome (value) (measure1) + case None ==> _compareNone (measure1) - @override - toString : String = - assignments .mkString (",") + compareAssignment (assignment0 : Assignment) (assignment1 : Assignment) : Int = + if assignment0 .actor == assignment1 .actor + then compareResource (assignment0 .resource) (assignment1 .resource) + else compareActor (assignment0 .actor) (assignment1 .actor) end + diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala index 3acf6ac..6d4b9cd 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -8,6 +8,11 @@ package soda.tiles.fairness.tool +/* +directive lean +import Soda.tiles.fairness.tool.StringComparator +*/ + type Identifier = String type Actor = Identifier @@ -18,41 +23,84 @@ type Context = Identifier type Measure = Option [Int] +trait Assignment +{ + + def actor : Actor + def resource : Resource + +} + +case class Assignment_ (actor : Actor, resource : Resource) extends Assignment + +object Assignment { + def mk (actor : Actor) (resource : Resource) : Assignment = + Assignment_ (actor, resource) +} + +trait Outcome +{ + + def assignments : Seq [Assignment] + +} + +case class Outcome_ (assignments : Seq [Assignment]) extends Outcome + +object Outcome { + def mk (assignments : Seq [Assignment]) : Outcome = + Outcome_ (assignments) +} + trait Comparator { - def compareToIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = - identifier0 .compareTo (identifier1) +/* + directive lean + def compareString (string0 : String) (string1 : String) : Int := + StringComparator.compare (string0) (string1) +*/ + + def compareString (string0 : String) (string1 : String) : Int = + StringComparator.mk.compare (string0) (string1) - def compareToActor (actor0 : Actor) (actor1 : Actor) : Int = - compareToIdentifier (actor0) (actor1) + def compareIdentifier (identifier0 : Identifier) (identifier1 : Identifier) : Int = + compareString (identifier0) (identifier1) - def compareToResource (resource0 : Resource) (resource1 : Resource) : Int = - compareToIdentifier (resource0) (resource1) + def compareActor (actor0 : Actor) (actor1 : Actor) : Int = + compareIdentifier (actor0) (actor1) - def compareToContext (context0 : Context) (context1 : Context) : Int = - compareToIdentifier (context0) (context1) + def compareResource (resource0 : Resource) (resource1 : Resource) : Int = + compareIdentifier (resource0) (resource1) - private def _compareNoneTo (measure : Measure) : Int = + def compareContext (context0 : Context) (context1 : Context) : Int = + compareIdentifier (context0) (context1) + + private def _compareNone (measure : Measure) : Int = measure match { case Some (value) => -1 case None => 0 } - private def _compareSomeTo (value : Int) (measure : Measure) : Int = + private def _compareSome (value : Int) (measure : Measure) : Int = measure match { case Some (other_value) => value - other_value case None => 1 } - def compareToMeasure (measure0 : Measure) (measure1 : Measure) : Int = + def compareMeasure (measure0 : Measure) (measure1 : Measure) : Int = measure0 match { - case Some (value) => _compareSomeTo (value) (measure1) - case None => _compareNoneTo (measure1) + case Some (value) => _compareSome (value) (measure1) + case None => _compareNone (measure1) } + def compareAssignment (assignment0 : Assignment) (assignment1 : Assignment) : Int = + if ( assignment0 .actor == assignment1 .actor + ) compareResource (assignment0 .resource) (assignment1 .resource) + else compareActor (assignment0 .actor) (assignment1 .actor) + } case class Comparator_ () extends Comparator @@ -62,52 +110,11 @@ object Comparator { Comparator_ () } -trait Assignment - extends - Comparable [Assignment] -{ - - def actor : Actor - def resource : Resource - - def compareTo (other : Assignment) : Int = - if ( actor == other .actor - ) resource .compareTo (other .resource) - else actor .compareTo (other .actor) - - override - lazy val toString : String = - "\u27E8" + actor + ", " + resource + "\u27E9" - -} - -case class Assignment_ (actor : Actor, resource : Resource) extends Assignment - -object Assignment { - def mk (actor : Actor) (resource : Resource) : Assignment = - Assignment_ (actor, resource) -} - -trait Outcome -{ - - def assignments : Seq [Assignment] - - override - lazy val toString : String = - assignments .mkString (",") - -} - -case class Outcome_ (assignments : Seq [Assignment]) extends Outcome - -object Outcome { - def mk (assignments : Seq [Assignment]) : Outcome = - Outcome_ (assignments) -} - - +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ /** * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - @@ -230,6 +237,94 @@ object ScoringCategory { } + + +trait HelperTuple +{ + + def comparison : Int + def remaining : Seq [Char] + +} + +case class HelperTuple_ (comparison : Int, remaining : Seq [Char]) extends HelperTuple + +object HelperTuple { + def mk (comparison : Int) (remaining : Seq [Char]) : HelperTuple = + HelperTuple_ (comparison, remaining) +} + +trait StringComparator +{ + + + + lazy val it_is_greater : Int = 1 + + lazy val it_is_less : Int = -1 + + lazy val they_are_equal : Int = 0 + + private def _tailrec_foldl_while [A , B ] (sequence : Seq [A] ) (current : B) + (next : B => A => B) (condition : B => A => Boolean) : B = + sequence match { + case Nil => current + case (head) +: (tail) => + if ( (! (condition (current) (head) ) ) + ) current + else _tailrec_foldl_while [A, B] (tail) (next (current) (head) ) (next) (condition) + } + + private def _compare_char_seq (current_char : Char) (other_seq : Seq [Char] ) : HelperTuple = + other_seq match { + case head +: tail => + if ( current_char < head + ) HelperTuple_ (it_is_less, Nil) + else + if ( current_char > head + ) HelperTuple_ (it_is_greater, Nil) + else HelperTuple_ (they_are_equal, tail) + case Nil => HelperTuple_ (it_is_greater, Nil) + } + + private def _condition (other_seq_cmp : HelperTuple) (current_char : Char) : Boolean = + other_seq_cmp .comparison == they_are_equal + + private def _next (other_seq_cmp : HelperTuple) (current_char : Char) : HelperTuple = + if ( other_seq_cmp .comparison == they_are_equal + ) _compare_char_seq (current_char) (other_seq_cmp .remaining) + else other_seq_cmp + + private def _interpret_comparison (result : HelperTuple) : Int = + result .remaining match { + case head +: tail => it_is_less + case Nil => result .comparison + } + + private def _compare_seq (seq0 : Seq [Char] ) (seq1 : Seq [Char] ) : Int = + _interpret_comparison ( + _tailrec_foldl_while [Char, HelperTuple] (seq0) ( + HelperTuple_ (they_are_equal, seq1) ) (_next) (_condition) + ) + + def compare (str0 : String) (str1 : String) : Int = + _compare_seq (str0 .toList) (str1 .toList) + +} + +case class StringComparator_ () extends StringComparator + +object StringComparator { + def mk : StringComparator = + StringComparator_ () +} + + +/* +directive lean +import Soda.tiles.fairness.tool.Entity +*/ + trait TilePair [A , B ] { diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda index 07f8b61..2d2a6e3 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda @@ -1,10 +1,15 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + /** * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - * \bar{y})^{2}}} */ + class MathTool abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda new file mode 100644 index 0000000..4183516 --- /dev/null +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda @@ -0,0 +1,64 @@ + + +class HelperTuple + + abstract + comparison : Int + remaining : Seq [Char] + +end + +class StringComparator + + abstract + + it_is_greater : Int = 1 + + it_is_less : Int = -1 + + they_are_equal : Int = 0 + + _tailrec_foldl_while [A : Type] [B : Type] (sequence : Seq [A] ) (current : B) + (next : B -> A -> B) (condition : B -> A -> Boolean) : B = + match sequence + case Nil ==> current + case (head) +: (tail) ==> + if (not (condition (current) (head) ) ) + then current + else _tailrec_foldl_while [A] [B] (tail) (next (current) (head) ) (next) (condition) + + _compare_char_seq (current_char : Char) (other_seq : Seq [Char] ) : HelperTuple = + match other_seq + case head +: tail ==> + if current_char < head + then HelperTuple_ (it_is_less) (Nil) + else + if current_char > head + then HelperTuple_ (it_is_greater) (Nil) + else HelperTuple_ (they_are_equal) (tail) + case Nil ==> HelperTuple_ (it_is_greater) (Nil) + + _condition (other_seq_cmp : HelperTuple) (current_char : Char) : Boolean = + other_seq_cmp .comparison == they_are_equal + + _next (other_seq_cmp : HelperTuple) (current_char : Char) : HelperTuple = + if other_seq_cmp .comparison == they_are_equal + then _compare_char_seq (current_char) (other_seq_cmp .remaining) + else other_seq_cmp + + _interpret_comparison (result : HelperTuple) : Int = + match result .remaining + case head +: tail ==> it_is_less + case Nil ==> result .comparison + + _compare_seq (seq0 : Seq [Char] ) (seq1 : Seq [Char] ) : Int = + _interpret_comparison ( + _tailrec_foldl_while [Char] [HelperTuple] (seq0) ( + HelperTuple_ (they_are_equal) (seq1) ) (_next) (_condition) + ) + + compare (str0 : String) (str1 : String) : Int = + _compare_seq (str0 .toList) (str1 .toList) + +end + diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda index 4b03d8f..525dc38 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.Entity + + class TilePair [A : Type] [B : Type] abstract diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala index 8c3eadf..dbe59ce 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala @@ -253,3 +253,160 @@ case class ScoringToolSpec () } + +case class StringComparatorSpec () + extends + AnyFunSuite +{ + + def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + lazy val empty_string : String = "" + + lazy val string0 : String = "an" + + lazy val string1 : String = "example" + + lazy val string2 : String = "z" + + lazy val instance : StringComparator = StringComparator_ () + + def sign (a : Int) : Int = + if ( a > 0 + ) 1 + else + if ( a < 0 + ) -1 + else 0 + + test ("compare equal strings 0") ( + check ( + obtained = instance .compare (empty_string) (empty_string) + ) ( + expected = 0 + ) + ) + + test ("compare equal strings 1") ( + check ( + obtained = instance .compare (string0) (string0) + ) ( + expected = 0 + ) + ) + + test ("compare equal strings 2") ( + check ( + obtained = instance .compare (string1) (string1) + ) ( + expected = 0 + ) + ) + + test ("compare equal strings 3") ( + check ( + obtained = instance .compare (string2) (string2) + ) ( + expected = 0 + ) + ) + + test ("compare smaller strings 0") ( + check ( + obtained = instance .compare (empty_string) (string0) + ) ( + expected = -1 + ) + ) + + test ("compare smaller strings 0 compareTo") ( + check ( + obtained = instance .compare (empty_string) (string0) + ) ( + expected = sign (empty_string .compareTo (string0) ) + ) + ) + + test ("compare smaller strings 1") ( + check ( + obtained = instance .compare (string0) (empty_string) + ) ( + expected = 1 + ) + ) + + test ("compare smaller strings 1 compareTo") ( + check ( + obtained = instance .compare (string0) (empty_string) + ) ( + expected = sign (string0 .compareTo (empty_string) ) + ) + ) + + test ("compare smaller strings 2") ( + check ( + obtained = instance .compare (string0) (string2) + ) ( + expected = -1 + ) + ) + + test ("compare smaller strings 2 compareTo") ( + check ( + obtained = instance .compare (string0) (string2) + ) ( + expected = sign (string0 .compareTo (string2) ) + ) + ) + + test ("compare smaller strings 3") ( + check ( + obtained = instance .compare (string2) (string0) + ) ( + expected = 1 + ) + ) + + test ("compare smaller strings 3 compareTo") ( + check ( + obtained = instance .compare (string2) (string0) + ) ( + expected = sign (string2 .compareTo (string0) ) + ) + ) + + test ("compare smaller strings 4") ( + check ( + obtained = instance .compare (string0) (string1) + ) ( + expected = -1 + ) + ) + + test ("compare smaller strings 4 compareTo") ( + check ( + obtained = instance .compare (string0) (string1) + ) ( + expected = sign (string0 .compareTo (string1) ) + ) + ) + + test ("compare smaller strings 5") ( + check ( + obtained = instance .compare (string1) (string0) + ) ( + expected = 1 + ) + ) + + test ("compare smaller strings 5 compareTo") ( + check ( + obtained = instance .compare (string1) (string0) + ) ( + expected = sign (string1 .compareTo (string0) ) + ) + ) + +} + diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda b/tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda new file mode 100644 index 0000000..0e8768b --- /dev/null +++ b/tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda @@ -0,0 +1,156 @@ + +class StringComparatorSpec () + extends + AnyFunSuite + + check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + empty_string : String = "" + + string0 : String = "an" + + string1 : String = "example" + + string2 : String = "z" + + instance : StringComparator = StringComparator_ () + + sign (a : Int) : Int = + if a > 0 + then 1 + else + if a < 0 + then -1 + else 0 + + test ("compare equal strings 0") ( + check ( + obtained := instance .compare (empty_string) (empty_string) + ) ( + expected := 0 + ) + ) + + test ("compare equal strings 1") ( + check ( + obtained := instance .compare (string0) (string0) + ) ( + expected := 0 + ) + ) + + test ("compare equal strings 2") ( + check ( + obtained := instance .compare (string1) (string1) + ) ( + expected := 0 + ) + ) + + test ("compare equal strings 3") ( + check ( + obtained := instance .compare (string2) (string2) + ) ( + expected := 0 + ) + ) + + test ("compare smaller strings 0") ( + check ( + obtained := instance .compare (empty_string) (string0) + ) ( + expected := -1 + ) + ) + + test ("compare smaller strings 0 compareTo") ( + check ( + obtained := instance .compare (empty_string) (string0) + ) ( + expected := sign (empty_string .compareTo (string0) ) + ) + ) + + test ("compare smaller strings 1") ( + check ( + obtained := instance .compare (string0) (empty_string) + ) ( + expected := 1 + ) + ) + + test ("compare smaller strings 1 compareTo") ( + check ( + obtained := instance .compare (string0) (empty_string) + ) ( + expected := sign (string0 .compareTo (empty_string) ) + ) + ) + + test ("compare smaller strings 2") ( + check ( + obtained := instance .compare (string0) (string2) + ) ( + expected := -1 + ) + ) + + test ("compare smaller strings 2 compareTo") ( + check ( + obtained := instance .compare (string0) (string2) + ) ( + expected := sign (string0 .compareTo (string2) ) + ) + ) + + test ("compare smaller strings 3") ( + check ( + obtained := instance .compare (string2) (string0) + ) ( + expected := 1 + ) + ) + + test ("compare smaller strings 3 compareTo") ( + check ( + obtained := instance .compare (string2) (string0) + ) ( + expected := sign (string2 .compareTo (string0) ) + ) + ) + + test ("compare smaller strings 4") ( + check ( + obtained := instance .compare (string0) (string1) + ) ( + expected := -1 + ) + ) + + test ("compare smaller strings 4 compareTo") ( + check ( + obtained := instance .compare (string0) (string1) + ) ( + expected := sign (string0 .compareTo (string1) ) + ) + ) + + test ("compare smaller strings 5") ( + check ( + obtained := instance .compare (string1) (string0) + ) ( + expected := 1 + ) + ) + + test ("compare smaller strings 5 compareTo") ( + check ( + obtained := instance .compare (string1) (string0) + ) ( + expected := sign (string1 .compareTo (string0) ) + ) + ) + +end + From 4af656aa58da152f7cc7f5fda1df5a478472b3ec Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Wed, 21 Feb 2024 00:48:05 +0100 Subject: [PATCH 16/28] Add some imports for Lean translation --- .../tiles/fairness/tile/AllActorPairTile.soda | 8 +- .../tiles/fairness/tile/AllActorTile.soda | 4 + .../fairness/tile/AllActorTripleTile.soda | 4 + .../tiles/fairness/tile/AllEqual1Tile.soda | 4 + .../tiles/fairness/tile/AllEqualTile.soda | 5 + .../soda/tiles/fairness/tile/AtLeastTile.soda | 4 + .../tiles/fairness/tile/AttributePTile.soda | 4 + .../tiles/fairness/tile/CorrelationTile.soda | 4 + .../tiles/fairness/tile/DecisionTile.soda | 4 + .../tiles/fairness/tile/EqualityTile.soda | 7 + .../soda/tiles/fairness/tile/EquityTile.soda | 10 ++ .../tiles/fairness/tile/FalsePosTile.soda | 5 + .../soda/tiles/fairness/tile/NeededPTile.soda | 5 + .../soda/tiles/fairness/tile/Package.scala | 140 +++++++++++++++++- .../tiles/fairness/tile/PredictionPTile.soda | 5 + .../fairness/tile/ReceivedSigmaPTile.soda | 4 + .../soda/tiles/fairness/tile/ResultPTile.soda | 5 + .../soda/tiles/fairness/tile/SigmaTile.soda | 4 + .../tiles/fairness/tile/UnbiasednessTile.soda | 15 ++ .../tiles/fairness/tile/UnzipPairTile.soda | 4 + .../tiles/fairness/tile/UnzipTripleTile.soda | 4 + .../soda/tiles/fairness/tile/WithPTile.soda | 5 + .../soda/tiles/fairness/tile/ZipTile.soda | 4 + 23 files changed, 254 insertions(+), 4 deletions(-) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda index 38e479e..2e414c6 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda @@ -1,11 +1,15 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AllActorPairTile abstract apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TilePair [Actor] [Actor] ] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( - ( (message .outcome) .assignments) + TileMessageBuilder_ () .build ( + message .context) (message .outcome) ( ( (message .outcome) .assignments) .map (lambda assignment --> assignment .actor) .distinct .sorted diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda index bf91449..94f8eb7 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AllActorTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda index ea4dd7f..8a69982 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AllActorTripleTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda index bc3b049..caf5951 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AllEqual1Tile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda index b994800..f0bb79f 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllEqual1Tile + + class AllEqualTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda index 46ec522..9788bdb 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AtLeastTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda index 5281dbd..fe449cf 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class AttributePTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda index e855f9a..73580b4 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class CorrelationTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda index 64d3334..83252c2 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class DecisionTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda index 2bd4aee..13deb2a 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda @@ -1,4 +1,11 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTile +import Soda.tiles.fairness.tile.AllEqualTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile + + class EqualityTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda index aea2923..cc0e9eb 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda @@ -1,4 +1,14 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AtLeastTile +import Soda.tiles.fairness.tile.NeededPTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +import Soda.tiles.fairness.tile.UnzipPairFstTile +import Soda.tiles.fairness.tile.UnzipPairSndTile +import Soda.tiles.fairness.tile.ZipTile + + class EquityTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda index 48e4567..3ae2e1e 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.SigmaTile + + class FalsePosTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda index e0e5fd2..e99988a 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile + + class NeededPTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala index 54173ff..758b694 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -24,14 +24,19 @@ import soda.tiles.fairness.tool.TileTriple_ +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AllActorPairTile { def apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TilePair [Actor, Actor] ] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( - ( (message .outcome) .assignments) + TileMessageBuilder_ () .build ( + message .context) (message .outcome) ( ( (message .outcome) .assignments) .map ( assignment => assignment .actor) .distinct .sorted @@ -48,6 +53,11 @@ object AllActorPairTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AllActorTile { @@ -71,6 +81,11 @@ object AllActorTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AllActorTripleTile { @@ -96,6 +111,11 @@ object AllActorTripleTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AllEqual1Tile { @@ -117,6 +137,12 @@ object AllEqual1Tile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllEqual1Tile +*/ + trait AllEqualTile { @@ -139,6 +165,11 @@ object AllEqualTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AtLeastTile { @@ -165,6 +196,11 @@ object AtLeastTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait AttributePTile { @@ -186,6 +222,11 @@ object AttributePTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait CorrelationTile { @@ -231,6 +272,11 @@ object CorrelationTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait DecisionTile { @@ -255,6 +301,14 @@ object DecisionTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTile +import Soda.tiles.fairness.tile.AllEqualTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +*/ + trait EqualityTile { @@ -284,6 +338,17 @@ object EqualityTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AtLeastTile +import Soda.tiles.fairness.tile.NeededPTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +import Soda.tiles.fairness.tile.UnzipPairFstTile +import Soda.tiles.fairness.tile.UnzipPairSndTile +import Soda.tiles.fairness.tile.ZipTile +*/ + trait EquityTile { @@ -334,6 +399,12 @@ object EquityTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.SigmaTile +*/ + trait FalsePosTile { @@ -362,6 +433,12 @@ object FalsePosTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile +*/ + trait NeededPTile { @@ -380,6 +457,12 @@ object NeededPTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +*/ + trait PredictionPTile { @@ -405,6 +488,11 @@ object PredictionPTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait ReceivedSigmaPTile { @@ -440,6 +528,12 @@ object ReceivedSigmaPTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile +*/ + trait ResultPTile { @@ -458,6 +552,11 @@ object ResultPTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait SigmaTile { @@ -480,6 +579,22 @@ object SigmaTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTripleTile +import Soda.tiles.fairness.tile.CorrelationTile +import Soda.tiles.fairness.tile.DecisionTile +import Soda.tiles.fairness.tile.FalsePosTile +import Soda.tiles.fairness.tile.PredictionPTile +import Soda.tiles.fairness.tile.ResultPTile +import Soda.tiles.fairness.tile.UnzipTripleFstTile +import Soda.tiles.fairness.tile.UnzipTripleSndTile +import Soda.tiles.fairness.tile.UnzipTripleTrdTile +import Soda.tiles.fairness.tile.WithPTile +import Soda.tiles.fairness.tile.ZipTile +*/ + trait UnbiasednessTile { @@ -553,6 +668,11 @@ object UnbiasednessTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait UnzipPairFstTile { @@ -600,6 +720,11 @@ object UnzipPairSndTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait UnzipTripleFstTile { @@ -673,6 +798,12 @@ object UnzipTripleTrdTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile +*/ + trait WithPTile { @@ -691,6 +822,11 @@ object WithPTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + trait ZipTile { diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda index 5e85cfc..14befc9 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.ReceivedSigmaPTile + + class PredictionPTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda index dbc99db..7b85151 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class ReceivedSigmaPTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda index bdf10dc..213e71e 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile + + class ResultPTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda index 00d608a..719b419 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class SigmaTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda index 59a2f5d..c9380b0 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda @@ -1,4 +1,19 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTripleTile +import Soda.tiles.fairness.tile.CorrelationTile +import Soda.tiles.fairness.tile.DecisionTile +import Soda.tiles.fairness.tile.FalsePosTile +import Soda.tiles.fairness.tile.PredictionPTile +import Soda.tiles.fairness.tile.ResultPTile +import Soda.tiles.fairness.tile.UnzipTripleFstTile +import Soda.tiles.fairness.tile.UnzipTripleSndTile +import Soda.tiles.fairness.tile.UnzipTripleTrdTile +import Soda.tiles.fairness.tile.WithPTile +import Soda.tiles.fairness.tile.ZipTile + + class UnbiasednessTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda index 7aa1dce..ee383a7 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class UnzipPairFstTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda index 536f090..b09c1a9 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class UnzipTripleFstTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda index 79e9e2f..35d92b0 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda @@ -1,4 +1,9 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AttributePTile + + class WithPTile abstract diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda index 057ae4d..5bb92b0 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda @@ -1,4 +1,8 @@ +directive lean +import Soda.tiles.fairness.tool.TileMessage + + class ZipTile abstract From ba0dd03ad7ea1a944b77c956f3c02632ca29c530 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Wed, 21 Feb 2024 21:20:59 +0100 Subject: [PATCH 17/28] Add class to test a child care subsidy scenario --- .../tile/ChildCareSubsidyScenarioExample.soda | 138 +++++++++++++++++ .../soda/tiles/fairness/tile/Package.scala | 145 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda b/tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda new file mode 100644 index 0000000..b5bced1 --- /dev/null +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda @@ -0,0 +1,138 @@ + +class ChildCareSubsidyScenarioExample + + abstract + + resource0 = "no subsidy - 0" + + resource1 = "subsidy - 100" + + resource2 = "subsidy - 200" + + resource3 = "subsidy - 300" + + actor0 = "family A" + + actor1 = "family B" + + actor2 = "family C" + + actor_children_map : Map [Actor] [Measure] = Seq ( + Tuple2 [Actor] [Measure] (actor0 , Some (2) ) , + Tuple2 [Actor] [Measure] (actor1 , Some (3) ) , + Tuple2 [Actor] [Measure] (actor2 , Some (1) ) + ) .toMap + + actor_adults_map : Map [Actor] [Measure] = Seq ( + Tuple2 [Actor] [Measure] (actor0 , Some (2) ) , + Tuple2 [Actor] [Measure] (actor1 , Some (1) ) , + Tuple2 [Actor] [Measure] (actor2 , Some (2) ) + ) .toMap + + actor_income_map : Map [Actor] [Measure] = Seq ( + Tuple2 [Actor] [Measure] (actor0 , Some (5000) ) , + Tuple2 [Actor] [Measure] (actor1 , Some (3000) ) , + Tuple2 [Actor] [Measure] (actor2 , Some (800) ) + ) .toMap + + context = "context" + + outcome_no_subsidy : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource0) , + Assignment .mk (actor2) (resource0) + ) + ) + + outcome_per_family_0 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource1) + ) + ) + + outcome_per_family_1 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + outcome_single_guardian : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource0) + ) + ) + + outcome_per_child : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + outcome_decreasing_on_income_0 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + outcome_decreasing_on_income_1 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource3) + ) + ) + + outcome_decreasing_per_child : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + initial_no_subsidy : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_no_subsidy) (true) + + initial_per_family_0 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_family_0) (true) + + initial_per_family_1 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_family_1) (true) + + initial_single_guardian : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_single_guardian) (true) + + initial_per_child : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_child) (true) + + initial_decreasing_on_income_0 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_0) (true) + + initial_decreasing_on_income_1 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_1) (true) + + initial_decreasing_per_child : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_per_child) (true) + + +end + diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala index d0a8c12..64299f2 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -22,6 +22,151 @@ import soda.tiles.fairness.tool.TilePair_ import soda.tiles.fairness.tool.Random import soda.tiles.fairness.tool.Random_ +trait ChildCareSubsidyScenarioExample +{ + + + + lazy val resource0 = "no subsidy - 0" + + lazy val resource1 = "subsidy - 100" + + lazy val resource2 = "subsidy - 200" + + lazy val resource3 = "subsidy - 300" + + lazy val actor0 = "family A" + + lazy val actor1 = "family B" + + lazy val actor2 = "family C" + + lazy val actor_children_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (2) ) , + Tuple2 [Actor, Measure] (actor1 , Some (3) ) , + Tuple2 [Actor, Measure] (actor2 , Some (1) ) + ) .toMap + + lazy val actor_adults_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (2) ) , + Tuple2 [Actor, Measure] (actor1 , Some (1) ) , + Tuple2 [Actor, Measure] (actor2 , Some (2) ) + ) .toMap + + lazy val actor_income_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (5000) ) , + Tuple2 [Actor, Measure] (actor1 , Some (3000) ) , + Tuple2 [Actor, Measure] (actor2 , Some (800) ) + ) .toMap + + lazy val context = "context" + + lazy val outcome_no_subsidy : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource0) , + Assignment .mk (actor2) (resource0) + ) + ) + + lazy val outcome_per_family_0 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val outcome_per_family_1 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + lazy val outcome_single_guardian : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource0) + ) + ) + + lazy val outcome_per_child : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val outcome_decreasing_on_income_0 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + lazy val outcome_decreasing_on_income_1 : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource3) + ) + ) + + lazy val outcome_decreasing_per_child : Outcome = + Outcome_ ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val initial_no_subsidy : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_no_subsidy) (true) + + lazy val initial_per_family_0 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_family_0) (true) + + lazy val initial_per_family_1 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_family_1) (true) + + lazy val initial_single_guardian : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_single_guardian) (true) + + lazy val initial_per_child : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_per_child) (true) + + lazy val initial_decreasing_on_income_0 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_0) (true) + + lazy val initial_decreasing_on_income_1 : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_1) (true) + + lazy val initial_decreasing_per_child : TileMessage [Boolean] = + TileMessageBuilder_ () .build (context) (outcome_decreasing_per_child) (true) + +} + +case class ChildCareSubsidyScenarioExample_ () extends ChildCareSubsidyScenarioExample + +object ChildCareSubsidyScenarioExample { + def mk : ChildCareSubsidyScenarioExample = + ChildCareSubsidyScenarioExample_ () +} + + case class EqualityTileSpec () extends AnyFunSuite From 19ec821abcbf943cf0934d34595b9ff8d354f280 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Fri, 23 Feb 2024 00:45:55 +0100 Subject: [PATCH 18/28] Change ScoringTool to use Float instead of Double --- .../tiles/fairness/tile/CorrelationTile.soda | 12 +-- .../soda/tiles/fairness/tile/Package.scala | 12 +-- .../soda/tiles/fairness/tool/Package.scala | 79 ++++++++++++------- .../soda/tiles/fairness/tool/ScoringTool.soda | 72 ++++++++++------- .../soda/tiles/fairness/tool/Package.scala | 8 +- .../tiles/fairness/tool/ScoringToolSpec.soda | 8 +- 6 files changed, 116 insertions(+), 75 deletions(-) diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda index 73580b4..fdf31fb 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda @@ -9,23 +9,23 @@ class CorrelationTile _measure_zero : Measure = Some (0) - _percentage_constant : Double = 100.0 + _percentage_constant : Float = 100.0 - get_coefficient (xlist : Seq [Double] ) (ylist : Seq [Double] ) : Double = + get_coefficient (xlist : Seq [Float] ) (ylist : Seq [Float] ) : Float = Pearson_ (xlist) (ylist) .coefficient - to_double (m : Measure) : Double = + to_double (m : Measure) : Float = if (m == _measure_zero) then 0.0 else 1.0 - to_measure (d : Double) : Measure = + to_measure (d : Float) : Measure = Some ( (d * _percentage_constant) .intValue) - get_fst_list (lists : Seq [TilePair [Measure] [Measure] ] ) : Seq [Double] = + get_fst_list (lists : Seq [TilePair [Measure] [Measure] ] ) : Seq [Float] = lists .map (lambda pair --> to_double (pair .fst) ) - get_snd_list (lists : Seq [TilePair [Measure] [Measure] ] ) : Seq [Double] = + get_snd_list (lists : Seq [TilePair [Measure] [Measure] ] ) : Seq [Float] = lists .map (lambda pair --> to_double (pair .snd) ) process_tuples (lists : Seq [TilePair [Measure] [Measure] ] ) : Measure = diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala index 758b694..9953288 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -234,23 +234,23 @@ trait CorrelationTile private lazy val _measure_zero : Measure = Some (0) - private lazy val _percentage_constant : Double = 100.0 + private lazy val _percentage_constant : Float = 100.0 - def get_coefficient (xlist : Seq [Double] ) (ylist : Seq [Double] ) : Double = + def get_coefficient (xlist : Seq [Float] ) (ylist : Seq [Float] ) : Float = Pearson_ (xlist, ylist) .coefficient - def to_double (m : Measure) : Double = + def to_double (m : Measure) : Float = if ( (m == _measure_zero) ) 0.0 else 1.0 - def to_measure (d : Double) : Measure = + def to_measure (d : Float) : Measure = Some ( (d * _percentage_constant) .intValue) - def get_fst_list (lists : Seq [TilePair [Measure, Measure] ] ) : Seq [Double] = + def get_fst_list (lists : Seq [TilePair [Measure, Measure] ] ) : Seq [Float] = lists .map ( pair => to_double (pair .fst) ) - def get_snd_list (lists : Seq [TilePair [Measure, Measure] ] ) : Seq [Double] = + def get_snd_list (lists : Seq [TilePair [Measure, Measure] ] ) : Seq [Float] = lists .map ( pair => to_double (pair .snd) ) def process_tuples (lists : Seq [TilePair [Measure, Measure] ] ) : Measure = diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala index 6d4b9cd..2f86f53 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -127,19 +127,27 @@ trait MathTool - def squared (x : Double) : Double = + private def _tailrec_foldl [A , B ] (sequence : Seq [A] ) (current : B) + (next : B => A => B) : B = + sequence match { + case Nil => current + case (head) +: (tail) => + _tailrec_foldl [A, B] (tail) (next (current) (head) ) (next) + } + + def squared (x : Float) : Float = x * x - private lazy val _sum_init : Double = 0 + private lazy val _sum_init : Float = 0 - private def _sum_next (accum : Double , elem : Double) : Double = + private def _sum_next (accum : Float) (elem : Float) : Float = accum + elem - def sum (seq : Seq [Double] ) : Double = - seq .foldLeft (_sum_init) (_sum_next) + def sum (seq : Seq [Float] ) : Float = + _tailrec_foldl [Float, Float] (seq) (_sum_init) (_sum_next) - def average (seq : Seq [Double] ) : Double = - sum (seq) / seq .length .toDouble + def average (seq : Seq [Float] ) : Float = + sum (seq) / seq .length .toFloat } @@ -153,46 +161,61 @@ object MathTool { trait Pearson { - def xlist : Seq [Double] - def ylist : Seq [Double] + def xlist : Seq [Float] + def ylist : Seq [Float] + + private lazy val _mm : MathTool = MathTool .mk + +/* + directive lean + notation "Math.sqrt" => Float.sqrt + notation "_mm.average" => MathTool.average + notation "_mm.sum" => MathTool.sum + notation "_mm.squared" => MathTool.squared +*/ + + def _to_Float (d : Double) : Float = d .toFloat - private lazy val _mt : MathTool = MathTool_ () +/* + directive lean + def _to_Float (x : Float) : Float := x +*/ - private def _sum_squared_diff_with (seq : Seq [Double] ) (x_average : Double) : Double = - _mt .sum (seq .map ( x_i => _mt .squared (x_i - x_average) ) ) + private def _sum_squared_diff_with (seq : Seq [Float] ) (x_average : Float) : Float = + _mm .sum (seq .map ( x_i => _mm .squared (x_i - x_average) ) ) - def sum_squared_diff (seq : Seq [Double] ) : Double = - _sum_squared_diff_with (seq) (_mt .average (seq) ) + def sum_squared_diff (seq : Seq [Float] ) : Float = + _sum_squared_diff_with (seq) (_mm .average (seq) ) - private def _sqrt_sum_squared_diff (seq : Seq [Double] ) : Double = - Math.sqrt (sum_squared_diff (seq) ) + private def _sqrt_sum_squared_diff (seq : Seq [Float] ) : Float = + _to_Float ( Math.sqrt (sum_squared_diff (seq) ) ) - private lazy val _denominator : Double = + private lazy val _denominator : Float = _sqrt_sum_squared_diff (xlist) * _sqrt_sum_squared_diff (ylist) - private def _multip (x_i : Double) (y_i : Double) (x_average : Double) (y_average : Double) : Double = + private def _multip (x_i : Float) (y_i : Float) (x_average : Float) (y_average : Float) : Float = (x_i - x_average) * (y_i - y_average) - private def _numerator_with (pair_list : Seq [Tuple2 [Double, Double] ] ) (x_average : Double) - (y_average : Double) : Double = - _mt .sum (pair_list .map ( pair => + private def _numerator_with (pair_list : Seq [Tuple2 [Float, Float] ] ) (x_average : Float) + (y_average : Float) : Float = + _mm .sum (pair_list .map ( pair => _multip (pair ._1) (pair ._2) (x_average) (y_average) ) ) - private lazy val _x_y_together : Seq [Tuple2 [Double, Double] ] = + private lazy val _x_y_together : Seq [Tuple2 [Float, Float] ] = xlist .zip (ylist) - private lazy val _numerator : Double = - _numerator_with (_x_y_together) (_mt .average (xlist) ) (_mt .average (ylist) ) + private lazy val _numerator : Float = + _numerator_with (_x_y_together) (_mm .average (xlist) ) (_mm .average (ylist) ) - lazy val coefficient : Double = + lazy val coefficient : Float = _numerator / _denominator } -case class Pearson_ (xlist : Seq [Double], ylist : Seq [Double]) extends Pearson +case class Pearson_ (xlist : Seq [Float], ylist : Seq [Float]) extends Pearson object Pearson { - def mk (xlist : Seq [Double]) (ylist : Seq [Double]) : Pearson = + def mk (xlist : Seq [Float]) (ylist : Seq [Float]) : Pearson = Pearson_ (xlist, ylist) } @@ -217,7 +240,7 @@ trait ScoringCategory lazy val strong_negative_correlation : Int = 7 - def categorize (x : Double) : Int = + def categorize (x : Float) : Int = if ( (x > 0.5) && (x <= 1.0) ) strong_positive_correlation else if ( (x > 0.3) && (x <= 0.5) ) moderate_positive_correlation else if ( (x > 0) && (x <= 0.3) ) weak_positive_correlation diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda b/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda index 2d2a6e3..0e0eba9 100644 --- a/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda +++ b/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda @@ -2,7 +2,6 @@ directive lean import Soda.tiles.fairness.tool.TileMessage - /** * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - @@ -14,19 +13,26 @@ class MathTool abstract - squared (x : Double) : Double = + _tailrec_foldl [A : Type] [B : Type] (sequence : Seq [A] ) (current : B) + (next : B -> A -> B) : B = + match sequence + case Nil ==> current + case (head) +: (tail) ==> + _tailrec_foldl [A] [B] (tail) (next (current) (head) ) (next) + + squared (x : Float) : Float = x * x - _sum_init : Double = 0 + _sum_init : Float = 0 - _sum_next (accum : Double , elem : Double) : Double = + _sum_next (accum : Float) (elem : Float) : Float = accum + elem - sum (seq : Seq [Double] ) : Double = - seq .foldLeft (_sum_init) (_sum_next) + sum (seq : Seq [Float] ) : Float = + _tailrec_foldl [Float] [Float] (seq) (_sum_init) (_sum_next) - average (seq : Seq [Double] ) : Double = - sum (seq) / seq .length .toDouble + average (seq : Seq [Float] ) : Float = + sum (seq) / seq .length .toFloat end @@ -34,38 +40,50 @@ end class Pearson abstract - xlist : Seq [Double] - ylist : Seq [Double] + xlist : Seq [Float] + ylist : Seq [Float] + + _mm : MathTool = MathTool .mk + + directive lean + notation "Math.sqrt" => Float.sqrt + notation "_mm.average" => MathTool.average + notation "_mm.sum" => MathTool.sum + notation "_mm.squared" => MathTool.squared + + directive scala + def _to_Float (d : Double) : Float = d .toFloat - _mt : MathTool = MathTool_ () + directive lean + def _to_Float (x : Float) : Float := x - _sum_squared_diff_with (seq : Seq [Double] ) (x_average : Double) : Double = - _mt .sum (seq .map (lambda x_i --> _mt .squared (x_i - x_average) ) ) + _sum_squared_diff_with (seq : Seq [Float] ) (x_average : Float) : Float = + _mm .sum (seq .map (lambda x_i --> _mm .squared (x_i - x_average) ) ) - sum_squared_diff (seq : Seq [Double] ) : Double = - _sum_squared_diff_with (seq) (_mt .average (seq) ) + sum_squared_diff (seq : Seq [Float] ) : Float = + _sum_squared_diff_with (seq) (_mm .average (seq) ) - _sqrt_sum_squared_diff (seq : Seq [Double] ) : Double = - Math.sqrt (sum_squared_diff (seq) ) + _sqrt_sum_squared_diff (seq : Seq [Float] ) : Float = + _to_Float ( Math.sqrt (sum_squared_diff (seq) ) ) - _denominator : Double = + _denominator : Float = _sqrt_sum_squared_diff (xlist) * _sqrt_sum_squared_diff (ylist) - _multip (x_i : Double) (y_i : Double) (x_average : Double) (y_average : Double) : Double = + _multip (x_i : Float) (y_i : Float) (x_average : Float) (y_average : Float) : Float = (x_i - x_average) * (y_i - y_average) - _numerator_with (pair_list : Seq [Tuple2 [Double] [Double] ] ) (x_average : Double) - (y_average : Double) : Double = - _mt .sum (pair_list .map (lambda pair --> + _numerator_with (pair_list : Seq [Tuple2 [Float] [Float] ] ) (x_average : Float) + (y_average : Float) : Float = + _mm .sum (pair_list .map (lambda pair --> _multip (pair ._1) (pair ._2) (x_average) (y_average) ) ) - _x_y_together : Seq [Tuple2 [Double] [Double] ] = + _x_y_together : Seq [Tuple2 [Float] [Float] ] = xlist .zip (ylist) - _numerator : Double = - _numerator_with (_x_y_together) (_mt .average (xlist) ) (_mt .average (ylist) ) + _numerator : Float = + _numerator_with (_x_y_together) (_mm .average (xlist) ) (_mm .average (ylist) ) - coefficient : Double = + coefficient : Float = _numerator / _denominator end @@ -91,7 +109,7 @@ class ScoringCategory strong_negative_correlation : Int = 7 - categorize (x : Double) : Int = + categorize (x : Float) : Int = if (x > 0.5) and (x <= 1.0) then strong_positive_correlation else if (x > 0.3) and (x <= 0.5) then moderate_positive_correlation else if (x > 0) and (x <= 0.3) then weak_positive_correlation diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala b/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala index dbe59ce..db7ae1d 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala +++ b/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala @@ -203,9 +203,9 @@ case class ScoringToolSpec () def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - lazy val example_xlist_1 : Seq [Double] = Seq (1 , 3 , 5 , 8) + lazy val example_xlist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) - lazy val example_ylist_1 : Seq [Double] = Seq (1 , 3 , 5 , 8) + lazy val example_ylist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) lazy val instance_1 : Pearson = Pearson_ (example_xlist_1, example_ylist_1) @@ -237,9 +237,9 @@ case class ScoringToolSpec () ) ) - lazy val example_xlist_2 : Seq [Double] = Seq (43 , 21 , 25 , 42 , 57 , 59) + lazy val example_xlist_2 : Seq [Float] = Seq (43 , 21 , 25 , 42 , 57 , 59) - lazy val example_ylist_2 : Seq [Double] = Seq (99 , 65 , 79 , 75 , 87 , 81) + lazy val example_ylist_2 : Seq [Float] = Seq (99 , 65 , 79 , 75 , 87 , 81) lazy val instance_2 : Pearson = Pearson_ (example_xlist_2, example_ylist_2) diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda b/tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda index 280bbe6..aa94c0e 100644 --- a/tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda +++ b/tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda @@ -6,9 +6,9 @@ class ScoringToolSpec () check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - example_xlist_1 : Seq [Double] = Seq (1 , 3 , 5 , 8) + example_xlist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) - example_ylist_1 : Seq [Double] = Seq (1 , 3 , 5 , 8) + example_ylist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) instance_1 : Pearson = Pearson_ (example_xlist_1) (example_ylist_1) @@ -41,9 +41,9 @@ class ScoringToolSpec () ) ) - example_xlist_2 : Seq [Double] = Seq (43 , 21 , 25 , 42 , 57 , 59) + example_xlist_2 : Seq [Float] = Seq (43 , 21 , 25 , 42 , 57 , 59) - example_ylist_2 : Seq [Double] = Seq (99 , 65 , 79 , 75 , 87 , 81) + example_ylist_2 : Seq [Float] = Seq (99 , 65 , 79 , 75 , 87 , 81) instance_2 : Pearson = Pearson_ (example_xlist_2) (example_ylist_2) From bbef3f291609b0ab48f080c8370bf639a8d47cdf Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 10:49:44 +0100 Subject: [PATCH 19/28] Rename main module to `core` --- build.sbt | 6 +++--- .../scala/soda/tiles/fairness/tile/AllActorPairTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/AllActorTile.soda | 0 .../scala/soda/tiles/fairness/tile/AllActorTripleTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda | 0 .../main/scala/soda/tiles/fairness/tile/AllEqualTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/AtLeastTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/AttributePTile.soda | 0 .../scala/soda/tiles/fairness/tile/CorrelationTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/DecisionTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/EqualityTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tile/EquityTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/FalsePosTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/NeededPTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tile/Package.scala | 0 .../src/main/scala/soda/tiles/fairness/tile/Package.soda | 0 .../scala/soda/tiles/fairness/tile/PredictionPTile.soda | 0 .../scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/ResultPTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda | 0 .../scala/soda/tiles/fairness/tile/UnbiasednessTile.soda | 0 .../main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda | 0 .../scala/soda/tiles/fairness/tile/UnzipTripleTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tile/WithPTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tile/ZipTile.soda | 0 .../src/main/scala/soda/tiles/fairness/tool/Entity.soda | 0 .../src/main/scala/soda/tiles/fairness/tool/Package.scala | 0 .../src/main/scala/soda/tiles/fairness/tool/Package.soda | 0 .../main/scala/soda/tiles/fairness/tool/ScoringTool.soda | 0 .../scala/soda/tiles/fairness/tool/StringComparator.soda | 0 .../main/scala/soda/tiles/fairness/tool/TileMessage.soda | 0 .../fairness/tile/ChildCareSubsidyScenarioExample.soda | 0 .../scala/soda/tiles/fairness/tile/EqualityTileSpec.soda | 0 .../test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda | 0 .../src/test/scala/soda/tiles/fairness/tile/Package.scala | 0 .../src/test/scala/soda/tiles/fairness/tile/Package.soda | 0 .../fairness/tile/ResourceAllocationScenarioExample.soda | 0 .../soda/tiles/fairness/tile/ScoringScenarioExample.soda | 0 .../soda/tiles/fairness/tile/UnbiasednessTileSpec.soda | 0 .../src/test/scala/soda/tiles/fairness/tool/Package.scala | 0 .../src/test/scala/soda/tiles/fairness/tool/Package.soda | 0 .../soda/tiles/fairness/tool/RandomNumberGenerator.soda | 0 .../src/test/scala/soda/tiles/fairness/tool/Recursion.soda | 0 .../scala/soda/tiles/fairness/tool/ScoringToolSpec.soda | 0 .../soda/tiles/fairness/tool/StringComparatorSpec.soda | 0 45 files changed, 3 insertions(+), 3 deletions(-) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/Package.scala (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/Package.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/Entity.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/Package.scala (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/Package.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda (100%) rename {tiles => core}/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/Package.scala (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/Package.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/Package.scala (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/Package.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/Recursion.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda (100%) rename {tiles => core}/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda (100%) diff --git a/build.sbt b/build.sbt index 9291a27..e5cd7bd 100644 --- a/build.sbt +++ b/build.sbt @@ -46,11 +46,11 @@ lazy val docs = lazy val core = project - .withId("tiles-core") - .in(file("tiles")) + .withId("core") + .in(file("core")) .settings( commonSettings, - assembly / assemblyJarName := "tiles-" + version.value + ".jar" + assembly / assemblyJarName := "core-" + version.value + ".jar" ) lazy val root = diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala rename to core/src/main/scala/soda/tiles/fairness/tile/Package.scala diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda b/core/src/main/scala/soda/tiles/fairness/tile/Package.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/Package.soda rename to core/src/main/scala/soda/tiles/fairness/tile/Package.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda b/core/src/main/scala/soda/tiles/fairness/tool/Entity.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/Entity.soda rename to core/src/main/scala/soda/tiles/fairness/tool/Entity.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala b/core/src/main/scala/soda/tiles/fairness/tool/Package.scala similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala rename to core/src/main/scala/soda/tiles/fairness/tool/Package.scala diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/Package.soda b/core/src/main/scala/soda/tiles/fairness/tool/Package.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/Package.soda rename to core/src/main/scala/soda/tiles/fairness/tool/Package.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda b/core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda rename to core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda b/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda rename to core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda diff --git a/tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda b/core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda similarity index 100% rename from tiles/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda rename to core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda rename to core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/Package.scala rename to core/src/test/scala/soda/tiles/fairness/tile/Package.scala diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda b/core/src/test/scala/soda/tiles/fairness/tile/Package.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/Package.soda rename to core/src/test/scala/soda/tiles/fairness/tile/Package.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda rename to core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda rename to core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala b/core/src/test/scala/soda/tiles/fairness/tool/Package.scala similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/Package.scala rename to core/src/test/scala/soda/tiles/fairness/tool/Package.scala diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/Package.soda b/core/src/test/scala/soda/tiles/fairness/tool/Package.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/Package.soda rename to core/src/test/scala/soda/tiles/fairness/tool/Package.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda b/core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda rename to core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/Recursion.soda b/core/src/test/scala/soda/tiles/fairness/tool/Recursion.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/Recursion.soda rename to core/src/test/scala/soda/tiles/fairness/tool/Recursion.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda b/core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda rename to core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda diff --git a/tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda b/core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda similarity index 100% rename from tiles/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda rename to core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda From 61bca851b600e895240f20fa7ee6d732ce3509dc Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 11:10:02 +0100 Subject: [PATCH 20/28] Create module `examples` --- build.sbt | 15 ++++++++++-- .../example/childcaresubsidy/Package.soda | 21 ++++++++++++++++ .../example/childcaresubsidy/Package.soda | 24 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda create mode 100644 examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda diff --git a/build.sbt b/build.sbt index e5cd7bd..619910e 100644 --- a/build.sbt +++ b/build.sbt @@ -53,12 +53,23 @@ lazy val core = assembly / assemblyJarName := "core-" + version.value + ".jar" ) +lazy val examples = + project + .withId("examples") + .in(file("examples")) + .aggregate(core) + .dependsOn(core) + .settings( + commonSettings, + assembly / assemblyJarName := "examples-" + version.value + ".jar" + ) + lazy val root = project .withId("tiles") .in(file(".")) - .aggregate(docs, core) - .dependsOn(docs, core) + .aggregate(docs, core, examples) + .dependsOn(docs, core, examples) .settings( commonSettings, assembly / assemblyJarName := "tiles-" + version.value + ".jar" diff --git a/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda new file mode 100644 index 0000000..9466655 --- /dev/null +++ b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda @@ -0,0 +1,21 @@ +package soda.tiles.fairness.example.childcaresubsidy + +import + org.scalatest.funsuite.AnyFunSuite + soda.tiles.fairness.tool.Actor + soda.tiles.fairness.tool.Assignment + soda.tiles.fairness.tool.Assignment_ + soda.tiles.fairness.tool.Context + soda.tiles.fairness.tool.Measure + soda.tiles.fairness.tool.Outcome + soda.tiles.fairness.tool.Outcome_ + soda.tiles.fairness.tool.Resource + soda.tiles.fairness.tool.TileMessage + soda.tiles.fairness.tool.TileMessage_ + soda.tiles.fairness.tool.TileMessageBuilder + soda.tiles.fairness.tool.TileMessageBuilder_ + soda.tiles.fairness.tool.TilePair + soda.tiles.fairness.tool.TilePair_ + soda.tiles.fairness.tool.Random + soda.tiles.fairness.tool.Random_ + diff --git a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda new file mode 100644 index 0000000..6ffe4ff --- /dev/null +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda @@ -0,0 +1,24 @@ +package soda.tiles.fairness.example.childcaresubsidy + +/* + * This package contains tests for the classes to model a resource allocation scenario. + */ + +import + org.scalatest.funsuite.AnyFunSuite + soda.tiles.fairness.tool.Actor + soda.tiles.fairness.tool.Assignment + soda.tiles.fairness.tool.Assignment_ + soda.tiles.fairness.tool.Context + soda.tiles.fairness.tool.Measure + soda.tiles.fairness.tool.Outcome + soda.tiles.fairness.tool.Outcome_ + soda.tiles.fairness.tool.Resource + soda.tiles.fairness.tool.TileMessage + soda.tiles.fairness.tool.TileMessage_ + soda.tiles.fairness.tool.TileMessageBuilder + soda.tiles.fairness.tool.TileMessageBuilder_ + soda.tiles.fairness.tool.TilePair + soda.tiles.fairness.tool.TilePair_ + soda.tiles.fairness.tool.Random + soda.tiles.fairness.tool.Random_ From 95ee089e321ff84466d97f493e2cadb095b48540 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 12:20:09 +0100 Subject: [PATCH 21/28] Replace constructor calls by `mk` calls --- .../tiles/fairness/tile/AllActorPairTile.soda | 4 +- .../tiles/fairness/tile/AllActorTile.soda | 2 +- .../fairness/tile/AllActorTripleTile.soda | 4 +- .../tiles/fairness/tile/AllEqualTile.soda | 4 +- .../soda/tiles/fairness/tile/AtLeastTile.soda | 4 +- .../tiles/fairness/tile/AttributePTile.soda | 2 +- .../tiles/fairness/tile/CorrelationTile.soda | 4 +- .../tiles/fairness/tile/DecisionTile.soda | 4 +- .../tiles/fairness/tile/EqualityTile.soda | 6 +- .../soda/tiles/fairness/tile/EquityTile.soda | 14 +-- .../tiles/fairness/tile/FalsePosTile.soda | 2 +- .../soda/tiles/fairness/tile/NeededPTile.soda | 2 +- .../soda/tiles/fairness/tile/Package.scala | 98 ++++++++-------- .../soda/tiles/fairness/tile/Package.soda | 2 +- .../tiles/fairness/tile/PredictionPTile.soda | 2 +- .../fairness/tile/ReceivedSigmaPTile.soda | 2 +- .../soda/tiles/fairness/tile/ResultPTile.soda | 2 +- .../soda/tiles/fairness/tile/SigmaTile.soda | 2 +- .../tiles/fairness/tile/UnbiasednessTile.soda | 22 ++-- .../tiles/fairness/tile/UnzipPairTile.soda | 4 +- .../tiles/fairness/tile/UnzipTripleTile.soda | 6 +- .../soda/tiles/fairness/tile/WithPTile.soda | 2 +- .../soda/tiles/fairness/tile/ZipTile.soda | 2 +- .../soda/tiles/fairness/tool/Package.scala | 12 +- .../tiles/fairness/tool/StringComparator.soda | 10 +- .../soda/tiles/fairness/tool/TileMessage.soda | 2 +- .../tile/ChildCareSubsidyScenarioExample.soda | 33 +++--- .../tiles/fairness/tile/EqualityTileSpec.soda | 4 +- .../tiles/fairness/tile/EquityTileSpec.soda | 4 +- .../soda/tiles/fairness/tile/Package.scala | 108 +++++++++--------- .../ResourceAllocationScenarioExample.soda | 42 +++---- .../fairness/tile/ScoringScenarioExample.soda | 16 +-- .../fairness/tile/UnbiasednessTileSpec.soda | 10 +- .../soda/tiles/fairness/tool/Package.scala | 16 +-- .../fairness/tool/RandomNumberGenerator.soda | 6 +- .../tiles/fairness/tool/ScoringToolSpec.soda | 8 +- .../fairness/tool/StringComparatorSpec.soda | 2 +- 37 files changed, 234 insertions(+), 235 deletions(-) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda index 2e414c6..6090ed8 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda @@ -8,12 +8,12 @@ class AllActorPairTile abstract apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TilePair [Actor] [Actor] ] ] = - TileMessageBuilder_ () .build ( + TileMessageBuilder .mk .build ( message .context) (message .outcome) ( ( (message .outcome) .assignments) .map (lambda assignment --> assignment .actor) .distinct .sorted - .map (lambda actor --> TilePair_ (actor , actor) ) + .map (lambda actor --> TilePair .mk (actor) (actor) ) ) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda index 94f8eb7..367fd8b 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda @@ -8,7 +8,7 @@ class AllActorTile abstract apply (message : TileMessage [Boolean] ) : TileMessage [Seq [Actor] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .outcome) .assignments) .map (lambda assignment --> assignment .actor) .distinct diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda index 8a69982..b42fcec 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda @@ -9,12 +9,12 @@ class AllActorTripleTile apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TileTriple [Actor] [Actor] [Actor] ] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .outcome) .assignments) .map (lambda assignment --> assignment .actor) .distinct .sorted - .map (lambda actor --> TileTriple_ (actor , actor , actor) ) + .map (lambda actor --> TileTriple .mk (actor) (actor) (actor) ) ) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda index f0bb79f..f1c156f 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda @@ -8,10 +8,10 @@ class AllEqualTile abstract - all_equal_1_tile = AllEqual1Tile_ () + all_equal_1_tile = AllEqual1Tile .mk apply (message : TileMessage [Seq [Measure] ] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( all_equal_1_tile .apply (message) (message .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda index 9788bdb..96adcb6 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda @@ -9,10 +9,10 @@ class AtLeastTile apply (message : TileMessage [Seq [TilePair [Measure] [Measure] ] ] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map (lambda pair --> - (Comparator_ () + (Comparator .mk .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall (lambda e --> e) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda index fe449cf..c718fc2 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda @@ -9,7 +9,7 @@ class AttributePTile p : Actor -> Measure apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map (lambda actor --> p (actor) ) ) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda index fdf31fb..db1034a 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda @@ -12,7 +12,7 @@ class CorrelationTile _percentage_constant : Float = 100.0 get_coefficient (xlist : Seq [Float] ) (ylist : Seq [Float] ) : Float = - Pearson_ (xlist) (ylist) .coefficient + (Pearson .mk (xlist) (ylist) ) .coefficient to_double (m : Measure) : Float = if (m == _measure_zero) @@ -33,7 +33,7 @@ class CorrelationTile apply (message : TileMessage [Seq [TilePair [Measure] [Measure] ] ] ) : TileMessage [Measure] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( process_tuples (message .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda index 83252c2..d8b3507 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda @@ -9,11 +9,11 @@ class DecisionTile maximum_acceptable_bias_percentage : Measure to_boolean (m : Measure) : Boolean = - ( Comparator_ () + ( Comparator .mk .compareMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( to_boolean (message .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda index 13deb2a..cdd975b 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda @@ -12,11 +12,11 @@ class EqualityTile sigma : Measure -> Measure -> Measure p_utility : Resource -> Measure - all_equal_tile = AllEqualTile_ () + all_equal_tile = AllEqualTile .mk - received_sigma_p_tile = ReceivedSigmaPTile_ (sigma , p_utility) + received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) - all_actor_tile = AllActorTile_ () + all_actor_tile = AllActorTile .mk apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = all_equal_tile .apply ( diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda index cc0e9eb..ec68830 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda @@ -16,19 +16,19 @@ class EquityTile p0_need : Actor -> Measure p1_utility : Resource -> Measure - at_least_tile = AtLeastTile_ () + at_least_tile = AtLeastTile .mk - received_sigma_p_tile = ReceivedSigmaPTile_ (sigma , p1_utility) + received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p1_utility) - needed_p_tile = NeededPTile_ (p0_need) + needed_p_tile = NeededPTile .mk (p0_need) - all_actor_pair_tile = AllActorPairTile_ () + all_actor_pair_tile = AllActorPairTile .mk - unzip_fst_tile = UnzipPairFstTile_ () + unzip_fst_tile = UnzipPairFstTile .mk - unzip_snd_tile = UnzipPairSndTile_ () + unzip_snd_tile = UnzipPairSndTile .mk - zip_tile = ZipTile_ () + zip_tile = ZipTile .mk get_branch_0 (message : TileMessage [Seq [TilePair [Actor] [Actor] ] ] ) : TileMessage [Seq [Measure] ] = diff --git a/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda index 3ae2e1e..cd2b721 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda @@ -19,7 +19,7 @@ class FalsePosTile apply (message : TileMessage [Seq [TilePair [Measure] [Measure] ] ] ) : TileMessage [Seq [Measure] ] = - SigmaTile_ (sigma) .apply (message) + SigmaTile .mk (sigma) .apply (message) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda index e99988a..7217c80 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda @@ -10,7 +10,7 @@ class NeededPTile p : Actor -> Measure apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala index 9953288..fe6567f 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -14,7 +14,7 @@ import soda.tiles.fairness.tool.Pearson import soda.tiles.fairness.tool.Pearson_ import soda.tiles.fairness.tool.Resource import soda.tiles.fairness.tool.TileMessage -import soda.tiles.fairness.tool.TileMessageBuilder_ +import soda.tiles.fairness.tool.TileMessageBuilder import soda.tiles.fairness.tool.TilePair import soda.tiles.fairness.tool.TilePair_ import soda.tiles.fairness.tool.TileTriple @@ -35,12 +35,12 @@ trait AllActorPairTile def apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TilePair [Actor, Actor] ] ] = - TileMessageBuilder_ () .build ( + TileMessageBuilder .mk .build ( message .context) (message .outcome) ( ( (message .outcome) .assignments) .map ( assignment => assignment .actor) .distinct .sorted - .map ( actor => TilePair_ (actor , actor) ) + .map ( actor => TilePair .mk (actor) (actor) ) ) } @@ -64,7 +64,7 @@ trait AllActorTile def apply (message : TileMessage [Boolean] ) : TileMessage [Seq [Actor] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .outcome) .assignments) .map ( assignment => assignment .actor) .distinct @@ -93,12 +93,12 @@ trait AllActorTripleTile def apply (message : TileMessage [Boolean] ) : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .outcome) .assignments) .map ( assignment => assignment .actor) .distinct .sorted - .map ( actor => TileTriple_ (actor , actor , actor) ) + .map ( actor => TileTriple .mk (actor) (actor) (actor) ) ) } @@ -148,10 +148,10 @@ trait AllEqualTile - lazy val all_equal_1_tile = AllEqual1Tile_ () + lazy val all_equal_1_tile = AllEqual1Tile .mk def apply (message : TileMessage [Seq [Measure] ] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( all_equal_1_tile .apply (message) (message .contents) ) @@ -177,10 +177,10 @@ trait AtLeastTile def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map ( pair => - (Comparator_ () + (Comparator .mk .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) .forall ( e => e) ) @@ -207,7 +207,7 @@ trait AttributePTile def p : Actor => Measure def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map ( actor => p (actor) ) ) ) @@ -237,7 +237,7 @@ trait CorrelationTile private lazy val _percentage_constant : Float = 100.0 def get_coefficient (xlist : Seq [Float] ) (ylist : Seq [Float] ) : Float = - Pearson_ (xlist, ylist) .coefficient + (Pearson .mk (xlist) (ylist) ) .coefficient def to_double (m : Measure) : Float = if ( (m == _measure_zero) @@ -258,7 +258,7 @@ trait CorrelationTile def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) : TileMessage [Measure] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( process_tuples (message .contents) ) @@ -283,11 +283,11 @@ trait DecisionTile def maximum_acceptable_bias_percentage : Measure def to_boolean (m : Measure) : Boolean = - ( Comparator_ () + ( Comparator .mk .compareMeasure (m) (maximum_acceptable_bias_percentage) ) <= 0 def apply (message : TileMessage [Measure] ) : TileMessage [Boolean] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( to_boolean (message .contents) ) @@ -315,11 +315,11 @@ trait EqualityTile def sigma : Measure => Measure => Measure def p_utility : Resource => Measure - lazy val all_equal_tile = AllEqualTile_ () + lazy val all_equal_tile = AllEqualTile .mk - lazy val received_sigma_p_tile = ReceivedSigmaPTile_ (sigma , p_utility) + lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) - lazy val all_actor_tile = AllActorTile_ () + lazy val all_actor_tile = AllActorTile .mk def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = all_equal_tile .apply ( @@ -356,19 +356,19 @@ trait EquityTile def p0_need : Actor => Measure def p1_utility : Resource => Measure - lazy val at_least_tile = AtLeastTile_ () + lazy val at_least_tile = AtLeastTile .mk - lazy val received_sigma_p_tile = ReceivedSigmaPTile_ (sigma , p1_utility) + lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p1_utility) - lazy val needed_p_tile = NeededPTile_ (p0_need) + lazy val needed_p_tile = NeededPTile .mk (p0_need) - lazy val all_actor_pair_tile = AllActorPairTile_ () + lazy val all_actor_pair_tile = AllActorPairTile .mk - lazy val unzip_fst_tile = UnzipPairFstTile_ () + lazy val unzip_fst_tile = UnzipPairFstTile .mk - lazy val unzip_snd_tile = UnzipPairSndTile_ () + lazy val unzip_snd_tile = UnzipPairSndTile .mk - lazy val zip_tile = ZipTile_ () + lazy val zip_tile = ZipTile .mk def get_branch_0 (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) : TileMessage [Seq [Measure] ] = @@ -421,7 +421,7 @@ trait FalsePosTile def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) : TileMessage [Seq [Measure] ] = - SigmaTile_ (sigma) .apply (message) + SigmaTile .mk (sigma) .apply (message) } @@ -445,7 +445,7 @@ trait NeededPTile def p : Actor => Measure def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) } @@ -476,7 +476,7 @@ trait PredictionPTile else m0 def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - ReceivedSigmaPTile_ (measure_or , p) .apply (message) + (ReceivedSigmaPTile .mk (measure_or) (p) ) .apply (message) } @@ -513,7 +513,7 @@ trait ReceivedSigmaPTile .foldLeft (_measure_zero) (_sigma2) def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map ( actor => get_measure (message .outcome) (actor) ) ) ) @@ -540,7 +540,7 @@ trait ResultPTile def p : Actor => Measure def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) } @@ -564,7 +564,7 @@ trait SigmaTile def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( (message .contents) .map ( pair => sigma (pair .fst) (pair .snd) ) ) @@ -603,27 +603,27 @@ trait UnbiasednessTile def p2_with_p : Actor => Measure def p3_acceptable_bias : Measure - lazy val all_actor_triple_tile = AllActorTripleTile_ () + lazy val all_actor_triple_tile = AllActorTripleTile .mk - lazy val unzip_fst_tile = UnzipTripleFstTile_ () + lazy val unzip_fst_tile = UnzipTripleFstTile .mk - lazy val unzip_snd_tile = UnzipTripleSndTile_ () + lazy val unzip_snd_tile = UnzipTripleSndTile .mk - lazy val unzip_trd_tile = UnzipTripleTrdTile_ () + lazy val unzip_trd_tile = UnzipTripleTrdTile .mk - lazy val zip_tile = ZipTile_ () + lazy val zip_tile = ZipTile .mk - lazy val prediction_p_tile = PredictionPTile_ (p0_evaluation) + lazy val prediction_p_tile = PredictionPTile .mk (p0_evaluation) - lazy val result_p_tile = ResultPTile_ (p1_result) + lazy val result_p_tile = ResultPTile .mk (p1_result) - lazy val with_p_tile = WithPTile_ (p2_with_p) + lazy val with_p_tile = WithPTile .mk (p2_with_p) - lazy val false_pos_tile = FalsePosTile_ () + lazy val false_pos_tile = FalsePosTile .mk - lazy val correlation_tile = CorrelationTile_ () + lazy val correlation_tile = CorrelationTile .mk - lazy val decision_tile = DecisionTile_ (p3_acceptable_bias) + lazy val decision_tile = DecisionTile .mk (p3_acceptable_bias) def get_prediction (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) : TileMessage [Seq [Measure] ] = @@ -683,7 +683,7 @@ trait UnzipPairFstTile def apply [A , B ] (message : TileMessage [Seq [TilePair [A, B] ] ] ) : TileMessage [Seq [A] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_fst_list (message .contents) ) @@ -706,7 +706,7 @@ trait UnzipPairSndTile def apply [A , B ] (message : TileMessage [Seq [TilePair [A, B] ] ] ) : TileMessage [Seq [B] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_snd_list (message .contents) ) @@ -736,7 +736,7 @@ trait UnzipTripleFstTile def apply [A , B , C ] ( message : TileMessage [Seq [TileTriple [A, B, C] ] ] ) : TileMessage [Seq [A] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_fst_list (message .contents) ) @@ -760,7 +760,7 @@ trait UnzipTripleSndTile def apply [A , B , C ] ( message : TileMessage [Seq [TileTriple [A, B, C] ] ] ) : TileMessage [Seq [B] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_snd_list (message .contents) ) @@ -784,7 +784,7 @@ trait UnzipTripleTrdTile def apply [A , B , C ] ( message : TileMessage [Seq [TileTriple [A, B, C] ] ] ) : TileMessage [Seq [C] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_trd_list (message .contents) ) @@ -810,7 +810,7 @@ trait WithPTile def p : Actor => Measure def apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) } @@ -840,7 +840,7 @@ trait ZipTile def apply [A , B ] (message0 : TileMessage [Seq [A] ] ) (message1 : TileMessage [Seq [B] ] ) : TileMessage [Seq [TilePair [A, B] ] ] = - TileMessageBuilder_ () .build (message0 .context) (message0 .outcome) ( + TileMessageBuilder .mk .build (message0 .context) (message0 .outcome) ( zip_lists (message0 .contents) (message1 .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/Package.soda b/core/src/main/scala/soda/tiles/fairness/tile/Package.soda index 77b96c8..a9a612c 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/Package.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/Package.soda @@ -15,7 +15,7 @@ import soda.tiles.fairness.tool.Pearson_ soda.tiles.fairness.tool.Resource soda.tiles.fairness.tool.TileMessage - soda.tiles.fairness.tool.TileMessageBuilder_ + soda.tiles.fairness.tool.TileMessageBuilder soda.tiles.fairness.tool.TilePair soda.tiles.fairness.tool.TilePair_ soda.tiles.fairness.tool.TileTriple diff --git a/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda index 14befc9..1545a6e 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda @@ -17,7 +17,7 @@ class PredictionPTile else m0 apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - ReceivedSigmaPTile_ (measure_or , p) .apply (message) + (ReceivedSigmaPTile .mk (measure_or) (p) ) .apply (message) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda index 7b85151..4b0f5ce 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda @@ -23,7 +23,7 @@ class ReceivedSigmaPTile .foldLeft (_measure_zero) (_sigma2) apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( ( (message .contents) .map (lambda actor --> get_measure (message .outcome) (actor) ) ) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda index 213e71e..7f9cf80 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda @@ -10,6 +10,6 @@ class ResultPTile p : Actor -> Measure apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda index 719b419..13c0f55 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda @@ -10,7 +10,7 @@ class SigmaTile apply (message : TileMessage [Seq [TilePair [Measure] [Measure] ] ] ) : TileMessage [Seq [Measure] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( (message .contents) .map (lambda pair --> sigma (pair .fst) (pair .snd) ) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda index c9380b0..68682e8 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda @@ -22,27 +22,27 @@ class UnbiasednessTile p2_with_p : Actor -> Measure p3_acceptable_bias : Measure - all_actor_triple_tile = AllActorTripleTile_ () + all_actor_triple_tile = AllActorTripleTile .mk - unzip_fst_tile = UnzipTripleFstTile_ () + unzip_fst_tile = UnzipTripleFstTile .mk - unzip_snd_tile = UnzipTripleSndTile_ () + unzip_snd_tile = UnzipTripleSndTile .mk - unzip_trd_tile = UnzipTripleTrdTile_ () + unzip_trd_tile = UnzipTripleTrdTile .mk - zip_tile = ZipTile_ () + zip_tile = ZipTile .mk - prediction_p_tile = PredictionPTile_ (p0_evaluation) + prediction_p_tile = PredictionPTile .mk (p0_evaluation) - result_p_tile = ResultPTile_ (p1_result) + result_p_tile = ResultPTile .mk (p1_result) - with_p_tile = WithPTile_ (p2_with_p) + with_p_tile = WithPTile .mk (p2_with_p) - false_pos_tile = FalsePosTile_ () + false_pos_tile = FalsePosTile .mk - correlation_tile = CorrelationTile_ () + correlation_tile = CorrelationTile .mk - decision_tile = DecisionTile_ (p3_acceptable_bias) + decision_tile = DecisionTile .mk (p3_acceptable_bias) get_prediction (message : TileMessage [Seq [TileTriple [Actor] [Actor] [Actor] ] ] ) : TileMessage [Seq [Measure] ] = diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda index ee383a7..e3fa610 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda @@ -12,7 +12,7 @@ class UnzipPairFstTile apply [A : Type] [B : Type] (message : TileMessage [Seq [TilePair [A] [B] ] ] ) : TileMessage [Seq [A] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_fst_list (message .contents) ) @@ -28,7 +28,7 @@ class UnzipPairSndTile apply [A : Type] [B : Type] (message : TileMessage [Seq [TilePair [A] [B] ] ] ) : TileMessage [Seq [B] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_snd_list (message .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda index b09c1a9..7f1389b 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda @@ -13,7 +13,7 @@ class UnzipTripleFstTile apply [A : Type] [B : Type] [C : Type] ( message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [A] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_fst_list (message .contents) ) @@ -30,7 +30,7 @@ class UnzipTripleSndTile apply [A : Type] [B : Type] [C : Type] ( message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [B] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_snd_list (message .contents) ) @@ -47,7 +47,7 @@ class UnzipTripleTrdTile apply [A : Type] [B : Type] [C : Type] ( message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [C] ] = - TileMessageBuilder_ () .build (message .context) (message .outcome) ( + TileMessageBuilder .mk .build (message .context) (message .outcome) ( unzip_trd_list (message .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda index 35d92b0..81047e8 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda @@ -10,7 +10,7 @@ class WithPTile p : Actor -> Measure apply (message : TileMessage [Seq [Actor] ] ) : TileMessage [Seq [Measure] ] = - AttributePTile_ (p) .apply (message) + AttributePTile .mk (p) .apply (message) end diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda index 5bb92b0..06bd4e1 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda @@ -15,7 +15,7 @@ class ZipTile apply [A : Type] [B : Type] (message0 : TileMessage [Seq [A] ] ) (message1 : TileMessage [Seq [B] ] ) : TileMessage [Seq [TilePair [A] [B] ] ] = - TileMessageBuilder_ () .build (message0 .context) (message0 .outcome) ( + TileMessageBuilder .mk .build (message0 .context) (message0 .outcome) ( zip_lists (message0 .contents) (message1 .contents) ) diff --git a/core/src/main/scala/soda/tiles/fairness/tool/Package.scala b/core/src/main/scala/soda/tiles/fairness/tool/Package.scala index 2f86f53..90c976d 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/core/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -302,12 +302,12 @@ trait StringComparator other_seq match { case head +: tail => if ( current_char < head - ) HelperTuple_ (it_is_less, Nil) + ) HelperTuple .mk (it_is_less) (Nil) else if ( current_char > head - ) HelperTuple_ (it_is_greater, Nil) - else HelperTuple_ (they_are_equal, tail) - case Nil => HelperTuple_ (it_is_greater, Nil) + ) HelperTuple .mk (it_is_greater) (Nil) + else HelperTuple .mk (they_are_equal) (tail) + case Nil => HelperTuple .mk (it_is_greater) (Nil) } private def _condition (other_seq_cmp : HelperTuple) (current_char : Char) : Boolean = @@ -327,7 +327,7 @@ trait StringComparator private def _compare_seq (seq0 : Seq [Char] ) (seq1 : Seq [Char] ) : Int = _interpret_comparison ( _tailrec_foldl_while [Char, HelperTuple] (seq0) ( - HelperTuple_ (they_are_equal, seq1) ) (_next) (_condition) + HelperTuple .mk (they_are_equal) (seq1) ) (_next) (_condition) ) def compare (str0 : String) (str1 : String) : Int = @@ -401,7 +401,7 @@ trait TileMessageBuilder def build [A ] (context : Context) (outcome : Outcome) (contents : A) : TileMessage [A] = - TileMessage_ (context, outcome, contents) + TileMessage .mk (context) (outcome) (contents) } diff --git a/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda b/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda index 4183516..c3390ba 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda +++ b/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda @@ -31,12 +31,12 @@ class StringComparator match other_seq case head +: tail ==> if current_char < head - then HelperTuple_ (it_is_less) (Nil) + then HelperTuple .mk (it_is_less) (Nil) else if current_char > head - then HelperTuple_ (it_is_greater) (Nil) - else HelperTuple_ (they_are_equal) (tail) - case Nil ==> HelperTuple_ (it_is_greater) (Nil) + then HelperTuple .mk (it_is_greater) (Nil) + else HelperTuple .mk (they_are_equal) (tail) + case Nil ==> HelperTuple .mk (it_is_greater) (Nil) _condition (other_seq_cmp : HelperTuple) (current_char : Char) : Boolean = other_seq_cmp .comparison == they_are_equal @@ -54,7 +54,7 @@ class StringComparator _compare_seq (seq0 : Seq [Char] ) (seq1 : Seq [Char] ) : Int = _interpret_comparison ( _tailrec_foldl_while [Char] [HelperTuple] (seq0) ( - HelperTuple_ (they_are_equal) (seq1) ) (_next) (_condition) + HelperTuple .mk (they_are_equal) (seq1) ) (_next) (_condition) ) compare (str0 : String) (str1 : String) : Int = diff --git a/core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda b/core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda index 525dc38..9e5426c 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda +++ b/core/src/main/scala/soda/tiles/fairness/tool/TileMessage.soda @@ -37,7 +37,7 @@ class TileMessageBuilder abstract build [A : Type] (context : Context) (outcome : Outcome) (contents : A) : TileMessage [A] = - TileMessage_ (context) (outcome) (contents) + TileMessage .mk (context) (outcome) (contents) end diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda index b5bced1..f73df14 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda @@ -38,7 +38,7 @@ class ChildCareSubsidyScenarioExample context = "context" outcome_no_subsidy : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource0) , Assignment .mk (actor1) (resource0) , @@ -47,7 +47,7 @@ class ChildCareSubsidyScenarioExample ) outcome_per_family_0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource1) , @@ -56,7 +56,7 @@ class ChildCareSubsidyScenarioExample ) outcome_per_family_1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource2) , @@ -65,7 +65,7 @@ class ChildCareSubsidyScenarioExample ) outcome_single_guardian : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource0) , Assignment .mk (actor1) (resource1) , @@ -74,7 +74,7 @@ class ChildCareSubsidyScenarioExample ) outcome_per_child : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource3) , @@ -83,7 +83,7 @@ class ChildCareSubsidyScenarioExample ) outcome_decreasing_on_income_0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource2) , @@ -92,7 +92,7 @@ class ChildCareSubsidyScenarioExample ) outcome_decreasing_on_income_1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource1) , @@ -101,7 +101,7 @@ class ChildCareSubsidyScenarioExample ) outcome_decreasing_per_child : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource3) , @@ -110,29 +110,28 @@ class ChildCareSubsidyScenarioExample ) initial_no_subsidy : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_no_subsidy) (true) + TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) initial_per_family_0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_family_0) (true) + TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) initial_per_family_1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_family_1) (true) + TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) initial_single_guardian : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_single_guardian) (true) + TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) initial_per_child : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_child) (true) + TileMessageBuilder .mk .build (context) (outcome_per_child) (true) initial_decreasing_on_income_0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_0) (true) + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) initial_decreasing_on_income_1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_1) (true) + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) initial_decreasing_per_child : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_per_child) (true) - + TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) end diff --git a/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda index badaae2..56f47c2 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda @@ -6,9 +6,9 @@ class EqualityTileSpec () check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - example = ResourceAllocationScenarioExample_ () + example = ResourceAllocationScenarioExample .mk - equality_tile = EqualityTile_ (example .measure_sum , example .resource_height) + equality_tile = EqualityTile .mk (example .measure_sum) (example .resource_height) test ("equality on outcome 0") ( check ( diff --git a/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda index 1e40f81..6970981 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda @@ -6,10 +6,10 @@ class EquityTileSpec () check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - example = ResourceAllocationScenarioExample_ () + example = ResourceAllocationScenarioExample .mk equity_tile = - EquityTile_ (example .measure_sum , example .actor_need , example .resource_height) + EquityTile .mk (example .measure_sum) (example .actor_need) (example .resource_height) test ("equity on outcome 0") ( check ( diff --git a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala index 64299f2..14c4a7e 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -62,7 +62,7 @@ trait ChildCareSubsidyScenarioExample lazy val context = "context" lazy val outcome_no_subsidy : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource0) , Assignment .mk (actor1) (resource0) , @@ -71,7 +71,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_per_family_0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource1) , @@ -80,7 +80,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_per_family_1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource2) , @@ -89,7 +89,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_single_guardian : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource0) , Assignment .mk (actor1) (resource1) , @@ -98,7 +98,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_per_child : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource3) , @@ -107,7 +107,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_decreasing_on_income_0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource2) , @@ -116,7 +116,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_decreasing_on_income_1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource1) , Assignment .mk (actor1) (resource1) , @@ -125,7 +125,7 @@ trait ChildCareSubsidyScenarioExample ) lazy val outcome_decreasing_per_child : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( Assignment .mk (actor0) (resource2) , Assignment .mk (actor1) (resource3) , @@ -134,28 +134,28 @@ trait ChildCareSubsidyScenarioExample ) lazy val initial_no_subsidy : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_no_subsidy) (true) + TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) lazy val initial_per_family_0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_family_0) (true) + TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) lazy val initial_per_family_1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_family_1) (true) + TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) lazy val initial_single_guardian : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_single_guardian) (true) + TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) lazy val initial_per_child : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_per_child) (true) + TileMessageBuilder .mk .build (context) (outcome_per_child) (true) lazy val initial_decreasing_on_income_0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_0) (true) + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) lazy val initial_decreasing_on_income_1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_on_income_1) (true) + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) lazy val initial_decreasing_per_child : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome_decreasing_per_child) (true) + TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) } @@ -175,9 +175,9 @@ case class EqualityTileSpec () def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - lazy val example = ResourceAllocationScenarioExample_ () + lazy val example = ResourceAllocationScenarioExample .mk - lazy val equality_tile = EqualityTile_ (example .measure_sum , example .resource_height) + lazy val equality_tile = EqualityTile .mk (example .measure_sum) (example .resource_height) test ("equality on outcome 0") ( check ( @@ -222,10 +222,10 @@ case class EquityTileSpec () def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - lazy val example = ResourceAllocationScenarioExample_ () + lazy val example = ResourceAllocationScenarioExample .mk lazy val equity_tile = - EquityTile_ (example .measure_sum , example .actor_need , example .resource_height) + EquityTile .mk (example .measure_sum) (example .actor_need) (example .resource_height) test ("equity on outcome 0") ( check ( @@ -268,7 +268,7 @@ trait ResourceAllocationScenarioExample private def _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = - Assignment_ (actor, resource) + Assignment .mk (actor) (resource) private def _addValueTo (value : Int) (m : Measure) : Measure = m match { @@ -315,52 +315,52 @@ trait ResourceAllocationScenarioExample lazy val context = "context" lazy val outcome0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource2) , - _mk_Assignment (actor1) (resource1) , - _mk_Assignment (actor2) (resource0) + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource0) ) ) lazy val outcome1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource0) , - _mk_Assignment (actor1) (resource0) , - _mk_Assignment (actor2) (resource0) + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource0) , + Assignment .mk (actor2) (resource0) ) ) lazy val outcome2 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource1) , - _mk_Assignment (actor1) (resource1) , - _mk_Assignment (actor2) (resource1) + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource1) ) ) lazy val outcome3 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource2) , - _mk_Assignment (actor1) (resource2) , - _mk_Assignment (actor2) (resource2) + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) ) ) lazy val initial0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome0) (true) + TileMessageBuilder .mk .build (context) (outcome0) (true) lazy val initial1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome1) (true) + TileMessageBuilder .mk .build (context) (outcome1) (true) lazy val initial2 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome2) (true) + TileMessageBuilder .mk .build (context) (outcome2) (true) lazy val initial3 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome3) (true) + TileMessageBuilder .mk .build (context) (outcome3) (true) } @@ -403,7 +403,7 @@ trait ScoringScenarioExample mod (x) (protected_attribute_modulus) lazy val protected_attribute : Seq [Measure] = - Random_ () .get_next_seq (seed_protected_attribute) (actors .length) + Random .mk .get_next_seq (seed_protected_attribute) (actors .length) .map ( x => Some ( as_protected_attribute (x .intValue) ) ) lazy val protected_attribute_map : Map [Actor, Measure] = @@ -441,7 +441,7 @@ trait ScoringScenarioExample else _measure_zero lazy val result_values : Seq [Int] = - Random_ () + Random .mk .get_next_seq (seed_result) (actors .length) .map ( x => as_prediction ( (x .intValue) % prediction_modulus) ) @@ -485,20 +485,20 @@ trait ScoringScenarioExample .map ( x => make_binary_resource (x) ) lazy val unbiased_outcome : Outcome = - Outcome_ ( + Outcome .mk ( actors .indices .map ( index => - Assignment_ (actors .apply (index) , unbiased_prediction .apply (index) ) + Assignment .mk (actors .apply (index) ) (unbiased_prediction .apply (index) ) ) ) lazy val biased_outcome : Outcome = - Outcome_ ( + Outcome .mk ( actors .indices .map ( index => - Assignment_ (actors .apply (index) , biased_prediction .apply (index) ) + Assignment .mk (actors .apply (index) ) (biased_prediction .apply (index) ) ) ) @@ -510,10 +510,10 @@ trait ScoringScenarioExample lazy val context = "context" lazy val initial_unbiased : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (unbiased_outcome) (true) + TileMessageBuilder .mk .build (context) (unbiased_outcome) (true) lazy val initial_biased : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (biased_outcome) (true) + TileMessageBuilder .mk .build (context) (biased_outcome) (true) } @@ -533,13 +533,13 @@ case class UnbiasednessTileSpec () def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - lazy val ex = ScoringScenarioExample_ () + lazy val ex = ScoringScenarioExample .mk lazy val unbiasedness_tile = - UnbiasednessTile_ ( - ex .evaluation , - ex .result_function , - ex .protected_attribute_function, + UnbiasednessTile .mk ( + ex .evaluation) ( + ex .result_function) ( + ex .protected_attribute_function) ( ex .maximum_acceptable_bias_percentage ) diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda index f2d67d3..231da0c 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda @@ -4,7 +4,7 @@ class ResourceAllocationScenarioExample abstract _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = - Assignment_ (actor) (resource) + Assignment .mk (actor) (resource) _addValueTo (value : Int) (m : Measure) : Measure = match m @@ -49,52 +49,52 @@ class ResourceAllocationScenarioExample context = "context" outcome0 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource2) , - _mk_Assignment (actor1) (resource1) , - _mk_Assignment (actor2) (resource0) + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource0) ) ) outcome1 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource0) , - _mk_Assignment (actor1) (resource0) , - _mk_Assignment (actor2) (resource0) + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource0) , + Assignment .mk (actor2) (resource0) ) ) outcome2 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource1) , - _mk_Assignment (actor1) (resource1) , - _mk_Assignment (actor2) (resource1) + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource1) ) ) outcome3 : Outcome = - Outcome_ ( + Outcome .mk ( Seq [Assignment] ( - _mk_Assignment (actor0) (resource2) , - _mk_Assignment (actor1) (resource2) , - _mk_Assignment (actor2) (resource2) + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) ) ) initial0 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome0) (true) + TileMessageBuilder .mk .build (context) (outcome0) (true) initial1 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome1) (true) + TileMessageBuilder .mk .build (context) (outcome1) (true) initial2 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome2) (true) + TileMessageBuilder .mk .build (context) (outcome2) (true) initial3 : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (outcome3) (true) + TileMessageBuilder .mk .build (context) (outcome3) (true) end diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda index 1fcb055..c2f65fc 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda @@ -29,7 +29,7 @@ class ScoringScenarioExample mod (x) (protected_attribute_modulus) protected_attribute : Seq [Measure] = - Random_ () .get_next_seq (seed_protected_attribute) (actors .length) + Random .mk .get_next_seq (seed_protected_attribute) (actors .length) .map (lambda x --> Some ( as_protected_attribute (x .intValue) ) ) protected_attribute_map : Map [Actor] [Measure] = @@ -67,7 +67,7 @@ class ScoringScenarioExample else _measure_zero result_values : Seq [Int] = - Random_ () + Random .mk .get_next_seq (seed_result) (actors .length) .map (lambda x --> as_prediction ( (x .intValue) % prediction_modulus) ) @@ -111,20 +111,20 @@ class ScoringScenarioExample .map (lambda x --> make_binary_resource (x) ) unbiased_outcome : Outcome = - Outcome_ ( + Outcome .mk ( actors .indices .map (lambda index --> - Assignment_ (actors .apply (index) ) (unbiased_prediction .apply (index) ) + Assignment .mk (actors .apply (index) ) (unbiased_prediction .apply (index) ) ) ) biased_outcome : Outcome = - Outcome_ ( + Outcome .mk ( actors .indices .map (lambda index --> - Assignment_ (actors .apply (index) ) (biased_prediction .apply (index) ) + Assignment .mk (actors .apply (index) ) (biased_prediction .apply (index) ) ) ) @@ -136,10 +136,10 @@ class ScoringScenarioExample context = "context" initial_unbiased : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (unbiased_outcome) (true) + TileMessageBuilder .mk .build (context) (unbiased_outcome) (true) initial_biased : TileMessage [Boolean] = - TileMessageBuilder_ () .build (context) (biased_outcome) (true) + TileMessageBuilder .mk .build (context) (biased_outcome) (true) end diff --git a/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda index 7aca290..7096d06 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda @@ -6,13 +6,13 @@ class UnbiasednessTileSpec () check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = assert (obtained == expected) - ex = ScoringScenarioExample_ () + ex = ScoringScenarioExample .mk unbiasedness_tile = - UnbiasednessTile_ ( - ex .evaluation , - ex .result_function , - ex .protected_attribute_function, + UnbiasednessTile .mk ( + ex .evaluation) ( + ex .result_function) ( + ex .protected_attribute_function) ( ex .maximum_acceptable_bias_percentage ) diff --git a/core/src/test/scala/soda/tiles/fairness/tool/Package.scala b/core/src/test/scala/soda/tiles/fairness/tool/Package.scala index db7ae1d..c8a0da4 100644 --- a/core/src/test/scala/soda/tiles/fairness/tool/Package.scala +++ b/core/src/test/scala/soda/tiles/fairness/tool/Package.scala @@ -34,9 +34,9 @@ trait LinearCongruentialGenerator def multiplier : Long def increment : Long - lazy val fold = Fold_ () + lazy val fold = Fold .mk - lazy val range = Range_ () + lazy val range = Range .mk lazy val get_next_long : Long => Long = seed => @@ -73,7 +73,7 @@ trait Random - lazy val generator = LinearCongruentialGenerator_ (0x1000000000000L , 0x5DEECE66DL , 0x0BL) + lazy val generator = LinearCongruentialGenerator .mk (0x1000000000000L) (0x5DEECE66DL) (0x0BL) lazy val get_next_long : Long => Long = seed => @@ -207,11 +207,11 @@ case class ScoringToolSpec () lazy val example_ylist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) - lazy val instance_1 : Pearson = Pearson_ (example_xlist_1, example_ylist_1) + lazy val instance_1 : Pearson = Pearson .mk (example_xlist_1) (example_ylist_1) - private lazy val _mt : MathTool = MathTool_ () + private lazy val _mt : MathTool = MathTool .mk - private lazy val _mc : ScoringCategory = ScoringCategory_ () + private lazy val _mc : ScoringCategory = ScoringCategory .mk test ("sum") ( check ( @@ -241,7 +241,7 @@ case class ScoringToolSpec () lazy val example_ylist_2 : Seq [Float] = Seq (99 , 65 , 79 , 75 , 87 , 81) - lazy val instance_2 : Pearson = Pearson_ (example_xlist_2, example_ylist_2) + lazy val instance_2 : Pearson = Pearson .mk (example_xlist_2) (example_ylist_2) test ("coefficient") ( check ( @@ -270,7 +270,7 @@ case class StringComparatorSpec () lazy val string2 : String = "z" - lazy val instance : StringComparator = StringComparator_ () + lazy val instance : StringComparator = StringComparator .mk def sign (a : Int) : Int = if ( a > 0 diff --git a/core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda b/core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda index f2e7d59..dfce5e8 100644 --- a/core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda +++ b/core/src/test/scala/soda/tiles/fairness/tool/RandomNumberGenerator.soda @@ -16,9 +16,9 @@ class LinearCongruentialGenerator multiplier : Long increment : Long - fold = Fold_ () + fold = Fold .mk - range = Range_ () + range = Range .mk get_next_long : Long -> Long = lambda seed --> @@ -47,7 +47,7 @@ class Random abstract - generator = LinearCongruentialGenerator_ (0x1000000000000L , 0x5DEECE66DL , 0x0BL) + generator = LinearCongruentialGenerator .mk (0x1000000000000L) (0x5DEECE66DL) (0x0BL) get_next_long : Long -> Long = lambda seed --> diff --git a/core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda b/core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda index aa94c0e..4b220fb 100644 --- a/core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda +++ b/core/src/test/scala/soda/tiles/fairness/tool/ScoringToolSpec.soda @@ -10,11 +10,11 @@ class ScoringToolSpec () example_ylist_1 : Seq [Float] = Seq (1 , 3 , 5 , 8) - instance_1 : Pearson = Pearson_ (example_xlist_1) (example_ylist_1) + instance_1 : Pearson = Pearson .mk (example_xlist_1) (example_ylist_1) - _mt : MathTool = MathTool_ () + _mt : MathTool = MathTool .mk - _mc : ScoringCategory = ScoringCategory_ () + _mc : ScoringCategory = ScoringCategory .mk test ("sum") ( @@ -45,7 +45,7 @@ class ScoringToolSpec () example_ylist_2 : Seq [Float] = Seq (99 , 65 , 79 , 75 , 87 , 81) - instance_2 : Pearson = Pearson_ (example_xlist_2) (example_ylist_2) + instance_2 : Pearson = Pearson .mk (example_xlist_2) (example_ylist_2) test ("coefficient") ( check ( diff --git a/core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda b/core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda index 0e8768b..3b146f3 100644 --- a/core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda +++ b/core/src/test/scala/soda/tiles/fairness/tool/StringComparatorSpec.soda @@ -14,7 +14,7 @@ class StringComparatorSpec () string2 : String = "z" - instance : StringComparator = StringComparator_ () + instance : StringComparator = StringComparator .mk sign (a : Int) : Int = if a > 0 From 5fae6b2ef387d9555ecd365063751a451b429eae Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 13:38:50 +0100 Subject: [PATCH 22/28] Add example of child care subsidy --- .../CcsNoSubsidyPipeline.soda | 21 ++ .../CcsPerFamilyPipeline.soda | 21 ++ .../example/childcaresubsidy/Package.soda | 33 +- .../CcsNoSubsidyPipelineSpec.soda | 28 ++ .../CcsPerFamilyPipelineSpec.soda | 28 ++ .../ChildCareSubsidyScenarioExample.soda | 87 +++-- .../example/childcaresubsidy/Package.scala | 306 ++++++++++++++++++ .../example/childcaresubsidy/Package.soda | 26 ++ 8 files changed, 523 insertions(+), 27 deletions(-) create mode 100644 examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipeline.soda create mode 100644 examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipeline.soda create mode 100644 examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipelineSpec.soda create mode 100644 examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipelineSpec.soda rename {core/src/test/scala/soda/tiles/fairness/tile => examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy}/ChildCareSubsidyScenarioExample.soda (71%) create mode 100644 examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.scala diff --git a/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipeline.soda b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipeline.soda new file mode 100644 index 0000000..1911e5b --- /dev/null +++ b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipeline.soda @@ -0,0 +1,21 @@ + +class CcsNoSubsidyPipeline + + abstract + sigma : Measure -> Measure -> Measure + p_utility : Resource -> Measure + + all_equal_tile = AllEqualTile .mk + + received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) + + all_actor_tile = AllActorTile .mk + + apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = + all_equal_tile .apply ( + received_sigma_p_tile .apply ( + all_actor_tile .apply (message) + ) + ) + +end diff --git a/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipeline.soda b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipeline.soda new file mode 100644 index 0000000..40baf68 --- /dev/null +++ b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipeline.soda @@ -0,0 +1,21 @@ + +class CcsPerFamily + + abstract + sigma : Measure -> Measure -> Measure + p_utility : Resource -> Measure + + all_equal_tile = AllEqualTile .mk + + received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) + + all_actor_tile = AllActorTile .mk + + apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = + all_equal_tile .apply ( + received_sigma_p_tile .apply ( + all_actor_tile .apply (message) + ) + ) + +end diff --git a/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda index 9466655..b2a4e96 100644 --- a/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda +++ b/examples/src/main/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda @@ -1,21 +1,38 @@ package soda.tiles.fairness.example.childcaresubsidy import - org.scalatest.funsuite.AnyFunSuite soda.tiles.fairness.tool.Actor soda.tiles.fairness.tool.Assignment - soda.tiles.fairness.tool.Assignment_ soda.tiles.fairness.tool.Context soda.tiles.fairness.tool.Measure soda.tiles.fairness.tool.Outcome - soda.tiles.fairness.tool.Outcome_ soda.tiles.fairness.tool.Resource soda.tiles.fairness.tool.TileMessage - soda.tiles.fairness.tool.TileMessage_ soda.tiles.fairness.tool.TileMessageBuilder - soda.tiles.fairness.tool.TileMessageBuilder_ soda.tiles.fairness.tool.TilePair - soda.tiles.fairness.tool.TilePair_ - soda.tiles.fairness.tool.Random - soda.tiles.fairness.tool.Random_ + soda.tiles.fairness.tile.AllActorPairTile + soda.tiles.fairness.tile.AllActorTile + soda.tiles.fairness.tile.AllActorTripleTile + soda.tiles.fairness.tile.AllEqual1Tile + soda.tiles.fairness.tile.AllEqualTile + soda.tiles.fairness.tile.AtLeastTile + soda.tiles.fairness.tile.AttributePTile + soda.tiles.fairness.tile.CorrelationTile + soda.tiles.fairness.tile.DecisionTile + soda.tiles.fairness.tile.EqualityTile + soda.tiles.fairness.tile.EquityTile + soda.tiles.fairness.tile.FalsePosTile + soda.tiles.fairness.tile.NeededPTile + soda.tiles.fairness.tile.PredictionPTile + soda.tiles.fairness.tile.ReceivedSigmaPTile + soda.tiles.fairness.tile.ResultPTile + soda.tiles.fairness.tile.SigmaTile + soda.tiles.fairness.tile.UnbiasednessTile + soda.tiles.fairness.tile.UnzipPairFstTile + soda.tiles.fairness.tile.UnzipPairSndTile + soda.tiles.fairness.tile.UnzipTripleFstTile + soda.tiles.fairness.tile.UnzipTripleSndTile + soda.tiles.fairness.tile.UnzipTripleTrdTile + soda.tiles.fairness.tile.WithPTile + soda.tiles.fairness.tile.ZipTile diff --git a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipelineSpec.soda b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipelineSpec.soda new file mode 100644 index 0000000..6e1fc4e --- /dev/null +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsNoSubsidyPipelineSpec.soda @@ -0,0 +1,28 @@ + +class CcsNoSubsidyPipelineSpec () + extends + AnyFunSuite + + check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + _mm = ChildCareSubsidyScenarioExample .mk + + all_cases = _mm .all_cases + + no_subsidy_pipeline = + CcsNoSubsidyPipeline .mk (_mm .measure_sum) (_mm .resource_value) + + test ("no subsidy on all outcomes") ( + check ( + obtained := all_cases + .map (lambda scenario --> + no_subsidy_pipeline .apply (scenario) .contents + ) + ) ( + expected := Seq (true , true , true , false , false , false , false , false) + ) + ) + +end + diff --git a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipelineSpec.soda b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipelineSpec.soda new file mode 100644 index 0000000..8b04497 --- /dev/null +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/CcsPerFamilyPipelineSpec.soda @@ -0,0 +1,28 @@ + +class CcsPerFamilyPipelineSpec () + extends + AnyFunSuite + + check [A : Type] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + _mm = ChildCareSubsidyScenarioExample .mk + + all_cases = _mm .all_cases + + no_subsidy_pipeline = + CcsNoSubsidyPipeline .mk (_mm .measure_sum) (_mm .resource_value) + + test ("per family on all outcomes") ( + check ( + obtained := all_cases + .map (lambda scenario --> + no_subsidy_pipeline .apply (scenario) .contents + ) + ) ( + expected := Seq (true , true , true , false , false , false , false , false) + ) + ) + +end + diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/ChildCareSubsidyScenarioExample.soda similarity index 71% rename from core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda rename to examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/ChildCareSubsidyScenarioExample.soda index f73df14..28e8b17 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/ChildCareSubsidyScenarioExample.soda +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/ChildCareSubsidyScenarioExample.soda @@ -17,24 +17,58 @@ class ChildCareSubsidyScenarioExample actor2 = "family C" + _add_value_to (value : Int) (m : Measure) : Measure = + match m + case Some (other_value) ==> Some (value + other_value) + case None ==> None + + measure_sum (a : Measure) (b : Measure) : Measure = + match a + case Some (value) ==> _add_value_to (value) (b) + case None ==> None + + get_or_else [A : Type] (map : Map [A] [Measure] ) (key : A) (default : Measure) : Measure = + match map .get (key) + case Some (value) ==> value + case None ==> default + actor_children_map : Map [Actor] [Measure] = Seq ( Tuple2 [Actor] [Measure] (actor0 , Some (2) ) , Tuple2 [Actor] [Measure] (actor1 , Some (3) ) , Tuple2 [Actor] [Measure] (actor2 , Some (1) ) ) .toMap + actor_children (actor : Actor) : Measure = + get_or_else [Actor] (actor_children_map) (actor) (Some (-1) ) + actor_adults_map : Map [Actor] [Measure] = Seq ( Tuple2 [Actor] [Measure] (actor0 , Some (2) ) , Tuple2 [Actor] [Measure] (actor1 , Some (1) ) , Tuple2 [Actor] [Measure] (actor2 , Some (2) ) ) .toMap + actor_adults (actor : Actor) : Measure = + get_or_else [Actor] (actor_adults_map) (actor) (Some (-1) ) + actor_income_map : Map [Actor] [Measure] = Seq ( Tuple2 [Actor] [Measure] (actor0 , Some (5000) ) , Tuple2 [Actor] [Measure] (actor1 , Some (3000) ) , Tuple2 [Actor] [Measure] (actor2 , Some (800) ) ) .toMap + actor_income (actor : Actor) : Measure = + get_or_else [Actor] (actor_income_map) (actor) (Some (-1) ) + + resource_value_map : Map [Resource] [Measure] = Seq ( + Tuple2 [Resource] [Measure] (resource0 , Some (0) ) , + Tuple2 [Resource] [Measure] (resource1 , Some (100) ) , + Tuple2 [Resource] [Measure] (resource2 , Some (200) ) , + Tuple2 [Resource] [Measure] (resource3 , Some (300) ) + ) .toMap + + resource_value (resource : Resource) : Measure = + get_or_else [Resource] (resource_value_map) (resource) (Some (-1) ) + context = "context" outcome_no_subsidy : Outcome = @@ -46,6 +80,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_no_subsidy : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) + outcome_per_family_0 : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -55,6 +92,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_per_family_0 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) + outcome_per_family_1 : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -64,6 +104,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_per_family_1 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) + outcome_single_guardian : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -73,6 +116,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_single_guardian : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) + outcome_per_child : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -82,6 +128,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_per_child : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_child) (true) + outcome_decreasing_on_income_0 : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -91,6 +140,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_decreasing_on_income_0 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) + outcome_decreasing_on_income_1 : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -100,6 +152,9 @@ class ChildCareSubsidyScenarioExample ) ) + initial_decreasing_on_income_1 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) + outcome_decreasing_per_child : Outcome = Outcome .mk ( Seq [Assignment] ( @@ -109,29 +164,23 @@ class ChildCareSubsidyScenarioExample ) ) - initial_no_subsidy : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) - - initial_per_family_0 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) - - initial_per_family_1 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) - - initial_single_guardian : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) + initial_decreasing_per_child : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) - initial_per_child : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_child) (true) + all_cases : Seq [TileMessage [Boolean] ] = + Seq ( + initial_no_subsidy , + initial_per_family_0 , + initial_per_family_1 , + initial_single_guardian , + initial_per_child , + initial_decreasing_on_income_0 , + initial_decreasing_on_income_1 , + initial_decreasing_per_child + ) - initial_decreasing_on_income_0 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) - initial_decreasing_on_income_1 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) - initial_decreasing_per_child : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) end diff --git a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.scala b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.scala new file mode 100644 index 0000000..4708342 --- /dev/null +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.scala @@ -0,0 +1,306 @@ +package soda.tiles.fairness.example.childcaresubsidy + +/* + * This package contains tests for the classes to model a resource allocation scenario. + */ + +import org.scalatest.funsuite.AnyFunSuite +import soda.tiles.fairness.tool.Actor +import soda.tiles.fairness.tool.Assignment +import soda.tiles.fairness.tool.Assignment_ +import soda.tiles.fairness.tool.Context +import soda.tiles.fairness.tool.Measure +import soda.tiles.fairness.tool.Outcome +import soda.tiles.fairness.tool.Outcome_ +import soda.tiles.fairness.tool.Resource +import soda.tiles.fairness.tool.TileMessage +import soda.tiles.fairness.tool.TileMessage_ +import soda.tiles.fairness.tool.TileMessageBuilder +import soda.tiles.fairness.tool.TileMessageBuilder_ +import soda.tiles.fairness.tool.TilePair +import soda.tiles.fairness.tool.TilePair_ +import soda.tiles.fairness.tool.Random +import soda.tiles.fairness.tool.Random_ +import soda.tiles.fairness.tile.AllActorPairTile +import soda.tiles.fairness.tile.AllActorTile +import soda.tiles.fairness.tile.AllActorTripleTile +import soda.tiles.fairness.tile.AllEqual1Tile +import soda.tiles.fairness.tile.AllEqualTile +import soda.tiles.fairness.tile.AtLeastTile +import soda.tiles.fairness.tile.AttributePTile +import soda.tiles.fairness.tile.CorrelationTile +import soda.tiles.fairness.tile.DecisionTile +import soda.tiles.fairness.tile.EqualityTile +import soda.tiles.fairness.tile.EquityTile +import soda.tiles.fairness.tile.FalsePosTile +import soda.tiles.fairness.tile.NeededPTile +import soda.tiles.fairness.tile.PredictionPTile +import soda.tiles.fairness.tile.ReceivedSigmaPTile +import soda.tiles.fairness.tile.ResultPTile +import soda.tiles.fairness.tile.SigmaTile +import soda.tiles.fairness.tile.UnbiasednessTile +import soda.tiles.fairness.tile.UnzipPairFstTile +import soda.tiles.fairness.tile.UnzipPairSndTile +import soda.tiles.fairness.tile.UnzipTripleFstTile +import soda.tiles.fairness.tile.UnzipTripleSndTile +import soda.tiles.fairness.tile.UnzipTripleTrdTile +import soda.tiles.fairness.tile.WithPTile +import soda.tiles.fairness.tile.ZipTile + + + + + +case class CcsNoSubsidyPipelineSpec () + extends + AnyFunSuite +{ + + def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + private lazy val _mm = ChildCareSubsidyScenarioExample .mk + + lazy val all_cases = _mm .all_cases + + lazy val no_subsidy_pipeline = + CcsNoSubsidyPipeline .mk (_mm .measure_sum) (_mm .resource_value) + + test ("no subsidy on all outcomes") ( + check ( + obtained = all_cases + .map ( scenario => + no_subsidy_pipeline .apply (scenario) .contents + ) + ) ( + expected = Seq (true , true , true , false , false , false , false , false) + ) + ) + +} + + +case class CcsPerFamilyPipelineSpec () + extends + AnyFunSuite +{ + + def check [A ] (obtained : A) (expected : A) : org.scalatest.compatible.Assertion = + assert (obtained == expected) + + private lazy val _mm = ChildCareSubsidyScenarioExample .mk + + lazy val all_cases = _mm .all_cases + + lazy val no_subsidy_pipeline = + CcsNoSubsidyPipeline .mk (_mm .measure_sum) (_mm .resource_value) + + test ("per family on all outcomes") ( + check ( + obtained = all_cases + .map ( scenario => + no_subsidy_pipeline .apply (scenario) .contents + ) + ) ( + expected = Seq (true , true , true , false , false , false , false , false) + ) + ) + +} + + +trait ChildCareSubsidyScenarioExample +{ + + + + lazy val resource0 = "no subsidy - 0" + + lazy val resource1 = "subsidy - 100" + + lazy val resource2 = "subsidy - 200" + + lazy val resource3 = "subsidy - 300" + + lazy val actor0 = "family A" + + lazy val actor1 = "family B" + + lazy val actor2 = "family C" + + private def _add_value_to (value : Int) (m : Measure) : Measure = + m match { + case Some (other_value) => Some (value + other_value) + case None => None + } + + def measure_sum (a : Measure) (b : Measure) : Measure = + a match { + case Some (value) => _add_value_to (value) (b) + case None => None + } + + def get_or_else [A ] (map : Map [A, Measure] ) (key : A) (default : Measure) : Measure = + map .get (key) match { + case Some (value) => value + case None => default + } + + lazy val actor_children_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (2) ) , + Tuple2 [Actor, Measure] (actor1 , Some (3) ) , + Tuple2 [Actor, Measure] (actor2 , Some (1) ) + ) .toMap + + def actor_children (actor : Actor) : Measure = + get_or_else [Actor] (actor_children_map) (actor) (Some (-1) ) + + lazy val actor_adults_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (2) ) , + Tuple2 [Actor, Measure] (actor1 , Some (1) ) , + Tuple2 [Actor, Measure] (actor2 , Some (2) ) + ) .toMap + + def actor_adults (actor : Actor) : Measure = + get_or_else [Actor] (actor_adults_map) (actor) (Some (-1) ) + + lazy val actor_income_map : Map [Actor, Measure] = Seq ( + Tuple2 [Actor, Measure] (actor0 , Some (5000) ) , + Tuple2 [Actor, Measure] (actor1 , Some (3000) ) , + Tuple2 [Actor, Measure] (actor2 , Some (800) ) + ) .toMap + + def actor_income (actor : Actor) : Measure = + get_or_else [Actor] (actor_income_map) (actor) (Some (-1) ) + + lazy val resource_value_map : Map [Resource, Measure] = Seq ( + Tuple2 [Resource, Measure] (resource0 , Some (0) ) , + Tuple2 [Resource, Measure] (resource1 , Some (100) ) , + Tuple2 [Resource, Measure] (resource2 , Some (200) ) , + Tuple2 [Resource, Measure] (resource3 , Some (300) ) + ) .toMap + + def resource_value (resource : Resource) : Measure = + get_or_else [Resource] (resource_value_map) (resource) (Some (-1) ) + + lazy val context = "context" + + lazy val outcome_no_subsidy : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource0) , + Assignment .mk (actor2) (resource0) + ) + ) + + lazy val initial_no_subsidy : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) + + lazy val outcome_per_family_0 : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val initial_per_family_0 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) + + lazy val outcome_per_family_1 : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + lazy val initial_per_family_1 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) + + lazy val outcome_single_guardian : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource0) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource0) + ) + ) + + lazy val initial_single_guardian : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) + + lazy val outcome_per_child : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val initial_per_child : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_per_child) (true) + + lazy val outcome_decreasing_on_income_0 : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource2) , + Assignment .mk (actor2) (resource2) + ) + ) + + lazy val initial_decreasing_on_income_0 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) + + lazy val outcome_decreasing_on_income_1 : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource1) , + Assignment .mk (actor1) (resource1) , + Assignment .mk (actor2) (resource3) + ) + ) + + lazy val initial_decreasing_on_income_1 : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) + + lazy val outcome_decreasing_per_child : Outcome = + Outcome .mk ( + Seq [Assignment] ( + Assignment .mk (actor0) (resource2) , + Assignment .mk (actor1) (resource3) , + Assignment .mk (actor2) (resource1) + ) + ) + + lazy val initial_decreasing_per_child : TileMessage [Boolean] = + TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) + + lazy val all_cases : Seq [TileMessage [Boolean] ] = + Seq ( + initial_no_subsidy , + initial_per_family_0 , + initial_per_family_1 , + initial_single_guardian , + initial_per_child , + initial_decreasing_on_income_0 , + initial_decreasing_on_income_1 , + initial_decreasing_per_child + ) + + + +} + +case class ChildCareSubsidyScenarioExample_ () extends ChildCareSubsidyScenarioExample + +object ChildCareSubsidyScenarioExample { + def mk : ChildCareSubsidyScenarioExample = + ChildCareSubsidyScenarioExample_ () +} + diff --git a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda index 6ffe4ff..b04e2be 100644 --- a/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda +++ b/examples/src/test/scala/soda/tiles/fairness/example/childcaresubsidy/Package.soda @@ -22,3 +22,29 @@ import soda.tiles.fairness.tool.TilePair_ soda.tiles.fairness.tool.Random soda.tiles.fairness.tool.Random_ + soda.tiles.fairness.tile.AllActorPairTile + soda.tiles.fairness.tile.AllActorTile + soda.tiles.fairness.tile.AllActorTripleTile + soda.tiles.fairness.tile.AllEqual1Tile + soda.tiles.fairness.tile.AllEqualTile + soda.tiles.fairness.tile.AtLeastTile + soda.tiles.fairness.tile.AttributePTile + soda.tiles.fairness.tile.CorrelationTile + soda.tiles.fairness.tile.DecisionTile + soda.tiles.fairness.tile.EqualityTile + soda.tiles.fairness.tile.EquityTile + soda.tiles.fairness.tile.FalsePosTile + soda.tiles.fairness.tile.NeededPTile + soda.tiles.fairness.tile.PredictionPTile + soda.tiles.fairness.tile.ReceivedSigmaPTile + soda.tiles.fairness.tile.ResultPTile + soda.tiles.fairness.tile.SigmaTile + soda.tiles.fairness.tile.UnbiasednessTile + soda.tiles.fairness.tile.UnzipPairFstTile + soda.tiles.fairness.tile.UnzipPairSndTile + soda.tiles.fairness.tile.UnzipTripleFstTile + soda.tiles.fairness.tile.UnzipTripleSndTile + soda.tiles.fairness.tile.UnzipTripleTrdTile + soda.tiles.fairness.tile.WithPTile + soda.tiles.fairness.tile.ZipTile + From a7e13d6b5c56ea8e122139d95afcf32206d4c52d Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 14:54:13 +0100 Subject: [PATCH 23/28] Move example --- .../soda/tiles/fairness/tile/Package.scala | 145 ------------------ 1 file changed, 145 deletions(-) diff --git a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala index 14c4a7e..addbdc7 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -22,151 +22,6 @@ import soda.tiles.fairness.tool.TilePair_ import soda.tiles.fairness.tool.Random import soda.tiles.fairness.tool.Random_ -trait ChildCareSubsidyScenarioExample -{ - - - - lazy val resource0 = "no subsidy - 0" - - lazy val resource1 = "subsidy - 100" - - lazy val resource2 = "subsidy - 200" - - lazy val resource3 = "subsidy - 300" - - lazy val actor0 = "family A" - - lazy val actor1 = "family B" - - lazy val actor2 = "family C" - - lazy val actor_children_map : Map [Actor, Measure] = Seq ( - Tuple2 [Actor, Measure] (actor0 , Some (2) ) , - Tuple2 [Actor, Measure] (actor1 , Some (3) ) , - Tuple2 [Actor, Measure] (actor2 , Some (1) ) - ) .toMap - - lazy val actor_adults_map : Map [Actor, Measure] = Seq ( - Tuple2 [Actor, Measure] (actor0 , Some (2) ) , - Tuple2 [Actor, Measure] (actor1 , Some (1) ) , - Tuple2 [Actor, Measure] (actor2 , Some (2) ) - ) .toMap - - lazy val actor_income_map : Map [Actor, Measure] = Seq ( - Tuple2 [Actor, Measure] (actor0 , Some (5000) ) , - Tuple2 [Actor, Measure] (actor1 , Some (3000) ) , - Tuple2 [Actor, Measure] (actor2 , Some (800) ) - ) .toMap - - lazy val context = "context" - - lazy val outcome_no_subsidy : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource0) , - Assignment .mk (actor1) (resource0) , - Assignment .mk (actor2) (resource0) - ) - ) - - lazy val outcome_per_family_0 : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource1) , - Assignment .mk (actor1) (resource1) , - Assignment .mk (actor2) (resource1) - ) - ) - - lazy val outcome_per_family_1 : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource2) , - Assignment .mk (actor1) (resource2) , - Assignment .mk (actor2) (resource2) - ) - ) - - lazy val outcome_single_guardian : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource0) , - Assignment .mk (actor1) (resource1) , - Assignment .mk (actor2) (resource0) - ) - ) - - lazy val outcome_per_child : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource2) , - Assignment .mk (actor1) (resource3) , - Assignment .mk (actor2) (resource1) - ) - ) - - lazy val outcome_decreasing_on_income_0 : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource1) , - Assignment .mk (actor1) (resource2) , - Assignment .mk (actor2) (resource2) - ) - ) - - lazy val outcome_decreasing_on_income_1 : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource1) , - Assignment .mk (actor1) (resource1) , - Assignment .mk (actor2) (resource3) - ) - ) - - lazy val outcome_decreasing_per_child : Outcome = - Outcome .mk ( - Seq [Assignment] ( - Assignment .mk (actor0) (resource2) , - Assignment .mk (actor1) (resource3) , - Assignment .mk (actor2) (resource1) - ) - ) - - lazy val initial_no_subsidy : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_no_subsidy) (true) - - lazy val initial_per_family_0 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_family_0) (true) - - lazy val initial_per_family_1 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_family_1) (true) - - lazy val initial_single_guardian : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_single_guardian) (true) - - lazy val initial_per_child : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_per_child) (true) - - lazy val initial_decreasing_on_income_0 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_0) (true) - - lazy val initial_decreasing_on_income_1 : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_on_income_1) (true) - - lazy val initial_decreasing_per_child : TileMessage [Boolean] = - TileMessageBuilder .mk .build (context) (outcome_decreasing_per_child) (true) - -} - -case class ChildCareSubsidyScenarioExample_ () extends ChildCareSubsidyScenarioExample - -object ChildCareSubsidyScenarioExample { - def mk : ChildCareSubsidyScenarioExample = - ChildCareSubsidyScenarioExample_ () -} - - case class EqualityTileSpec () extends AnyFunSuite From ddd126b7e0704736d46403e6e1fbacb8e8fa6db4 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 15:12:04 +0100 Subject: [PATCH 24/28] Update example --- core/src/test/scala/soda/tiles/fairness/tile/Package.scala | 7 ++----- .../fairness/tile/ResourceAllocationScenarioExample.soda | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala index addbdc7..3693a8a 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/test/scala/soda/tiles/fairness/tile/Package.scala @@ -122,10 +122,7 @@ trait ResourceAllocationScenarioExample - private def _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = - Assignment .mk (actor) (resource) - - private def _addValueTo (value : Int) (m : Measure) : Measure = + private def _add_value_to (value : Int) (m : Measure) : Measure = m match { case Some (other_value) => Some (value + other_value) case None => None @@ -133,7 +130,7 @@ trait ResourceAllocationScenarioExample def measure_sum (a : Measure) (b : Measure) : Measure = a match { - case Some (value) => _addValueTo (value) (b) + case Some (value) => _add_value_to (value) (b) case None => None } diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda index 231da0c..0d6eb53 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda +++ b/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda @@ -3,17 +3,14 @@ class ResourceAllocationScenarioExample abstract - _mk_Assignment (actor : Actor) (resource : Resource) : Assignment = - Assignment .mk (actor) (resource) - - _addValueTo (value : Int) (m : Measure) : Measure = + _add_value_to (value : Int) (m : Measure) : Measure = match m case Some (other_value) ==> Some (value + other_value) case None ==> None measure_sum (a : Measure) (b : Measure) : Measure = match a - case Some (value) ==> _addValueTo (value) (b) + case Some (value) ==> _add_value_to (value) (b) case None ==> None resource0 = "small box - 0.1 m" From cc92f3c556e096b6b2f4a223276d5f43375b3f8a Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 18:05:30 +0100 Subject: [PATCH 25/28] Add comments to tiles --- .../tiles/fairness/tile/AllActorPairTile.soda | 5 + .../tiles/fairness/tile/AllActorTile.soda | 4 + .../fairness/tile/AllActorTripleTile.soda | 5 + .../tiles/fairness/tile/AllEqual1Tile.soda | 4 + .../tiles/fairness/tile/AllEqualTile.soda | 3 + .../soda/tiles/fairness/tile/AtLeastTile.soda | 6 + .../tiles/fairness/tile/AttributePTile.soda | 5 + .../tiles/fairness/tile/CorrelationTile.soda | 4 + .../tiles/fairness/tile/DecisionTile.soda | 4 + .../tiles/fairness/tile/EqualityTile.soda | 4 + .../soda/tiles/fairness/tile/EquityTile.soda | 5 + .../tiles/fairness/tile/FalsePosTile.soda | 4 + .../soda/tiles/fairness/tile/NeededPTile.soda | 3 + .../soda/tiles/fairness/tile/Package.scala | 126 ++++++++++++++++++ .../tiles/fairness/tile/PredictionPTile.soda | 5 + .../fairness/tile/ReceivedSigmaPTile.soda | 7 + .../soda/tiles/fairness/tile/ResultPTile.soda | 5 + .../soda/tiles/fairness/tile/SigmaTile.soda | 6 + .../tiles/fairness/tile/UnbiasednessTile.soda | 3 + .../tiles/fairness/tile/UnzipPairTile.soda | 10 ++ .../tiles/fairness/tile/UnzipTripleTile.soda | 16 +++ .../soda/tiles/fairness/tile/WithPTile.soda | 4 + .../soda/tiles/fairness/tile/ZipTile.soda | 6 + .../soda/tiles/fairness/tool/Entity.soda | 4 + .../soda/tiles/fairness/tool/Package.scala | 20 ++- .../soda/tiles/fairness/tool/ScoringTool.soda | 13 +- .../tiles/fairness/tool/StringComparator.soda | 5 + 27 files changed, 279 insertions(+), 7 deletions(-) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda index 6090ed8..50a11c5 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorPairTile.soda @@ -3,6 +3,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile returns a sequence of pairs containing the same actor, sorted by actor, where each + * pair of actors occurs exactly once. + */ + class AllActorPairTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda index 367fd8b..b7ac4a4 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda @@ -3,6 +3,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile returns a sorted sequence of actors, where each actor occurs exactly once. + */ + class AllActorTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda index b42fcec..5b15bc2 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda @@ -3,6 +3,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile returns a sequence of triples containing the same actor, sorted by actor, where + * each triple of actors occurs exactly once. + */ + class AllActorTripleTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda index caf5951..7f5de22 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllEqual1Tile.soda @@ -2,6 +2,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of measures and returns 'true' when all measures are the same as + * the first one. + */ class AllEqual1Tile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda index f1c156f..c05a7d1 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda @@ -3,6 +3,9 @@ directive lean import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AllEqual1Tile +/** + * This tile takes a sequence of measures and returns 'true' when they are all the same. + */ class AllEqualTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda index 96adcb6..b303a16 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda @@ -3,6 +3,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of pairs of measures, and compares both components (m0, m1). + * If for each pair (m0, m1), it holds that m0 >= m1, it returns 'true, otherwise, it returns + * 'false'. + */ + class AtLeastTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda index c718fc2..5abcc96 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda @@ -2,6 +2,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of actors as input and returns the a sequence of measures, such + * that, each position in output sequence is the projection of an attribute for its respective + * actor from the input. + */ class AttributePTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda index db1034a..7e8f1cf 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda @@ -2,6 +2,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile computes the Pearson correlation, and for that, takes two sequences of measures, + * and computes a single measure. + */ class CorrelationTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda index d8b3507..0b94cdb 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda @@ -2,6 +2,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile works as a binary threshold for a measure. It returns 'true' if the input measure + * is than or equal to a given threshold, and 'false' otherwise. + */ class DecisionTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda index cdd975b..ddf56bf 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda @@ -5,6 +5,10 @@ import Soda.tiles.fairness.tile.AllActorTile import Soda.tiles.fairness.tile.AllEqualTile import Soda.tiles.fairness.tile.ReceivedSigmaPTile +/** + * This pipeline returns 'true' when all the actors in the input receive a resource of the + * value, and 'false' otherwise. + */ class EqualityTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda index ec68830..cd4a569 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda @@ -9,6 +9,11 @@ import Soda.tiles.fairness.tile.UnzipPairSndTile import Soda.tiles.fairness.tile.ZipTile +/** + * This pipeline returns 'true' when all the actors in the input receive a resource that + * satisfies their needs, and 'false' otherwise. + */ + class EquityTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda index cd2b721..2ebc571 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda @@ -3,6 +3,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.SigmaTile +/** + * This tiles takes a sequence of pairs of measures (m0, m1), and returns a sequence, which + * for each pair is 1, if m0 = 1 and m1 = 0, and 0 otherwise. + */ class FalsePosTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda index 7217c80..41ebc72 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda @@ -3,6 +3,9 @@ directive lean import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile +/** + * This tile is a particular case of an 'AttributePTile', where the attribute is 'need'. + */ class NeededPTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala index fe6567f..9e026cb 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -29,6 +29,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile returns a sequence of pairs containing the same actor, sorted by actor, where each + * pair of actors occurs exactly once. + */ + trait AllActorPairTile { @@ -58,6 +63,10 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile returns a sorted sequence of actors, where each actor occurs exactly once. + */ + trait AllActorTile { @@ -86,6 +95,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile returns a sequence of triples containing the same actor, sorted by actor, where + * each triple of actors occurs exactly once. + */ + trait AllActorTripleTile { @@ -116,6 +130,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of measures and returns 'true' when all measures are the same as + * the first one. + */ + trait AllEqual1Tile { @@ -143,6 +162,10 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AllEqual1Tile */ +/** + * This tile takes a sequence of measures and returns 'true' when they are all the same. + */ + trait AllEqualTile { @@ -170,6 +193,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of pairs of measures, and compares both components (m0, m1). + * If for each pair (m0, m1), it holds that m0 >= m1, it returns 'true, otherwise, it returns + * 'false'. + */ + trait AtLeastTile { @@ -201,6 +230,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of actors as input and returns the a sequence of measures, such + * that, each position in output sequence is the projection of an attribute for its respective + * actor from the input. + */ + trait AttributePTile { @@ -227,6 +262,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile computes the Pearson correlation, and for that, takes two sequences of measures, + * and computes a single measure. + */ + trait CorrelationTile { @@ -277,6 +317,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile works as a binary threshold for a measure. It returns 'true' if the input measure + * is than or equal to a given threshold, and 'false' otherwise. + */ + trait DecisionTile { @@ -309,6 +354,11 @@ import Soda.tiles.fairness.tile.AllEqualTile import Soda.tiles.fairness.tile.ReceivedSigmaPTile */ +/** + * This pipeline returns 'true' when all the actors in the input receive a resource of the + * value, and 'false' otherwise. + */ + trait EqualityTile { @@ -349,6 +399,11 @@ import Soda.tiles.fairness.tile.UnzipPairSndTile import Soda.tiles.fairness.tile.ZipTile */ +/** + * This pipeline returns 'true' when all the actors in the input receive a resource that + * satisfies their needs, and 'false' otherwise. + */ + trait EquityTile { @@ -405,6 +460,11 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.SigmaTile */ +/** + * This tiles takes a sequence of pairs of measures (m0, m1), and returns a sequence, which + * for each pair is 1, if m0 = 1 and m1 = 0, and 0 otherwise. + */ + trait FalsePosTile { @@ -439,6 +499,10 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile */ +/** + * This tile is a particular case of an 'AttributePTile', where the attribute is 'need'. + */ + trait NeededPTile { @@ -463,6 +527,11 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.ReceivedSigmaPTile */ +/** + * This tile is a particular case of a 'ReceivedSigmaPTile' where the resource is a prediction + * score. + */ + trait PredictionPTile { @@ -493,6 +562,13 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of actors as input and returns a sequence containing, for each + * actor in the input sequence, a measure amounting the value of all the resources given that + * actor. This tile requires a function to count multiple resources, and another function that + * informs the value of each resource. + */ + trait ReceivedSigmaPTile { @@ -534,6 +610,11 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile */ +/** + * This tile is a particular case of an 'AttributePTile', where the attribute is the 'result'. + * This tile is used to contrast actual results to predicted results. + */ + trait ResultPTile { @@ -557,6 +638,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of pair of measures as input, and returns a sequence such that, + * for each pair (m0, m1) in the input, is m = sigma (m0, m1), where sigma is a given function + * to combine measures. + */ + trait SigmaTile { @@ -595,6 +682,10 @@ import Soda.tiles.fairness.tile.WithPTile import Soda.tiles.fairness.tile.ZipTile */ +/** + * This pipeline check unbiasedness for a give scenario. + */ + trait UnbiasednessTile { @@ -673,6 +764,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of pairs (a, b), and returns a sequence with the first + * component of each pair from the input. + */ + trait UnzipPairFstTile { @@ -696,6 +792,11 @@ object UnzipPairFstTile { UnzipPairFstTile_ () } +/** + * This tile takes a sequence of pairs (a, b), and returns a sequence with the second + * component of each pair from the input. + */ + trait UnzipPairSndTile { @@ -725,6 +826,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the first + * component of each pair from the input. + */ + trait UnzipTripleFstTile { @@ -749,6 +855,11 @@ object UnzipTripleFstTile { UnzipTripleFstTile_ () } +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the second + * component of each pair from the input. + */ + trait UnzipTripleSndTile { @@ -773,6 +884,11 @@ object UnzipTripleSndTile { UnzipTripleSndTile_ () } +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the third + * component of each pair from the input. + */ + trait UnzipTripleTrdTile { @@ -804,6 +920,10 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile */ +/** + * This tile is a particular case of a 'AttributePTile', that projects given property. + */ + trait WithPTile { @@ -827,6 +947,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage */ +/** + * This tile connects two sequences and returns a sequence of pairs, such that for each + * position in both sequences, it has a pair with elements for the corresponding input + * sequences. + */ + trait ZipTile { diff --git a/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda index 1545a6e..94dde54 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda @@ -4,6 +4,11 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.ReceivedSigmaPTile +/** + * This tile is a particular case of a 'ReceivedSigmaPTile' where the resource is a prediction + * score. + */ + class PredictionPTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda index 4b0f5ce..d199c66 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda @@ -3,6 +3,13 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of actors as input and returns a sequence containing, for each + * actor in the input sequence, a measure amounting the value of all the resources given that + * actor. This tile requires a function to count multiple resources, and another function that + * informs the value of each resource. + */ + class ReceivedSigmaPTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda index 7f9cf80..1a83d68 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda @@ -4,6 +4,11 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile +/** + * This tile is a particular case of an 'AttributePTile', where the attribute is the 'result'. + * This tile is used to contrast actual results to predicted results. + */ + class ResultPTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda index 13c0f55..85d67a2 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/SigmaTile.soda @@ -3,6 +3,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of pair of measures as input, and returns a sequence such that, + * for each pair (m0, m1) in the input, is m = sigma (m0, m1), where sigma is a given function + * to combine measures. + */ + class SigmaTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda index 68682e8..5ae3236 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda @@ -13,6 +13,9 @@ import Soda.tiles.fairness.tile.UnzipTripleTrdTile import Soda.tiles.fairness.tile.WithPTile import Soda.tiles.fairness.tile.ZipTile +/** + * This pipeline check unbiasedness for a give scenario. + */ class UnbiasednessTile diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda index e3fa610..240c67c 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda @@ -3,6 +3,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of pairs (a, b), and returns a sequence with the first + * component of each pair from the input. + */ + class UnzipPairFstTile abstract @@ -19,6 +24,11 @@ class UnzipPairFstTile end +/** + * This tile takes a sequence of pairs (a, b), and returns a sequence with the second + * component of each pair from the input. + */ + class UnzipPairSndTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda index 7f1389b..1703744 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda @@ -3,6 +3,11 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the first + * component of each pair from the input. + */ + class UnzipTripleFstTile abstract @@ -20,6 +25,12 @@ class UnzipTripleFstTile end +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the second + * component of each pair from the input. + */ + + class UnzipTripleSndTile abstract @@ -37,6 +48,11 @@ class UnzipTripleSndTile end +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the third + * component of each pair from the input. + */ + class UnzipTripleTrdTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda index 81047e8..eab4546 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda @@ -4,6 +4,10 @@ import Soda.tiles.fairness.tool.TileMessage import Soda.tiles.fairness.tile.AttributePTile +/** + * This tile is a particular case of a 'AttributePTile', that projects given property. + */ + class WithPTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda index 06bd4e1..f700209 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda @@ -3,6 +3,12 @@ directive lean import Soda.tiles.fairness.tool.TileMessage +/** + * This tile connects two sequences and returns a sequence of pairs, such that for each + * position in both sequences, it has a pair with elements for the corresponding input + * sequences. + */ + class ZipTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tool/Entity.soda b/core/src/main/scala/soda/tiles/fairness/tool/Entity.soda index bd62f56..87584ce 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/Entity.soda +++ b/core/src/main/scala/soda/tiles/fairness/tool/Entity.soda @@ -35,6 +35,10 @@ class Outcome end +/** + * This class contains functions to compare different types of objects. + */ + class Comparator abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tool/Package.scala b/core/src/main/scala/soda/tiles/fairness/tool/Package.scala index 90c976d..24f24de 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/Package.scala +++ b/core/src/main/scala/soda/tiles/fairness/tool/Package.scala @@ -52,6 +52,10 @@ object Outcome { Outcome_ (assignments) } +/** + * This class contains functions to compare different types of objects. + */ + trait Comparator { @@ -117,9 +121,7 @@ import Soda.tiles.fairness.tool.TileMessage */ /** - * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - - * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - - * \bar{y})^{2}}} + * This class contains helper functions for mathematical calculations. */ trait MathTool @@ -158,6 +160,14 @@ object MathTool { MathTool_ () } +/** + * The main function in this class computes the Pearson correlation coefficient. + * + * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - + * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - + * \bar{y})^{2}}} + */ + trait Pearson { @@ -277,6 +287,10 @@ object HelperTuple { HelperTuple_ (comparison, remaining) } +/** + * The main function of this class compares two strings. + */ + trait StringComparator { diff --git a/core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda b/core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda index 0e0eba9..5a82d99 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda +++ b/core/src/main/scala/soda/tiles/fairness/tool/ScoringTool.soda @@ -3,12 +3,9 @@ directive lean import Soda.tiles.fairness.tool.TileMessage /** - * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - - * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - - * \bar{y})^{2}}} + * This class contains helper functions for mathematical calculations. */ - class MathTool abstract @@ -37,6 +34,14 @@ class MathTool end +/** + * The main function in this class computes the Pearson correlation coefficient. + * + * r_{x,y} =\frac{\sum _{i=1}^{n}(x_{i} - \bar{x})(y_{i} - + * \bar{y})}{\sqrt{\sum _{i=1}^{n}(x_{i} - \bar{x})^2} \sqrt{\sum ^{n} _{i=1}(y_{i} - + * \bar{y})^{2}}} + */ + class Pearson abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda b/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda index c3390ba..dbee504 100644 --- a/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda +++ b/core/src/main/scala/soda/tiles/fairness/tool/StringComparator.soda @@ -8,6 +8,11 @@ class HelperTuple end + +/** + * The main function of this class compares two strings. + */ + class StringComparator abstract From 182a40d335f80a4c927348fdcb2d2008351292e3 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 18:22:19 +0100 Subject: [PATCH 26/28] Move standard pipelines to their own package --- .../EqualityPipeline.soda} | 0 .../EquityPipeline.soda} | 2 +- .../tiles/fairness/pipeline/Package.scala | 244 +++++++++++++++ .../soda/tiles/fairness/pipeline/Package.soda | 41 +++ .../UnbiasednessPipeline.soda} | 0 .../{AtLeastTile.soda => AllAtLeastTile.soda} | 2 +- .../soda/tiles/fairness/tile/Package.scala | 295 ++++-------------- .../soda/tiles/fairness/tile/Package.soda | 2 - .../tiles/fairness/tile/UnzipPairFstTile.soda | 25 ++ ...zipPairTile.soda => UnzipPairSndTile.soda} | 21 -- .../fairness/tile/UnzipTripleFstTile.soda | 26 ++ .../fairness/tile/UnzipTripleSndTile.soda | 27 ++ .../tiles/fairness/tile/UnzipTripleTile.soda | 71 ----- .../fairness/tile/UnzipTripleTrdTile.soda | 26 ++ .../{tile => pipeline}/EqualityTileSpec.soda | 0 .../{tile => pipeline}/EquityTileSpec.soda | 0 .../fairness/{tile => pipeline}/Package.scala | 8 +- .../fairness/{tile => pipeline}/Package.soda | 9 +- .../ResourceAllocationScenarioExample.soda | 0 .../ScoringScenarioExample.soda | 0 .../UnbiasednessTileSpec.soda | 0 21 files changed, 449 insertions(+), 350 deletions(-) rename core/src/main/scala/soda/tiles/fairness/{tile/EqualityTile.soda => pipeline/EqualityPipeline.soda} (100%) rename core/src/main/scala/soda/tiles/fairness/{tile/EquityTile.soda => pipeline/EquityPipeline.soda} (97%) create mode 100644 core/src/main/scala/soda/tiles/fairness/pipeline/Package.scala create mode 100644 core/src/main/scala/soda/tiles/fairness/pipeline/Package.soda rename core/src/main/scala/soda/tiles/fairness/{tile/UnbiasednessTile.soda => pipeline/UnbiasednessPipeline.soda} (100%) rename core/src/main/scala/soda/tiles/fairness/tile/{AtLeastTile.soda => AllAtLeastTile.soda} (96%) create mode 100644 core/src/main/scala/soda/tiles/fairness/tile/UnzipPairFstTile.soda rename core/src/main/scala/soda/tiles/fairness/tile/{UnzipPairTile.soda => UnzipPairSndTile.soda} (52%) create mode 100644 core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleFstTile.soda create mode 100644 core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleSndTile.soda delete mode 100644 core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda create mode 100644 core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTrdTile.soda rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/EqualityTileSpec.soda (100%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/EquityTileSpec.soda (100%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/Package.scala (97%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/Package.soda (65%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/ResourceAllocationScenarioExample.soda (100%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/ScoringScenarioExample.soda (100%) rename core/src/test/scala/soda/tiles/fairness/{tile => pipeline}/UnbiasednessTileSpec.soda (100%) diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda b/core/src/main/scala/soda/tiles/fairness/pipeline/EqualityPipeline.soda similarity index 100% rename from core/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda rename to core/src/main/scala/soda/tiles/fairness/pipeline/EqualityPipeline.soda diff --git a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda b/core/src/main/scala/soda/tiles/fairness/pipeline/EquityPipeline.soda similarity index 97% rename from core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda rename to core/src/main/scala/soda/tiles/fairness/pipeline/EquityPipeline.soda index cd4a569..bb5a04a 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/pipeline/EquityPipeline.soda @@ -21,7 +21,7 @@ class EquityTile p0_need : Actor -> Measure p1_utility : Resource -> Measure - at_least_tile = AtLeastTile .mk + at_least_tile = AllAtLeastTile .mk received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p1_utility) diff --git a/core/src/main/scala/soda/tiles/fairness/pipeline/Package.scala b/core/src/main/scala/soda/tiles/fairness/pipeline/Package.scala new file mode 100644 index 0000000..a548f80 --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/pipeline/Package.scala @@ -0,0 +1,244 @@ +package soda.tiles.fairness.pipeline + +/* + * This package contains classes to model the tiles. + */ + +import soda.tiles.fairness.tool.Actor +import soda.tiles.fairness.tool.Assignment +import soda.tiles.fairness.tool.Comparator +import soda.tiles.fairness.tool.Measure +import soda.tiles.fairness.tool.Outcome +import soda.tiles.fairness.tool.Pearson +import soda.tiles.fairness.tool.Resource +import soda.tiles.fairness.tool.TileMessage +import soda.tiles.fairness.tool.TileMessageBuilder +import soda.tiles.fairness.tool.TilePair +import soda.tiles.fairness.tool.TileTriple +import soda.tiles.fairness.tile.AllActorPairTile +import soda.tiles.fairness.tile.AllActorTile +import soda.tiles.fairness.tile.AllActorTripleTile +import soda.tiles.fairness.tile.AllAtLeastTile +import soda.tiles.fairness.tile.AllEqual1Tile +import soda.tiles.fairness.tile.AllEqualTile +import soda.tiles.fairness.tile.AttributePTile +import soda.tiles.fairness.tile.CorrelationTile +import soda.tiles.fairness.tile.DecisionTile +import soda.tiles.fairness.tile.FalsePosTile +import soda.tiles.fairness.tile.NeededPTile +import soda.tiles.fairness.tile.PredictionPTile +import soda.tiles.fairness.tile.ReceivedSigmaPTile +import soda.tiles.fairness.tile.ResultPTile +import soda.tiles.fairness.tile.SigmaTile +import soda.tiles.fairness.tile.UnzipPairFstTile +import soda.tiles.fairness.tile.UnzipPairSndTile +import soda.tiles.fairness.tile.UnzipTripleFstTile +import soda.tiles.fairness.tile.UnzipTripleSndTile +import soda.tiles.fairness.tile.UnzipTripleTrdTile +import soda.tiles.fairness.tile.WithPTile +import soda.tiles.fairness.tile.ZipTile + + + + + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTile +import Soda.tiles.fairness.tile.AllEqualTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +*/ + +/** + * This pipeline returns 'true' when all the actors in the input receive a resource of the + * value, and 'false' otherwise. + */ + +trait EqualityTile +{ + + def sigma : Measure => Measure => Measure + def p_utility : Resource => Measure + + lazy val all_equal_tile = AllEqualTile .mk + + lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) + + lazy val all_actor_tile = AllActorTile .mk + + def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = + all_equal_tile .apply ( + received_sigma_p_tile .apply ( + all_actor_tile .apply (message) + ) + ) + +} + +case class EqualityTile_ (sigma : Measure => Measure => Measure, p_utility : Resource => Measure) extends EqualityTile + +object EqualityTile { + def mk (sigma : Measure => Measure => Measure) (p_utility : Resource => Measure) : EqualityTile = + EqualityTile_ (sigma, p_utility) +} + + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AtLeastTile +import Soda.tiles.fairness.tile.NeededPTile +import Soda.tiles.fairness.tile.ReceivedSigmaPTile +import Soda.tiles.fairness.tile.UnzipPairFstTile +import Soda.tiles.fairness.tile.UnzipPairSndTile +import Soda.tiles.fairness.tile.ZipTile +*/ + +/** + * This pipeline returns 'true' when all the actors in the input receive a resource that + * satisfies their needs, and 'false' otherwise. + */ + +trait EquityTile +{ + + def sigma : Measure => Measure => Measure + def p0_need : Actor => Measure + def p1_utility : Resource => Measure + + lazy val at_least_tile = AllAtLeastTile .mk + + lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p1_utility) + + lazy val needed_p_tile = NeededPTile .mk (p0_need) + + lazy val all_actor_pair_tile = AllActorPairTile .mk + + lazy val unzip_fst_tile = UnzipPairFstTile .mk + + lazy val unzip_snd_tile = UnzipPairSndTile .mk + + lazy val zip_tile = ZipTile .mk + + def get_branch_0 (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) + : TileMessage [Seq [Measure] ] = + received_sigma_p_tile .apply (unzip_fst_tile .apply (message) ) + + def get_branch_1 (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) + : TileMessage [Seq [Measure] ] = + needed_p_tile .apply (unzip_snd_tile .apply (message) ) + + def zip_branches (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) + : TileMessage [Seq [TilePair [Measure, Measure] ] ] = + zip_tile .apply (get_branch_0 (message) ) (get_branch_1 (message) ) + + def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = + at_least_tile .apply ( + zip_branches ( + all_actor_pair_tile .apply (message) + ) + ) + +} + +case class EquityTile_ (sigma : Measure => Measure => Measure, p0_need : Actor => Measure, p1_utility : Resource => Measure) extends EquityTile + +object EquityTile { + def mk (sigma : Measure => Measure => Measure) (p0_need : Actor => Measure) (p1_utility : Resource => Measure) : EquityTile = + EquityTile_ (sigma, p0_need, p1_utility) +} + + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +import Soda.tiles.fairness.tile.AllActorTripleTile +import Soda.tiles.fairness.tile.CorrelationTile +import Soda.tiles.fairness.tile.DecisionTile +import Soda.tiles.fairness.tile.FalsePosTile +import Soda.tiles.fairness.tile.PredictionPTile +import Soda.tiles.fairness.tile.ResultPTile +import Soda.tiles.fairness.tile.UnzipTripleFstTile +import Soda.tiles.fairness.tile.UnzipTripleSndTile +import Soda.tiles.fairness.tile.UnzipTripleTrdTile +import Soda.tiles.fairness.tile.WithPTile +import Soda.tiles.fairness.tile.ZipTile +*/ + +/** + * This pipeline check unbiasedness for a give scenario. + */ + +trait UnbiasednessTile +{ + + def p0_evaluation : Resource => Measure + def p1_result : Actor => Measure + def p2_with_p : Actor => Measure + def p3_acceptable_bias : Measure + + lazy val all_actor_triple_tile = AllActorTripleTile .mk + + lazy val unzip_fst_tile = UnzipTripleFstTile .mk + + lazy val unzip_snd_tile = UnzipTripleSndTile .mk + + lazy val unzip_trd_tile = UnzipTripleTrdTile .mk + + lazy val zip_tile = ZipTile .mk + + lazy val prediction_p_tile = PredictionPTile .mk (p0_evaluation) + + lazy val result_p_tile = ResultPTile .mk (p1_result) + + lazy val with_p_tile = WithPTile .mk (p2_with_p) + + lazy val false_pos_tile = FalsePosTile .mk + + lazy val correlation_tile = CorrelationTile .mk + + lazy val decision_tile = DecisionTile .mk (p3_acceptable_bias) + + def get_prediction (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) + : TileMessage [Seq [Measure] ] = + prediction_p_tile .apply (unzip_fst_tile .apply (message) ) + + def get_result (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) + : TileMessage [Seq [Measure] ] = + result_p_tile .apply (unzip_snd_tile .apply (message) ) + + def get_with_p (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) + : TileMessage [Seq [Measure] ] = + with_p_tile .apply (unzip_trd_tile .apply (message) ) + + def get_false_pos (prediction : TileMessage [Seq [Measure] ] ) ( + result : TileMessage [Seq [Measure] ] ) : TileMessage [Seq [Measure] ] = + false_pos_tile .apply (zip_tile .apply (prediction) (result) ) + + def get_correlation (false_pos : TileMessage [Seq [Measure] ] ) ( + with_p : TileMessage [Seq [Measure] ] ) : TileMessage [Measure] = + correlation_tile .apply (zip_tile .apply (false_pos) (with_p) ) + + def get_correlation_plumbing (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) + : TileMessage [Measure] = + get_correlation ( + get_false_pos (get_prediction (message) ) (get_result (message) ) + ) (get_with_p (message) ) + + def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = + decision_tile .apply ( + get_correlation_plumbing ( + all_actor_triple_tile .apply (message) + ) + ) + +} + +case class UnbiasednessTile_ (p0_evaluation : Resource => Measure, p1_result : Actor => Measure, p2_with_p : Actor => Measure, p3_acceptable_bias : Measure) extends UnbiasednessTile + +object UnbiasednessTile { + def mk (p0_evaluation : Resource => Measure) (p1_result : Actor => Measure) (p2_with_p : Actor => Measure) (p3_acceptable_bias : Measure) : UnbiasednessTile = + UnbiasednessTile_ (p0_evaluation, p1_result, p2_with_p, p3_acceptable_bias) +} + diff --git a/core/src/main/scala/soda/tiles/fairness/pipeline/Package.soda b/core/src/main/scala/soda/tiles/fairness/pipeline/Package.soda new file mode 100644 index 0000000..dec3a92 --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/pipeline/Package.soda @@ -0,0 +1,41 @@ +package soda.tiles.fairness.pipeline + +/* + * This package contains classes to model the tiles. + */ + +import + soda.tiles.fairness.tool.Actor + soda.tiles.fairness.tool.Assignment + soda.tiles.fairness.tool.Comparator + soda.tiles.fairness.tool.Measure + soda.tiles.fairness.tool.Outcome + soda.tiles.fairness.tool.Pearson + soda.tiles.fairness.tool.Resource + soda.tiles.fairness.tool.TileMessage + soda.tiles.fairness.tool.TileMessageBuilder + soda.tiles.fairness.tool.TilePair + soda.tiles.fairness.tool.TileTriple + soda.tiles.fairness.tile.AllActorPairTile + soda.tiles.fairness.tile.AllActorTile + soda.tiles.fairness.tile.AllActorTripleTile + soda.tiles.fairness.tile.AllAtLeastTile + soda.tiles.fairness.tile.AllEqual1Tile + soda.tiles.fairness.tile.AllEqualTile + soda.tiles.fairness.tile.AttributePTile + soda.tiles.fairness.tile.CorrelationTile + soda.tiles.fairness.tile.DecisionTile + soda.tiles.fairness.tile.FalsePosTile + soda.tiles.fairness.tile.NeededPTile + soda.tiles.fairness.tile.PredictionPTile + soda.tiles.fairness.tile.ReceivedSigmaPTile + soda.tiles.fairness.tile.ResultPTile + soda.tiles.fairness.tile.SigmaTile + soda.tiles.fairness.tile.UnzipPairFstTile + soda.tiles.fairness.tile.UnzipPairSndTile + soda.tiles.fairness.tile.UnzipTripleFstTile + soda.tiles.fairness.tile.UnzipTripleSndTile + soda.tiles.fairness.tile.UnzipTripleTrdTile + soda.tiles.fairness.tile.WithPTile + soda.tiles.fairness.tile.ZipTile + diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda b/core/src/main/scala/soda/tiles/fairness/pipeline/UnbiasednessPipeline.soda similarity index 100% rename from core/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda rename to core/src/main/scala/soda/tiles/fairness/pipeline/UnbiasednessPipeline.soda diff --git a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/AllAtLeastTile.soda similarity index 96% rename from core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/AllAtLeastTile.soda index b303a16..4982324 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/AllAtLeastTile.soda @@ -9,7 +9,7 @@ import Soda.tiles.fairness.tool.TileMessage * 'false'. */ -class AtLeastTile +class AllAtLeastTile abstract diff --git a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala index 9e026cb..d99c747 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/main/scala/soda/tiles/fairness/tile/Package.scala @@ -7,11 +7,9 @@ package soda.tiles.fairness.tile import soda.tiles.fairness.tool.Actor import soda.tiles.fairness.tool.Assignment import soda.tiles.fairness.tool.Comparator -import soda.tiles.fairness.tool.Comparator_ import soda.tiles.fairness.tool.Measure import soda.tiles.fairness.tool.Outcome import soda.tiles.fairness.tool.Pearson -import soda.tiles.fairness.tool.Pearson_ import soda.tiles.fairness.tool.Resource import soda.tiles.fairness.tool.TileMessage import soda.tiles.fairness.tool.TileMessageBuilder @@ -125,6 +123,43 @@ object AllActorTripleTile { } +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + +/** + * This tile takes a sequence of pairs of measures, and compares both components (m0, m1). + * If for each pair (m0, m1), it holds that m0 >= m1, it returns 'true, otherwise, it returns + * 'false'. + */ + +trait AllAtLeastTile +{ + + + + def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) + : TileMessage [Boolean] = + TileMessageBuilder .mk .build (message .context) (message .outcome) ( + ( (message .contents) + .map ( pair => + (Comparator .mk + .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) + .forall ( e => e) + ) + ) + +} + +case class AllAtLeastTile_ () extends AllAtLeastTile + +object AllAtLeastTile { + def mk : AllAtLeastTile = + AllAtLeastTile_ () +} + + /* directive lean import Soda.tiles.fairness.tool.TileMessage @@ -188,43 +223,6 @@ object AllEqualTile { } -/* -directive lean -import Soda.tiles.fairness.tool.TileMessage -*/ - -/** - * This tile takes a sequence of pairs of measures, and compares both components (m0, m1). - * If for each pair (m0, m1), it holds that m0 >= m1, it returns 'true, otherwise, it returns - * 'false'. - */ - -trait AtLeastTile -{ - - - - def apply (message : TileMessage [Seq [TilePair [Measure, Measure] ] ] ) - : TileMessage [Boolean] = - TileMessageBuilder .mk .build (message .context) (message .outcome) ( - ( (message .contents) - .map ( pair => - (Comparator .mk - .compareMeasure (pair .fst) (pair .snd) ) >= 0 ) - .forall ( e => e) - ) - ) - -} - -case class AtLeastTile_ () extends AtLeastTile - -object AtLeastTile { - def mk : AtLeastTile = - AtLeastTile_ () -} - - /* directive lean import Soda.tiles.fairness.tool.TileMessage @@ -346,114 +344,6 @@ object DecisionTile { } -/* -directive lean -import Soda.tiles.fairness.tool.TileMessage -import Soda.tiles.fairness.tile.AllActorTile -import Soda.tiles.fairness.tile.AllEqualTile -import Soda.tiles.fairness.tile.ReceivedSigmaPTile -*/ - -/** - * This pipeline returns 'true' when all the actors in the input receive a resource of the - * value, and 'false' otherwise. - */ - -trait EqualityTile -{ - - def sigma : Measure => Measure => Measure - def p_utility : Resource => Measure - - lazy val all_equal_tile = AllEqualTile .mk - - lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p_utility) - - lazy val all_actor_tile = AllActorTile .mk - - def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = - all_equal_tile .apply ( - received_sigma_p_tile .apply ( - all_actor_tile .apply (message) - ) - ) - -} - -case class EqualityTile_ (sigma : Measure => Measure => Measure, p_utility : Resource => Measure) extends EqualityTile - -object EqualityTile { - def mk (sigma : Measure => Measure => Measure) (p_utility : Resource => Measure) : EqualityTile = - EqualityTile_ (sigma, p_utility) -} - - -/* -directive lean -import Soda.tiles.fairness.tool.TileMessage -import Soda.tiles.fairness.tile.AtLeastTile -import Soda.tiles.fairness.tile.NeededPTile -import Soda.tiles.fairness.tile.ReceivedSigmaPTile -import Soda.tiles.fairness.tile.UnzipPairFstTile -import Soda.tiles.fairness.tile.UnzipPairSndTile -import Soda.tiles.fairness.tile.ZipTile -*/ - -/** - * This pipeline returns 'true' when all the actors in the input receive a resource that - * satisfies their needs, and 'false' otherwise. - */ - -trait EquityTile -{ - - def sigma : Measure => Measure => Measure - def p0_need : Actor => Measure - def p1_utility : Resource => Measure - - lazy val at_least_tile = AtLeastTile .mk - - lazy val received_sigma_p_tile = ReceivedSigmaPTile .mk (sigma) (p1_utility) - - lazy val needed_p_tile = NeededPTile .mk (p0_need) - - lazy val all_actor_pair_tile = AllActorPairTile .mk - - lazy val unzip_fst_tile = UnzipPairFstTile .mk - - lazy val unzip_snd_tile = UnzipPairSndTile .mk - - lazy val zip_tile = ZipTile .mk - - def get_branch_0 (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) - : TileMessage [Seq [Measure] ] = - received_sigma_p_tile .apply (unzip_fst_tile .apply (message) ) - - def get_branch_1 (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) - : TileMessage [Seq [Measure] ] = - needed_p_tile .apply (unzip_snd_tile .apply (message) ) - - def zip_branches (message : TileMessage [Seq [TilePair [Actor, Actor] ] ] ) - : TileMessage [Seq [TilePair [Measure, Measure] ] ] = - zip_tile .apply (get_branch_0 (message) ) (get_branch_1 (message) ) - - def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = - at_least_tile .apply ( - zip_branches ( - all_actor_pair_tile .apply (message) - ) - ) - -} - -case class EquityTile_ (sigma : Measure => Measure => Measure, p0_need : Actor => Measure, p1_utility : Resource => Measure) extends EquityTile - -object EquityTile { - def mk (sigma : Measure => Measure => Measure) (p0_need : Actor => Measure) (p1_utility : Resource => Measure) : EquityTile = - EquityTile_ (sigma, p0_need, p1_utility) -} - - /* directive lean import Soda.tiles.fairness.tool.TileMessage @@ -666,99 +556,6 @@ object SigmaTile { } -/* -directive lean -import Soda.tiles.fairness.tool.TileMessage -import Soda.tiles.fairness.tile.AllActorTripleTile -import Soda.tiles.fairness.tile.CorrelationTile -import Soda.tiles.fairness.tile.DecisionTile -import Soda.tiles.fairness.tile.FalsePosTile -import Soda.tiles.fairness.tile.PredictionPTile -import Soda.tiles.fairness.tile.ResultPTile -import Soda.tiles.fairness.tile.UnzipTripleFstTile -import Soda.tiles.fairness.tile.UnzipTripleSndTile -import Soda.tiles.fairness.tile.UnzipTripleTrdTile -import Soda.tiles.fairness.tile.WithPTile -import Soda.tiles.fairness.tile.ZipTile -*/ - -/** - * This pipeline check unbiasedness for a give scenario. - */ - -trait UnbiasednessTile -{ - - def p0_evaluation : Resource => Measure - def p1_result : Actor => Measure - def p2_with_p : Actor => Measure - def p3_acceptable_bias : Measure - - lazy val all_actor_triple_tile = AllActorTripleTile .mk - - lazy val unzip_fst_tile = UnzipTripleFstTile .mk - - lazy val unzip_snd_tile = UnzipTripleSndTile .mk - - lazy val unzip_trd_tile = UnzipTripleTrdTile .mk - - lazy val zip_tile = ZipTile .mk - - lazy val prediction_p_tile = PredictionPTile .mk (p0_evaluation) - - lazy val result_p_tile = ResultPTile .mk (p1_result) - - lazy val with_p_tile = WithPTile .mk (p2_with_p) - - lazy val false_pos_tile = FalsePosTile .mk - - lazy val correlation_tile = CorrelationTile .mk - - lazy val decision_tile = DecisionTile .mk (p3_acceptable_bias) - - def get_prediction (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) - : TileMessage [Seq [Measure] ] = - prediction_p_tile .apply (unzip_fst_tile .apply (message) ) - - def get_result (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) - : TileMessage [Seq [Measure] ] = - result_p_tile .apply (unzip_snd_tile .apply (message) ) - - def get_with_p (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) - : TileMessage [Seq [Measure] ] = - with_p_tile .apply (unzip_trd_tile .apply (message) ) - - def get_false_pos (prediction : TileMessage [Seq [Measure] ] ) ( - result : TileMessage [Seq [Measure] ] ) : TileMessage [Seq [Measure] ] = - false_pos_tile .apply (zip_tile .apply (prediction) (result) ) - - def get_correlation (false_pos : TileMessage [Seq [Measure] ] ) ( - with_p : TileMessage [Seq [Measure] ] ) : TileMessage [Measure] = - correlation_tile .apply (zip_tile .apply (false_pos) (with_p) ) - - def get_correlation_plumbing (message : TileMessage [Seq [TileTriple [Actor, Actor, Actor] ] ] ) - : TileMessage [Measure] = - get_correlation ( - get_false_pos (get_prediction (message) ) (get_result (message) ) - ) (get_with_p (message) ) - - def apply (message : TileMessage [Boolean] ) : TileMessage [Boolean] = - decision_tile .apply ( - get_correlation_plumbing ( - all_actor_triple_tile .apply (message) - ) - ) - -} - -case class UnbiasednessTile_ (p0_evaluation : Resource => Measure, p1_result : Actor => Measure, p2_with_p : Actor => Measure, p3_acceptable_bias : Measure) extends UnbiasednessTile - -object UnbiasednessTile { - def mk (p0_evaluation : Resource => Measure) (p1_result : Actor => Measure) (p2_with_p : Actor => Measure) (p3_acceptable_bias : Measure) : UnbiasednessTile = - UnbiasednessTile_ (p0_evaluation, p1_result, p2_with_p, p3_acceptable_bias) -} - - /* directive lean import Soda.tiles.fairness.tool.TileMessage @@ -792,6 +589,12 @@ object UnzipPairFstTile { UnzipPairFstTile_ () } + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + /** * This tile takes a sequence of pairs (a, b), and returns a sequence with the second * component of each pair from the input. @@ -855,6 +658,12 @@ object UnzipTripleFstTile { UnzipTripleFstTile_ () } + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + /** * This tile takes a sequence of triples (a, b, c), and returns a sequence with the second * component of each pair from the input. @@ -884,6 +693,12 @@ object UnzipTripleSndTile { UnzipTripleSndTile_ () } + +/* +directive lean +import Soda.tiles.fairness.tool.TileMessage +*/ + /** * This tile takes a sequence of triples (a, b, c), and returns a sequence with the third * component of each pair from the input. diff --git a/core/src/main/scala/soda/tiles/fairness/tile/Package.soda b/core/src/main/scala/soda/tiles/fairness/tile/Package.soda index a9a612c..5802ceb 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/Package.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/Package.soda @@ -8,11 +8,9 @@ import soda.tiles.fairness.tool.Actor soda.tiles.fairness.tool.Assignment soda.tiles.fairness.tool.Comparator - soda.tiles.fairness.tool.Comparator_ soda.tiles.fairness.tool.Measure soda.tiles.fairness.tool.Outcome soda.tiles.fairness.tool.Pearson - soda.tiles.fairness.tool.Pearson_ soda.tiles.fairness.tool.Resource soda.tiles.fairness.tool.TileMessage soda.tiles.fairness.tool.TileMessageBuilder diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairFstTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairFstTile.soda new file mode 100644 index 0000000..d4af4d5 --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairFstTile.soda @@ -0,0 +1,25 @@ + +directive lean +import Soda.tiles.fairness.tool.TileMessage + + +/** + * This tile takes a sequence of pairs (a, b), and returns a sequence with the first + * component of each pair from the input. + */ + +class UnzipPairFstTile + + abstract + + unzip_fst_list [A : Type] [B : Type] (list : Seq [TilePair [A] [B] ] ) : Seq [A] = + list .map (lambda pair --> pair .fst) + + apply [A : Type] [B : Type] (message : TileMessage [Seq [TilePair [A] [B] ] ] ) + : TileMessage [Seq [A] ] = + TileMessageBuilder .mk .build (message .context) (message .outcome) ( + unzip_fst_list (message .contents) + ) + +end + diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairSndTile.soda similarity index 52% rename from core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda rename to core/src/main/scala/soda/tiles/fairness/tile/UnzipPairSndTile.soda index 240c67c..c055d86 100644 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairSndTile.soda @@ -3,27 +3,6 @@ directive lean import Soda.tiles.fairness.tool.TileMessage -/** - * This tile takes a sequence of pairs (a, b), and returns a sequence with the first - * component of each pair from the input. - */ - -class UnzipPairFstTile - - abstract - - unzip_fst_list [A : Type] [B : Type] (list : Seq [TilePair [A] [B] ] ) : Seq [A] = - list .map (lambda pair --> pair .fst) - - apply [A : Type] [B : Type] (message : TileMessage [Seq [TilePair [A] [B] ] ] ) - : TileMessage [Seq [A] ] = - TileMessageBuilder .mk .build (message .context) (message .outcome) ( - unzip_fst_list (message .contents) - ) - -end - - /** * This tile takes a sequence of pairs (a, b), and returns a sequence with the second * component of each pair from the input. diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleFstTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleFstTile.soda new file mode 100644 index 0000000..bfeedaa --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleFstTile.soda @@ -0,0 +1,26 @@ + +directive lean +import Soda.tiles.fairness.tool.TileMessage + + +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the first + * component of each pair from the input. + */ + +class UnzipTripleFstTile + + abstract + + unzip_fst_list [A : Type] [B : Type] [C : Type] ( + list : Seq [TileTriple [A] [B] [C] ] ) : Seq [A] = + list .map (lambda triple --> triple .fst) + + apply [A : Type] [B : Type] [C : Type] ( + message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [A] ] = + TileMessageBuilder .mk .build (message .context) (message .outcome) ( + unzip_fst_list (message .contents) + ) + +end + diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleSndTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleSndTile.soda new file mode 100644 index 0000000..9c7521e --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleSndTile.soda @@ -0,0 +1,27 @@ + +directive lean +import Soda.tiles.fairness.tool.TileMessage + + +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the second + * component of each pair from the input. + */ + + +class UnzipTripleSndTile + + abstract + + unzip_snd_list [A : Type] [B : Type] [C : Type] ( + list : Seq [TileTriple [A] [B] [C] ] ) : Seq [B] = + list .map (lambda triple --> triple .snd) + + apply [A : Type] [B : Type] [C : Type] ( + message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [B] ] = + TileMessageBuilder .mk .build (message .context) (message .outcome) ( + unzip_snd_list (message .contents) + ) + +end + diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda deleted file mode 100644 index 1703744..0000000 --- a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTile.soda +++ /dev/null @@ -1,71 +0,0 @@ - -directive lean -import Soda.tiles.fairness.tool.TileMessage - - -/** - * This tile takes a sequence of triples (a, b, c), and returns a sequence with the first - * component of each pair from the input. - */ - -class UnzipTripleFstTile - - abstract - - unzip_fst_list [A : Type] [B : Type] [C : Type] ( - list : Seq [TileTriple [A] [B] [C] ] ) : Seq [A] = - list .map (lambda triple --> triple .fst) - - apply [A : Type] [B : Type] [C : Type] ( - message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [A] ] = - TileMessageBuilder .mk .build (message .context) (message .outcome) ( - unzip_fst_list (message .contents) - ) - -end - - -/** - * This tile takes a sequence of triples (a, b, c), and returns a sequence with the second - * component of each pair from the input. - */ - - -class UnzipTripleSndTile - - abstract - - unzip_snd_list [A : Type] [B : Type] [C : Type] ( - list : Seq [TileTriple [A] [B] [C] ] ) : Seq [B] = - list .map (lambda triple --> triple .snd) - - apply [A : Type] [B : Type] [C : Type] ( - message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [B] ] = - TileMessageBuilder .mk .build (message .context) (message .outcome) ( - unzip_snd_list (message .contents) - ) - -end - - -/** - * This tile takes a sequence of triples (a, b, c), and returns a sequence with the third - * component of each pair from the input. - */ - -class UnzipTripleTrdTile - - abstract - - unzip_trd_list [A : Type] [B : Type] [C : Type] ( - list : Seq [TileTriple [A] [B] [C] ] ) : Seq [C] = - list .map (lambda triple --> triple .trd) - - apply [A : Type] [B : Type] [C : Type] ( - message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [C] ] = - TileMessageBuilder .mk .build (message .context) (message .outcome) ( - unzip_trd_list (message .contents) - ) - -end - diff --git a/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTrdTile.soda b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTrdTile.soda new file mode 100644 index 0000000..5f49079 --- /dev/null +++ b/core/src/main/scala/soda/tiles/fairness/tile/UnzipTripleTrdTile.soda @@ -0,0 +1,26 @@ + +directive lean +import Soda.tiles.fairness.tool.TileMessage + + +/** + * This tile takes a sequence of triples (a, b, c), and returns a sequence with the third + * component of each pair from the input. + */ + +class UnzipTripleTrdTile + + abstract + + unzip_trd_list [A : Type] [B : Type] [C : Type] ( + list : Seq [TileTriple [A] [B] [C] ] ) : Seq [C] = + list .map (lambda triple --> triple .trd) + + apply [A : Type] [B : Type] [C : Type] ( + message : TileMessage [Seq [TileTriple [A] [B] [C] ] ] ) : TileMessage [Seq [C] ] = + TileMessageBuilder .mk .build (message .context) (message .outcome) ( + unzip_trd_list (message .contents) + ) + +end + diff --git a/core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/EqualityTileSpec.soda similarity index 100% rename from core/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/EqualityTileSpec.soda diff --git a/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/EquityTileSpec.soda similarity index 100% rename from core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/EquityTileSpec.soda diff --git a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala b/core/src/test/scala/soda/tiles/fairness/pipeline/Package.scala similarity index 97% rename from core/src/test/scala/soda/tiles/fairness/tile/Package.scala rename to core/src/test/scala/soda/tiles/fairness/pipeline/Package.scala index 3693a8a..d8be955 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/Package.scala +++ b/core/src/test/scala/soda/tiles/fairness/pipeline/Package.scala @@ -1,4 +1,4 @@ -package soda.tiles.fairness.tile +package soda.tiles.fairness.pipeline /* * This package contains tests for the classes to model a resource allocation scenario. @@ -7,20 +7,14 @@ package soda.tiles.fairness.tile import org.scalatest.funsuite.AnyFunSuite import soda.tiles.fairness.tool.Actor import soda.tiles.fairness.tool.Assignment -import soda.tiles.fairness.tool.Assignment_ import soda.tiles.fairness.tool.Context import soda.tiles.fairness.tool.Measure import soda.tiles.fairness.tool.Outcome -import soda.tiles.fairness.tool.Outcome_ import soda.tiles.fairness.tool.Resource import soda.tiles.fairness.tool.TileMessage -import soda.tiles.fairness.tool.TileMessage_ import soda.tiles.fairness.tool.TileMessageBuilder -import soda.tiles.fairness.tool.TileMessageBuilder_ import soda.tiles.fairness.tool.TilePair -import soda.tiles.fairness.tool.TilePair_ import soda.tiles.fairness.tool.Random -import soda.tiles.fairness.tool.Random_ case class EqualityTileSpec () extends diff --git a/core/src/test/scala/soda/tiles/fairness/tile/Package.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/Package.soda similarity index 65% rename from core/src/test/scala/soda/tiles/fairness/tile/Package.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/Package.soda index dd1604d..c48a47d 100644 --- a/core/src/test/scala/soda/tiles/fairness/tile/Package.soda +++ b/core/src/test/scala/soda/tiles/fairness/pipeline/Package.soda @@ -1,4 +1,4 @@ -package soda.tiles.fairness.tile +package soda.tiles.fairness.pipeline /* * This package contains tests for the classes to model a resource allocation scenario. @@ -8,17 +8,12 @@ import org.scalatest.funsuite.AnyFunSuite soda.tiles.fairness.tool.Actor soda.tiles.fairness.tool.Assignment - soda.tiles.fairness.tool.Assignment_ soda.tiles.fairness.tool.Context soda.tiles.fairness.tool.Measure soda.tiles.fairness.tool.Outcome - soda.tiles.fairness.tool.Outcome_ soda.tiles.fairness.tool.Resource soda.tiles.fairness.tool.TileMessage - soda.tiles.fairness.tool.TileMessage_ soda.tiles.fairness.tool.TileMessageBuilder - soda.tiles.fairness.tool.TileMessageBuilder_ soda.tiles.fairness.tool.TilePair - soda.tiles.fairness.tool.TilePair_ soda.tiles.fairness.tool.Random - soda.tiles.fairness.tool.Random_ + diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/ResourceAllocationScenarioExample.soda similarity index 100% rename from core/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/ResourceAllocationScenarioExample.soda diff --git a/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/ScoringScenarioExample.soda similarity index 100% rename from core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/ScoringScenarioExample.soda diff --git a/core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda b/core/src/test/scala/soda/tiles/fairness/pipeline/UnbiasednessTileSpec.soda similarity index 100% rename from core/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda rename to core/src/test/scala/soda/tiles/fairness/pipeline/UnbiasednessTileSpec.soda From ae1017e4b80f7f1724f5437106ea31151e90c874 Mon Sep 17 00:00:00 2001 From: Julian Mendez Date: Sun, 25 Feb 2024 20:17:43 +0100 Subject: [PATCH 27/28] Update README.md --- docs/README.md | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/README.md b/docs/README.md index 77f37f9..3331ece 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,14 +12,14 @@ written in [Soda](https://julianmendez.github.io/soda) and grouped in packages t The fairness tiles are defined in [package tile]( -https://github.com/julianmendez/soda/tree/master/tiles/src/main/scala/soda/tiles/fairness/tile +https://github.com/julianmendez/tiles/tree/master/core/src/main/scala/soda/tiles/fairness/tile ) [(Scala translation)]( -https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/Package.scala +https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/Package.scala ) and they use entities and other tools defined in [package tool]( -https://github.com/julianmendez/soda/tree/master/tiles/src/main/scala/soda/tiles/fairness/tool +https://github.com/julianmendez/tiles/tree/master/core/src/main/scala/soda/tiles/fairness/tool ) [(Scala translation)]( -https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tool/Package.scala +https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tool/Package.scala ). @@ -29,16 +29,16 @@ These are some of the implemented fairness tiles for resource allocation scenari | Tile | Class | |:-----------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------| -| all-actor *(a)* | [AllActorTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda) | -| *(a)* received-σ-p *(m)* | [ReceivedSigmaPTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda) | -| *(m)* all-equal *b* | [AllEqualTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda) | -| *(a)* needed-p *(m)* | [NeededPTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda) | -| *(m0, m1)* at-least *b* | [AtLeastTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/AtLeastTile.soda) | -| equality *b* | [EqualityTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/EqualityTile.soda) | -| equity *b* | [EquityTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/EquityTile.soda) | +| all-actor *(a)* | [AllActorTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/AllActorTile.soda) | +| *(a)* received-σ-p *(m)* | [ReceivedSigmaPTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/ReceivedSigmaPTile.soda) | +| *(m)* all-equal *b* | [AllEqualTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/AllEqualTile.soda) | +| *(a)* needed-p *(m)* | [NeededPTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/NeededPTile.soda) | +| *(m0, m1)* all-at-least *b* | [AllAtLeastTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/AllAtLeastTile.soda) | +| equality *b* | [EqualityPipeline](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/pipeline/EqualityPipeline.soda) | +| equity *b* | [EquityPipeline](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/pipeline/EquityPipeline.soda) | -A specific scenario is given as an example in [ResourceAllocationScenarioExample](https://github.com/julianmendez/soda/blob/master/tiles/src/test/scala/soda/tiles/fairness/tile/ResourceAllocationScenarioExample.soda). -This scenario is used to test the equality tile with [EqualityTileSpec](https://github.com/julianmendez/soda/blob/master/tiles/src/test/scala/soda/tiles/fairness/tile/EqualityTileSpec.soda) and the equity tile with [EquityTileSpec](https://github.com/julianmendez/soda/blob/master/tiles/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda). +A specific scenario is given as an example in [ResourceAllocationScenarioExample](https://github.com/julianmendez/tiles/blob/master/core/src/test/scala/soda/tiles/fairness/pipeline/ResourceAllocationScenarioExample.soda). +This scenario is used to test the equality tile with [EqualityPipelineSpec](https://github.com/julianmendez/tiles/blob/master/core/src/test/scala/soda/tiles/fairness/pipeline/EqualityPipelineSpec.soda) and the equity tile with [EquityTileSpec](https://github.com/julianmendez/tiles/blob/master/core/src/test/scala/soda/tiles/fairness/tile/EquityTileSpec.soda). #### Equality @@ -67,18 +67,18 @@ These are some of the implemented fairness tiles for scoring scenarios: | Tile | Class | |:-------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------| -| all-actor *(a0, a1, a2)* | [AllActorTripleTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda) | -| *(a)* prediction-p *(m)* | [PredictionPTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda) | -| *(a)* result-p *(m)* | [ResultPTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda) | -| *(m0, m1)* false-pos *(m)* | [FalsePosTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda) | -| *(a)* with-p *(m)* | [WithPTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda) | -| *(m0, m1)* correlation *m* | [CorrelationTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda) | -| *m* decision *b* | [DecisionTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda) | -| unbiasedness *b* | [UnbiasednessTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/UnbiasednessTile.soda) | - -A specific scenario is given as an example in [ScoringScenarioExample](https://github.com/julianmendez/soda/blob/master/tiles/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda). +| all-actor *(a0, a1, a2)* | [AllActorTripleTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/AllActorTripleTile.soda) | +| *(a)* prediction-p *(m)* | [PredictionPTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/PredictionPTile.soda) | +| *(a)* result-p *(m)* | [ResultPTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/ResultPTile.soda) | +| *(m0, m1)* false-pos *(m)* | [FalsePosTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda) | +| *(a)* with-p *(m)* | [WithPTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/WithPTile.soda) | +| *(m0, m1)* correlation *m* | [CorrelationTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/CorrelationTile.soda) | +| *m* decision *b* | [DecisionTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/DecisionTile.soda) | +| unbiasedness *b* | [UnbiasednessTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/pipeline/UnbiasednessPipeline.soda) | + +A specific scenario is given as an example in [ScoringScenarioExample](https://github.com/julianmendez/tiles/blob/master/core/src/test/scala/soda/tiles/fairness/tile/ScoringScenarioExample.soda). This scenario is used to test the scoring scenario tile (unbiasedness with respect to false positives) with -[UnbiasednessTileSpec](https://github.com/julianmendez/soda/blob/master/tiles/src/test/scala/soda/tiles/fairness/tile/UnbiasednessTileSpec.soda). +[UnbiasednessPipelineSpec](https://github.com/julianmendez/tiles/blob/master/core/src/test/scala/soda/tiles/fairness/pipeline/UnbiasednessPipelineSpec.soda). #### Unbiasedness @@ -103,11 +103,11 @@ are: | Tile | Class | |:-------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------| -| *(a)* attribute-p *(m)* | [AttributePTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda) | -| *(m0, m1)* σ-p *(m)* | [SigmaTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda) | -| *(α0) (α1)* zip *(α0, α1)* | [ZipTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda) | -| *(α0, α1)* unzip-0 *(α0)* | [UnzipPairFstTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda) | -| *(α0, α1)* unzip-1 *(α1)* | [UnzipPairSndTile](https://github.com/julianmendez/soda/blob/master/tiles/src/main/scala/soda/tiles/fairness/tile/UnzipPairTile.soda) | +| *(a)* attribute-p *(m)* | [AttributePTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/AttributePTile.soda) | +| *(m0, m1)* σ-p *(m)* | [SigmaTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/FalsePosTile.soda) | +| *(α0) (α1)* zip *(α0, α1)* | [ZipTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/ZipTile.soda) | +| *(α0, α1)* unzip-0 *(α0)* | [UnzipPairFstTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairFstTile.soda) | +| *(α0, α1)* unzip-1 *(α1)* | [UnzipPairSndTile](https://github.com/julianmendez/tiles/blob/master/core/src/main/scala/soda/tiles/fairness/tile/UnzipPairSndTile.soda) |