def check_2PC_abc(Csf): out = [] n = len(Csf) P = Csf[0][0].shape z = sym.zeros(*P) for a in range(n): for b in range(n): for c in range(n): temp = matrix_multiply_elementwise( Csf[a][c], Csf[c][b]) - matrix_multiply_elementwise(Csf[c][c], Csf[a][b]) check = temp.expand().simplify().as_real_imag() out.append(check[0] == z and check[1] == z) return all(out)
def conv(a, b): af = dft(sym.conjugate(a)) bf = dft(b) return idft( matrix_multiply_elementwise( sym.conjugate(af), bf)).expand().simplify()
def backProp(self, prevNodes, goal, learningRate): functionDerivative = (prevNodes * self.weights + self.biases).applyfunc( lambdify(x, self.derivative)) #goal -= self.nodes #WEIGHTS weightChange = prevNodes.T * functionDerivative weightScalar = ((goal - self.nodes).T * prevNodes).T #print(pretty(N(weightChange, precision), use_unicode=True)) #print(pretty(N(weightScalar, precision), use_unicode=True)) weightChange = matrix_multiply_elementwise(weightChange, weightScalar) #print(pretty(N(weightChange, precision), use_unicode=True)) self.weights += weightChange #print(weightChange.shape, self.weights.shape) #BIASES biasChange = functionDerivative #print(biasChange.shape, self.biases.shape) #NODES nodeChange = (self.weights * functionDerivative.T).T
def test_multiplication(): a = ArithmeticOnlyMatrix(( (1, 2), (3, 1), (0, 6), )) b = ArithmeticOnlyMatrix(( (1, 2), (3, 0), )) raises(ShapeError, lambda: b * a) raises(TypeError, lambda: a * {}) c = a * b assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 try: eval('c = a @ b') except SyntaxError: pass else: assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 h = a.multiply_elementwise(c) assert h == matrix_multiply_elementwise(a, c) assert h[0, 0] == 7 assert h[0, 1] == 4 assert h[1, 0] == 18 assert h[1, 1] == 6 assert h[2, 0] == 0 assert h[2, 1] == 0 raises(ShapeError, lambda: a.multiply_elementwise(b)) c = b * Symbol("x") assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == x assert c[0, 1] == 2 * x assert c[1, 0] == 3 * x assert c[1, 1] == 0 c2 = x * b assert c == c2 c = 5 * b assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2 * 5 assert c[1, 0] == 3 * 5 assert c[1, 1] == 0 try: eval('c = 5 @ b') except SyntaxError: pass else: assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2 * 5 assert c[1, 0] == 3 * 5 assert c[1, 1] == 0
def test_multiplication(): a = ArithmeticOnlyMatrix(( (1, 2), (3, 1), (0, 6), )) b = ArithmeticOnlyMatrix(( (1, 2), (3, 0), )) raises(ShapeError, lambda: b*a) raises(TypeError, lambda: a*{}) c = a*b assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 try: eval('c = a @ b') except SyntaxError: pass else: assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 h = a.multiply_elementwise(c) assert h == matrix_multiply_elementwise(a, c) assert h[0, 0] == 7 assert h[0, 1] == 4 assert h[1, 0] == 18 assert h[1, 1] == 6 assert h[2, 0] == 0 assert h[2, 1] == 0 raises(ShapeError, lambda: a.multiply_elementwise(b)) c = b * Symbol("x") assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == x assert c[0, 1] == 2*x assert c[1, 0] == 3*x assert c[1, 1] == 0 c2 = x * b assert c == c2 c = 5 * b assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0 try: eval('c = 5 @ b') except SyntaxError: pass else: assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2*5 assert c[1, 0] == 3*5 assert c[1, 1] == 0
def test_multiplication(): a = ArithmeticOnlyMatrix(( (1, 2), (3, 1), (0, 6), )) b = ArithmeticOnlyMatrix(( (1, 2), (3, 0), )) raises(ShapeError, lambda: b * a) raises(TypeError, lambda: a * {}) c = a * b assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 try: eval('c = a @ b') except SyntaxError: pass else: assert c[0, 0] == 7 assert c[0, 1] == 2 assert c[1, 0] == 6 assert c[1, 1] == 6 assert c[2, 0] == 18 assert c[2, 1] == 0 h = a.multiply_elementwise(c) assert h == matrix_multiply_elementwise(a, c) assert h[0, 0] == 7 assert h[0, 1] == 4 assert h[1, 0] == 18 assert h[1, 1] == 6 assert h[2, 0] == 0 assert h[2, 1] == 0 raises(ShapeError, lambda: a.multiply_elementwise(b)) c = b * Symbol("x") assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == x assert c[0, 1] == 2 * x assert c[1, 0] == 3 * x assert c[1, 1] == 0 c2 = x * b assert c == c2 c = 5 * b assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2 * 5 assert c[1, 0] == 3 * 5 assert c[1, 1] == 0 try: eval('c = 5 @ b') except SyntaxError: pass else: assert isinstance(c, ArithmeticOnlyMatrix) assert c[0, 0] == 5 assert c[0, 1] == 2 * 5 assert c[1, 0] == 3 * 5 assert c[1, 1] == 0 # https://github.com/sympy/sympy/issues/22353 A = Matrix(ones(3, 1)) _h = -Rational(1, 2) B = Matrix([_h, _h, _h]) assert A.multiply_elementwise(B) == Matrix([[_h], [_h], [_h]])
def ODESS(filename, injections=[], givenCQs=[], neglect=[], sparsifyLevel = 2, outputFormat='R'): filename=str(filename) file=csv.reader(open(filename), delimiter=',') print('Reading csv-file ...') L=[] nrrow=0 nrcol=0 for row in file: nrrow=nrrow+1 nrcol=len(row) L.append(row) nrspecies=nrcol-2 ##### Remove injections counter=0 for i in range(1,len(L)): if(L[i-counter][1] in injections): L.remove(L[i-counter]) counter=counter+1 ##### Define flux vector F F=[] for i in range(1,len(L)): F.append(L[i][1]) #print(F) F[i-1]=F[i-1].replace('^','**') F[i-1]=parse_expr(F[i-1]) for inj in injections: F[i-1]=F[i-1].subs(parse_expr(inj),0) F=Matrix(F) #print(F) ##### Define state vector X X=[] X=L[0][2:] for i in range(len(X)): X[i]=parse_expr(X[i]) X=Matrix(X) #print(X) Xo=X.copy() ##### Define stoichiometry matrix SM SM=[] for i in range(len(L)-1): SM.append(L[i+1][2:]) for i in range(len(SM)): for j in range(len(SM[0])): if (SM[i][j]==''): SM[i][j]='0' SM[i][j]=parse_expr(SM[i][j]) SM=Matrix(SM) SM=SM.T SMorig=SM.copy() ##### Check for zero fluxes icounter=0 jcounter=0 for i in range(len(F)): if(F[i-icounter]==0): F.row_del(i-icounter) for j in range(len(SM.col(i-icounter))): if(SM[j-jcounter,i-icounter]!=0): #UsedRC.append(X[j-jcounter]) X.row_del(j-jcounter) SM.row_del(j-jcounter) SMorig.row_del(j-jcounter) jcounter=jcounter+1 SM.col_del(i-icounter) SMorig.col_del(i-icounter) icounter=icounter+1 print('Removed '+str(icounter)+' fluxes that are a priori zero!') nrspecies=nrspecies-icounter #printmatrix(SM) #print(F) #print(X) #print(UsedRC) #####Check if some species are zero and remove them from the system zeroStates=[] NegRows=checkNegRows(SM) PosRows=checkPosRows(SM) #print(PosRows) #print(NegRows) while((NegRows!=[]) | (PosRows!=[])): #print(PosRows) #print(NegRows) if(NegRows!=[]): row=NegRows[0] zeroStates.append(X[row]) counter=0 for i in range(len(F)): if(F[i-counter].subs(X[row],1)!=F[i-counter] and F[i-counter].subs(X[row],0)==0): F.row_del(i-counter) SM.col_del(i-counter) counter=counter+1 else: if(F[i-counter].subs(X[row],1)!=F[i-counter] and F[i-counter].subs(X[row],0)!=0): F[i-counter]=F[i-counter].subs(X[row],0) X.row_del(row) SM.row_del(row) else: row=PosRows[0] zeroFluxes=[] for j in range(len(SM.row(row))): if(SM.row(row)[j]!=0): zeroFluxes.append(F[j]) for k in zeroFluxes: StateinFlux=[] for state in X: if(k.subs(state,1)!=k): StateinFlux.append(state) if(len(StateinFlux)==1): zeroStates.append(StateinFlux[0]) row=list(X).index(StateinFlux[0]) counter=0 for i in range(len(F)): if(F[i-counter].subs(X[row],1)!=F[i-counter]): if(F[i-counter].subs(X[row],0)==0): F.row_del(i-counter) SM.col_del(i-counter) else: F[i-counter]=F[i-counter].subs(X[row],0) counter=counter+1 #printmatrix(SM) NegRows=checkNegRows(SM) PosRows=checkPosRows(SM) #printmatrix(SM) #print(F) #print(X) nrspecies=nrspecies-len(zeroStates) if(nrspecies==0): print('All states are zero!') return(0) else: if(zeroStates==[]): print('No states found that are a priori zero!') else: print('These states are zero:') for state in zeroStates: print('\t'+str(state)) nrspecies=nrspecies+len(zeroStates) ##### Identify linearities, bilinearities and multilinearities Xsquared=[] for i in range(len(X)): Xsquared.append(X[i]*X[i]) Xsquared=Matrix(Xsquared) BLList=[] MLList=[] for i in range(len(SM*F)): LHS=str(expand((SM*F)[i])) LHS=LHS.replace(' ','') LHS=LHS.replace('-','+') LHS=LHS.replace('**2','tothepowerof2') LHS=LHS.replace('**3','tothepowerof3') exprList=LHS.split('+') for expr in exprList: VarList=expr.split('*') counter=0 factors=[] for j in range(len(X)): anz=0 if(str(X[j]) in VarList): anz=1 factors.append(X[j]) if((str(X[j])+'tothepowerof2') in VarList): anz=2 factors.append(X[j]) factors.append(X[j]) if((str(X[j])+'tothepowerof3') in VarList): anz=3 factors.append(X[j]) factors.append(X[j]) factors.append(X[j]) counter=counter+anz if(counter==2): string='' for l in range(len(factors)): if(l==len(factors)-1): string=string+str(factors[l]) else: string=string+str(factors[l])+'*' if(not(string in BLList)): BLList.append(string) if(counter>2): string='' for l in range(len(factors)): if(l==len(factors)-1): string=string+str(factors[l]) else: string=string+str(factors[l])+'*' if(not(string in MLList)): MLList.append(string) COPlusLIPlusBL=[] for i in range(len(SM*F)): COPlusLIPlusBL.append((SM*F)[i]) for j in range(len(MLList)): ToSubs=expand((SM*F)[i]).coeff(MLList[j]) COPlusLIPlusBL[i]=expand(COPlusLIPlusBL[i]-ToSubs*parse_expr(MLList[j])) COPlusLI=[] for i in range(len(COPlusLIPlusBL)): COPlusLI.append(COPlusLIPlusBL[i]) for j in range(len(BLList)): ToSubs=expand((COPlusLIPlusBL)[i]).coeff(BLList[j]) COPlusLI[i]=expand(COPlusLI[i]-ToSubs*parse_expr(BLList[j])) ##### C*X contains linear terms C=zeros(len(COPlusLI),len(X)) for i in range(len(COPlusLI)): for j in range(len(X)): C[i*len(X)+j]=expand((COPlusLI)[i]).coeff(X[j]) ##### ML contains multilinearities ML=expand(Matrix(SM*F)-Matrix(COPlusLIPlusBL)) ##### BL contains bilinearities BL=expand(Matrix(COPlusLIPlusBL)-Matrix(COPlusLI)) #### CM is coefficient matrix of linearities CM=C #####CMBL gives coefficient matrix of bilinearities CMBL=[] if(BLList!=[]): for i in range(len(BLList)): CVBL=[] for k in range(len(BL)): CVBL.append(BL[k].coeff(BLList[i])) CMBL.append(CVBL) else: CVBL=[] for k in range(len(BL)): CVBL.append(0) CMBL.append(CVBL) CMBL=Matrix(CMBL).T #####CMML gives coefficient matrix of multilinearities #####Summarize multilinearities and bilinearities if(MLList!=[]): CMML=[] for i in range(len(MLList)): CVML=[] for k in range(len(ML)): CVML.append(expand(ML[k]).coeff(MLList[i])) CMML.append(CVML) CMML=Matrix(CMML).T BLList=BLList+MLList CMBL=Matrix(concatenate((CMBL,CMML),axis=1)) for i in range(len(BLList)): BLList[i]=parse_expr(BLList[i]) if(BLList!=[]): CMbig=Matrix(concatenate((CM,CMBL),axis=1)) else: CMbig=Matrix(CM) #### Save ODE equations for testing solutions at the end print('Rank of SM is '+str(SM.rank()) + '!') SMorig=SM.copy() ODE=SMorig*F #### Get Flux Parameters fluxpars=[] for flux in F: if(flux.args!=()): foundFluxpar=False for el in flux.args: if(not foundFluxpar and el not in X and not is_number(str(el))): if(flux.subs(el, 0)==0): fluxpars.append(el) foundFluxpar=True else: fluxpars.append(flux) ##### Increase Sparsity of stoichiometry matrix SM print('Sparsify stoichiometry matrix with sparsify-level '+str(sparsifyLevel)+'!') newSM=(Sparsify(SM.T, level=sparsifyLevel, sparseIter=1)).T if(newSM!=SM): print("Sparsified!") SM=newSM #### Find conserved quantities #printmatrix(CMbig) #print(X) if(givenCQs==[]): print('\nFinding conserved quantities ...') LCLs, rowsToDel=FindLCL(CMbig.transpose(), X) else: print('\nI took the given conserved quantities!') LCLs=givenCQs if(LCLs!=[]): print(LCLs) else: print('System has no conserved quantities!') #### Define graph structure print('\nDefine graph structure ...\n') SSgraph=DetermineGraphStructure(SM, F, X, neglect) #printgraph(SSgraph) #print(fluxpars) #### Check for Cycles cycle=FindCycle(SSgraph, X) #### Remove cycles step by step gesnew=0 eqOut=[] while(cycle!=None): print('Removing cycle '+str(counter)) #printmatrix(SM) #print(F) minType, state2Rem, fp2Rem, signChanged = GetBestPair(cycle, SM, fluxpars, X, LCLs, neglect) #print(cycle) #print(state2Rem) #print(fp2Rem) #print(minType) if(minType==-1): print(" The cycle") print(" "+str(cycle)) print(" cannot be removed. Set more parameters free or enable steady-state expressions with minus signs. The latter is not yet provided by the tool.") return(0) if(minType==0): for LCL in LCLs: ls=parse_expr(LCL.split(' = ')[0]) if(ls.subs(parse_expr(state2Rem),1)!=ls): LCL2Rem=LCL LCLs.remove(LCL2Rem) index=list(X).index(parse_expr(state2Rem)) eqOut.append(state2Rem+' = '+state2Rem) print(' '+str(state2Rem)+' --> '+'Done by CQ') if(minType==1): index=list(X).index(parse_expr(state2Rem)) eq=(SM*F)[index] sol=solve(eq, fp2Rem, simplify=False)[0] eqOut.append(str(fp2Rem)+' = '+str(sol)) print(' '+str(state2Rem)+' --> '+str(fp2Rem)) if(minType==2): anz, sign=GetDimension(state2Rem, X, SM, getSign=True) index=list(X).index(parse_expr(state2Rem)) negs, sumnegs, negfps=GetOutfluxes(state2Rem, X, SM, F, fluxpars) poss, sumposs, posfps=GetInfluxes(state2Rem, X, SM, F, fluxpars) if(anz==1): print("Error in Type Determination. Please report this bug!") return(0) else: nenner=1 for j in range(anz): if(j>0): nenner=nenner+parse_expr('r_'+state2Rem+'_'+str(j)) trafoList=[] if((sign=="minus" and not signChanged) or (sign=="plus" and signChanged)): for j in range(len(negs)): flux=negs[j] fp=negfps[j] prefactor=flux/fp if(j==0): trafoList.append(str(fp)+' = ('+str(sumposs)+')*1/('+str(nenner)+')*1/('+str(prefactor)+')') else: gesnew=gesnew+1 trafoList.append(str(fp)+' = ('+str(sumposs)+')*'+'r_'+state2Rem+'_'+str(j)+'/('+str(nenner)+')*1/('+str(prefactor)+')') print(' '+str(state2Rem)+' --> '+str(negfps)) else: for j in range(len(poss)): flux=poss[j] fp=posfps[j] prefactor=flux/fp if(j==0): trafoList.append(str(fp)+' = ('+str(sumnegs)+')*1/('+str(nenner)+')*1/('+str(prefactor)+')') else: gesnew=gesnew+1 trafoList.append(str(fp)+' = ('+str(sumnegs)+')*'+'r_'+state2Rem+'_'+str(j)+'/('+str(nenner)+')*1/('+str(prefactor)+')') print(' '+str(state2Rem)+' --> '+str(posfps)) for eq in trafoList: eqOut.append(eq) if(minType==3): anz, sign=GetDimension(state2Rem, X, SM, getSign=True) index=list(X).index(parse_expr(state2Rem)) negs, sumnegs, negfps=GetOutfluxes(state2Rem, X, SM, F, fluxpars) poss, sumposs, posfps=GetInfluxes(state2Rem, X, SM, F, fluxpars) if(anz==1): if((sign=="minus" and not signChanged) or (sign=="plus" and signChanged)): fp2Rem=negfps[0] flux=negs[0] else: fp2Rem=posfps[0] flux=poss[0] eq=(SM*F)[index] sol=solve(eq, fp2Rem, simplify=False)[0] eqOut.append(str(fp2Rem)+' = '+str(sol)) FsearchFlux = matrix_multiply_elementwise(abs(SM[index,:]),F.T) colindex=list(FsearchFlux).index(flux) for row2repl in range(len(SM.col(0))): if(SM[row2repl,colindex]!=0 and row2repl!=index): SM=SM.row_insert(row2repl,SM.row(row2repl)-(SM[row2repl,colindex]/SM[index,colindex])*SM.row(index)) SM.row_del(row2repl+1) else: nenner=1 for j in range(anz): if(j>0): nenner=nenner+parse_expr('r_'+state2Rem+'_'+str(j)) trafoList=[] if((sign=="minus" and not signChanged) or (sign=="plus" and signChanged)): for j in range(len(negs)): flux=negs[j] fp=negfps[j] prefactor=flux/fp if(j==0): trafoList.append(str(fp)+' = ('+str(sumposs)+')*1/('+str(nenner)+')*1/('+str(prefactor)+')') else: gesnew=gesnew+1 trafoList.append(str(fp)+' = ('+str(sumposs)+')*'+'r_'+state2Rem+'_'+str(j)+'/('+str(nenner)+')*1/('+str(prefactor)+')') FsearchFlux = matrix_multiply_elementwise(abs(SM[index,:]),F.T) colindex=list(FsearchFlux).index(flux) for k in range(len(posfps)): SM=SM.col_insert(len(SM.row(0)),SM.col(colindex)) F=F.row_insert(len(F),Matrix(1,1,[poss[k]/nenner])) fluxpars.append(posfps[k]) SM.col_del(colindex) F.row_del(colindex) fluxpars.__delitem__(colindex) print(' '+str(state2Rem)+' --> '+str(negfps)) else: for j in range(len(poss)): flux=poss[j] fp=posfps[j] prefactor=flux/fp if(j==0): trafoList.append(str(fp)+' = ('+str(sumnegs)+')*1/('+str(nenner)+')*1/('+str(prefactor)+')') else: gesnew=gesnew+1 trafoList.append(str(fp)+' = ('+str(sumnegs)+')*'+'r_'+state2Rem+'_'+str(j)+'/('+str(nenner)+')*1/('+str(prefactor)+')') FsearchFlux = matrix_multiply_elementwise(abs(SM[index,:]),F.T) colindex=list(FsearchFlux).index(flux) for k in range(len(negfps)): SM=SM.col_insert(len(SM.row(0)),SM.col(colindex)) F=F.row_insert(len(F),Matrix(1,1,[negs[k]/nenner])) fluxpars.append(negfps[k]) SM.col_del(colindex) F.row_del(colindex) fluxpars.__delitem__(colindex) print(' '+str(state2Rem)+' --> '+str(posfps)) for eq in trafoList: eqOut.append(eq) X.row_del(index) SM.row_del(index) SSgraph=DetermineGraphStructure(SM, F, X, neglect) #print(X) #printgraph(SSgraph) cycle=FindCycle(SSgraph, X) counter=counter+1 print('There is no cycle in the system!\n') #### Solve remaining equations eqOut.reverse() print('Solving remaining equations ...\n') while(SSgraph!={}): #print(SSgraph) node=FindNodeToSolve(SSgraph) #print(node) index=list(X).index(parse_expr(node)) #print((SM*F)[index]) sol=solve((SM*F)[index],parse_expr(node), simplify=True) #print(sol) eqOut.insert(0,node+' = '+str(sol[0])) for f in range(len(F)): F[f]=F[f].subs(parse_expr(node), sol[0]) #print(node+' = '+str(sol[0])) X.row_del(index) SM.row_del(index) SSgraph=DetermineGraphStructure(SM, F, X, neglect=[]) #### Test Solution print('Testing Steady State...\n') NonSteady=False #print(eqOut) #print(ODE) #print(SM*F) for i in range(len(ODE)): expr=parse_expr(str(ODE[i])) for j in range(len(zeroStates)): zeroState=zeroStates[j] expr=expr.subs(zeroState, 0) #print(len(eqOut)) for j in range(len(eqOut)): ls, rs = eqOut[-(j+1)].split('=') #print(ls) ls=parse_expr(ls) #print(rs) rs=parse_expr(rs) expr=expr.subs(ls, rs) #print(simplify(expr)) expr=simplify(expr) #print(expr) if(expr!=0): print(' Equation '+str(ODE[i])) print(' results:'+str(expr)) NonSteady=True if(NonSteady): print('Solution is wrong!\n') else: print('Solution is correct!\n') #### Print Equations print('I obtained the following equations:\n') if(outputFormat=='M'): for state in zeroStates: print('\tinit_'+str(state)+' "0"'+'\n') eqOutReturn=[] for i in range(len(eqOut)): ls, rs = eqOut[i].split('=') ls=parse_expr(ls) rs=parse_expr(rs) for j in range(i,len(eqOut)): ls2, rs2 = eqOut[j].split('=') rs2=parse_expr(rs2) rs2=rs2.subs(ls,rs) eqOut[j]=str(ls2)+'='+str(rs2) for state in Xo: ls=ls.subs(state, parse_expr('init_'+str(state))) rs=rs.subs(state, parse_expr('init_'+str(state))) eqOut[i]=str(ls)+' "'+str(rs)+'"' for i in range(len(eqOut)): eqOut[i]=eqOut[i].replace('**','^') for eq in eqOut: print('\t'+eq+'\n') eqOutReturn.append(eq) else: for state in zeroStates: print('\t'+str(state)+' = 0'+'\n') eqOutReturn=[] for eq in eqOut: ls, rs = eq.split(' = ') print('\t'+ls+' = "'+rs+'",'+'\n') eqOutReturn.append(ls+'='+rs) print('Number of Species: '+str(nrspecies)) print('Number of Equations: '+str(len(eqOut)+len(zeroStates))) print('Number of new introduced variables: '+str(gesnew)) return(eqOutReturn)