<commit_before>from __future__ import print_function, division
import numpy as np
import pylab

from smt.problems import CantileverBeam, Carre, ReducedProblem, RobotArm, Rosenbrock
from smt.problems import TensorProduct, TorsionVibration, WaterFlow, WeldedBeam, WingWeight
from smt.sampling import LHS, Random, FullFactorial
from smt.ls import LS
from smt.pa2 import PA2
from smt.kpls import KPLS
from smt.idw import IDW
from smt.rmts import RMTS
from smt.rmtb import RMTB


# prob = Carre(ndim=4)
prob = TensorProduct(ndim=3, func='tanh', width=5.)
prob = WeldedBeam(ndim=3)
prob = CantileverBeam(ndim=3)
prob = Rosenbrock(ndim=4)
# prob = RobotArm(ndim=4)


sampling = LHS(xlimits=prob.xlimits)
sampling = FullFactorial(xlimits=prob.xlimits, clip=True)
# sampling = Random(xlimits=prob.xlimits)


ndim = prob.options['ndim']

# sm = RMTS({'name':'RMTS','num_elem':[4]*ndim, 'smoothness':[1.0]*ndim,
#     'xlimits':prob.xlimits, 'approx_norm': 4, 'min_energy': False,
#     'reg_dv': 1e-10, 'reg_cons': 1e-10, 'save_solution': False,
#     'mg_factors': [4], 'solver': 'krylov-lu', 'max_nln_iter': 0,
#     'line_search': 'backtracking', 'max_print_depth': 5,
# }, {})
sm = RMTB({'name':'RMTB', 'order':[3]*ndim, 'num_ctrl_pts':[10]*ndim, 'xlimits':prob.xlimits,
    'max_nln_iter': 10, 'max_print_depth': 5, 'min_energy': False, 'save_solution': False,
    'line_search': 'null', 'use_mtx_free': False})
# sm = IDW({'name':'IDW'},{'global':False})
# sm = KPLS({'name':'KRG', 'n_comp':ndim, 'theta0': [1e-2]*ndim},{})

nt = 10000 * ndim
ne = 100 * ndim

np.random.seed(0)
xt = sampling(nt)
yt = prob(xt)

np.random.seed(1)
xe = sampling(ne)
ye = prob(xe)

sm.add_training_pts('exact', xt, yt)
sm.train()

print(sm.compute_rms_error())
print(sm.compute_rms_error(xe, ye))

nplot = 50<commit_msg>Edits to run_plot<commit_after>from __future__ import print_function, division
import numpy as np
import pylab

from smt.problems import CantileverBeam, Carre, ReducedProblem, RobotArm, Rosenbrock
from smt.problems import TensorProduct, TorsionVibration, WaterFlow, WeldedBeam, WingWeight
from smt.sampling import LHS, Random, FullFactorial
from smt.ls import LS
from smt.pa2 import PA2
from smt.kpls import KPLS
from smt.idw import IDW
from smt.rmts import RMTS
from smt.rmtb import RMTB


# prob = Carre(ndim=4)
prob = TensorProduct(ndim=3, func='tanh', width=5.)
prob = WeldedBeam(ndim=3)
prob = CantileverBeam(ndim=3)
prob = Rosenbrock(ndim=4)
# prob = RobotArm(ndim=4)


sampling = LHS(xlimits=prob.xlimits)
sampling = FullFactorial(xlimits=prob.xlimits, clip=True)
# sampling = Random(xlimits=prob.xlimits)


ndim = prob.options['ndim']

# sm = RMTS({'name':'RMTS','num_elem':[4]*ndim, 'smoothness':[1.0]*ndim,
#     'xlimits':prob.xlimits, 'approx_norm': 4, 'min_energy': False,
#     'reg_dv': 1e-10, 'reg_cons': 1e-10, 'save_solution': False,
#     'mg_factors': [4], 'solver': 'krylov-lu', 'max_nln_iter': 0,
#     'line_search': 'backtracking', 'max_print_depth': 5,
# }, {})
sm = RMTB({'name':'RMTB', 'order':[3]*ndim, 'num_ctrl_pts':[10]*ndim, 'xlimits':prob.xlimits,
    'max_nln_iter': 10, 'max_print_depth': 5, 'min_energy': False, 'save_solution': False,
    'line_search': 'null'})
# sm = IDW({'name':'IDW'},{'global':False})
# sm = KPLS({'name':'KRG', 'n_comp':ndim, 'theta0': [1e-2]*ndim},{})

nt = 10000 * ndim
ne = 100 * ndim

np.random.seed(0)
xt = sampling(nt)
yt = prob(xt)

np.random.seed(1)
xe = sampling(ne)
ye = prob(xe)

sm.add_training_pts('exact', xt, yt)
sm.train()

print(sm.compute_rms_error())
print(sm.compute_rms_error(xe, ye))

nplot = 50
{'fraction_non_alphanumeric': 0.17408340330254687, 'fraction_numerical': 0.02406940945983767, 'mean_word_length': 5.99412915851272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1263799', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1462, 'n_words': 305}