def print_to_image(path): grid = grid_to_metrix(path) if algo.solve(grid) : # algo.print_board(grid) t=0 for i in range(9): for j in range(9): if(t<len(temp1)): if(i==temp1[t] and j==temp2[t]): x = j*50+10 y = i*50+40 cv2.putText(image_final,str(grid[i][j]), (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255),2) t+=1 return image_final else: return "Detection Error!"
print('done. time:', tconv, flush=True) print('solving...', end=' ', flush=True) tsolve = time() WWhat = la.solve(mat, Vhat) tsolve = time() - tsolve print('done. time:', tsolve, flush=True) An += phi(tj) * WWhat Bn += phi(tj) * psi(tj) * WWhat if its == True: print('its solving...', end=' ', flush=True) What = np.zeros((m, 1), dtype=np.complex) for ii in range(l): v = Vhat[:, ii] tsolve = time() x = solve(met, v) What = np.concatenate((What, x.reshape(m, 1)), axis=1) What = What[:, 1:] tsolve = time() - tsolve print('done. time:', tsolve, flush=True) AN += phi(tj) * What BN += phi(tj) * psi(tj) * What AN, BN = 1/(1j*N) * AN, 1/(1j*N) * BN An, Bn = 1/(1j*N) * An, 1/(1j*N) * Bn A, B = An, Bn print(' ') print('shape(MET)=', met.shape)
listeVal = [] valEntree = 10.0 valSortie = 0.0 listE = [] listS = [] listePression = [] nbN = len(listeNoeuds) posE = 0 posS = nbN - 1 [A, b] = data.generateMatriceReseau(listeNoeuds, listeArcs, posE, valEntree, posS, valSortie) if (choixMeth == "1"): listePression = algo.cramer(A, b) if (choixMeth == "2"): listePression = algo.solve(A, b) listE = [posE] listS = [posS] verif = algo.verifReseau(listeNoeuds, listeArcs, listePression, listE, listS) affichage.afficherReseauResultat(listeNoeuds, listeArcs, listePression, listE, listS) ##---------------------------------- ##---------------------------------- # Detection dans le reseau de toute les positions de source et de sortie admissibles : # Decommenter et completer ICI : if (butPrgm == "3"): listeNoeuds = []
xtf = xTF(kRef, n) xtf.setRHS(dir_data, neu_data) space = xtf.space shape = xtf.shape fd, fn = xtf.getDir(), xtf.getNeu() fdir, fneu = xtf.getGFdir(), xtf.getGFneu() STF, MTF = STF(xtf), MTF(xtf) stf, rhs_stf = STF.get(), STF.rhs() mtf, rhs_mtf = MTF.get(), MTF.rhs() x_stf = solve(stf, rhs_stf) xd_stf, xn_stf = x_stf[0:shape], x_stf[shape:] x_mtf = solve(mtf, rhs_mtf) xd_mtf, xn_mtf = x_mtf[0:shape], x_mtf[shape:2 * shape] yd_mtf, yn_mtf = x_mtf[2 * shape:3 * shape], x_mtf[3 * shape:4 * shape] print('') print('l2 norm (relative)') print(la.norm(xd_mtf - xd_stf), la.norm(xn_mtf - xn_stf)) print( la.norm(xd_mtf - yd_mtf - fd) / la.norm(xd_mtf), la.norm(-xn_mtf - yn_mtf - fn) / la.norm(xn_mtf)) gd_mtf = bem.GridFunction(space, coefficients=xd_mtf) gn_mtf = bem.GridFunction(space, coefficients=xn_mtf)
import input from algo import solve a_file = "files/a_an_example.in.txt" b_file = "files/b_better_start_small.in.txt" c_file = "files/c_collaboration.in.txt" d_file = "files/d_dense_schedule.in.txt" e_file = "files/e_exceptional_skills.in.txt" f_file = "files/f_find_great_mentors.in.txt" file = a_file sim = input.SimulationData(file) sim.print_info() output = solve(sim.contributor_to_skills_dict, sim.projects_info_dict, sim.projects_skills_dict)
print('done. time:', tconv, flush=True) print('solving...', end=' ', flush=True) tsolve = time() WWhat = la.solve(mat, Vhat) tsolve = time() - tsolve print('done. time:', tsolve, flush=True) An += phi(tj) * WWhat Bn += phi(tj) * psi(tj) * WWhat if its == True: print('its solving...', end=' ', flush=True) What = np.zeros((m, 1), dtype=np.complex) for ii in range(l): v = Vhat[:, ii] tsolve = time() x = solve(met, v) What = np.concatenate((What, x.reshape(m, 1)), axis=1) What = What[:, 1:] tsolve = time() - tsolve print('done. time:', tsolve, flush=True) AN += phi(tj) * What BN += phi(tj) * psi(tj) * What AN, BN = 1 / (1j * N) * AN, 1 / (1j * N) * BN An, Bn = 1 / (1j * N) * An, 1 / (1j * N) * Bn A, B = An, Bn print(' ') print('shape(MET)=', met.shape)
result[0] = -1j * normal[1] * kRef * np.exp( 1j * kRef * x[1]) xtf = xTF(kRef, n) xtf.setRHS(dir_data, neu_data) space = xtf.space shape = xtf.shape fd, fn = xtf.getDir(), xtf.getNeu() fdir, fneu = xtf.getGFdir(), xtf.getGFneu() STF, MTF = STF(xtf), MTF(xtf) stf, rhs_stf = STF.get(), STF.rhs() mtf, rhs_mtf = MTF.get(), MTF.rhs() x_stf = solve(stf, rhs_stf) xd_stf, xn_stf = x_stf[0:shape], x_stf[shape:] x_mtf = solve(mtf, rhs_mtf) xd_mtf, xn_mtf = x_mtf[0:shape], x_mtf[shape:2*shape] yd_mtf, yn_mtf = x_mtf[2*shape:3*shape], x_mtf[3*shape:4*shape] print('') print('l2 norm (relative)') print(la.norm(xd_mtf - xd_stf), la.norm(xn_mtf - xn_stf)) print(la.norm(xd_mtf - yd_mtf - fd)/la.norm(xd_mtf), la.norm(-xn_mtf - yn_mtf -fn)/la.norm(xn_mtf)) gd_mtf = bem.GridFunction(space, coefficients=xd_mtf) gn_mtf = bem.GridFunction(space, coefficients=xn_mtf) ggd_mtf = bem.GridFunction(space, coefficients=yd_mtf)