Skip to content

Instantly share code, notes, and snippets.

View iomz's full-sized avatar
❤️‍🔥

Iori Mizutani iomz

❤️‍🔥
  • University of St.Gallen
  • St.Gallen, Switzerland
  • 22:20 (UTC +02:00)
  • X @iomz
View GitHub Profile
@iomz
iomz / mas.md
Last active July 29, 2021 20:35

Terminology and Tooling in Mutli-agent System (MAS)

MAS is a computerized system composed of multiple interacting intelligent agents to solve problems that cannot be solved by a monolithic approach.

The definition of intelligent agents varies between different approaches such as methodic, functional, procedural approaches, algorithmic search, or reinforcement learning.

In this note, I attempt to summarize the terminology and tooling used in one of the MAS approaches; procedural reasoning systems (PRS) based on the belief-desire-intention (BDI) model.

AgentSpeak

AgentSpeak [1] is a programming language to formalize BDI architecture for (cognitive) autonomous agents as an abstraction of one of the implemented PRS, and falls in the logic programming paradigm with horn-clauses.

@iomz
iomz / sfs-hw-grade-extractor.py
Last active April 25, 2016 01:45
For extracting grade from comments in SFC-SFS assignment page
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from HTMLParser import HTMLParser
from re import match, search
from sys import exit, stdout
import csv
class HWParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
# download http://scanningtheearth.org/data/[0-9]+
wget -q -O - http://scanningtheearth.org/data | grep "href=\"[0-9]\+\"" | sed "s/^.*href=\"//g" | sed "s/\".*$//g" | xargs -I {} wget -O {}.csv http://scanningtheearth.org/data/{}
## 対象のhtmlをダウンロードして、stdoutからpipeする
#wget -q -O - http://scanningtheearth.org/data |
#
## 数字のみを含むhrefがある行をまず抽出して、その前後をトリムする
#grep "href=\"[0-9]\+\"" | sed "s/^.*href=\"//g" | sed "s/\".*$//g" |
#
## できた数字の列からurlとファイル名をして出力
@iomz
iomz / transAccelsToAngles.js
Last active August 29, 2015 14:16
accelXY to double servo angles (for Node-RED demo)
/* Parse a string received as MQTT message to a JSON object */
var data = JSON.parse(msg.payload);
/* Extrace attributes stored in the JSON */
var accelX = data.accelX;
var accelY = data.accelY;
/* Compute the Theta and Phi from Acceleration along x/y axis */
var theta = - (Math.asin(accelY));
var phi = Math.asin(accelX/Math.cos(theta));
[{"id":"20ea5e9c.df15a2","type":"mqtt-broker","broker":"lain.sfc.wide.ad.jp","port":"1883","clientid":""},{"id":"f82418fa.07dbe8","type":"mqtt in","name":"Subscriber","topic":"gif-iot/data/","broker":"20ea5e9c.df15a2","x":138.5,"y":80,"z":"55f994be.aa066c","wires":[["bd027790.42fd88"]]},{"id":"9419ee6a.6be61","type":"mqtt out","name":"Publisher","topic":"gif-iot/cmd/<OpenBlocks MAC address>/servo","qos":"0","retain":"false","broker":"20ea5e9c.df15a2","x":537.5,"y":80,"z":"55f994be.aa066c","wires":[]},{"id":"bd027790.42fd88","type":"function","name":"2*objectTemp >> angle","func":"return {\n\tpayload: {\n\t\tid: 0,\n\t\tangle: 2*JSON.parse(msg.payload).objectTemp\n\t}\n};","outputs":1,"x":341,"y":80,"z":"55f994be.aa066c","wires":[["9419ee6a.6be61","eb9a908d.14657"]]},{"id":"eb9a908d.14657","type":"debug","name":"","active":true,"console":"false","complete":"false","x":548,"y":120,"z":"55f994be.aa066c","wires":[]}]
@iomz
iomz / gif-iot-demo.json
Last active May 2, 2019 01:38
gif-iot-demo for Node-RED
[{"id":"20ea5e9c.df15a2","type":"mqtt-broker","broker":"lain.sfc.wide.ad.jp","port":"1883","clientid":""},{"id":"e6455180.19bab","type":"function","name":"pwm1","func":"return {\n\tpayload: {\n\t\tid: 1,\n\t\tangle: Math.floor(msg.payload.pwm1)\n\t}\n};","outputs":1,"x":510,"y":80,"z":"8c26fbba.73d908","wires":[["5df8adb5.a20754","bc0f8744.43f078"]]},{"id":"b0f29aba.4f0d68","type":"function","name":"pwm0","func":"return {\n\tpayload: {\n\t\tid: 0,\n\t\tangle: Math.floor(msg.payload.pwm0)\n\t}\n};","outputs":1,"x":510,"y":40,"z":"8c26fbba.73d908","wires":[["5df8adb5.a20754","bc0f8744.43f078"]]},{"id":"bc0f8744.43f078","type":"mqtt out","name":"openblocks14/servo","topic":"gif-iot/cmd/78:4B:87:AA:9A:74/servo","qos":"0","retain":"false","broker":"20ea5e9c.df15a2","x":811,"y":80,"z":"8c26fbba.73d908","wires":[]},{"id":"df42383c.20bdc8","type":"mqtt in","name":"gif-iot/data/78:A5:04:8C:29:BA","topic":"gif-iot/data/78:A5:04:8C:29:BA","broker":"20ea5e9c.df15a2","x":139.5,"y":40,"z":"8c26fbba.73d908","wires":[["91da0
@iomz
iomz / gist:a0d5f86eceee39e110c0
Created January 25, 2015 07:46
Node-RED: door-demo
[{"id":"68bf71d.f97409","type":"mongodb","hostname":"YOURHOST","port":"00000","db":"YOUR_DB","name":"IBMCloud MongoDB"},{"id":"f8a512bc.075af","type":"websocket-listener","path":"/ws/door","wholemsg":"false"},{"id":"bd385f48.42c7a","type":"debug","name":"device data","active":true,"complete":"true","x":290.83332443237305,"y":147.6666717529297,"z":"5cf8236b.a307dc","wires":[]},{"id":"731fcbfd.8ce034","type":"websocket out","name":"/ws/door","server":"f8a512bc.075af","x":757,"y":183,"z":"5cf8236b.a307dc","wires":[]},{"id":"443b3381.bbc4cc","type":"ibmiot in","authentication":"quickstart","apiKey":"","inputType":"evt","deviceId":"784b87a33025","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT App In","service":"quickstart","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","x":95,"y":148,"z":"5cf8236b.a307dc","wires":[["bd385f48.42c7a","136e1892.ec91e7"]]},{"id":"136e1892.ec91e7","type":"function","name":
@iomz
iomz / rename_photos_like_dropbox.sh
Last active August 29, 2015 13:58
Rename photos in the specified directory like Dropbox's "Camera Upload" based on last modified dates
#!/bin/sh
ABSPATH=$(cd "$1"; pwd)
COUNT=0
if [ ! -e $ABSPATH ]; then
echo "*** $ABSPATH doesn't exist! ***"
exit
fi
for F in $ABSPATH/*; do
@iomz
iomz / keio_gpa.py
Created April 4, 2014 01:37
Grade report parser for Keio University web system
#!/usr/bin/python
# -*- coding: utf-8 -*-
from HTMLParser import HTMLParser
from re import match
Grades = {
u'\uff21': 'A',
u'\uff22': 'B',
u'\uff23': 'C',
u'\uff30': 'P'
@iomz
iomz / duplicate_dynamodb_table.py
Created March 26, 2014 00:21
Duplicate a table in AWS DynamoDB (for renaming or manual fix)
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
print 'Usage: %s <source_table_name> <destination_table_name>' % sys.argv[0]