亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? onesidedauction.java

?? 中間件開發詳細說明:清華大學J2EE教程講義(ppt)-Tsinghua University J2EE tutorial lectures (ppt) [上載源碼成為會員下載此源碼] [成為VIP會
?? JAVA
字號:
/*
 * Title:        GridSim Toolkit
 * Description:  GridSim (Grid Simulation) Toolkit for Modeling and Simulation
 *               of Parallel and Distributed Systems such as Clusters and Grids
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * $Id: OneSidedAuction.java,v 1.4 2006/03/23 03:40:56 anthony Exp $
 */
package gridsim.auction;

import eduni.simjava.Sim_event;
import eduni.simjava.Sim_port;
import gridsim.GridSim;
import gridsim.GridSimTags;

/**
 * This class represents an one-sided auction. One-sided auctions
 * send announcements of a good to be sold and receive bids from
 * bidders. It can have several rounds.
 *
 * @author       Marcos Dias de Assuncao
 * @since        GridSim Toolkit 4.0
 * @see gridsim.auction.Auction
 * @see gridsim.auction.AuctionTags
 */

public abstract class OneSidedAuction extends Auction {
	//reserve price is the minimum price expected to obtain in the auction
	private double reservePrice = 0f;
	
	//minimum price used by the auction. 
	private double minPrice = 0f;
	
	//current price is the current price achieved by the auction
	private double currentPrice = 0f;
	
	//current price is the current price achieved by the auction
	private double finalPrice = 0f;
	
	//maximum price used by the auction
	private double maxPrice = 0f;
	
	//duration of a single round
	private double durationOfRounds;
	
	//an auction may have several rounds
	private int totalRound = 1;
	
	//an auction can have multiple rounds. So, this variable indicates the current round
	private int currentRound = 0;
	
	// this attribute keeps the winner's ID
	private int winnerID = -1;
	
	private Object syncStep = new Object();
	
	// this attribute defines if the auction has been closed or not
	private boolean closed = false;
	
	
	/**
	 * Default constructor
	 * @param auctionName A name for the auction
	 * @param auctioneerID the ID of the auctioneer
	 * @param auctionProtocol the auction protocol
	 * @param durationOfRounds duration in simulation time of each round
	 * @param totalRound the number of rounds
	 * @param output the auctioneer's output port
	 * @throws Exception
	 */
	public OneSidedAuction(String auctionName, int auctioneerID, 
			int auctionProtocol, double durationOfRounds,
			int totalRound, Sim_port output)throws Exception {
		super(auctionName, auctioneerID, auctionProtocol, output);
		this.durationOfRounds = durationOfRounds;
		this.totalRound = totalRound; 
	}
	
	/**
	 * Default constructor
	 * @param auctionName A name for the auction
	 * @param auctionProtocol the auction protocol
	 * @param durationOfRounds duration in simulation time of each round
	 * @param totalRound the number of rounds
	 * @throws Exception
	 */
	public OneSidedAuction(String auctionName,  
			int auctionProtocol, double durationOfRounds,
			int totalRound)throws Exception {
		super(auctionName, auctionProtocol);
		this.durationOfRounds = durationOfRounds;
		this.totalRound = totalRound; 
	}
	
    /**
     * Sets the winner ID
     * @param winnerID
     * @pre winnerID == some GridSim entity's ID || winnerID == -1 if there's no winner
     * @return <tt>true</tt> if the winner's id is properly set
     */
    protected boolean setWinner(int winnerID){
    	if(winnerID < -1)
    		return false;
    	
    	this.winnerID = winnerID;
    	return true;
    }
    
    /**
     * Returns the winner's ID
     * @return the GridSim id of the winner
     */
    public int getWinner(){
    	return winnerID;
    }

	/**
	 * Returns the duration of a round
	 * @return the simulation time of a round
	 */
	protected double getDurationOfRounds(){
		return this.durationOfRounds;
	}
	
	/**
	 * Set the reserve price. The auctioneer may not sell
	 * the good for less than the value specified in reserve price
	 * @param price
	 * @pre price >= 0.0D
	 * @return <tt>true</tt> if the price is properly set
	 */
	public boolean setReservePrice(double price){
		if(price < 0.0D)
			return false;
		
		reservePrice = price;
		return true;
	}
	
	/**
	 * Returns the reserve price
	 * @return the reserve price of this auction
	 */
	public double getReservePrice(){
		return reservePrice;
	}
	
	/**
	 * Sets the final price achieved in the auction
	 * @param price
	 * @pre price >= 0.0D
	 * @return <tt>true</tt> if the price is properly set
	 */
	public boolean setFinalPrice(double price){
		if(price < 0.0D)
			return false;
		
		finalPrice = price;
		return true;
	}
	
	/**
	 * Returns the final price achieved by the auction
	 * @return the final price achieved
	 */
	public double getFinalPrice(){
		return finalPrice;
	}
	
	/**
	 * Returns the current round of the auction 
	 * @return the active round
	 */
	public synchronized int currentRound(){
		return currentRound;
	}
	
	/**
	 * Returns the number of rounds of the auction
	 * @return the number of rounds
	 */
	public int getNumberOfRounds(){
		return this.totalRound;
	}
	
	/**
	 * Sets the current price in the auction
	 * @param price
	 * @pre price >= 0.0D
	 * @return <tt>true</tt> if the price is properly set
	 */
	public boolean setCurrentPrice(double price){
		if(price < 0.0D)
			return false;
		
		this.currentPrice = price;
		return true;
	}
	
	/**
	 * Returns the current price of this auction
	 * @return the current price
	 */
	public double getCurrentPrice(){
		return currentPrice;
	}
	
	/**
	 * Sets the minimum price for the auction 
	 * @param price the minimun price for the auction
	 * @pre price >= 0.0D
	 * @return <tt>true</tt> if the price is properly set
	 */
	public boolean setMinPrice(double price){
		if(price < 0.0D)
			return false;
		
		this.minPrice = price;
		return true;
	}
	
	/**
	 * Returns the minimun price of the auction
	 * @return the minimun price
	 */
	public double getMinPrice(){
		return minPrice;
	}
	
	/**
	 * Sets the maximum price for the auction 
	 * @param price the maximum price for the auction
	 * @pre price >= 0.0D
	 * @return <tt>true</tt> if the price is properly set
	 */
	public boolean setMaxPrice(double price){
		if(price < 0.0D)
			return false;
		
		this.maxPrice = price;
		return true;
	}
	
	/**
	 * Returns the maximum price of the auction
	 * @return the maximum price
	 */
	public double getMaxPrice(){
		return maxPrice;
	}
	
    /*
     * Used to avoid deadlock
     */
    private synchronized void setClosed(boolean value){
   		closed = value;
    }
    
    /*
     * Returns true if the auction is closed 
     * @return
     */
    private synchronized boolean isClosed(){
   		return closed;
    }
	
 	/**
	 * This method is called to start the auction and 
	 * initialize the necessary paramenters
	 */
    public void startAuction(){
    	if((super.getOutputPort() == null) || super.getAuctionID() == -1){
    		System.err.println(this.get_name() + 
    				"Error starting the auction. " + 
    				"The output port used by the auction is null or" +
    				"the auctioneer's ID was not provided!");
    		return;
    	}
    	synchronized(syncStep){
	    	// default values
	        setClosed(false);
	
	        // broadcast a message to all bidders informing about the auction
	        MessageInformStart mia = 
	        	new MessageInformStart(super.getAuctionID(), super.getAuctionProtocol());
	        
	        broadcastMessage(mia);
	        
	        setStartingTime(GridSim.clock());
	        
			onStart(++this.currentRound);
	
			// creates events for timeout of the rounds
			for(int i=this.currentRound;i<=this.totalRound;i++){
				super.send(super.get_id(), durationOfRounds * i, 
						AuctionTags.AUCTION_TIMEOUT, new Integer(i));
			}
    	}
    }
    
    /**
     * This method sets the auction as closed 
     */
    protected void closeAuction(){
		synchronized(syncStep){ 
			if(!this.isClosed()){
				onStop();
		
				setClosed(true);
			    	
		    	//sends message to the auctioneer informing about the end of the auction
		
				/* TODO: these messages back to auctioneer might not be needed.
				 * It is needed to find a better way to do it. 
				 */
				super.send(super.getAuctioneerID(), GridSimTags.SCHEDULE_NOW,
						AuctionTags.AUCTION_FINISHED, new Integer(super.getAuctionID()));
			}
		}
    }
	
	 /**
     * Processes events or services that are available for this Auctioneer
     * @param ev    a Sim_event object
     * @pre ev != null
     * @post $none
     */
    protected void processEvent(Sim_event ev){
        switch ( ev.get_tag() )
        {
            case AuctionTags.AUCTION_TIMEOUT:
            	int round = ((Integer)ev.get_data()).intValue();
    			synchronized(syncStep){ 
    				if(!isClosed())
    					this.onClose(round);
    				
    				if( (this.currentRound < this.totalRound) && !isClosed()){
   						onStart(++this.currentRound);
    				}
    				else if(!isClosed()){
    					closeAuction();
    				}
    			}
        	break;
        	
            case AuctionTags.AUCTION_PROPOSE:
         		MessageBid bid = (MessageBid)ev.get_data();
    			synchronized(syncStep){
    				if(!isClosed())
    					this.onReceiveBid(bid);
    			}
            break;
            
            case AuctionTags.AUCTION_REJECT_CALL_FOR_BID:
            	MessageRejectCallForBid rej = (MessageRejectCallForBid)ev.get_data();
    			synchronized(syncStep){ 
    				if(!isClosed())
    					this.onReceiveRejectCallForBid(rej);
    			}
        	break;
        	
            case AuctionTags.AUCTION_START:
    			synchronized(syncStep){ 
    				if(!isClosed())
    					this.startAuction();
    			}
        	break;
        	
            // other unknown tags are processed by this method
            default:
            	processOtherEvent(ev);
            break;
        }
    }
    
    /**
     * Overrides this method when making a new and different policy.
     * This method is called by {@link #body()} for incoming unknown tags.
     *
     * @param ev   a Sim_event object
     * @pre ev != null
     * @post $none
     */
	protected void processOtherEvent(Sim_event ev){
		if (ev == null){
	    	System.out.println(super.get_name() + ".processOtherEvent(): " +
	        	"Error - an event is null.");
	        return;
	    }
	}
    
	//abstract methods to be implemented by different one-sided auctions
	/**
	 * Called when a round is started
	 * @param round the number of the round that has started
	 */
	public abstract void onStart(int round);
	
	/**
	 * Called when a round finishes
	 * @param round the round that has finished
	 */
	public abstract void onClose(int round);
	
	/**
	 * Called when the auction finishes
	 */
	public abstract void onStop();
	
	/**
	 * Called when a bid is received.
	 * @param bid the bid received by the auctioneer
	 */
	public abstract void onReceiveBid(MessageBid bid);
	
	/**
	 * Called when a reject bid is received.
	 * @param mrej the reject received by the auctioneer
	 */
	public abstract void onReceiveRejectCallForBid(MessageRejectCallForBid mrej);
    
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
福利一区二区在线观看| 夜夜揉揉日日人人青青一国产精品| 久久亚洲精精品中文字幕早川悠里 | 色哟哟一区二区在线观看| 欧美电影影音先锋| 亚洲人成人一区二区在线观看 | jizzjizzjizz欧美| 欧美一区二区三区小说| 亚洲男帅同性gay1069| 久久99精品久久久久久动态图| 色呦呦网站一区| 国产精品久久久久一区二区三区| 久久精品国产精品亚洲精品| 欧美亚洲一区二区三区四区| 国产精品国模大尺度视频| 国产精品综合一区二区| 欧美mv日韩mv亚洲| 日本不卡视频在线| 在线播放视频一区| 亚洲一区在线免费观看| 色播五月激情综合网| 国产精品网曝门| 国产传媒久久文化传媒| 久久精品一区蜜桃臀影院| 老司机精品视频线观看86| 日韩午夜电影av| 美女精品一区二区| 日韩欧美国产一二三区| 久久99久久99小草精品免视看| 欧美精品xxxxbbbb| 午夜精品成人在线| 欧美蜜桃一区二区三区| 日韩精品五月天| 日韩精品专区在线影院观看| 蜜桃久久久久久| 精品国产亚洲在线| 国产美女在线精品| 欧美激情中文不卡| bt欧美亚洲午夜电影天堂| 亚洲欧洲三级电影| 在线视频一区二区三区| 视频一区国产视频| 精品88久久久久88久久久| 国内精品自线一区二区三区视频| 久久久.com| 色综合久久综合| 亚洲成人av一区二区| 日韩欧美国产高清| 国产成人aaa| 亚洲免费观看高清在线观看| 欧美视频一区在线观看| 久久精品国产亚洲一区二区三区| 欧美精品一区二区在线观看| yourporn久久国产精品| 国产精品一区二区无线| 中文字幕一区三区| 欧美日韩综合不卡| 九色|91porny| 亚洲色图欧美在线| 欧美肥胖老妇做爰| 不卡av电影在线播放| 亚洲aⅴ怡春院| 久久午夜色播影院免费高清| 99视频一区二区| 免费不卡在线观看| 最新久久zyz资源站| 欧美日韩国产另类一区| 国产91精品久久久久久久网曝门| 亚洲自拍都市欧美小说| www国产成人免费观看视频 深夜成人网| 懂色av中文一区二区三区| 亚洲精品久久久蜜桃| 欧美大片国产精品| 99精品视频在线播放观看| 日本成人在线不卡视频| 国产精品福利影院| 精品区一区二区| 欧洲色大大久久| 国产一区二区毛片| 天天影视网天天综合色在线播放| 国产日韩欧美a| 91精品国产综合久久婷婷香蕉| 懂色av一区二区三区免费观看| 五月激情丁香一区二区三区| 国产精品看片你懂得| 综合激情成人伊人| 精品99999| 日韩欧美综合在线| 欧美久久久久久久久中文字幕| 成人精品视频一区二区三区| 日本不卡123| 亚洲制服丝袜在线| 最新欧美精品一区二区三区| 久久精品水蜜桃av综合天堂| 日韩一级高清毛片| 欧美日本免费一区二区三区| 不卡的av电影| va亚洲va日韩不卡在线观看| 国产成人综合视频| 国产一区二区三区香蕉| 五月天久久比比资源色| 亚洲午夜国产一区99re久久| 亚洲人成在线播放网站岛国| 国产精品不卡在线| 国产欧美日韩在线看| 久久久久久久性| 久久久精品黄色| 国产亚洲成年网址在线观看| 久久五月婷婷丁香社区| 精品久久人人做人人爽| 日韩欧美久久久| 精品国产网站在线观看| 精品日韩一区二区| 久久免费视频一区| 国产丝袜在线精品| 中文子幕无线码一区tr| 中文字幕一区二区三区视频| 中文字幕制服丝袜一区二区三区| 国产精品久久久久天堂| 亚洲欧洲精品天堂一级| 国产伦精品一区二区三区在线观看| 九九国产精品视频| 国产一区二区三区高清播放| 国产精一品亚洲二区在线视频| 国产成人综合在线观看| 91亚洲精华国产精华精华液| 色婷婷久久一区二区三区麻豆| 在线视频欧美精品| 69精品人人人人| 久久奇米777| 中文字幕欧美一区| 五月激情综合色| 国产永久精品大片wwwapp | 在线视频你懂得一区| 欧美美女直播网站| 欧美白人最猛性xxxxx69交| 久久久美女艺术照精彩视频福利播放| 国产欧美一区二区三区在线老狼| 国产精品传媒在线| 婷婷成人综合网| 国产夫妻精品视频| 色欲综合视频天天天| 日韩视频在线永久播放| 中文子幕无线码一区tr | 亚洲欧美一区二区三区孕妇| 亚洲成人免费影院| 精品无码三级在线观看视频| 99久久久无码国产精品| 在线播放欧美女士性生活| 国产日韩亚洲欧美综合| 不卡视频在线看| 精品视频在线免费观看| 久久久久国产精品麻豆ai换脸 | 国产精品视频看| 午夜视频在线观看一区| 成人免费黄色在线| 欧美精品亚洲一区二区在线播放| 国产欧美日韩不卡免费| 婷婷激情综合网| 99精品欧美一区二区三区小说 | 另类调教123区| 色呦呦一区二区三区| 精品三级av在线| 亚洲小说春色综合另类电影| 国产成人综合自拍| 日韩欧美在线一区二区三区| 亚洲精品国产精品乱码不99| 国产在线观看一区二区| 欧美三片在线视频观看 | 99re热视频精品| 精品久久久久久无| 午夜视频在线观看一区二区 | 欧美不卡一区二区三区四区| 亚洲成人综合网站| www..com久久爱| 久久久久久久久岛国免费| 琪琪久久久久日韩精品| 欧美吞精做爰啪啪高潮| 中文字幕五月欧美| 国产一区二区三区电影在线观看| 欧美三级电影一区| 亚洲一区二区在线视频| 成人成人成人在线视频| 国产清纯白嫩初高生在线观看91 | 五月婷婷综合网| 在线日韩一区二区| 亚洲免费av高清| 91小视频在线免费看| 国产精品乱码人人做人人爱 | 黑人巨大精品欧美黑白配亚洲| 91精品国产色综合久久不卡蜜臀| 亚洲精品大片www| 色婷婷综合久久久中文一区二区| 中文字幕第一区二区| 国产凹凸在线观看一区二区| 精品国产sm最大网站| 激情文学综合丁香| 国产亚洲精品精华液| 成人午夜免费av| 亚洲欧美自拍偷拍色图|