Home > other >  Calculation process optimization, pycharm shows that ran out of the Windows 7 system input, is how t
Calculation process optimization, pycharm shows that ran out of the Windows 7 system input, is how t

Time:09-28

First thanked everyone a great god,
Calculation process optimization, pycharm shows that ran out of the Windows 7 system input, how can I solve, haven't found, found a day cry
Add, I joined the import dill as pickling, without complains not pickled lambda, join after complains ran out of the input.
But I look at the input in the input is not my own program, seems to be multi-threaded own startup input, collapse,,,

 import multiprocessing 
The import numpy as np
The import pandas as pd
The import copy
The import time
The from scipy. Optimize the import minimize
The import dill as pickled


# objective function:
Def sq (b) :
Global x, y
Return (np) dot ((np) dot (x, b) - (y - rf)), (np) dot (x, b) - (y - rf)), T))

Def func () :
Return sq

# constraints, including equality constraints and inequality constraints
Def con () :
Cons=({' type ':' ineq 'and' fun ': lambda b: b [0]},
{' type ':' ineq 'and' fun ': lambda b: b [1]},
{' type ':' ineq 'and' fun ': lambda b: b [2]},
{' type ':' ineq 'and' fun ': lambda b: b [3]},
{' type ':' ineq 'and' fun ': lambda b: b [4]},
{' type ':' eq 'and' fun ': lambda b: [0] b + b + [1] [2] - 1 b},
{' type ':' eq 'and' fun ': lambda b: b + b [4] - [3] 1},)
Return cons


Def get_res (func, b0, cons) :
Res=minimize (func (), b0, method='SLSQP', constraints=cons)
Return (res)

Def get_result2 (res) :
If Max (res. [3] : x)==res. X [0] :
A='x1'
Elif Max (res. [3] : x)==res. X [1] :
A='x2
The else:
A='x3'
If res. [3] - res. X x [4] & gt; 0.2:
B='y1
Elif res. [4] - res. X x [3] & gt; 0.2:
B='y2'
The else:
B='y3'
Return (a + b)

Def get_result3 (y0) :
Global y
Global b0
Global cons
Y=copy. Deepcopy (y0)
Res=minimize (func (), b0, method='SLSQP', constraints=cons)
Return (get_result2 (res))


# for below process content

Def func_m (I, data_all, y, cons, b0, out_all) :
Print (3)
Data=HTTP://https://bbs.csdn.net/topics/data_all.loc/I - 59: I, :
Data. The replace (to_replace='-', value=https://bbs.csdn.net/topics/np.nan, inplace=True)
Data. Dropna (axis=1, inplace=True)
Rf=data. Loc [: 'GC007]
Del data [' GC007]
Y_all=data [data columns [1: - 6]]
X=data [data columns [- 6:]]
[x] 'c'=1
X=[' 000001. SH '] x [' 000001. SH '] - rf
Out=pd. DataFrame ()
Out [' code ']=y_all. Columns
Print (' XXXXXXXXXXX ')
Out [' result ']=[get_result3 (y0) for y0 y_all. In T.v alues]
Out_num=pd. DataFrame ()
Out_num [' mix_type]=list (set) (out) the result)
Out_num [' num ']=[out [r]. Out. The result==t shape [0] for t in out_num [' mix_type]]
Out_num. Sort_values (' mix_type, inplace=True)
Out_num. Reset_index (drop=True, inplace=True)
Out_num. To_excel (' C:/Users//'T/Desktop/results + STR (I) +' XLSX ')
# out_all [STR (I)]=out_num


Data_all=pd. Read_excel (' C:/Users/T/Desktop/classification. XLSX ', sheet_name=3)

If __name__=="__main__" :
Y=[]
X=pd. DataFrame ()
Cons=con ()
B0=[1/3, 1/3, 1/3, 0.5, 0.5, 0.5, 0.5]
Run_list=list (range (data_all shape [0] 1, 59, 1))
Run_list run_zip_list=zip (run_list [0:47], [47:47 * 2], run_list couldest [47 * * 3],
3:47 run_list [47 * * 4], run_list [47 * when * 5), run_list [47 * publicans * 6],
Run_list 6:47 [47 * * 7], run_list [47 * * 8] utensils, run_list [* * 9] she was 47,
Run_list [47 * it * 10], run_list [11] 47 * when *, run_list then gathered [47 * * 12],
Run_list [13] 47 * "*, run_list [14] 47 * shouldest be *, run_list 47 whoever eats * * [15],
)
# missing so I=59, need for additional
Print (' xx ')
T1=time. Time ()
Out_all=multiprocessing. Manager (.) dict () # main process and the child to share this dictionary

I2 for i1, i2, i3, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15 run_zip_list in:
P1=multiprocessing. Process (target=func_m, args=(i1, data_all, y, cons, b0, out_all,))
# p2=multiprocess. Process (target=func_m, args=(i2, data_all, y, cons, b0, out_all, x,))
# p3=multiprocess. Process (target=func_m, args=(i3, data_all, y, cons, b0, out_all, x,))
"'
P4=multiprocess. Process (target=func_m, args=(i2, data_all, y, cons, b0, out_all))
P5=multiprocess. Process (target=func_m, args=(i5, data_all, y, cons, b0, out_all))
P6=multiprocess. Process (target=func_m, args=(i6, data_all, y, cons, b0, out_all))
P7=multiprocess. Process (target=func_m, args=(i7, data_all, y, cons, b0, out_all))
P8=multiprocess. Process (target=func_m, args=(i8, data_all, y, cons, b0, out_all))
P9=multiprocess. Process (target=func_m, args=(i9, data_all, y, cons, b0, out_all))
P10=multiprocess. Process (target=func_m, args=(i10, data_all, y, cons, b0, out_all))
P11=multiprocess. Process (target=func_m, args=(i11, data_all, y, cons, b0, out_all))
P12=multiprocess. Process (target=func_m, args=(i12, data_all, y, cons, b0, out_all))
P13=multiprocess. Process (target=func_m, args=(i13 data_all, y, cons, b0, out_all))
P14=multiprocess. Process (target=func_m, args=(i14, data_all, y, cons, b0, out_all))
P15=multiprocess. Process (target=func_m, args=(i15, data_all, y, cons, b0, out_all))
"'
T1=time. Time ()
P1. The start ()
P1. The join ()
"'
For p in (p1, p2, p3, p4, p5, p6 and p7, p8, p9, p10, p11, p12, p13, p14, p15) :
P. tart ()
nullnullnullnullnullnullnullnull
  • Related