Vector Lovers

よい

ProductName Vector Lovers
Vector Lovers
Soma / ¥ 1,851 (2004-09-14)


このくらい寒い夜にはいい感じのチル

ソファリにいった

初広見公園。古墳とか屋敷とかがある。あと、籠があって担げるようになっている。ゼンマイ侍好きの子どもたちはやたら喜んでいた。

1263475180 1263475216

併設されている公園。

1263475198 1263475210

さんざん行ってみたいと言ってたU隊長だが「これだったら、中央公園でいいわ」とぼそっとつぶやいたのは聞き逃さなかった。(離れた場所に遊び場あったけど)遊具的には大渕公園のが楽しいんじゃないか。きわだ路で蕎麦食えるし。

公園で遊んだら、そのまま降りて行って、吉原のsofariiでランチ。

つけナポに、五穀米ごはんを投入してスープを食べきるという技が最高でした。旨いですマジ。おすすめ。

1263475174 1263475204

U隊長の食べてたスープランチとガトーショコラ。

1263475192 1263475186

尚、つけナポの属性はつけ麺なので、僕の中ではラーメン的な扱いです。

それにしてもつけナポの公式サイトはあんまやるきないのかな(blog更新してないし)。やっつけナポリタンか?

迷路のやつをHaskellで解いてみる(未完)

実際にやってみると位置を記録すんのに手間取ったり(pythonはenumarateがあるので楽)とか、リストモナドの使い方をちゃんと理解してなかったりとかで、終わらん。

import List

maze = ["**************************",
        "*S* *                    *",
        "* * *  *  *************  *",
        "* *   *    ************  *",
        "*    *                   *",
        "************** ***********",
        "*                        *",
        "** ***********************",
        "*      *              G  *",
        "*  *      *********** *  *",
        "*    *        ******* *  *",
        "*       *                *",
        "**************************"]

type Pos = (Int,Int)
type Path = [Pos]

findPos :: [String] -> Char -> Pos
findPos maze c = 
    let y = findY maze c 0 
        x = findX (maze!!y) c 0
    in (x,y)
    where
      findY :: [String] -> Char -> Int -> Int
      findY [] _ _     = error (c : " not found\n")
      findY (x:xs) c n | c `elem` x = n
                       | otherwise  = findY xs c (n+1)
      findX :: String -> Char -> Int -> Int
      findX (x:xs) c n | x == c     = n
                       | otherwise  = findX xs c (n+1)

start = findPos maze 'S'
goal  = findPos maze 'G'

canMove :: [String] -> Pos -> Bool
canMove maze (x,y) | maze !! y !! x == '*' = False
                   | otherwise             = True

enableSteps :: [String] -> [Pos] -> [Pos]
enableSteps maze path@((x,y):_) = filter (canMove maze) [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]

getAllPaths :: [String] -> Pos -> [Path]
getAllPaths maze start = [[start]] >>= toward
                         where 
                           toward :: Path -> [Path]
                           toward path
                                  | not.null $ moves = map (:path) moves >>= toward
                                  | otherwise = [path]
                                  where 
                                    moves = enableSteps maze path

結局、リストモナドをどうつなげていったらいいのかというところでつまづいている。あと[String]っていう型じゃなくてMazeとかいう型にしといた方がよかったかも。

「アブダクション」を読んだ

年末からイノベーションに関する本をいろいろ読んでいたのだけどその流れでたどり着いた。これは名著でしょう。年明け早々いい本にあえてラッキーだ。

創薬ではある種の論理に基づいて、化合物の探索、合成を行う事になるわけだが、それはいわゆる定量的構造活性相関解析(QSAR)、定量的物性構造相関解析(QSPR)さらには動態特性(QSPkR)というような構造(やその特性)と変換したいパラメータの関連性からある程度論理的に探索対象を決定していくのが主流だ。ただし、このようなやり方では、ある意味推測が容易な答えしか出さないことが多いし、正しい答えの出るであろう予測の範囲もごく限られてしまうことが多い。予測範囲以外のものをアウトライヤーと呼び、予測の範囲外としてしまうが、実際にはそういう化合物の答えが知りたかったりするので常に苦労する。

我々は帰納的な推論から出発して、その枠を限りなく広げていきたいのだが、それはなかなか難しいし、実際問題として帰納の枠のなかでは無理ではないかと考えている。局所的な予測モデルを束ねてより大きい問題に対応すればよいのではないかという考え方もあるのだけど、それは結局、問題を小さくしておいてわかることの中だけで理解するということなのであまり上手くいかない。さらに、新規性の高い化合物にジャンプする(いわゆるホッピング)というものはQSARのような帰納的な推論方法からでは成し遂げることは非常に難しい。(ファーマコフォア探索は前提条件決め打ちだからなぁ、、)

いろいろ考えるに、結局創薬においては、それぞれのプロジェクトで(尤もらしい)仮説を構築できる力というものが一番重要なのだろうと考えているのだけど、本書はそういった仮説構築の論理というものに対して、帰納や演繹との対比をしながら明確に述べているので、QSARの論理的な限界はどこら辺なのかとか、より良い仮説を出すためにはどういう思考サイクルをまわせばいいかとかのヒントが満載だ。

ProductName アブダクション―仮説と発見の論理
米盛 裕二
勁草書房 / ¥ 2,940 ()
在庫あり。

さて、本書では科学的方法には帰納法の他に仮説の提案が必要であり、仮説の提案なしには帰納法を正しく用いることは出来ないと述べていて、その通りだと思う。しかし一方で、仮説は検討中の問題の現象についてもっともらしい、もっとも理にかなった説明を与えるものでなくてはならないとあるように、確度の高い仮説を構築するためには、高い分析能力や論理力、数多くの解析方法やマイニング方法への知識があってはじめて仮説提案力が高まるのだろうなと思うのだ。

  • 探求の論理学は思惟の動力学、論証の論理学は思惟の静力学
  • 分析的推論は前提の中にすでに含まれていること以上のことを結論をして導きだすことはできない
  • 現実の人間の思考においては、諸概念の意味は類比やモデルやメタファーなどによって絶えず修正され拡張されている
  • アブダクションとは説明仮説を形成する方法
  • 演繹、帰納、アブダクション
  • 発見のタイプ
    • ということの発見
    • なぜかの発見
  • 科学的仮説や理論は、観察された事実から導かれるのではなく、観察された事実を説明するために発明されるものである
  • アブダクションは遡及推論
  • 未知について推論するという目的にとって演繹は役に立たない
  • 仮説は検討中の問題の現象についてもっともらしい、もっとも理にかなった説明を与えるものでなくてはならない
  • 創造的想像力による推測の飛躍
  • アブダクションは理論を求める、帰納は事実を追及する
  • 単純帰納と質的帰納
  • 科学的方法には帰納法の他に仮説の提案が必要であり、仮説の提案なしには帰納法を正しく用いることは出来ない

HDBCとHDBC-SQLite3を入れた

21章は短い

ProductName Real World Haskell―実戦で学ぶ関数型言語プログラミング
Bryan O'Sullivan,John Goerzen,Don Stewart
オライリージャパン / ¥ 3,990 ()
在庫あり。

HDBC-2.1.0だと下のようなエラーがずらずらでるのでgitで入れる。

Database/HDBC/SqlValue.hs:585:9:
    Duplicate instance declarations:
      instance Typeable Day
        -- Defined at Database/HDBC/SqlValue.hs:585:9-20
      instance Typeable Day
        -- Defined in time-1.1.4:Data.Time.Calendar.Days

使ってみる

Prelude> :m Database.HDBC Database.HDBC.Sqlite3
Prelude Database.HDBC Database.HDBC.Sqlite3> conn <- connectSqlite3 "drkcore.db"
Prelude Database.HDBC Database.HDBC.Sqlite3> getTables conn
["entries","entry_tags","roles","tags","user_roles","users"]
Prelude Database.HDBC Database.HDBC.Sqlite3> \
quickQuery' conn "select title from entries where pubdate > '2010-01-01'" []
[[SqlByteString "\229\155\155\229\173\163\230\161\156\227\129\174\232\138\ ...

これをutf8で出力したいのでWIKIも読んどく。

迷路解いた(A*で)

A*で解いてみた。距離はマンハッタン使った。

迷路やった

maze = ["**************************",
        "*S* *                    *",
        "* * *  *  *************  *",
        "* *   *    ************  *",
        "*    *                   *",
        "************** ***********",
        "*                        *",
        "** ***********************",
        "*      *              G  *",
        "*  *      *********** *  *",
        "*    *        ******* *  *",
        "*       *                *",
        "**************************"]
start    = ()
goal     = () 
max = len(maze) + len(maze[0])

for (h,line) in enumerate(maze):
    for (w,word) in enumerate(line):
        if   word == 'S': start = (h,w)
        elif word == 'G': goal  = (h,w)

checked = [start]
sol = [start]

def add_route(r):
    (h,w) = r[-1]
    cand = [c for c in [(h+1,w),(h-1,w),(h,w+1),(h,w-1)] if c not in checked and not_wall(c)]
    if len(cand) == 0:
        return r[:-1]
    else:
        sol = (); cost = max
        for c in cand:
            c_cost = calc_cost(c)
            if c_cost < cost:
                cost = c_cost
                sol = c
        r.append(sol)
        checked.append(sol)
        return r

def not_wall(p): (h,w) = p; return  maze[h][w] != '*'
def calc_cost(p): return (abs(goal[0]-p[0]) + abs(goal[1]-p[1]))
def check_goal(sol): return sol[-1] != goal

def draw_sol(sol):
    solved_maze = ''
    for (h,line) in enumerate(maze):
        for (w,word) in enumerate(line):
            if (h,w) in sol[1:-1]:
                solved_maze += '$'
            else:
                solved_maze += word
        solved_maze += '\n'
    return solved_maze

while check_goal(sol): sol = add_route(sol)
print draw_sol(sol)

実行結果

$ python maze_aster.py
**************************
*S* * $$$                *
*$* *$$*$ *************  *
*$* $$* $  ************  *
*$$$$*  $$$$$$$          *
**************$***********
* $$$$$$$$$$$$$          *
**$***********************
* $$$$$*$$$$$$$$$$$$$$G  *
*  *  $$$ *********** *  *
*    *        ******* *  *
*       *                *
**************************

迷路やった

この問題

maze = ["**************************",
        "*S* *                    *",
        "* * *  *  *************  *",
        "* *   *    ************  *",
        "*    *                   *",
        "************** ***********",
        "*                        *",
        "** ***********************",
        "*      *              G  *",
        "*  *      *********** *  *",
        "*    *        ******* *  *",
        "*       *                *",
        "**************************"]
solution = []
start    = ()
goal     = () 
max = (len(maze)-2) * (len(maze[0])-2)

for (h,line) in enumerate(maze):
    for (w,word) in enumerate(line):
        if   word == 'S': start = (h,w)
        elif word == 'G': goal  = (h,w)

checked = [start]

def add_route(sols):
    newroute = []
    for sol in sols:
        (h,w) = sol[-1]
        if ((h+1,w) not in checked) and maze[h+1][w] != '*':
            nr = list(sol)
            nr.append((h+1,w))
            checked.append((h+1,w))
            newroute.append(nr)
        if ((h-1,w) not in checked) and maze[h-1][w] != '*':
            nr = list(sol)
            nr.append((h-1,w))
            checked.append((h-1,w))
            newroute.append(nr)
        if ((h,w+1) not in checked) and maze[h][w+1] != '*':
            nr = list(sol)
            nr.append((h,w+1))
            checked.append((h,w+1))
            newroute.append(nr)
        if ((h,w-1) not in checked) and maze[h][w-1] != '*':
            nr = list(sol)
            nr.append((h,w-1))
            checked.append((h,w-1))
            newroute.append(nr)
    return newroute

def check_goal(sols):
    for sol in sols:
        if sol[-1] == goal:
            print draw_sol(sol)
            exit

def draw_sol(sol):
    solved_maze = ''
    for (h,line) in enumerate(maze):
        for (w,word) in enumerate(line):
            if (h,w) in sol[1:-1]:
                solved_maze += '$'
            else:
                solved_maze += word
        solved_maze += '\n'
    return solved_maze

sols = [[start]]

for i in range(max):
    sols = add_route(sols)
    check_goal(sols)

ちょっと長い

$ python maze.py
**************************
*S* *$$$$                *
*$* *$ *$ *************  *
*$*$$$* $  ************  *
*$$$ *  $$$$$$$          *
**************$***********
* $$$$$$$$$$$$$          *
**$***********************
* $$$  *$$$$$$$$$$$$$$G  *
*  *$$$$$ *********** *  *
*    *        ******* *  *
*       *                *
**************************

ダイクストラ法とA*アルゴリズムの違いをあとで読む

Real World Haskell 20章

20.5はパイプ

ProductName Real World Haskell―実戦で学ぶ関数型言語プログラミング
Bryan O'Sullivan,John Goerzen,Don Stewart
オライリージャパン / ¥ 3,990 ()
在庫あり。

理解はあやしいがとりあえず写経して動くとこまで。

*RunProcessSimple> runIO $ "ls /Users/kzfm/haskell" -|- "grep '.hs~'" -|- "tr a-z A-Z"
BARCODE.HS~
LOGGER.HS~
PNM.HS~
PARSE.HS~
RANDOM.HS~
RUNPROCESSSIMPLE.HS~

「アイデアスポッティング」を読んだ

散文的なのでサラッと読んだというか眺めたというか。

ProductName アイデア スポッティング
サム・ハリソン
二見書房 / ¥ 1,575 ()
在庫あり。

アイデアスポッティングとは、『探索+関連づけ』のことである。

  • わかりきったことや決まりきったことを超える
  • 探索 -> 自由 -> 小休止 -> 受容 -> 活用
  • 正しい展望とはエンドユーザーの感情的な受け止め方をとらえること
  • 本や雑誌を開けば心も開く

Evaluation of Drug Candidates for Preclinical Development

新しい本が出るらしい。

  • Cover drug transporters, cytochrome P-450 and drug-drug interactions, plasma protein binding, stability, drug formulation, preclinical safety assessment, toxicology, and toxicokinetics
  • Address developability issues that challenge pharma companies, moving beyond isolated experimental results
  • Reveal connections between the key scientific areas that are critical for successful drug discovery and development
  • Inspire forward-thinking strategies and decision-making processes in preclinical evaluation to maximize the potential of drug candidates to progress through development efficiently and meet the increasing demands of the marketplace

Evaluation of Drug Candidates for Preclinical Development serves as an introductory reference for those new to the pharmaceutical industry and drug discovery in particular. It is especially well suited for scientists and management teams in small- to mid-sized pharmaceutical companies, as well as academic researchers and graduate students concerned with the practical aspects related to the evaluation of drug developability.