ScaFi Aggregate Programming Toolkit

Introduction

ScaFi (Scala Fields) is a Scala-based library and framework for Aggregate Programming. It implements a variant of the Higher-Order Field Calculus (HOFC) operational semantics, which is made available as a usable domain-specific language (DSL), and provides a platform and API for simulating and executing Aggregate Computing systems and applications.

Learning Resources

Usage

Notes

Steps

val scafiVersion = "1.1.5"
val scafi_core  = "it.unibo.scafi" %% "scafi-core"  % scafiVersion
val scafi_simulator  = "it.unibo.scafi" %% "scafi-simulator"  % scafiVersion
val scafi_simulator_gui  = "it.unibo.scafi" %% "scafi-simulator-gui"  % scafiVersion
val scafi_platform = "it.unibo.scafi" %% "scafi-distributed"  % scafiVersion

libraryDependencies ++= Seq(scafi_core, scafi_simulator_gui, scafi_platform)

or via Gradle (build.gradle.kts):

plugins {
    java
    scala
}

dependencies {
    val scalaMajor = "2.12"
    val scafiVersion = "1.1.5"
    implementation("org.scala-lang:scala-library:2.12.14")
    implementation("it.unibo.scafi:scafi-core_$scalaMajor:$scafiVersion")
    implementation("it.unibo.scafi:scafi-simulator-gui_$scalaMajor:$scafiVersion")
}
package experiments

import it.unibo.scafi.incarnations.BasicSimulationIncarnation.AggregateProgram

class MyAggregateProgram extends AggregateProgram {

  override def main() = gradient(isSource)

  def gradient(source: Boolean): Double =
    rep(Double.PositiveInfinity){ distance =>
      mux(source) { 0.0 } {
        foldhood(Double.PositiveInfinity)(Math.min)(nbr{distance}+nbrRange)
      }
    }

  def isSource = sense[Boolean]("sens1")
  def nbrRange = nbrvar[Double](NBR_RANGE_NAME)
}

import it.unibo.scafi.simulation.frontend.{Launcher, Settings}

object SimulationRunner extends Launcher {
  Settings.Sim_ProgramClass = "experiments.MyAggregateProgram"
  Settings.ShowConfigPanel = false
  launch()
}

More information is available in the ScaFi Documentation.

People

Main Researchers and Authors

Research Collaborators

References

Contacts