/** * Initialises the solver object, taking into account a list of positions of * A that may need to be updated when requested. This is needed by the MoM * algorithm. * @param A The matrix A of the linear system Ax = b * @param UList The list containing these positions as Tuple objects * @throws OperationNotSupportedException Thrown when the matrix A is not square */ @Override public void initialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables) throws OperationNotSupportedException { t.start(); this.A = A; N = A.length; if (A[0].length != N) { throw new OperationNotSupportedException("Matrix A of linear system is not square."); } this.UList = UList; this.uncomputables = uncomputables; curULevel = 0; cleanA = new BigRational[N][N]; MiscFunctions.arrayCopy(A, cleanA); t.pause(); }
@Override public void computeNormalisingConstant() throws InternalErrorException, OperationNotSupportedException, InconsistentLinearSystemException, BTFMatrixErrorException { current_N = new PopulationVector(0,R); for (int _class = 1; _class <= R; _class++) { System.out.println("Working on class " + _class); System.out.println("Current Population: " + current_N); current_N.plusOne(_class); system.initialiseForClass(current_N, _class); solveForClass(_class); } //Store the computed normalsing constant BigRational G = basis.getNormalisingConstant(); qnm.setNormalisingConstant(G); }
private void solveForClass(int _class) throws InternalErrorException, OperationNotSupportedException, InconsistentLinearSystemException, BTFMatrixErrorException { /* //If no jobs of current_class in target population, move onto next class if (target_N.get(current_class - 1) == 0) { return; } */ for (int class_population = current_N.get(_class - 1); class_population <= target_N.get(_class - 1); class_population++ ) { System.out.println("Solving for population: " + current_N); System.out.println(class_population); system.update(class_population); system.solve(); if (class_population < target_N.get(_class - 1)) { current_N.plusOne(_class); } } }
@Override public void solve() throws OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException, BTFMatrixErrorException { basis.startBasisComputation(); //System.out.println("BEFORE: "); //basis.print_values(); //Order of solving is important: //B First b1.solve(rhs); b2.solve(rhs); c.solve(rhs); //Then A; Y then X y.solve(rhs); //System.out.println("AFTER Y: "); //basis.print_values(); x.solve(rhs); //basis.print_values(); }
@Override public void solve() throws OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException, BTFMatrixErrorException { basis.startBasisComputation(); System.out.println("Solving System...\n"); BigRational[] sysB = B.multiply(); BigRational[] result = solver.solve(sysB); for (int i = 0; i < basis.getSize(); i++) { basis.setValue(result[i], i); } }
@Override public void initialiseMatricesForClass(PopulationVector current_N, int current_class) throws InternalErrorException, BTFMatrixErrorException, InconsistentLinearSystemException, OperationNotSupportedException { System.out.println("current_class: " + current_class); generateAB(current_N, current_class); System.out.println("Intialising A and B:"); if (Main.verbose) { System.out.println("A:"); A.print(); System.out.println("B:"); B.print(); } Integer maxA = (int)getMaxAElement(); Integer val = basis.getSize(); BigInteger maxB = qnm.getMaxG().multiply(new BigInteger(maxA.toString())).multiply(new BigInteger(val.toString())); solver.initialise(A.getArray(), A.getUpdateList(), basis.getUncomputables(), maxA, maxB, new BigRational(qnm.getMaxG())); }
@Override public void initialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables, int maxA, BigInteger maxb, BigRational maxG) throws OperationNotSupportedException, InternalErrorException { t.start(); super.initialise(A, UList, uncomputables); //this.previousInvocationSwapped = false; this.maxA = new BigInteger((new Integer(maxA).toString())); //this.maxOfAColumns = maxOfAColumns; this.maxG = maxG; int bitlength = lowerLimitForMMorhac(this.maxA, maxb); //int bitlength = lowerLimitForMG(this.maxG.asBigDecimal().toBigIntegerExact()); if (bitlength > M.bitLength()) { System.out.println("Selecting moduli. Total bitlength: " + bitlength); moduliSelectionTimer.start(); moduli = new ArrayList<BigInteger>(nThreads); M = BigInteger.ONE; for (BigInteger m : moduli) { M = M.multiply(m); } //selectModuli(bitlength); // Report linear system only /*BigInteger m = new BigInteger("775239"); moduli.add(m); M = M.multiply(moduli.get(moduli.size()-1)); minModulo = m; moduli.add(new BigInteger("1942111")); M = M.multiply(moduli.get(moduli.size()-1));*/ selectModuliInParallel(bitlength); if (M.bitLength() < bitlength || minModulo.compareTo(this.maxA) <= 0) { throw new InternalErrorException("Cannot select moduli"); } moduliSelectionTimer.pause(); System.out.println("Moduli selection took " + moduliSelectionTimer.getPrettyInterval() + ".\nWill now solve " + moduli.size() + " residue systems."); } taskList = new ArrayList<ModularSolverParallelTask>(moduli.size()); for (int i = 0; i < moduli.size(); i++) { taskList.add(new ModularSolverParallelTask(moduli.get(i), M)); } t.pause(); }
/** * Initialises the solver object. * @param A The matrix A of the linear system Ax = b * @throws OperationNotSupportedException Thrown when the matrix A is not square */ @Override public void initialise(BigRational[][] A) throws OperationNotSupportedException { t.start(); List<Tuple<Integer, Integer>> l = new ArrayList<Tuple<Integer, Integer>>(); Set<Integer> emptyUncomputables = new HashSet<Integer>(); t.pause(); this.initialise(A, l, emptyUncomputables); }
/** * Throws a naming exception is Context is not writable. */ protected boolean checkWritable() throws NamingException { if (isWritable()) { return true; } else { if (exceptionOnFailedWrite) { throw new javax.naming.OperationNotSupportedException( sm.getString("namingContext.readOnly")); } } return false; }
private BigRational[] solve(Solver s, BigRational[] b) throws InconsistentLinearSystemException, OperationNotSupportedException, InternalErrorException { BigRational[] sol = s.solve(b); // If the first element (current normalising constant) has been corrupted // then there is no recovery if (sol[0].isUndefined()) { throw new InconsistentLinearSystemException("Singular system. Cannot proceed."); } return sol; }
/** * Creates and initialises a RecursiveSolver object. * * @param qnm The QNModel object that we are working on * @throws InternalErrorException Thrown when the solver cannot be initialised */ public RecursiveSolver(QNModel qnm) throws InternalErrorException { super(qnm); try { initialise(); } catch (OperationNotSupportedException ex) { Logger.getLogger(RecursiveSolver.class.getName()).log(Level.SEVERE, null, ex); throw new InternalErrorException("Initialisation failed."); } }
/** * Returns the maximum possible normalising constant of the queueing network. * @return The maximum value as a BigInteger object * @throws OperationNotSupportedException Thrown if the maximum normalising constant cannot be computed */ public BigInteger getMaxG() throws OperationNotSupportedException { double Dmax = MiscFunctions.max(Z); for (int k = 0; k < this.M; k++) { for (int r = 0; r < this.R; r++) { if (D[k][r] > Dmax) { Dmax = D[k][r]; } } } int Ntot = N.sum(); int nmax = (int) (Math.round(Math.ceil(Math.log10(Dmax * (Ntot + M + R)))) * Ntot); return BigInteger.TEN.pow(nmax + 1); }
@Override public void solve(BigRational[] rhs) throws BTFMatrixErrorException, OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException { //Need to solve in bottom to top order, with secondary macro blocks interleaved //First solve last, alone macro block macro_blocks[macro_blocks.length - 1].solve(rhs); //Now, solve secondary macro block, marco block pairs in reverse order: for (int i = sec_macro_blocks.length - 1; i >= 0; i--) { sec_macro_blocks[i].solve(rhs); macro_blocks[i].solve(rhs); } }
/** * Alternative solve that uses the simple linear system solver * @param rhs * @throws BTFMatrixErrorException * @throws OperationNotSupportedException * @throws InconsistentLinearSystemException * @throws InternalErrorException */ public void solve2(BigRational[] rhs) throws BTFMatrixErrorException, OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException { System.out.print("Solving XMicroBlock...\n\n"); BigRational[] sysB = new BigRational[size.row]; BigRational[] result = new BigRational[size.row]; //copy portion of rhs to sysB for (int i = 0; i < size.row; i++) { sysB[i] = rhs[position.row + i]; } System.out.println("SysB"); MiscFunctions.printMatrix(sysB); //Solve... solver = new SimpleSolver(); solver.initialise(array, new LinkedList<Tuple<Integer, Integer>>() , new HashSet<Integer>()); result = solver.solve(sysB); System.out.println("result"); MiscFunctions.printMatrix(result); //copy result to basis for (int i = 0; i < size.row; i++) { basis.setValue(result[i], position.row + i); } }
@Override public void encrypt(final InputStream inputStream, final OutputStream outputStream) { throw new RuntimeException(new OperationNotSupportedException("Encrypting input stream is not supported")); }
@Override public void decrypt(final InputStream inputStream, final OutputStream outputStream) { throw new RuntimeException(new OperationNotSupportedException("Decrypting input stream is not supported")); }
/** * Used to test the provided API. * @throws BTFMatrixErrorException * @throws InconsistentLinearSystemException * @throws OperationNotSupportedException */ private static void interfaceTest() throws OperationNotSupportedException, InconsistentLinearSystemException, BTFMatrixErrorException { int R = 2, M = 4; int[] type = {MoMSolverDispatcher.LI, MoMSolverDispatcher.LI, MoMSolverDispatcher.LD, MoMSolverDispatcher.LD, MoMSolverDispatcher.LD}; int E = type.length; double[][] servt = new double[E][R]; int[] pop = new int[R]; pop[0] = 10; pop[1] = 10; MoMSolverDispatcher mClosed = new MoMSolverDispatcher(R, E, pop); //station 1 servt[0][0] = 10; servt[1][0] = 5; servt[2][0] = 91; servt[3][0] = 4; servt[4][0] = 10; //station 2 servt[0][1] = 5; servt[1][1] = 9; servt[2][1] = 0; servt[3][1] = 8; servt[4][1] = 10; double[][] visits = new double[E][R]; //station 1 visits[0][0] = 1; visits[1][0] = 1; visits[2][0] = 0; visits[3][0] = 0; visits[4][0] = 0; //station 2 visits[0][1] = 1; visits[1][1] = 1; visits[2][1] = 0; visits[3][1] = 0; visits[4][1] = 0; if (mClosed.input(type, servt, visits, Runtime.getRuntime().availableProcessors())) { try { mClosed.solve(); } catch (InternalErrorException ex) { System.err.println("Evaluation Failed!"); ex.printStackTrace(); } } else { System.out.println("Wrong input!"); } }
private double getMaxAElement() throws OperationNotSupportedException { double max = qnm.getMaxModelValue(); max *= qnm.multiplicities.max() + qnm.R; return max; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class == method.getDeclaringClass()) { String name = method.getName(); if ("equals".equals(name)) { return proxy == args[0]; } else if ("hashCode".equals(name)) { return System.identityHashCode(proxy); } else if ("toString".equals(name)) { return proxy.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(proxy)) + ", with InvocationHandler " + this; } else { throw new IllegalStateException(String.valueOf(method)); } } RequestMessage request = new RequestMessage(); request.setRequestId(UUID.randomUUID().toString()); request.setClassName(method.getDeclaringClass().getName()); request.setMethodName(method.getName()); request.setParameterTypes(method.getParameterTypes()); request.setParameters(args); AsyncInvokeFuture future = new AsyncInvokeFuture(); future.setRequest(request); RequestRepositryRegistry.register(future); LionConnectionManager.getInstance().getConnectionAndSendRequest(request); future.getLatch().await(); ResponseMessage resp= future.getResponse(); if("404".equals(resp.getError())){ throw new OperationNotSupportedException(method.getDeclaringClass().getName()+"."+method.getName()); }else if("408".equals(resp.getError())){ throw new InvokeTimeOutException("time out"); }else if("500".equals(resp.getError())){ throw new ServerInternalException("server 500"); }else{ if(!"0".equals(resp.getError())){ throw new RuntimeException("unkown exception"); } } return resp.getResult(); }
@Override public PersistentObject<Target> unmarshal(DeployTargetDto dto) throws OperationNotSupportedException { return dto.toDeployTarget(); }
/** * Searches in the named context or object for entries that satisfy the * given search filter. Performs the search as specified by the search * controls. * * @param name the name of the context or object to search * @param filter the filter expression to use for the search; may not be * null * @param cons the search controls that control the search. If null, * the default search controls are used (equivalent to * (new SearchControls())). * @return an enumeration of SearchResults of the objects that satisfy * the filter; never null * @exception javax.naming.directory.InvalidSearchFilterException if the * search filter specified is not supported or understood by the underlying * directory * @exception javax.naming.directory.InvalidSearchControlsException if the * search controls contain invalid settings * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException { throw new OperationNotSupportedException(); }
/** * Retrieves the full name of this context within its own namespace. * <p> * Many naming services have a notion of a "full name" for objects in * their respective namespaces. For example, an LDAP entry has a * distinguished name, and a DNS record has a fully qualified name. This * method allows the client application to retrieve this name. The string * returned by this method is not a JNDI composite name and should not be * passed directly to context methods. In naming systems for which the * notion of full name does not make sense, * OperationNotSupportedException is thrown. * * @return this context's name in its own namespace; never null * @exception OperationNotSupportedException if the naming system does * not have the notion of a full name * @exception NamingException if a naming exception is encountered */ @Override public String getNameInNamespace() throws NamingException { throw new OperationNotSupportedException (sm.getString("namingContext.noAbsoluteName")); //FIXME ? }
/** * RefreshInterval is now set only through the AdminDistributedSystem property refreshInterval. * Attempt to set refreshInterval on CacheServerJmx MBean would result in an * OperationNotSupportedException Auto-refresh is enabled on demand when a call to refreshConfig * is made * * @param refreshInterval the new refresh interval in seconds * @deprecated since 6.0 use DistributedSystemConfig.refreshInterval instead */ @Deprecated public void setRefreshInterval(int refreshInterval) throws OperationNotSupportedException { throw new OperationNotSupportedException( LocalizedStrings.MANAGED_RESOURCE_REFRESH_INTERVAL_CANT_BE_SET_DIRECTLY .toLocalizedString()); }
/** * Searches in a single context for objects that contain a specified set * of attributes, and retrieves selected attributes. The search is * performed using the default SearchControls settings. * * @param name the name of the context to search * @param matchingAttributes the attributes to search for. If empty or * null, all objects in the target context are returned. * @param attributesToReturn the attributes to return. null indicates * that all attributes are to be returned; an empty array indicates that * none are to be returned. * @return a non-null enumeration of SearchResult objects. Each * SearchResult contains the attributes identified by attributesToReturn * and the name of the corresponding object, named relative to the * context named by name. * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException { throw new OperationNotSupportedException(); }
/** * Searches in the named context or object for entries that satisfy the * given search filter. Performs the search as specified by the search * controls. * * @param name the name of the context or object to search * @param filterExpr the filter expression to use for the search. * The expression may contain variables of the form "{i}" where i is a * nonnegative integer. May not be null. * @param filterArgs the array of arguments to substitute for the * variables in filterExpr. The value of filterArgs[i] will replace each * occurrence of "{i}". If null, equivalent to an empty array. * @param cons the search controls that control the search. If null, the * default search controls are used (equivalent to (new SearchControls())). * @return an enumeration of SearchResults of the objects that satisfy the * filter; never null * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i} * expressions where i is outside the bounds of the array filterArgs * @exception javax.naming.directory.InvalidSearchControlsException if cons * contains invalid settings * @exception javax.naming.directory.InvalidSearchFilterException if * filterExpr with filterArgs represents an invalid search filter * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<SearchResult> search(String name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException { throw new OperationNotSupportedException(); }
/** * Retrieves the full name of this context within its own namespace. * <p> * Many naming services have a notion of a "full name" for objects in * their respective namespaces. For example, an LDAP entry has a * distinguished name, and a DNS record has a fully qualified name. This * method allows the client application to retrieve this name. The string * returned by this method is not a JNDI composite name and should not be * passed directly to context methods. In naming systems for which the * notion of full name does not make sense, * OperationNotSupportedException is thrown. * * @return this context's name in its own namespace; never null * @exception OperationNotSupportedException if the naming system does * not have the notion of a full name * @exception NamingException if a naming exception is encountered */ public String getNameInNamespace() throws NamingException { throw new OperationNotSupportedException (sm.getString("namingContext.noAbsoluteName")); //FIXME ? }
/** * RefreshInterval is now set only through the AdminDistributedSystem property refreshInterval. * Attempt to set refreshInterval on StatisticResourceJmx MBean would result in an * OperationNotSupportedException Auto-refresh is enabled on demand when a call to getStatistics * is made * * @param refreshInterval the new refresh interval in seconds * @deprecated since 6.0 use DistributedSystemConfig.refreshInterval instead */ @Deprecated public void setRefreshInterval(int refreshInterval) throws OperationNotSupportedException { throw new OperationNotSupportedException( LocalizedStrings.MANAGED_RESOURCE_REFRESH_INTERVAL_CANT_BE_SET_DIRECTLY .toLocalizedString()); }
/** * RefreshInterval is now set only through the AdminDistributedSystem property refreshInterval. * Attempt to set refreshInterval on SystemMemberJmx MBean would result in an * OperationNotSupportedException Auto-refresh is enabled on demand when a call to refreshConfig * is made * * @param refreshInterval the new refresh interval in seconds * @deprecated since 6.0 use DistributedSystemConfig.refreshInterval instead */ @Deprecated public void setRefreshInterval(int refreshInterval) throws OperationNotSupportedException { throw new OperationNotSupportedException( LocalizedStrings.MANAGED_RESOURCE_REFRESH_INTERVAL_CANT_BE_SET_DIRECTLY .toLocalizedString()); }
/** * Searches in a single context for objects that contain a specified set of * attributes. This method returns all the attributes of such objects. It is * equivalent to supplying null as the atributesToReturn parameter to the * method search(Name, Attributes, String[]). * * @param name * the name of the context to search * @param matchingAttributes * the attributes to search for. If empty or null, all objects in * the target context are returned. * @return a non-null enumeration of SearchResult objects. Each SearchResult * contains the attributes identified by attributesToReturn and the * name of the corresponding object, named relative to the context * named by name. * @exception NamingException * if a naming exception is encountered */ @Override public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException { throw new OperationNotSupportedException(); }
/** * Binds a new name to the object bound to an old name, and unbinds the * old name. Both names are relative to this context. Any attributes * associated with the old name become associated with the new name. * Intermediate contexts of the old name are not changed. * * @param oldName the name of the existing binding; may not be empty * @param newName the name of the new binding; may not be empty * @exception javax.naming.NameAlreadyBoundException if newName is already * bound * @exception NamingException if a naming exception is encountered */ @Override public void rename(String oldName, String newName) throws NamingException { throw new OperationNotSupportedException(); }
/** * Searches in a single context for objects that contain a specified set * of attributes. This method returns all the attributes of such objects. * It is equivalent to supplying null as the atributesToReturn parameter * to the method search(Name, Attributes, String[]). * * @param name the name of the context to search * @param matchingAttributes the attributes to search for. If empty or * null, all objects in the target context are returned. * @return a non-null enumeration of SearchResult objects. Each * SearchResult contains the attributes identified by attributesToReturn * and the name of the corresponding object, named relative to the * context named by name. * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException { throw new OperationNotSupportedException(); }
/** * Initialises the solver object, taking into account a list of positions of * A that may need to be updated when requested. This is needed by the MoM * algorithm. * @param A The matrix A of the linear system Ax = b * @param UList The list containing these positions as Tuple objects * @param uncomputables Set of the indices of possible zero-columns of A * @throws OperationNotSupportedException Thrown when the matrix A is not square */ public abstract void initialise(BigRational[][] A, List<Tuple<Integer, Integer>> UList, Set<Integer> uncomputables) throws OperationNotSupportedException;
/** * Gaussian elimination linear system solver with partial pivoting. * @param b The vector b of the linear system Ax = b * @return A vector containing the solutions of the linear system * @throws OperationNotSupportedException Thrown when the system cannot be solved due to bad vector b size * @throws InconsistentLinearSystemException Thrown when the system cannot failed due to singularity. * @throws InternalErrorException Thrown when an unrecoverable internal error has been detected by the solver. */ public BigRational[] solve(BigRational[] b) throws OperationNotSupportedException, InconsistentLinearSystemException, InternalErrorException;