def fitness(S):
    # first the yield
    marks = 0
    A=st.node_eq_mat(S) # matrix for bar tension
    
    if np.linalg.det(A) == 0: #if the matrix is not invesable say it is a shit structure
        return (0,0,100)
    B = np.linalg.inv(A) #linear alg for A x (tens|R) = Force
    utension = np.dot(B,action_vect(S))#THIS IS THE ACTION VECTOR FOR THE MOMENT 
    uextension = st.ext_vec(simdata.E,simdata.barref,S,utension)

    reactions=3

    Yield= tens_yield_check(S,utension)# Basic braking yield

    #displacement yield
    normtens=list(utension)
    
    for i in xrange(reactions):# getting rid of reactions
        normtens.pop()
    normtens =np.array(normtens)
    n1yield= VW_node1(normtens,uextension,simdata.n1disp,S) #%%timeit =30.8 µs

    #colision Yield

    C=st.node_disp_mat(S) #matrix of node displacements
    if np.linalg.det(C) == 0: #if the matrix is not invesable say it is a shit structure
        return (0,0,100)
    D=np.linalg.inv(C) # solving the  C x dipvars = Evect system
    dispv = np.dot(D,uextension)
    delta= st.listdipslacements(S,dispv)
    cyield= col_yield_check(S,simdata.minP,simdata.maxP,delta)

    
    optyield= abs(simdata.convyield - Yield)/simdata.convyield

    if cyield != 'No colision': #avoid out putting 0 if the cyield is False
        primitiveyield= min([Yield,n1yield,cyield])
    else:
        primitiveyield= min([Yield,n1yield])
    #now the categorization
    
    if primitiveyield <= 8500:
        marks =0
    elif n1yield <= 8500 and Yield > 8500 and cyield > 8500:
        marks =3
    elif primitiveyield > 8500 and Yield < 12000:
        marks = 5
    elif Yield> 12000 :
        marks =7
    else:
        pass
    return (Yield,marks,optyield)
Exemple #2
0
    sorted_pop = [copy.deepcopy(i[0]) for i in fPOP]
    POP = evol.remove_lowest(sorted_pop)
    POP =evol.refill_pop(POP,generation)
    print fPOP[0]
    S = fPOP[0][0] #take the supposetly best structure
    mod_graph(S)
print 'Done'




########################################Yields#################################
print rt.fitness(S)
print S

A=st.node_eq_mat(S) # for n=3 timing is 'good': 3 microsec
B = np.linalg.inv(A) # 100 microsec //
utension = np.dot(B,rt.action_vect(S))
uextension = st.ext_vec(simdata.E,simdata.barref,S,utension)

reactions=3

#Yield stress
#checking for extention stress


Yield= rt.tens_yield_check(S,utension)

#displacement yield
normtens=list(utension)
for i in xrange(reactions): #keeping only the bars