当前位置: 首页>>代码示例>>Java>>正文


Java Steppable类代码示例

本文整理汇总了Java中sim.engine.Steppable的典型用法代码示例。如果您正苦于以下问题:Java Steppable类的具体用法?Java Steppable怎么用?Java Steppable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Steppable类属于sim.engine包,在下文中一共展示了Steppable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import sim.engine.Steppable; //导入依赖的package包/类
@Override
public void start(FishState model) {
    Preconditions.checkArgument(receipt == null, "already started, love");


    //start all tiles
    for(Object element : rasterBackingGrid.elements())
    {
        SeaTile tile = (SeaTile) element; //cast
        tile.start(model);
    }

    Preconditions.checkArgument(receipt==null);
    //reset fished map count
    receipt =
            model.scheduleEveryDay(new Steppable() {
                @Override
                public void step(SimState simState) {
                    dailyTrawlsMap.setTo(0);
                }
            },StepOrder.DAWN);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:24,代码来源:NauticalMap.java

示例2: scheduleOnceAtTheBeginningOfYear

import sim.engine.Steppable; //导入依赖的package包/类
/**
 * will step this object only once when the specific year starts. If that year is in the past, it won't step.
 * Implementation wise unfortunately I just check every year to see whether to step this or not. It's quite silly.
 * @param steppable
 * @param order
 * @param year
 */
public Stoppable scheduleOnceAtTheBeginningOfYear(Steppable steppable,StepOrder order, int year)
{

    final Steppable container = new Steppable() {
        @Override
        public void step(SimState simState) {
            //the plus one is because when this is stepped it's the 365th day
            if(((FishState) simState).getYear()+1 == year) {
                steppable.step(simState);
            }

        }
    };
    return scheduleEveryYear(container,order);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:24,代码来源:FishState.java

示例3: schedulePerPolicy

import sim.engine.Steppable; //导入依赖的package包/类
public Stoppable schedulePerPolicy(Steppable steppable, StepOrder order, IntervalPolicy policy)
{
    switch (policy){
        case EVERY_STEP:
            return scheduleEveryStep(steppable,order);
        case EVERY_DAY:
            return scheduleEveryDay(steppable,order);
        case EVERY_MONTH:
            return scheduleEveryXDay(steppable,order,30);
        case EVERY_YEAR:
            return scheduleEveryYear(steppable, order);
        default:
            Preconditions.checkState(false,"Reset Policy not found");
    }

    return null;
}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:18,代码来源:FishState.java

示例4: apply

import sim.engine.Steppable; //导入依赖的package包/类
/**
 * Applies this function to the given argument.
 *
 * @param fishState the function argument
 * @return the function result
 */
@Override
public ExternalOpenCloseSeason apply(FishState fishState) {
    return locker.presentKey
            (fishState,
             new Supplier<ExternalOpenCloseSeason>() {
                 @Override
                 public ExternalOpenCloseSeason get() {
                     ExternalOpenCloseSeason toReturn = new ExternalOpenCloseSeason();

                     fishState.scheduleEveryXDay(new Steppable() {
                         @Override
                         public void step(SimState simState) {
                             toReturn.setOpen(fishState.getRandom().nextBoolean());
                         }
                     }, StepOrder.POLICY_UPDATE,30);

                     return toReturn;
                 }
             });

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:28,代码来源:RandomOpenCloseController.java

示例5: start

import sim.engine.Steppable; //导入依赖的package包/类
@Override
public void start(FishState model, Fisher fisher) {

    //shedule yourself to check for profits every year
    if(stoppable != null)
        throw  new RuntimeException("Already started!");

    Steppable steppable = new Steppable() {
        @Override
        public void step(SimState simState) {
            checkIfQuit(fisher);
        }
    };
    this.stoppable = model.scheduleEveryYear(steppable, StepOrder.DAWN);
    decorated.start(model,fisher);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:18,代码来源:ExitDepartingDecorator.java

示例6: start

import sim.engine.Steppable; //导入依赖的package包/类
@Override
public void start() {
   super.start();
   initSeries();
   
   scheduleRepeatingImmediatelyAfter(new Steppable() {
      private static final long serialVersionUID = 1L;
      private int lastCycleIndex   = 0;
      
      @Override
      public void step(final SimState state) {
         final AbstractModel model = (AbstractModel) state;
         final int currentCycleIndex = (int) Simulation.getFloorTime();
         
         if (model.schedule.getTime() != Schedule.AFTER_SIMULATION
             && currentCycleIndex != lastCycleIndex) {
            scheduleSeries(model);
            lastCycleIndex = currentCycleIndex;
         }
      }
   });
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:23,代码来源:MasterModelGUI.java

示例7: RecordingTestModel

import sim.engine.Steppable; //导入依赖的package包/类
public RecordingTestModel(long seed) {
    super(seed);
    
    for (int i = 0; i < agentNum; i++) {
        RecordingTestAgent recordingTestAgent = new RecordingTestAgent(i);
        agentList.add(recordingTestAgent);
        anonymList.add(recordingTestAgent);
    }
    
    schedule.scheduleRepeating(
        new Steppable() {
            private static final long
                serialVersionUID = 1023983258758828337L;
            
            @Override
            public void step(SimState state) {
                someDouble = state.schedule.getTime();
                intList.add((int) Math.round(someDouble));
            }
        }, 
        1);
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:23,代码来源:RecordingTestModel.java

示例8: addSteppables

import sim.engine.Steppable; //导入依赖的package包/类
@Override
public void addSteppables() {
	Steppable manager = (Steppable) this.getScenario().getProperties().get("ManagerAgent");
	try {
		this.registerShanksAgent((ShanksAgent) manager);
	} catch (ShanksException e) {
		logger.severe(e.getMessage());
		System.exit(1);
	}
	schedule.scheduleRepeating(Schedule.EPOCH, 3, manager, 1);
	Steppable generator = new DiagnosisCaseGenerator(this.getScenario().getProperties()
			.getProperty(SimulationConfiguration.TESTDATASET), this.getLogger());
	schedule.scheduleRepeating(Schedule.EPOCH, 6, generator, 1);
	boolean repMode = new Boolean(this.getScenario().getProperties()
			.getProperty(SimulationConfiguration.REPUTATIONMODE));
	Steppable evaluator = new DiagnosisCaseEvaluator(this.getScenario().getProperties()
			.getProperty(SimulationConfiguration.CLASSIFICATIONTARGET), this.getScenario()
			.getProperties().getProperty(SimulationConfiguration.EXPOUTPUT), this.getScenario()
			.getProperties().getProperty(SimulationConfiguration.TESTDATASET), repMode, this.getLogger());
	schedule.scheduleRepeating(Schedule.EPOCH, 5, evaluator, 1);
}
 
开发者ID:gsi-upm,项目名称:BARMAS,代码行数:22,代码来源:DiagnosisSimulation.java

示例9: setupProduction

import sim.engine.Steppable; //导入依赖的package包/类
private void setupProduction(final Firm seller) {
    sellerToInflowMap.put(seller,inflowPerSeller);
    getModel().scheduleSoon(ActionOrder.PRODUCTION,new Steppable() {
        @Override
        public void step(SimState simState) {
            if(destroyUnsoldInventoryEachDay)
                seller.consumeAll();

            //sell 4 goods!
            int inflow = sellerToInflowMap.get(seller);
            seller.receiveMany(UndifferentiatedGoodType.GENERIC,inflow);
            seller.reactToPlantProduction(UndifferentiatedGoodType.GENERIC,inflow);

            //every day
            getModel().scheduleTomorrow(ActionOrder.PRODUCTION,this);
        }
    });
}
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:19,代码来源:SimpleSellerScenario.java

示例10: createBuyer

import sim.engine.Steppable; //导入依赖的package包/类
private void createBuyer(final EconomicAgent seller, Market market, int price, float time){

        /**
         * For this scenario we use dummy buyers that shop only once every "period"
         */
        final DummyBuyer buyer = new DummyBuyer(getModel(),price,market);  market.registerBuyer(buyer);
        buyer.receiveMany(UndifferentiatedGoodType.MONEY,1000000);

        //Make it shop once a day for one good only!
        getModel().scheduleSoon(ActionOrder.TRADE,
                new Steppable() {
                    @Override
                    public void step(SimState simState) {


                        DummyBuyer.goShopping(buyer,seller, UndifferentiatedGoodType.GENERIC);
                        getModel().scheduleTomorrow(ActionOrder.TRADE,this);
                    }
                }
        );


        getAgents().add(buyer);
    }
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:25,代码来源:SimpleDecentralizedSellerScenario.java

示例11: buildFirm

import sim.engine.Steppable; //导入依赖的package包/类
public Firm buildFirm() {
    //only one seller
    final Firm built= new Firm(getModel());
    built.receiveMany(UndifferentiatedGoodType.MONEY,500000000);
    // built.setName("monopolist");
    //set up the firm at time 1
    getModel().scheduleSoon(ActionOrder.DAWN, new Steppable() {
        @Override
        public void step(SimState simState) {
            buildSalesDepartmentToFirm(built);
            Plant plant = buildPlantForFirm(built);
            buildHrForFirm(plant, built);


        }
    });

    model.addAgent(built);
    return built;
}
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:21,代码来源:MonopolistScenario.java

示例12: adjust

import sim.engine.Steppable; //导入依赖的package包/类
/**
 /**
 * The adjust is the main part of the a controller. It checks the new error and set the MV (which is the price, really)
 *
 * @param stockTarget the stock target
 * @param stockInput the stock input
 * @param flowInput the flow input
 * @param isActive true if the pid is not turned off
 * @param state   the simstate link to schedule the user
 * @param user     the user who calls the PID (it needs to be steppable since the PID doesn't adjust itself)
 */
public void adjust(float stockTarget,float stockInput, float flowInput, boolean isActive,
                    MacroII state,  Steppable user,  ActionOrder phase)
{
    //master
    pid1.adjust(stockTarget,stockInput,isActive,state,user,phase); //to avoid exxaggerating in disinvesting, the recorded inventory is never more than twice the target
    //slave

    targetForSlavePID = pid1.getCurrentMV();
    // targetForSlavePID = masterOutput > 1 ? (float)Math.log(masterOutput) : masterOutput < -1 ? -(float)Math.log(-masterOutput) : 0;
    //

    assert !Float.isNaN(targetForSlavePID) && !Float.isInfinite(targetForSlavePID);
    ControllerInput secondPIDInput = new ControllerInput(targetForSlavePID,flowInput);
    pid2.adjust(secondPIDInput, isActive, null, null, null);


}
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:29,代码来源:CascadePIDController.java

示例13: adjust

import sim.engine.Steppable; //导入依赖的package包/类
/**
 * The adjust is the main part of the PID Controller. This method doesn't compute but rather receive the new error
 * and just perform the PID magic on it
 * @param residual the residual/error: the difference between current value of y and its target
 * @param isActive is the agent calling this still alive and active?
 * @param simState a link to the model (to reschedule the user)
 * @param user     the user who calls the PID (it needs to be steppable since the PID doesn't adjust itself)
 * @param phase at which phase should this controller be rescheduled
 */
public void adjust(float residual, boolean isActive,
                   MacroII simState,  Steppable user,ActionOrder phase, Priority priority)
{
    //delegate the PID itself to adjustOnce, and worry about refactoring
    if (!adjustOnce(residual, isActive))
        return;


    /*************************
     * Reschedule
     *************************/


    if(simState != null && user != null){
        if(speed == 0)
            simState.scheduleTomorrow(phase, user,priority);
        else
        {
            assert speed > 0;
            simState.scheduleAnotherDay(phase,user,speed+1,priority);
        }
    }

}
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:34,代码来源:PIDController.java

示例14: adjust

import sim.engine.Steppable; //导入依赖的package包/类
/**
 /**
 * The adjust is the main part of the a controller. It checks the new error and set the MV (which is the price, really)
 *
 * @param stockTarget the stock target
 * @param stockInput the stock input
 * @param flowInput the flow input
 * @param isActive true if the pid is not turned off
 * @param state   the simstate link to schedule the user
 * @param user     the user who calls the PID (it needs to be steppable since the PID doesn't adjust itself)     * @param firstTarget
 */
public void adjust(float stockTarget,float stockInput, float flowInput, boolean isActive,
                   MacroII state,  Steppable user,  ActionOrder phase)
{
    //master
    pid1.adjust(stockTarget,Math.min(stockInput,stockTarget*5),isActive,state,user,phase); //to avoid exxaggerating in disinvesting, the recorded inventory is never more than twice the target
    //slave

    targetForSlavePID = pid1.getCurrentMV();
    // targetForSlavePID = masterOutput > 1 ? (float)Math.log(masterOutput) : masterOutput < -1 ? -(float)Math.log(-masterOutput) : 0;
    //

    assert !Float.isNaN(targetForSlavePID) && !Float.isInfinite(targetForSlavePID);
    ControllerInput secondPIDInput = new ControllerInput(targetForSlavePID,flowInput);
    pid2.adjust(secondPIDInput, isActive, null, null, null);


}
 
开发者ID:CarrKnight,项目名称:MacroIIDiscrete,代码行数:29,代码来源:CascadePToPIDController.java

示例15: createPeriodicNE

import sim.engine.Steppable; //导入依赖的package包/类
@Test
public void createPeriodicNE() {
    Steppable generator = new Steppable() {

        private static final long serialVersionUID = 1L;

        public void step(SimState arg0) {

        }
    };
    PeriodicNetworkElementEvent pe = new MyPeriodicNetElementEvent(
            generator);

    Assert.assertEquals(generator, pe.getLauncher());
    Assert.assertEquals(500, pe.getPeriod());

}
 
开发者ID:gsi-upm,项目名称:Shanks,代码行数:18,代码来源:EventTest.java


注:本文中的sim.engine.Steppable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。