Macroprogramming
≈ 4 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
In computer science, macroprogramming is a programming paradigm aimed at expressing the macroscopic, global behaviour of an entire system of agents or computing devices. In macroprogramming, the local programs for the individual components of a distributed system are compiled or interpreted from a macro-program typically expressed by a system-level perspective or in terms of the intended global goal. The aim of macroprogramming approaches is to support expressing the macroscopic interactive behaviour of a whole distributed system of computing devices or agents in a single program, or, similarly, to promote their collective intelligence. It is not to be confused with macros, the mechanism often found in programming languages (like C or Scala) to express substitution rules for program pieces. Macroprogramming originated in the context of wireless sensor network programming and found renewed interest in the context of the Internet of Things and swarm robotics. Macroprogramming shares similar goals (related to programming a system by a global perspective) with multitier programming, choreographic programming, and aggregate computing.
In computer science, macroprogramming is a programming paradigm aimed at expressing the macroscopic, global behaviour of an entire system of agents or computing devices. In macroprogramming, the local programs for the individual components of a distributed system are compiled or interpreted from a macro-program typically expressed by a system-level perspective or in terms of the intended global goal. The aim of macroprogramming approaches is to support expressing the macroscopic interactive behaviour of a whole distributed system of computing devices or agents in a single program, or, similarly, to promote their collective intelligence. It is not to be confused with macros, the mechanism often found in programming languages (like C or Scala) to express substitution rules for program pieces. Macroprogramming originated in the context of wireless sensor network programming and found renewed interest in the context of the Internet of Things and swarm robotics. Macroprogramming shares similar goals (related to programming a system by a global perspective) with multitier programming, choreographic programming, and aggregate computing. class SelfContainedChannel extends AggregateProgram with SensorDefinitions { def isObstacle = sense[Boolean]("obstacle") def isSource = sense[Boolean]("source") def isDestination = sense[Boolean]("target") override def main(): Boolean = branch(isObstacle){ false }{ channel(isSource, isDestination, 5) } def channel(src: Boolean, dest: Boolean, width: Double): Boolean = dilate(distanceTo(src) + distanceTo(dest) V, metric: =>Double): V = rep( (Double.MaxValue, field) ){ dv => mux(src) { (0.0, field) } { minHoodPlus { val (d, v) = nbr { (dv._1, dv._2) } (d + metric, acc(v)) } } }._2 def distanceTo(source: Boolean): Double = G[Double](source, 0, _ + nbrRange(), nbrRange()) def broadcast[V:OB](source: Boolean, field: V): V = G[V](source, field, x=>x, nbrRange()) def distanceBetween(source: Boolean, target: Boolean): Double = broadcast(source, gradient(target)) def dilate(region: Boolean, width: Double): Boolean = gradient(region) What is interesting to note is that the channel function, as well as the functions that are used to implement it, namely distanceTo , distanceBetween , dilate , broadcast etc. can be interpreted not just in terms of the individual behaviour of a device, but rather by a macroscopic perspective. In fact, for instance, distanceTo(s) is used to compute the field of minimum distances from the closest device for which expression s yields true : this is effectively a distributed data structure that is sustained through processing and communication with neighbours, in a self-organising way. Semantically, such functions define a macro-level (or collective) behaviour that yields a macro-level (or collective) data structure. Such macro-level functions/behaviours can be composed together to obtain another more complex macro-level function/behaviours. % function definition doSum :: float (float, int) -> (float, int); doSum(temperature, (sum, count)) { (sum+temperature, count+1) } % functional reactive program logic temperatureRegion = rmap(fun(node){ sense("temperature", node) }, world); sumSignal = rfold(doSum, (0.0, 0), temperatureRegion) avgSignal = smap(fun((sum,count)){ sum / count }, sumSignal) BASE temperatures = Resource.objects.filter(title="temp") results = [temp.GET() for temp in temperatures] avg = sum(results) / len(results) TEMP_THRESHOLD = 24 if avg > TEMP_THRESHOLD: Resource.objects.get(title="fan").PUT("on") SELECT nodeId , temperature WHERE temperature > k FROM sensors SAMPLE PERIOD 5 minutes
Text derived from https://en.wikipedia.org/w/index.php?oldid=1372816102 under CC BY-SA 4.0; modifications have been made.