This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
""" | |
参考URL | |
[1] 蟻コロニー最適化 - Wikipedia https://ja.wikipedia.org/wiki/蟻コロニー最適化 | |
[2] 任意の確率密度分布に従う乱数の生成(von Neumannの棄却法) | Pacocat's Life http://pacocat.com/?p=596 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import wave | |
from scipy import signal | |
""" | |
参考 | |
[1] 波形を見る - 人工知能に関する断創録 http://aidiary.hatenablog.com/entry/20110519/1305808715 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
# 0 <= h <= 179 (色相) OpenCVではmax=179なのでR:0(180),G:60,B:120となる | |
# 0 <= s <= 255 (彩度) 黒や白の値が抽出されるときはこの閾値を大きくする | |
# 0 <= v <= 255 (明度) これが大きいと明るく,小さいと暗い | |
# ここでは青色を抽出するので120±20を閾値とした | |
LOW_COLOR = np.array([100, 75, 75]) | |
HIGH_COLOR = np.array([140, 255, 255]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
class TSP: | |
def __init__(self,path=None,n_gene = 256,n_parent = 10,change_ratio = 0.1): | |
""" 初期化を行う関数 """ | |
self.n_gene = n_gene # 一世代の遺伝子の個数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
from sympy import * | |
from sympy.physics.mechanics import LagrangesMethod, Lagrangian | |
from sympy.physics.mechanics import ReferenceFrame, Particle, Point | |
from sympy.physics.mechanics import dynamicsymbols, kinetic_energy | |
from sympy.utilities.codegen import * | |
if __name__ == "__main__": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 4次ルンゲクッタ法によるロジスティック方程式の解の計算 */ | |
#include <stdio.h> | |
#define K 1000.0 // 個体数のしきい値 | |
#define r 0.9 // 1個体の増加率 | |
#define N_LOOP 10000 // ループ回数 | |
// 積分する関数g(t,N) | |
double g(double t,double N_t){ | |
return r*(K-N_t)*N_t/K; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
from serial.tools import list_ports | |
import time | |
def select_port(): | |
ser = serial.Serial() | |
ser.baudrate = 19200 # ArduinoのSerial.beginで指定した値 | |
ser.timeout = 0.1 # タイムアウトの時間 | |
ports = list_ports.comports() # ポートデータを取得 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! | |
! The simulation of Torricelli's law | |
! | |
program pendulum | |
implicit none | |
real,parameter :: g = 9.80665 ! gravity acceleration | |
real,parameter :: dt = 1e0 ! delta time | |
! initial value of theta and diff_theta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import time | |
import serial | |
import sys | |
""" | |
参考: pyserial公式ドキュメント | |
[1]サイトトップ http://pythonhosted.org/pyserial/ | |
[2]API一覧 http://pythonhosted.org/pyserial/pyserial_api.html | |
[3]イントロダクション http://pythonhosted.org/pyserial/shortintro.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import cv2 | |
import numpy as np | |
import time | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
""" | |
参考URL |
NewerOlder