Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go言語でシミュレーション用のシンプルなフレームワークStageをつくった/Fukuokago...

Go言語でシミュレーション用のシンプルなフレームワークStageをつくった/Fukuokago Stage

Fukuoka.go#16 (オンライン開催)
https://fukuokago.connpass.com/event/180414/

monochromegane

July 14, 2020
Tweet

More Decks by monochromegane

Other Decks in Technology

Transcript

  1. ࡾ୐༔հ / Pepabo R&D Institute, GMO Pepabo, Inc. 2020.07.14 Fukuoka.go#16

    GoݴޠͰγϛϡϨʔγϣϯ༻ͷ γϯϓϧͳϑϨʔϜϫʔΫ StageΛͭͬͨ͘
  2. 6 ίϯϐϡʔλγϛϡϨʔγϣϯ Arm0 Arm1 Arm2 User(s) System ଴ͪߦྻ ଟ࿹όϯσ Οοτ໰୊

    ౸ணաఔʹϙΞιϯ෼෍ɺαʔϏεաఔʹࢦ਺ ෼෍Λద༻ͨ͠଴ͪߦྻϞσϧͷγϛϡϨʔ γϣϯ ར༻ऀͷᅂ޷͔Β੒Δ঎඼ʹର͢Δ൓Ԡʢใ ुʣΛ͋Δ֬཰෼෍ʹݟཱͯɺظؒதͷྦྷੵใ ुΛ࠷େԽ͢ΔํࡦΛ୳ΔγϛϡϨʔγϣϯ
  3. • γϛϡϨʔγϣϯର৅͸ຖճҟͳΔ͕ɺࣅͨΑ͏ͳॲཧ͸ຖճ࣮૷͍ͯ͠Δ • Ұ࿈ͷॲཧʢධՁର৅ͷɺ͋Δےॻ͖ʹର͢ΔৼΔ෣͍Λෳ਺ճ؍ଌʣ • γϛϡϨʔγϣϯͷฒྻԽ • ਐḿͷ؂ࢹʢϓϩάϨεόʔʣ • ϩάग़ྗ

    • ཚ਺γʔυͷ؅ཧ • →࿦จࠪಡϓϩηεʹ͓͍ͯ࠶࣮ߦͯ͠ಉ݁͡Ռ͕ಘΒΕΔ؀ڥ͸ॏཁ • ݁ՌͷՄࢹԽ 7 ίϯϐϡʔλγϛϡϨʔγϣϯ࣮૷ͷ՝୊
  4. • ཚ਺Λ༻͍ͨίϯϐϡʔλγϛϡϨʔγϣϯʹ൐͏Ұ࿈͔ͭ൥ࡶͳॲཧΛ։ൃ ऀ͔ΒӅṭ͢ΔγϯϓϧͳϑϨʔϜϫʔΫ 10 monochromegane/stage • Ұ࿈ͷॲཧʢධՁର৅ͷɺ͋Δےॻ͖ʹର͢ΔৼΔ෣͍Λෳ਺ճ؍ଌʣ • γϛϡϨʔγϣϯͷฒྻԽ •

    ਐḿͷ؂ࢹʢϓϩάϨεόʔʣ • ϩάग़ྗ • ཚ਺γʔυͷ؅ཧ • ݁ՌͷՄࢹԽ 4UBHF͕ର৅ͱ͢Δൣғ ˎ౎౓ҟͳΔɺධՁର৅ͱےॻ͖ͷΈ Λ࣮૷͢Δ 4UBHF͕ର৅ͱ͠ͳ͍ൣғ ˎγϛϡϨʔγϣϯʹΑͬͯޮՌతͳՄࢹԽ͕ҟͳΔͷͰϩάग़ྗҎ߱͸౎౓࣮૷͕ྑ͍ͱ൑அ
  5. 11 γφϦΦͱΞΫλʔ • StageͰ͸γϛϡϨʔγϣϯΛܶʹྫ͑ͨϝλϑΝʔΛ࠾༻ • Stage = ܶ৔ɺScenario = ୆ຊʢγφϦΦʣɺActor

    = ԋऀ • ։ൃऀ͸ɺҰճͷγϛϡϨʔγϣϯͷ؀ڥͷมԽΛγφϦΦͱɺͦͷ؀ڥʹԠ ͨ͡ԋऀͷৼΔ෣͍ΛίʔυͰ࣮૷͢Δ
  6. γϛϡϨʔγϣϯͷྫ 21 Scenario (Abrupt change) Scenario (Gradual change) Actor (ADWIN)

    Action ({x, mu, sum, W}) • มԽݕग़ͷΞϧΰϦζϜʢADWINʣʹର͢ΔγϛϡϨʔγϣϯ • ࣌ܥྻͷมԽͷ౓߹͍ʢٸܹɺΏͬ͘Γʣʹରͯ͠ΞϧΰϦζϜΛධՁ
  7. γϛϡϨʔγϣϯͷྫʢΞϧΰϦζϜͷ௥Ճʣ 23 Scenario (Abrupt change) Scenario (Gradual change) Actor (ADWIN)

    Actor (ADWIN2) Action ({x, mu, sum, W}) • มԽݕग़ͷΞϧΰϦζϜʢADWINʣʹର͢ΔγϛϡϨʔγϣϯ • ࣌ܥྻͷมԽͷ౓߹͍ʢٸܹɺΏͬ͘Γʣʹରͯ͠ΞϧΰϦζϜΛධՁ
  8. Example of Go (preset template) 29 $ flagen go --dist

    erlang -e k/l --lambda 1.5 -k 1 -v var ( dist string e string lambda float64 k int v bool ) func init() { flag.StringVar(&dist, "dist", "erlang", "usage of dist") flag.StringVar(&e, "e", "k/l", "usage of e") flag.Float64Var(&lambda, "lambda", 1.5, "usage of lambda") flag.IntVar(&k, "k", 1, "usage of k") flag.BoolVar(&v, "v", false, "usage of v") } ίϚϯυϥΠϯΦϓγϣϯ໊͔Βม਺໊Λੜ੒ ίϚϯυϥΠϯΦϓγϣϯ஋͔ΒܕΛਪଌ ࣮ࡍʹ࢖༻͢ΔίϚϯυϥΠϯΦϓγϣϯ͔Β ίϚϯυϥΠϯͷղੳॲཧΛੜ੒
  9. Example of Python (preset template) 30 $ flagen py --dist

    erlang -e k/l --lambda 1.5 -k 1 -v import argparse parser = argparse.ArgumentParser() parser.add_argument("--dist", default="erlang", help="Help of dist") parser.add_argument("-e", default="k/l", help="Help of e") parser.add_argument("--lambda", type=float, default=1.5, help="Help of lambda") parser.add_argument("-k", type=int, default=1, help="Help of k") parser.add_argument("-v", action="store_false", help="Help of v") args = parser.parse_args() ϋϚΓ͕ͪͳ1ZUIPOͷCPPMͷσϑΥϧτ஋ͷઃఆ΋ ϘΠϥʔςϯϓϨʔτͳͷͰେৎ෉
  10. Example of Ruby (preset template) 31 $ flagen rb --dist

    erlang -e k/l --lambda 1.5 -k 1 -v require 'optparse' opts = { dist: 'erlang', e: 'k/l', lambda: 1.5, k: 1, v: false, } OptionParser.new do |op| op.on('--dist [VALUE]', 'Desc of dist') {|v| opts[:dist] = v } op.on('-e [VALUE]', 'Desc of e') {|v| opts[:e] = v } op.on('--lambda [VALUE]', 'Desc of lambda') {|v| opts[:lambda] = v.to_f } op.on('-k [VALUE]', 'Desc of k') {|v| opts[:k] = v.to_i } op.on('-v', 'Desc of v') {|v| opts[:v] = v } op.parse!(ARGV) end
  11. Example of Shell (preset template) 32 $ flagen sh --dist

    erlang -e k/l --lambda 1.5 -k 1 -v E="k/l" K="1" V="FALSE" while getopts e:k:v OPT do case $OPT in "e" ) E="$OPTARG";; "k" ) K="$OPTARG";; "v" ) V="TRUE";; esac done shift `expr $OPTIND - 1` HFUPQUT͸ҰจࣈͷҾ਺͚ͩѻ͑ΔͷͰ௕͍Φϓγϣϯ͸ແࢹ