Search in sources :

Example 6 with Vertex

use of nl.uva.cs.lobcder.optimization.Vertex in project lobcder by skoulouzis.

the class RandomPredictor method getNextState.

@Override
public Vertex getNextState(Vertex currentState) {
    String resource;
    Method method;
    try {
        switch(type) {
            case state:
                resource = getRandomResource();
                method = getRandomMethod();
                break;
            case resource:
                resource = getRandomResource();
                method = null;
                break;
            case method:
                resource = null;
                method = getRandomMethod();
                break;
            default:
                resource = getRandomResource();
                method = getRandomMethod();
                break;
        }
        return new Vertex(method, resource);
    } catch (SQLException ex) {
        Logger.getLogger(RandomPredictor.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
Also used : Vertex(nl.uva.cs.lobcder.optimization.Vertex) SQLException(java.sql.SQLException) Method(io.milton.http.Request.Method)

Example 7 with Vertex

use of nl.uva.cs.lobcder.optimization.Vertex in project lobcder by skoulouzis.

the class RecentPopularity method getPopularState.

private Vertex getPopularState(List<Vertex> listOfKSuccessors) {
    int count = 1, tempCount;
    Vertex popular = listOfKSuccessors.get(0);
    Vertex temp;
    for (int i = 0; i < (listOfKSuccessors.size() - 1); i++) {
        temp = listOfKSuccessors.get(i);
        tempCount = 0;
        for (int j = 1; j < listOfKSuccessors.size(); j++) {
            if (temp.getID().equals(listOfKSuccessors.get(j).getID())) {
                tempCount++;
            }
        }
        if (tempCount > count) {
            popular = temp;
            count = tempCount;
        }
    }
    if (count >= j) {
        return popular;
    } else {
        return null;
    }
}
Also used : Vertex(nl.uva.cs.lobcder.optimization.Vertex)

Aggregations

Vertex (nl.uva.cs.lobcder.optimization.Vertex)7 SQLException (java.sql.SQLException)4 Request (io.milton.http.Request)1 Method (io.milton.http.Request.Method)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1