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


Java PTMarking类代码示例

本文整理汇总了Java中de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking的典型用法代码示例。如果您正苦于以下问题:Java PTMarking类的具体用法?Java PTMarking怎么用?Java PTMarking使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setMarking

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
private void setMarking(PTNet net, String lineContent) {
    PTMarking marking = new PTMarking();
    String placeName;
    String multiplicityString;
    for (String token : getTokens(lineContent)) {
        int multiplicity;
        if (token.contains("=")) {
            placeName = PNUtils.sanitizeElementName(token.substring(0, token.indexOf("=")), "p");
            multiplicityString = token.substring(token.indexOf("=") + 1);
            Validate.notNegativeInteger(multiplicityString);
            multiplicity = Integer.parseInt(multiplicityString);
        } else {
            placeName = PNUtils.sanitizeElementName(token, "p");
            multiplicity = 1;
        }
        if (!net.containsPlace(placeName)) {
            throw new ParameterException("Unknown place: " + placeName);
        }
        marking.set(placeName, multiplicity);
    }
    net.setInitialMarking(marking);
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:23,代码来源:PetrifyParser.java

示例2: inOrDecrementPlaceState

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
@Override
/** Method for incrementing or decrementing the current #PTMarking of the given #PTPlace
 * @param cell
 * @param wheelRotation
 * @return 
 * @throws ParameterException
 */
public AbstractMarking inOrDecrementPlaceState(PNGraphCell cell, int wheelRotation) throws ParameterException {
	PTMarking initialMarking = getNetContainer().getPetriNet().getInitialMarking();
	PTMarking oldValue = initialMarking;
	Integer current = initialMarking.get(cell.getId());
	int capacity = getNetContainer().getPetriNet().getPlace(cell.getId()).getCapacity();	
	if(current != null && (capacity<0 ^ capacity>=(current - wheelRotation))) // null means here that the value "zero" has been set before / capacity -1 means infinite
	initialMarking.set(cell.getId(),  current - wheelRotation);
	else if(current == null && wheelRotation < 0 ) // create new Marking
	initialMarking.set(cell.getId(),  1);
	
	getNetContainer().getPetriNet().setInitialMarking(initialMarking);
	return oldValue;
}
 
开发者ID:iig-uni-freiburg,项目名称:WOLFGANG,代码行数:21,代码来源:PTGraph.java

示例3: create

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public PTNet create(PTNet ifnc) {

		// the start event directly corresponds to a transition
		ifnc.addTransition(name);
		int i;

		// add a single preplace with a single black token indicating that the event is enabled and can be fired when there is no incoming message flow
		ifnc.addPlace(name+"pre");

		PTMarking h = ifnc.getMarking();

		Multiset<String> pInMarking = new Multiset<String>();
		pInMarking.add("black");
		
		//h.set(name+"pre", pInMarking); //for ifnet
		h.set(name+"pre", 1); //for ptnet

		ifnc.setMarking(h);		
		ifnc.addFlowRelationPT(name+"pre", name);

		// create a postplace for each outgoing sequence flow (parallel flow)
		i=0;
		for(String k : this.outBound) {
			ifnc.addPlace(name+"post"+k+"_"+i+"_");
			ifnc.addFlowRelationTP(name, name+"post"+k+"_"+i+"_");
			end.put(k, name+"post"+k+"_"+i+"_");
		}		

		return ifnc;
	}
 
开发者ID:iig-uni-freiburg,项目名称:SWAT20,代码行数:31,代码来源:EndEvent.java

示例4: create

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public PTNet create(PTNet ifnc) {

		// the start event directly corresponds to a transition
		ifnc.addTransition(name);
		int i;

		// add a single preplace with a single black token indicating that the event is enabled and can be fired when there is no incoming message flow
		ifnc.addPlace(name+"pre");

		// IFNetMarking h = ifnc.getMarking(); //for ifnet
		PTMarking h = ifnc.getMarking(); //for ptnet

		Multiset<String> pInMarking = new Multiset<String>();
		pInMarking.add("black");
		//h.set(name+"pre", pInMarking);
		h.set(name+"pre", 1);

		ifnc.setMarking(h);

		ifnc.addFlowRelationPT(name+"pre", name);

		// create a postplace for each outgoing sequence flow (parallel flow)
		i=0;
		for(String k : this.outBound) {
			ifnc.addPlace(name+"post"+k+"_"+i+"_");
			ifnc.addFlowRelationTP(name, name+"post"+k+"_"+i+"_");
			end.put(k, name+"post"+k+"_"+i+"_");
		}		

		return ifnc;
	}
 
开发者ID:iig-uni-freiburg,项目名称:SWAT20,代码行数:32,代码来源:StartEvent.java

示例5: sharedResource

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public static PTNet sharedResource(int processes, int ressources) {
	Validate.bigger(processes, 1);
	Validate.bigger(ressources, 0);
	
	PTNet ptNet = new PTNet();
	ptNet.setName("SharedResource_"+processes+"_"+ressources);
	PTMarking initialMarking = new PTMarking();
	
	ptNet.addPlace("r");
	ptNet.getPlace("r").setCapacity(ressources);
	initialMarking.set("r", ressources);
	
	for(int i=1; i<=processes; i++){
		ptNet.addTransition("t"+i+"1");
		ptNet.addTransition("t"+i+"2");
		ptNet.addTransition("t"+i+"3");
		ptNet.addTransition("t"+i+"4");
		ptNet.addPlace("p"+i+"1");
		ptNet.addPlace("p"+i+"2");
		ptNet.addPlace("p"+i+"3");
		ptNet.addPlace("p"+i+"4");
		ptNet.addFlowRelationTP("t"+i+"1", "p"+i+"1");
		ptNet.addFlowRelationTP("t"+i+"2", "p"+i+"2");
		ptNet.addFlowRelationTP("t"+i+"3", "p"+i+"3");
		ptNet.addFlowRelationTP("t"+i+"4", "p"+i+"4");
		ptNet.addFlowRelationPT("p"+i+"1", "t"+i+"2");
		ptNet.addFlowRelationPT("p"+i+"2", "t"+i+"3");
		ptNet.addFlowRelationPT("p"+i+"3", "t"+i+"4");
		ptNet.addFlowRelationPT("p"+i+"4", "t"+i+"1");
		
		ptNet.addFlowRelationPT("r", "t"+i+"1");
		ptNet.addFlowRelationTP("t"+i+"2", "r");
		
		initialMarking.set("p"+i+"4", 1);
	}
	ptNet.setInitialMarking(initialMarking);
	return ptNet;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:39,代码来源:PNGenerator.java

示例6: producerConsumer

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public static PTNet producerConsumer(int producer, int consumer) {
	Validate.bigger(producer, 0);
	Validate.bigger(consumer, 0);
	
	PTNet ptNet = new PTNet();
	ptNet.setName("ProducerConsumer_"+producer+"_"+consumer);
	PTMarking initialMarking = new PTMarking();
	
	ptNet.addPlace("r1");
	ptNet.getPlace("r1").setCapacity(producer);
	ptNet.addPlace("r2");
	ptNet.getPlace("r2").setCapacity(producer);
	ptNet.addTransition("c");
	ptNet.addFlowRelationPT("r1", "c").setWeight(consumer);
	ptNet.addFlowRelationTP("c", "r2").setWeight(consumer);
	initialMarking.set("r2", consumer);
	
	for(int i=1; i<=producer; i++){
		ptNet.addTransition("use_"+i);
		ptNet.addTransition("produce_"+i);
		ptNet.addPlace("ready_"+i);
		ptNet.getPlace("ready_"+i).setCapacity(producer);
		ptNet.addPlace("produced_"+i);
		ptNet.getPlace("produced_"+i).setCapacity(producer);
		ptNet.addFlowRelationPT("ready_"+i, "produce_"+i);
		ptNet.addFlowRelationTP("produce_"+i, "produced_"+i);
		ptNet.addFlowRelationPT("produced_"+i, "use_"+i);
		ptNet.addFlowRelationTP("use_"+i, "ready_"+i);
		ptNet.addFlowRelationTP("use_"+i, "r1");
		ptNet.addFlowRelationPT("r2", "use_"+i);
		initialMarking.set("ready_"+i, 1);
	}
	
	ptNet.setInitialMarking(initialMarking);
	return ptNet;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:37,代码来源:PNGenerator.java

示例7: boundedPipeline

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public static PTNet boundedPipeline(int processes, int bound) {
		Validate.bigger(processes, 1);
		Validate.bigger(bound, 0);
		
		PTNet ptNet = new PTNet();
		ptNet.setName("BoundedPipeline_"+processes+"_"+bound);
		PTMarking initialMarking = new PTMarking();
		
		for(int i=1; i<=processes; i++){
			if(i==1){
				ptNet.addTransition("a0");
			}
			ptNet.addTransition("a"+i);
			ptNet.addPlace("p"+i+"1");
			ptNet.addPlace("p"+i+"2");
			ptNet.addFlowRelationTP("a"+(i-1), "p"+i+"2").setWeight(bound);
			ptNet.addFlowRelationPT("p"+i+"1", "a"+(i-1)).setWeight(bound);
			ptNet.addFlowRelationPT("p"+i+"2", "a"+i);
			ptNet.addFlowRelationTP("a"+i, "p"+i+"1");
			switch(i){
			case 1:
//				ptNet.addFlowRelationTP("c_"+i, "p_"+i+"_1").setWeight(bound);
//				ptNet.addFlowRelationPT("p_"+i+"_1", "c_"+(i-1));
				initialMarking.set("p"+i+"2", bound);
				break;
			default:
//				ptNet.addFlowRelationTP("c_"+i, "p_"+i+"_1");
//				ptNet.addFlowRelationPT("p_"+i+"_1", "c_"+(i-1)).setWeight(bound);
				initialMarking.set("p"+i+"1", bound);
			}
		}
		
		ptNet.setInitialMarking(initialMarking);
		return ptNet;
	}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:36,代码来源:PNGenerator.java

示例8: main

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public static void main(String[] args) throws BoundednessException {
	PTNet net = new PTNet();
	net.addPlace("p0");
	net.addTransition("t0");
	net.addFlowRelationPT("p0", "t0");
	net.addFlowRelationTP("t0", "p0", 1);
	PTMarking marking = new PTMarking();
	marking.set("p0", 100);
	net.setInitialMarking(marking);
	
	BoundednessCheck.initiateBoundednessCheck(net, new Test());
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:13,代码来源:Test.java

示例9: updatePlaceState

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
@Override
public void updatePlaceState(String name, Multiset<String> state) throws ParameterException {
	int tokens =  state.multiplicity("black");
	PTMarking initialMarking = getNetContainer().getPetriNet().getInitialMarking();
	initialMarking.set(name, tokens);
	getNetContainer().getPetriNet().setInitialMarking(initialMarking);	
	graphListenerSupport.notifyMarkingForPlaceChanged(name, state);
}
 
开发者ID:iig-uni-freiburg,项目名称:WOLFGANG,代码行数:9,代码来源:PTGraph.java

示例10: getORFragment

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public static PTNet getORFragment(Set<String> alternatives) {
    PTNet ptNet = new PTNet();
    String[] alt = new String[alternatives.size()];
    alternatives.toArray(alt);

    int k = alternatives.size();

    ptNet.addPlace("in");
    ptNet.addPlace("active");
    ptNet.addPlace("fin");
    ptNet.addPlace("out");

    ptNet.addTransition("start", true);
    ptNet.addTransition("end", true);
    ptNet.addTransition("no_option", true);

    ptNet.addFlowRelationPT("fin", "end");
    ptNet.addFlowRelationTP("end", "out");
    ptNet.addFlowRelationTP("start", "active");
    ptNet.addFlowRelationPT("active", "end");
    ptNet.addFlowRelationPT("in", "start");

    boolean[][] truthTable = MathUtils.getTruthTable(k);

    for (int i = 1; i <= k; i++) {
        String alternative = alt[i - 1];
        ptNet.addPlace("p" + i);
        ptNet.addPlace("p_" + alternative);
        ptNet.addPlace("p_not_" + alternative);

        ptNet.addTransition(alternative);
        ptNet.addTransition("Not " + alternative, true);

        ptNet.addFlowRelationTP("start", "p" + i);
        ptNet.addFlowRelationPT("p" + i, alternative);
        ptNet.addFlowRelationPT("p" + i, "Not " + alternative);
        ptNet.addFlowRelationTP(alternative, "p_" + alternative);
        ptNet.addFlowRelationTP("Not " + alternative, "p_not_" + alternative);
        ptNet.addFlowRelationPT("p_not_" + alternative, "no_option");
        ptNet.addFlowRelationTP("no_option", "p" + i);
    }

    for (int j = 0; j < Math.pow(2, k) - 1; j++) {
        String optionTransitionName = "Option_" + (j + 1);
        ptNet.addTransition(optionTransitionName, true);
        for (int l = 0; l < k; l++) {
            if (truthTable[l][j]) {
                ptNet.addFlowRelationPT("p_" + alt[l], optionTransitionName);
            } else {
                ptNet.addFlowRelationPT("p_not_" + alt[l], optionTransitionName);
            }
        }
        ptNet.addFlowRelationTP(optionTransitionName, "fin");
    }

    PTMarking marking = new PTMarking();
    marking.set("in", 1);
    ptNet.setInitialMarking(marking);

    return ptNet;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:62,代码来源:PNUtils.java

示例11: PTMarkingGraphState

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
public PTMarkingGraphState(String name, PTMarking element) {
	super(name, element);
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:4,代码来源:PTMarkingGraphState.java

示例12: createNewState

import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTMarking; //导入依赖的package包/类
@Override
protected PTMarkingGraphState createNewState(String name, PTMarking element) {
	return new PTMarkingGraphState(name, element);
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:5,代码来源:PTMarkingGraph.java


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