public Reservation createReservation(double startTime, int duration, 
    		int numPE, int resID) {
    	
        // check all the values first
        boolean success = validateValue(startTime, duration, numPE);
        if (!success) {
            return null;
        }
        
        Reservation reservation = null;
        try {
        	
        	// create the reservation itself
        	reservation = new Reservation(super.get_id());
        	reservation.setStartTime(startTime);
        	reservation.setDurationTime(duration);
        	reservation.setResourceID(resID);
        	reservation.setNumPE(numPE);
        	
        	// creates the message to be sent to the grid resource
        	ReservationMessage message = new ReservationMessage(super.get_id(), resID, reservation);
        	message.setMessageType(MessageType.CREATE);
        	
        	// gets the reply from the grid resource
            ReservationMessage reply = sendReservationMessage(message);
            
            // If error code is NO_ERROR, the reservation has been successful.
            ErrorType error = reply.getErrorCode();
            if(error == ErrorType.NO_ERROR) {
            	reservations_.put(reservation.getID(), reservation);
            }
            else if(error == ErrorType.OPERATION_FAILURE_BUT_OPTIONS) {
            	reservation = reply.getReservation();
            }
            else {
            	logger.info("Reservation # " + reservation.getID() + 
            			" has not been accepted by resource # " + 
            			resID + " at time = " + GridSim.clock());
            	reservation = null;
            }
        }
        
        catch (Exception ex) {
        	logger.log(Level.WARNING, "Reservation # " +
        			reservation.getID() + " has not been accepted by "+ 
        			"resource # " + resID + " at time = " + GridSim.clock(), ex);
        	reservation = null;
        }
        
        return reservation;
    }