Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial_data指定時のsimulator実行失敗 #32

Closed
rarai01 opened this issue Sep 13, 2021 · 1 comment
Closed

initial_data指定時のsimulator実行失敗 #32

rarai01 opened this issue Sep 13, 2021 · 1 comment

Comments

@rarai01
Copy link

rarai01 commented Sep 13, 2021

PHYSBO V.1.0.1

physbo.search.discrete.policyでinitial_dataを指定した際、policy.random_searchでsimulatorを用いると下記エラーが発生します。
TypeError: only integer scalar arrays can be converted to a scalar index

通常、ndarray型のpolicy.actionsがlist型になっており、policy.actionsをndarrayにキャストするとエラーが回避できました。
ソースを確認したところ、policy.__init__が原因であると思われます。
ご確認のほどよろしくお願いいたします。

Code
import physbo
import numpy as np

def load_data():
    A =  np.asarray(np.loadtxt('./example.csv',skiprows=1, delimiter=',') )
    X = A[:,0:3]
    t  = -A[:,3]
    return X, t

X, t = load_data()
X = physbo.misc.centering(X)

class simulator:
    def __init__(self, t):
        self.t = t
    
    def __call__(self, action):
        return -self.t[action]

import random
random.seed(0)
calculated_ids = random.sample(range(t.size), 20)
t_initial = t[calculated_ids]

policy = physbo.search.discrete.policy(test_X=X, initial_data=[calculated_ids, t_initial])
actions = policy.random_search(max_num_probes=10, simulator=simulator(t))
@yomichi
Copy link
Contributor

yomichi commented Mar 11, 2022

ご報告、どうもありがとうございます、遅くなって申し訳ありません。
修正しました (#34, develop branch)。
他の微修正と合わせて 1.0.2 を早めに出します。

@yomichi yomichi closed this as completed Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants