// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   WalrasServer.java

package walras;


// Referenced classes of package walras:
//			WalrasMarket

class WalrasServer
{

	public double _MinX1;
	public double _MaxX1;
	public double _X1;
	public double _X1Step;
	public double _MinX2;
	public double _MaxX2;
	public double _X2;
	public double _X2Step;
	public double _MinY;
	public double _MaxY;
	public double _Y;
	public double _YStep;
	public double _MinP;
	public double _MaxP;
	public double _P;
	public double _PStep;
	public double _Z0;
	public double _Z1;
	public double _Z2;
	public double _C0;
	public double _tau;
	public double _timeLeft;
	public int _ai;
	public int _ni;
	public int _s_nr;
	public WalrasMarket _market;

	public WalrasServer()
	{
		_MinX1 = 1.0D;
		_MaxX1 = 1.0D;
		_X1 = 1.0D;
		_X1Step = 1.0D;
		_MinX2 = 1.0D;
		_X2 = 1.0D;
		_X2Step = 1.0D;
		_MinY = 1.0D;
		_MaxY = 1.0D;
		_Y = 1.0D;
		_YStep = 1.0D;
		_MinP = 1.0D;
		_MaxP = 1.0D;
		_P = 1.0D;
		_PStep = 1.0D;
		_Z0 = 1.0D;
		_Z1 = 1.0D;
		_Z2 = 1.0D;
		_C0 = 1.0D;
	}

	public double getC0()
	{
		return _C0;
	}

	public double getMaxP()
	{
		return _MaxP;
	}

	public double getMaxX1()
	{
		return _MaxX1;
	}

	public double getMaxX2()
	{
		return _MaxX2;
	}

	public double getMaxY()
	{
		return _MaxY;
	}

	public double getMinP()
	{
		return _MinP;
	}

	public double getMinX1()
	{
		return _MinX1;
	}

	public double getMinX2()
	{
		return _MinX2;
	}

	public double getMinY()
	{
		return _MinY;
	}

	public double getP()
	{
		return _P;
	}

	public double getPStep()
	{
		return _PStep;
	}

	public int getServedClients()
	{
		return _ai;
	}

	public double getX1()
	{
		return _X1;
	}

	public double getX1Step()
	{
		return _X1Step;
	}

	public double getX2()
	{
		return _X2;
	}

	public double getX2Step()
	{
		return _X2Step;
	}

	public double getY()
	{
		return _Y;
	}

	public double getYStep()
	{
		return _YStep;
	}

	public double getZ0()
	{
		return _Z0;
	}

	public double getZ1()
	{
		return _Z2;
	}

	public double getZ2()
	{
		return _Z2;
	}

	public double getZi()
	{
		double d = -getZ1() * getX1();
		double d1 = -getZ2() * getX2();
		double d2 = getZ0() * (1.0D - Math.exp(d)) * (1.0D - Math.exp(d1));
		return d2;
	}

	public int getni()
	{
		return _ni;
	}

	public double getserviceTime()
	{
		return _tau;
	}

	public double getvi()
	{
		double d;
		if(_s_nr == 0)
		{
			double d1 = _market.GetB1();
			d = (_market.serverList[0].getP() * (1.0D + _market.Eps * _market.serverList[0].getP()) * _market.serverList[0].getX1() + _market.serverList[0].getP() * (1.0D + _market.Eps * _market.serverList[0].getP()) * _market.serverList[1].getX1() + _market.serverList[1].getP() * _market.serverList[0].getX2()) - _market.serverList[0].getP() * (1.0D + _market.Eps * _market.serverList[0].getP()) * d1;
		} else
		{
			double d2 = _market.GetB2();
			d = (_market.serverList[1].getP() * (1.0D + _market.Eps * _market.serverList[1].getP()) * _market.serverList[1].getX2() + _market.serverList[1].getP() * (1.0D + _market.Eps * _market.serverList[1].getP()) * _market.serverList[0].getX2() + _market.serverList[0].getP() * _market.serverList[1].getX1()) - _market.serverList[1].getP() * (1.0D + _market.Eps * _market.serverList[1].getP()) * d2;
		}
		return d;
	}

	public double profit()
	{
		double d = getvi();
		double d1;
		if(d >= 0.0D)
			d1 = _market.Alfa1;
		else
			d1 = _market.Alfa2;
		double d2 = (double)_ai * getY() - (1.0D + d1) * d;
		return d2;
	}

	public double serveClients(double d)
	{
		for(; _tau <= d && _ni != 0; _tau = WalrasMarket.randomDouble(getZi()))
		{
			_ni--;
			_ai++;
			d -= _tau;
		}

		return d;
	}

	public void setC0(double d)
	{
		_C0 = d;
	}

	public void setMarket(WalrasMarket walrasmarket)
	{
		_market = walrasmarket;
	}

	public void setMaxP(double d)
	{
		_MaxP = d;
	}

	public void setMaxX1(double d)
	{
		_MaxX1 = d;
	}

	public void setMaxX2(double d)
	{
		_MaxX2 = d;
	}

	public void setMaxY(double d)
	{
		_MaxY = d;
	}

	public void setMinP(double d)
	{
		_MinP = d;
	}

	public void setMinX1(double d)
	{
		_MinX1 = d;
	}

	public void setMinX2(double d)
	{
		_MinX2 = d;
	}

	public void setMinY(double d)
	{
		_MinY = d;
	}

	public void setP(double d)
	{
		_P = d;
	}

	public void setPStep(double d)
	{
		_PStep = d;
	}

	public void setS_Nr(int i)
	{
		_s_nr = i;
	}

	public void setServedClients(int i)
	{
		_ai = i;
	}

	public void setX1(double d)
	{
		_X1 = d;
	}

	public void setX1Step(double d)
	{
		_X1Step = d;
	}

	public void setX2(double d)
	{
		_X2 = d;
	}

	public void setX2Step(double d)
	{
		_X2Step = d;
	}

	public void setY(double d)
	{
		_Y = d;
	}

	public void setYStep(double d)
	{
		_YStep = d;
	}

	public void setZ0(double d)
	{
		_Z0 = d;
	}

	public void setZ1(double d)
	{
		_Z2 = d;
	}

	public void setZ2(double d)
	{
		_Z2 = d;
	}

	public void setni(int i)
	{
		_ni = i;
	}

	public void setserviceTime(double d)
	{
		_tau = d;
	}

	public double timeLeft()
	{
		return _timeLeft;
	}

	public double totalCost()
	{
		double d = getZi();
		double d1;
		if(d == 0.0D)
			d1 = 1.7976931348623157E+308D;
		else
			d1 = (double)getni() / d;
		return getY() + d1;
	}
}
