Component-Based Abstraction and Refinement

Component-Based Abstraction and Refinement
Component-Based Abstraction and Refinement

Component-Based Abstraction and Re?nement

Juncao Li1,Xiuli Sun2,Fei Xie1,and Xiaoyu Song2

1Dept.of Computer Science,Portland State University,Portland,OR97207

2Dept.of ECE,Portland State University,Portland,OR97207

Abstract.In this paper,we present a comprehensive approach to model check-

ing component-based systems(including software,hardware,and embedded

systems)through abstraction and re?nement.This approach is based on assume-

guarantee compositional reasoning and features two synergistic techniques:(1)

an automatic algorithm to component-based abstraction and(2)a mechanized as-

sistant for abstraction re?nement.The key insight to the abstraction algorithm is

that a veri?ed property is a natural abstraction of a component.The abstraction

algorithm automatically determines which component properties can be included

in the abstraction for verifying a system property by determining whether the as-

sumptions of the component properties hold in the context of the system.If the

abstraction fails to establish the system property,the re?nement assistant deter-

mines the causes of the failure,e.g.,why a component property is not included,

and provides automatic remedies or requests manual remedies.This approach has

been applied in component-based hardware/software co-veri?cation of embedded

systems.Case studies have shown that this approach is very effective in abstract-

ing component-based embedded systems and guiding abstraction re?nement.

1Introduction

A common trend in both hardware and software industries is component-based develop-ment(CBD):developing systems via assembly of components[1,2].(In the hardware industry,CBD is also known as IP-based development[1].)Embedded systems are also increasingly component-based and include only the necessary hardware and soft-ware components for their missions,due to their diverse applications and often stringent physical constraints.CBD introduces compositional structures and standard component interfaces into systems and promotes reuse of design and development efforts.As veri-?cation becomes increasingly important,it is also desired to reuse veri?cation efforts.

Reuse of veri?cation efforts is further made possible by the increasing practice of assertion-based veri?cation(ABV)[3].ABV was initially developed for hardware veri-?cation,however,it is gaining popularity in software veri?cation and embedded system veri?cation.ABV requires component developers to specify temporal correctness prop-erties of components as they are https://www.360docs.net/doc/8d4426869.html,ponent properties are often speci?ed in standard property speci?cation languages such as the IEEE Property Speci?cation Language(PSL)[4],which facilitates reuse of component properties.

This research was supported by Semiconductor Research Corporation Contract1356.001and National Science Foundation Grant0720546.

H.Mei(Ed.):ICSR2008,LNCS5030,pp.39–51,2008.

c Springer-Verlag Berlin Heidelberg2008

40J.Li et al.

Model checking[5]is a formal veri?cation method that has great potential in system veri?cation.It provides exhaustive state space coverages for the systems being veri?ed.

A stumbling block to scalable application of model checking is its intrinsic complex-ity.The number of possible states and execution paths in a real-world system can be extremely large,which requires state space https://www.360docs.net/doc/8d4426869.html,positional reasoning[6],as applied in model checking,is a powerful state space reduction algorithm and accom-plishes veri?cation of a property on a system by decomposing the system into mod-ules,checking the module properties locally,and deriving the system property from the module https://www.360docs.net/doc/8d4426869.html,positional system structures introduced by CBD may greatly simplify application of compositional reasoning in system veri?cation.

To leverage the collective effectiveness of CBD,ABV,model checking,and compo-sitional reasoning in system veri?cation,the following challenges need to be addressed:–How to determine which component properties should be considered in deriving

a system-level property?ABV tends to introduce a large number of component

properties.Automation is needed in managing these properties and extracting the appropriate component properties for verifying a system-level property.

–How to determine which component properties can be used in verifying a system-level properties?Many properties have enabling assumptions.Automation is needed in determining whether a component property is enabled,i.e.,whether its assumptions hold in the context of the system.

–How to determine the causes for a compositional reasoning failure,i.e.,failure to derive a system property from component properties that have been established, and identify remedies for the problems?To address these problems,manual efforts are sometimes needed.It is desired to reduce the manual efforts when possible.

In this paper,we present a comprehensive approach to model checking component-based systems(including software,hardware,and embedded systems)through abstraction and re?nement.This approach is based on assume-guarantee compositional reasoning[7,8,9,10,11,12,13]and features two synergistic techniques:(1)an automatic algorithm to component-based abstraction and(2)a mechanized assistant for abstrac-tion re?nement.The key insight to the abstraction algorithm is that a veri?ed property is a natural abstraction of a component.This algorithm automatically determines which component properties should be considered in constructing the abstraction for verify-ing a system property by dependency analysis and which component properties can be included in the abstraction by determining whether the assumptions of these properties hold in the context of the system.If the abstraction fails to establish the system prop-erty,the re?nement assistant determines the causes of the failure,e.g.,why a component property is not included,and provides automatic remedies or requests manual remedies.

Our approach to component-based abstraction and re?nement has been applied in hardware/software co-veri?cation of embedded systems.Case studies have shown that this approach is very effective in abstracting component-based embedded systems and guiding abstraction re?nement.In particular,this abstraction and re?nement approach can be applied across the hardware/software boundaries smoothly.

The reminder of this paper is organized as follows.In Section2,we provide the background of this work.In Section3,we introduce the algorithm to component-based abstraction and the procedure for mechanizing abstraction re?nement.In Section4,

Component-Based Abstraction and Re?nement41 we present application of component-based abstraction and re?nement in hardware/ software co-veri?cation and evaluate its effectiveness.In Section5,we discuss related work.In Section6,we conclude this paper and touch on future work.

2Background

2.1ω-Automaton Semantics

We adopt the L-process model ofω-automaton semantics,details of which can be found in[14].Only the concepts necessary for this paper are given below.For an L-process,ω,its language,L(ω),is the set of all in?nite sequences accepted byω.For L-processes,ω1,...,ωn,their synchronous parallel composition,ω=ω1?...?ωn,

is an L-process and L(ω)=∩L(ωi),and their Cartesian sum,ω =ω1⊕...⊕ωn,is also an L-process and L(ω)=∪L(ωi).The safety closure CL(ω)of an L-processωis an L-process whose language is the safety closure of the language ofω,L(CL(ω))= cl(L(ω)).In[14],cl(L)is termed as the smallest limit pre?x-closed language con-taining L.Given L-processesω1andω2,ω1implementsω2(denoted byω1|=ω2)if L(ω1)?L(ω2).

Under theω-automaton semantics,model checking is reduced to checking L-process language containment.Suppose a system is modeled by the compositionω1?...?ωn of L-processes,ω1,...,ωn,and a property to be checked on the system is modeled by an L-processes,ω.The property holds on the system if and only if the language of ω1?...?ωn is contained by the language ofω,L(ω1?...?ωn)?L(ω).A realization of theω-automaton semantics is the S/R language[15].S/R is the input formal language of the COSPAN model checker[15],which we utilize in this research.

2.2Assume-Guarantee Compositional Reasoning

Assume-guarantee compositional reasoning,that each module guarantees certain prop-erties based on properties of the other modules,was introduced by Chandy and Misra[7]and Jones[8]for analyzing safety properties.Abadi and Lamport[9],Alur and Henzinger[10],and McMillan[11]extended it to liveness properties.These ex-tensions are incomplete,i.e.,there exist properties of systems which are true but not provable using these extensions[12].Amla,Emerson,Namjoshi,and Tre?er proposed a sound and complete compositional reasoning rule for both safety and liveness prop-erties[13].This rule,Rule1,has been realized in theω-automaton semantics as shown below.

Rule1.Forω-automata P1and P2modeling two components of a system,and Q mod-eling a property of the system,to show that P1?P2|=Q,?ndω-automata Q1and Q2 modeling the component properties such that the following conditions are satis?ed.

C0:V i(Q1)?V i(P1)and Q1does not block P2,and vice versa for Q2

C1:P1?Q2|=Q1and P2?Q1|=Q2

C2:Q1?Q2|=Q

C3:Either P1?CL(Q)|=(Q⊕Q1⊕Q2)or P2?CL(Q)|=(Q⊕Q1⊕Q2)

42J.Li et al.

V i(P)is the set of interface variables of P.A process Q does not block process P iff(i)any initial state of P can be extended to an initial state of P?Q,and(ii)for any reachable state of P?Q,any transition of P from that state can be extended to a transition of P?Q.An additional restriction on P s and Q s,which is not shown in Rule1,is that P1(or Q1,respectively)and P2(or Q2)modify disjoint sets of variables.

Note that checking Condition C3is not needed if one of Q1,Q2,and Q is a safety property since its safety closure is itself.In[16],Rule1has also been extended to support compositional reasoning with components that have shared sub-components.

3Component-Based Abstraction and Re?nement

In this section,we?rst present a key observation that leads to our component-based approach to abstraction and re?nement:veri?ed properties of a component can serve as abstractions of the component if their assumptions are satis?ed.Then,we introduce our automatic algorithm that constructs abstractions of a composite component(a system is a composite component)from veri?ed properties of its sub-components.After that,we introduce a mechanized assistant to re?nement of component-based abstraction.

3.1Veri?ed Properties as Component Abstractions

Once a property p is veri?ed on a component C,we have C|=p,i.e.,all behaviors that C exhibits are a subset of the behaviors allowed by p,and p is usually structurally less complex than C.Therefore,veri?ed properties are natural abstractions of components. In theω-automaton semantics,this is more appealing since systems,components,prop-erties,and assumptions are modeled uniformly asω-automata.In the rest of this paper, systems,components,properties,and assumptions are all modeled asω-automata.

However,when verifying component properties,assumptions are often introduced due to the dependencies of a component to its environment.For instance,if p is veri?ed on C under a set A(p)of assumptions,we have A(p)?C|=p.In this case,to utilize p as the abstraction of C,we must show that A(p)can be satis?ed.We introduce the concept of an enabled component property in a component composition as follows: De?nition1.Given a composition of components C=C1?...?C n.A property (p,A(p))of C i,1≤i≤n,is enabled in C if and only if C1?...?C n|=A(p). Checking whether p is enabled by checking C1?...?C n|=A(p)is often as expensive as,if not more expensive than,directly checking C1?...?C n|=p.On the other hand, it is often the case that many other properties of C1,...,C n have already been veri?ed. Therefore,it is desirable to determine whether(p,A(p))is enabled,through analyzing the veri?ed properties of C1,...,C n.

Determining whether a sub-component property is enabled is further complicated by the fact that there may exist circular dependencies among the sub-component proper-ties.It must be shown that these circular dependencies do not cause circular reasoning, before the sub-component properties can be deemed as enabled.

Not all enabled sub-component properties are necessary in verifying a property of the composition since properties are asserted on certain aspects of a component.There-fore,we only need to determine whether the sub-component properties related to the

Component-Based Abstraction and Re?nement43

property of the composition are enabled.To ensure all the related sub-component prop-erties are included,a straightforward approach is to apply cone-of-in?uence analysis[5] based on the component interfaces and their connections.This may bring in unnecessary properties.More accurate dependency analysis are needed to exclude such properties.

Based on the above discussion,we de?ne an abstraction of a component as follows: De?nition2.Given a component C=C1?...?C n and a property(p,A(p))to be veri?ed on C,an abstraction for checking(p,A(p))is the composition of all veri?ed properties of C1,...,C n that are related to p by dependency analysis and can be shown to be enabled through analyzing A(p)and the veri?ed properties of C1,...,C n.

The abstraction is conservative since each enabled property of a sub-component is a conservative abstraction of the https://www.360docs.net/doc/8d4426869.html,position of conservative abstrac-tions is a conservative abstraction due to the language intersection property of ω-automata.Therefore,if(p,A(p))holds on the abstraction,it also holds on C.

According to[17],properties can be categorized as safety properties,liveness proper-ties,and their hybrids.(The same categorization is also applicable to assumptions.)Any property p can be represented as the intersection of a safety property and a liveness prop-erty.In theω-automaton semantics,this is represented as p≡CL(p)∧(?CL(p)∨p) where CL(p)is the safety closure[17]of p.In this study,we specify properties and as-sumptions using theω-automata assertion templates in[16].Based on these templates, it is easy to identify a safety or liveness assertion and decompose a hybrid assertion into its safety and liveness parts.Being able to identify safety and liveness assertions enables us to better determine whether circular dependencies among component properties can cause circular reasoning.We assume that the components and properties involved in component-based abstraction and re?nement meet the restrictions imposed by Rule1. Therefore,cycles with safety properties will not cause circular reasoning.We only need to consider pure liveness property cycles for possible circular reasoning.

3.2Automatic Component-Based Abstraction

There are two major tasks for the component-based abstraction algorithm:(1)deciding which sub-component properties should be considered in constructing the abstraction for a composite component and(2)determining whether these sub-component prop-erties are enabled.The ef?ciency and effectiveness of this algorithm lies in whether unnecessary properties can be excluded from the abstraction and necessary properties can be shown to be enabled as possible only by analyzing the sub-component properties. Suppose that C is a composite component with sub-components C1,...,C n.The interface I i of C i is a pair(V I i,V O i)where V I i is the set of variables C i imports and V O i is the set of variables C i exports.We assume all V O i’s are disjoint.When C i is composed with other components,the input variables in V I i are mapped to the output variables in V O i’s of other components.P i is a set of properties of C i that are de?ned on I i and has been veri?ed.Each property in P i is of the form(p ij,A(p ij)),1≤j≤m i and m i is the number of properties in P i.Our abstraction algorithm constructs the abstraction for verifying(p,A(p))on C from the sub-component properties,where (p,A(p))is de?ned on the interface I of C and I is also a pair(V I,V O).To simplify the presentation of our algorithm,let P=P1∪...∪P n∪{(true,p),(A(p),?)},i.e.,P

44J.Li et al.

is the set of all sub-component properties with addition of(true,p)and(A(p),?)which are derived from(p,A(p)).(A(p),?)is marked as enabled since A(p)are assumptions on the environment of C.Our automatic abstraction algorithm is shown in Figure1: Inputs:P={(true,{p}),(p1,A(p1)),...,(p s,A(p s)),(A(p),?)}

where s is the sum of the numbers of properties in P1,...,P n

Outputs:“p holds”or“re?nement needed”

Build the property dependency graph G from P;

foreach node t∈G do/*via DFS or BFS*/

Find all nodes N in G that t depends on;/*via dependency arcs from t*/

if!(P(N)|=A(t))then/*“!”representing logic negation*/

Mark t as DU(directly unsatis?ed);

enqueue(Que,t);

endif

endfor

while!empty(Que)do

t=dequeue(Que);

Find all unmarked nodes N in G that depend on t;/*via arcs to t*/

foreach t in N

Find all unmarked nodes N that t depends on;/*via dependency arcs from t */

if!(P(N )|=A(t ))then

Mark t as IU(indirectly unsatis?ed);

enqueue(Que,t );

endif

endfor

endwhile

if(true,{p})is marked DU or IU then return“re?nement needed”;

else

SCSs={strong connected subgraphs of unmarked liveness properties};

if!empty(SCSs)then return“re?nement needed”;

else return“p holds”;

endif

endif

https://www.360docs.net/doc/8d4426869.html,ponent-Based Abstraction Algorithm

Step1:Build the property dependency graph G.To determine which sub-component properties should be considered in abstraction construction,we?rst construct a depen-dency graph based on the potential enabling relations among the sub-component prop-erties.We initiate the graph with a single node(true,p)and expand the graph from it.For each node(p g,A(p g))in the graph,which has not been expanded,we?rst?nd all the sub-component properties(p h,A(p h))based on the direct variable dependen-cies between A(p g)and p h and then?nd all the sub-component properties(p k,A(p k))

Component-Based Abstraction and Re?nement 45

based on the direct or indirect dependencies between p h and p k through examining only the property part (but not the assumption part)of each node along the dependency chain.If any (p h ,A (p h ))or (p k ,A (p k ))is not in the graph,include it in the graph,add a directed arc from (p g ,A (p g ))to it,and put it in the queue for nodes to be expanded;otherwise,just add the arc.

Optimization based on ω-automata assertion templates.The above approach to building the property dependency graph may involve a lot of unnecessary component properties since it only considers variable dependencies.This may lead to signi?cant overhead in abstraction construction and re?nement.We optimize this approach

using heuristics based on the semantic meanings of the ω-automata assertion templates in [16].Example.Consider a system S with two components C 1and C 2.C 1outputs a variable a and inputs a variable b .C 2outputs two variables b and c and inputs a variable a .The properties of C 1and C 2are shown in Figure 2.(Note that all assertions in a set,e.g.,A 12,are conjunctive.)A system property to be veri?ed is p :Repeatedly (c )with no assumption.The property dependency graph constructed for verifying p is in Figure 2.

Property of C 1:p 11:After (a)Never (a)UnlessAfter (b);A 11:{Never (b)UnlessAfter (a);

After (b)Never (b)UnlessAfter (a);}

p 12:Repeatedly (a);A 12:{After (a)Eventually (b);

Never (b)UnlessAfter (a);

After (b)Never (b)UnlessAfter (a)};

Properties of C 2:p 21:Never (b)UnlessAfter (a);

After (b)Never (b)UnlessAfter (a);A 21:{After (a)Never (a)UnlessAfter (b);}

p 22:After (a)Eventually (b);A 22:{After (a)Never (a)UnlessAfter (b);}

p 23:Repeatedly (c);A 23:{Repeatedly (a);

After (a)Never (a)UnlessAfter (b);}https://www.360docs.net/doc/8d4426869.html,ponent Properties and Property Dependency Graph

Step 2:Determine enabled properties optimistically.After the dependency graph is constructed,we determine,in an optimistic way,whether a sub-component property in the graph is enabled.It is optimistic since we assume,at this point,that dependency cycles do not cause circular reasoning.We will deal with these cycles in the next step.We ?rst conduct a breadth-?rst or depth-?rst search on the graph.For each node t in the graph,we ?nd the set N of all nodes to which t has dependency arcs.We check P (N )|=A (t ),i.e.,whether the property assertions from all the nodes in N can conjunctively satisfy the assumption assertions in A (t ).If no,we mark t as “directly unsatis?ed”,i.e.,even if all the nodes in N are enabled,t will still not be enabled.

Starting from the set of nodes marked as “directly unsatis?ed”,we recursively iden-tify nodes that are unsatis?ed due to their dependencies to nodes that have been marked

46J.Li et al.

as unsatis?ed.That an unmarked node t has a dependency arc to an unsatis?ed node t

does not imply that t is unsatis?ed.We still need to check if the unmarked nodes which t depends on can satisfy t .This process terminates when there are no more unsatis?ed properties to mark(assuming that dependency cycles do not cause circular reasoning).

The unsatis?ed nodes identi?ed in this phase are marked“indirectly unsatis?ed”.

If(true,p)is marked as unsatis?ed,directly or indirectly,the abstraction algorithm returns and requests re?nement;otherwise,the algorithm moves on to Step3.

Step3:Detect liveness circular dependencies.In this step,we detect the existence of circular dependencies among the unmarked liveness sub-component properties in the graph G.The circular dependency detection is by?nding the strongly connected sub-graphs of the unmarked liveness sub-component properties.If there exist such sub-graphs in G,the abstraction algorithm returns and requests re?nement.

Remarks:The component-based abstraction constructed by our algorithm includes all

the sub-component properties which(true,p)depends on and are identi?ed as enabled.

In this algorithm,we determine whether a node t can be satis?ed by the nodes in N,

by applying model checking,speci?cally,applying COSPAN with P(N)as the system and A(t)as the property to be checked.The complexity of such a check depends on the property and assumption assertions involved.Since we specify these assertions using the templates in[16],each assertion is simple and has only a few states.Therefore,the number of assertions is the deciding factor.The overall complexity of our algorithm also depends on the number of calls to COSPAN.The number of calls to COSPAN is, in the worst case,the sum of the number of nodes and the number of arcs in G.Other complexities of this algorithm include that of building the property dependency graph and that of detecting strongly connected sub-graphs of unmarked liveness properties.

3.3Mechanized Abstraction Re?nement

Our abstraction algorithm may fail to verify a property(p,A(p))for the following two reasons:(1)the sub-component properties are insuf?cient to verify(p,A(p))and(2) there exist liveness property dependency cycles that,before being validated to be free of circular reasoning,preclude inclusion of the involved sub-component properties in the abstraction.Below,we present our mechanized approaches to addressing the problems. Insuf?cient sub-component properties.When our abstraction algorithm reports that it fails to establish(p,A(p))due to insuf?cient sub-component properties,our re?ne-ment assistant conducts a breadth-?rst search through the dependency graph generated by the abstraction algorithm to identify all nodes that are marked“directly unsatis-?ed”and reachable from(p,A(p))through only nodes marked“indirectly unsatis?ed”. For each such node,the assistant outputs the node,the nodes it depends on,and the error trace of the COSPAN call on this node.The user is asked to modify existing sub-component properties and introduce new sub-component properties.These modi?ed or new sub-components properties need to be veri?ed.If a sub-component is a primitive component,its modi?ed or new properties are directly checked on the component;oth-erwise,the properties are checked again through component-based abstraction. Liveness property circular dependencies.When our abstraction algorithm reports liveness property circular dependencies,our re?nement assistant provides to the user

Component-Based Abstraction and Re?nement47

all strongly connected sub-graphs of unmarked liveness properties.An automatic

rem-

edy the assistant can provide is to check the additional conditions(such as C3in Rule1) dictated by the rules in Sec2.2,which,if established,can prevent circular reasoning. These conditions are essentially additional properties to be checked on the involved sub-components.If a sub-component is primitive,its additional property can be checked directly;otherwise,component-based abstraction is recursively applied.If these rules fail,the user needs to manually validate that the sub-graphs be free of circular reasoning using techniques such as temporal induction[11],modify the existing sub-component properties,or introduce new sub-component properties.(Note that modi?cation of ex-isting properties and introduction of new properties may lead to new circular dependen-cies.)If all sub-graphs are shown to be free of circular reasoning,(p,A(p))holds. Remarks:The abstraction/re?nement loop terminates when(p,A(p))is veri?ed or the user aborts this loop.The user aborts this loop when an error is found or she has dif-?culty in modifying or introducing sub-component properties for verifying(p,A(p)). Errors in component composition are detected through the user examining the unsat-is?ed nodes in the dependency graph.Errors in sub-components are detected when veri?cation of sub-component properties fails.

4Application in Hardware/Software Co-veri?cation

An Illustrative Example.We illustrate component-based abstraction and re?nement with its application in hardware/software(HW/SW)co-veri?cation of a sensor system as shown in Figure3.Its software is partitioned into two components:software sensor (S-SEN)and software network(S-NET)and its hardware is partitioned into three com-ponents:hardware clock(H-CLK),hardware sensor(H-SEN),and hardware network (H-NET).The software components are speci?ed in xUML[18]while the hardware components are speci?ed in Verilog[19].The software and hardware components are connected by bridge components(B-SEN and B-NET),which interact with the soft-ware components following the software semantics and with the hardware components Legend:

Software Message

Hardware Signal

Component

Fig.3.Architecture of a sensor instance with software in xUML and hardware in Verilog

48J.Li et al.

Repeated(H-NET.?ag=true);Repeated(H-NET.?ag=false);

Fig.4.Repeated transmission property

/*Properties of S-SEN*/

P SS(1)→{P SN(1)}

P SS(2)→{P BS(1)}

P SS(3)→{P SN(4),P SN(1),P BS(1)}

P SS(4)→{P SN(4),P SN(1),P BS(3),P BS(2),P BS(1)}

/*Properties of S-NET*/

P SN(1)→{P SS(1)}

P SN(2)→{P SN(1),P SS(1),P BN(1)}

P SN(3)→{P SN(1),P SS(1),P BN(1)}

P SN(4)→{P SN(1),P SS(1),P BN(1)}

P SN(5)→{P SN(1),P SS(4),P SS(1),P BN(2),P BN(1)}

/*Properties of B-SEN and B-NET*/

P BS(1)→{P SS(2),P HS(1)}

P BS(2)→{P SS(3),P SS(2),P HS(2),P HS(1)}

P BS(3)→{P SS(3),P SS(2),P HC(1),P HS(2),P HS(1)}

P BN(1)→{P SN(2),P HN(1)}

P BN(2)→{P SN(3),P SN(2),P HN(2),P HN(1)}

P BN(3)→{P SN(5),P SN(3),P SN(2),P HN(2),P HN(1)}

/*Properties of H-NET*/

P HN(3)→{P BN(3)}

Fig.5.Dependencies among component properties

following the hardware semantics and propagate events such as software messages and hardware interrupts across the HW/SW boundary.A property to verify on this system is shown in Figure4.This property asserts that the sensor system transmits on the net-work repeatedly.Repeated setting and clearing of a?ag in H NET indicates repeated transmission.(Space limitation precludes presentation of the component properties).

We apply component-based abstraction to verify the system property.The abstrac-tion algorithm constructs an assume-guarantee dependency graph as shown in Figure5. The abstraction algorithm is able to enable each property optimistically by ignoring dependency cycles.In this graph,there are only dependency cycles involving safety properties,there is no need to check for additional conditions and all these properties hold and they enable all other properties that depend on them.All the involved proper-ties form the abstraction on which the system property is successfully veri?ed.

To evaluate the effectiveness of our re?nement assistant,we intentionally omit the properties P BN(3)and P BS(3)and their assumptions since these are properties of the bridge components that cannot be automatically generated from their designs.We then apply abstraction and re?nement.The assistant reports that the property P HN(3)is not enabled since one of its assumptions is not satis?ed due to the omission of P BN(3). When P BN(3)and its assumptions are introduced,the assistant then reports that the property P SS(4)is not enabled since one of its assumptions is not satis?ed due to the omission of P BS(3).The key here is that the user is only noti?ed when manual remedies are necessary.This re?nement assistant is effective in locating unsatis?ed assumptions and reports them to the user as hints for further property modi?cation and introduction.

Component-Based Abstraction and Re?nement49

Table1.Time and memory usage comparison

Usages Basic Multi Encrypting

TBCV Time(Sec)31272.8--

TBCV Memory(MB)1660.62Out of memory Out of memory Manual CBCV Time(Sec)41.8910.340.77

Manual CBCV Memory(MB)9.11 6.05 3.57

Manual CBCV#of COSPAN Calls824

Automatic CBCV Time(Sec)205.9310.4512.97

Automatic CBCV Memory(MB)27.57 4.44 3.54

Automatic CBCV#of COSPAN Calls392439 Experimental Results.Table1shows statistics from veri?cation of the property in Figure4on three sensor systems of increasing complexity using three different ap-proaches.The“Basic”system refers to the system discussed above.The“Multi”system and the“Encrypting”system are more complex than the“Basic”system.(See[20]for details of these systems.)TBCV denotes translation-based co-veri?cation[21]which translates an entire system into S/R and then veri?es the entire system with COSPAN. In the manual component-based co-veri?cation(CBCV)approach[20],the component-based abstraction of a system is manually constructed.(Manually created abstractions serve as guidance in optimizing our automatic algorithm.)In the automatic CBCV ap-proach,our automatic abstraction algorithm is applied to construct the abstraction.The time(or memory,respectively)usage of verifying a system using CBCV is the sum (or max)of the time(or memory)usages of verifying the new components and the abstraction.The component properties are veri?ed by translating the properties and the corresponding components into S/R and applying COSPAN.(Translation of hard-ware components in Verilog utilizes FormalCheck[22]while translation of software components in xUML and bridge components utilizes ObjectCheck[23].)It can be ob-served that the time and memory usages of automatic CBCV are order-of-magnitude smaller than those of TBCV in verifying the?rst system and TBCV fails to verify the other systems due to out-of-memory while automatic CBCV?nishes the veri?cation using little time and memory(which include those for graph construction and strongly connected sub-graph detection).Although automatic CBCV uses more time and mem-ory than manual CBCV,it is automatic and requires no manual effort in abstraction construction.

5Related Work

Our approach builds on and extends compositional reasoning[6],in particular, assume-guarantee compositional reasoning[7,8,9,10,11,12,13].It combines assume-guarantee compositional reasoning with abstraction/re?nement[14]by utilizing component properties as abstractions.It integrates compositional reasoning and ab-straction/re?nement with component-based development and leverages assertion-based veri?cation to address the component property formulation problem in application of compositional reasoning.

Abstraction techniques[5,14],as applied in model checking,reduce a system to a less complex system while preserving correctness of the property to be checked.Major

50J.Li et al.

approaches to abstraction that have been practically useful include(but are not lim-ited to)localization reduction[14],data abstraction[5],and predicate abstraction[24]. In[11],McMillan integrated data abstraction,assume-guarantee compositional reason-ing,and theorem proving techniques in the context of the Cadence SMV system[11]. Our approach,although more restricted compared to McMillan’s approach,is more lightweight and is more closely integrated with component-based development.

6Conclusions and Future Work

In this paper,we have presented a comprehensive approach to component-based ab-straction and re?nement.This approach is generally applicable although our imple-mentation is based on theω-automaton semantics and the COSPAN model checker, since its foundation is compositional reasoning.It advances compositional reasoning via integration with component-based development and assertion-based veri?cation.

The accuracy and ef?ciency of our abstraction algorithm and re?nement assistant is affected signi?cantly by the dependency graphs that are constructed over component properties.The dependency graphs are conservative in that they do not omit any true de-pendency.However,there may be false dependencies introduced by dependency analy-sis.False dependencies may prevent the abstraction algorithm from including properties that should have been included in an abstraction and may also prevent the re?nement assistant from providing an accurate description of the causes for a compositional rea-soning failure.We will research better methods for removing false dependencies. References

1.Jacome,M.F.,Peixoto,H.P.:A survey of digital design reuse.IEEE Design and Test of

Computers18(3)(2001)

2.Szyperski,C.:Component Software-Beyond Object-Oriented Programming.Addison-

Wesley,Reading(2002)

3.Maliniak,D.:Assertion-based veri?cation smooths the road to IP reuse.Electronic Design

(September2002)

4.IEEE:IEEE Property Speci?cation Language(PSL)(IEEE Std1850-2005).IEEE(2005)

5.Clarke,E.M.,Grumberg,O.,Peled,D.:Model checking.MIT Press,Cambridge(1999)

6.de Roever,W.P.,de Boer,F.,Hanneman,U.,Hooman,J.,Lakhnech,Y.,Poel,M.,Zwiers,

J.:Concurrency Veri?cation:Introduction to Compositional and Non-compositional Proof Methods.Cambridge University Press,Cambridge(2001)

7.Chandy,K.M.,Misra,J.:Proofs of networks of processes.IEEE Transaction on Software

Engineering7(4)(1981)

8.Jones,C.B.:Development methods for computer programs including a notion of interference.

PhD thesis,Oxford University(1981)

9.Abadi,M.,Lamport,L.:Conjoining speci?cations.TOPLAS17(3)(1995)

10.Alur,R.,Henzinger,T.:Reactive modules.FMSD15(1)(1999)

11.McMillan,K.L.:A methodology for hardware veri?cation using compositional model check-

ing.Cadence Design Systems Technical Reports(1999)

12.Namjoshi,K.S.,Tre?er,R.J.:On the completeness of compositional reasoning.In:Emerson,

E.A.,Sistla,A.P.(eds.)CA V2000.LNCS,vol.1855.Springer,Heidelberg(2000)

Component-Based Abstraction and Re?nement51 13.Amla,N.,Emerson,E.A.,Namjoshi,K.S.,Tre?er,R.:Assume-guarantee based composi-

tional reasoning for synchronous timing diagrams.In:Margaria,T.,Yi,W.(eds.)ETAPS 2001and TACAS2001.LNCS,vol.2031.Springer,Heidelberg(2001)

14.Kurshan,R.P.:Computer-Aided Veri?cation of Coordinating Processes:The Automata-

Theoretic Approach.Princeton University Press,Princeton(1994)

15.Hardin,R.H.,Har’El,Z.,Kurshan.,R.P.:COSPAN.In:Alur,R.,Henzinger,T.A.(eds.)CA V

1996.LNCS,vol.1102.Springer,Heidelberg(1996)

16.Xie,F.,Yang,G.,Song,X.:Compositional reasoning for hardware/software co-veri?cation.

In:Graf,S.,Zhang,W.(eds.)ATV A2006.LNCS,vol.4218.Springer,Heidelberg(2006)

17.Alpern,B.,Schneider,F.:De?ning https://www.360docs.net/doc/8d4426869.html,rmation Processing Letters21(4)(1985)

18.Mellor,S.J.,Balcer,M.J.:Executable UML:A Foundation for Model Driven Architecture.

Addison-Wesley,Reading(2002)

19.IEEE:IEEE Standard for Verilog(IEEE Std1364-2005).IEEE(2005)

20.Xie,F.,Yang,G.,Song,X.:Component-based hardware/software co-veri?cation.In:Proc.

of MEMOCODE(2006)

21.Xie,F.,Song,X.,Chung,H.,Nandi,R.:Translation-based co-veri?cation.In:Proc.of MEM-

OCODE(2005)

22.Kurshan,R.P.:FormalCheck User Manual.Cadence(1998)

23.Xie,F.,Levin,V.,Browne,J.C.:Objectcheck:A model checking tool for executable object-

oriented software system designs.In:Kutsche,R.-D.,Weber,H.(eds.)ETAPS2002and FASE2002.LNCS,vol.2306.Springer,Heidelberg(2002)

24.Graf,S.,Sa¨?di,H.:Construction of abstract state graphs with PVS.In:Grumberg,O.(ed.)

CA V1997.LNCS,vol.1254.Springer,Heidelberg(1997)

通达信函数大全使用说明

软件简介: 通达信全部函数及其用法(2011年最新版) (一)行情函数 1)HIGH(H)最高价返回该周期最高价.2)LOW(L)最低价返回该周期最低价.3)CLOSE(C)收盘价返回该周期收盘价.4)VOL(V)成交量(手)返回该周期成交量.5)OPEN (O)开盘价返回该周期开盘价.6)ADVANCE 上涨家数返回该周期上涨家数. (本函数仅对大盘有效)7)DECLINE 下跌家数返回该周期下跌家数. (本函数仅对大盘有效)8)AMOUNT 成交额(元)返回该周期成交额.9)VOLINSTK 持仓量返回期货该周期持仓量.10)QHJSJ 期货结算价返回期货该周期结算价. 11)BUYVOL 外盘(手)返回外盘,即时行情数据 12)SELVOL 外盘(手)返回外盘 13)ISBUYORDER 主动性买单返回当前成交是否为主动性买单.用法: ISBUYORDER,当本笔成交为主动性买盘时,返回1,否则为0 14)DHIGH 不定周期最高价返回该不定周期最高价.15)DOPEN 不定周期开盘价返回该不定周期开盘价.16) DLOW 不定周期最低价返回该不定周期最低价.17)DCLOSE 不定周期收盘价返回该不定周期收盘价.18) DVOL 不定周期成交量价返回该不定周期成交量价.19)NAMELIKE 模糊股票名称返回股票名称是否以参数开头.

用法: if(NAMELIKE('ST'),x,y); 20)CODELIKE 模糊股票代码返回股票代码是否以参数开头. 用法: if(CODELIKE('600'),x,y); 21)INBLOCK 属于某板块返回股票是否属于某板块. 用法: if(INBLOCK('沪深300'),x,y); (二)时间函数 1)PERIOD 周期取得周期类型. 结果从0到11,依次分别是1/5/15/30/60分钟,日/周/月,多分钟,多日,季,年. 2)DATE 日期取得该周期从1900以来的的年月日. 用法: DATE 例如函数返回1000101,表示2000年1月1 日,DATE+19000000后才是真正的日期值 3)TIME 时间取得该周期的时分秒.用法: TIME 函数返回有效值范围为(000000-235959) 4)YEAR 年份取得该周期的年份.5)MONTH 月份取得该周期的月份.用法: 函数返回有效值范围为(1-12) 6)WEEKDAY 星期取得该周期的星期数.用法: WEEKDAY 函数返回有效值范围为(1-7) 7)DAY 日取得该周期的日期.用法: DAY 函数返回有效值范围为(1-31) 8)HOUR 小时取得该周期的小时数.用法: HOUR 函数返回有效值范围为(0-23),对于日线及更长的分析周期值为0

指针与引用的区别(非常经典)

c++中,引用和指针的区别 (1)引用总是指向一个对象,没有所谓的null reference .所有当有可能指向一个对象也由可能不指向对象则必须使用指针. 由于C++ 要求reference 总是指向一个对象所以reference要求有初值. String & rs = string1; 由于没有所谓的null reference 所以所以在使用前不需要进行测试其是否有值.,而使用指针则需要测试其的有效性. (2)指针可以被重新赋值而reference则总是指向最初或地的对象. (3)必须使用reference的场合. Operator[] 操作符由于该操作符很特别地必须返回[能够被当做assignment 赋值对象] 的东西,所以需要给他返回一个reference. (4)其实引用在函数的参数中使用很经常. void Get***(const int& a) //这样使用了引用有可以保证不修改被引用的值 { } 引用和指针 ★相同点: 1. 都是地址的概念; 指针指向一块内存,它的内容是所指内存的地址;引用是某块内存的别名。 ★区别: 1. 指针是一个实体,而引用仅是个别名; 2. 引用使用时无需解引用(*),指针需要解引用; 3. 引用只能在定义时被初始化一次,之后不可变;指针可变; 引用“从一而终” ^_^ 4. 引用没有const,指针有const,const 的指针不可变; 5. 引用不能为空,指针可以为空; 6. “sizeof 引用”得到的是所指向的变量(对象)的大小,而“sizeof 指针”得到的是指针本身(所指向的变量或对象的地址)的大小; typeid(T) == typeid(T&) 恒为真,sizeof(T) == sizeof(T&) 恒为真, 但是当引用作为成员时,其占用空间与指针相同(没找到标准的规定)。

通达信公式函数使用方法及解释说明大全

通达信公式函数使用方法及解释说明大全 一、行情函数 HIGH 最高价 返回该周期最高价。 用法: HIGH H 最高价 返回该周期最高价。 用法: H LOW 最低价 返回该周期最低价。 用法: LOW L 最低价 返回该周期最低价。 用法: L CLOSE 收盘价 返回该周期收盘价。 用法: CLOSE C 收盘价 返回该周期收盘价。 用法: C VOL 成交量 返回该周期成交量。 用法: VOL V 成交量 返回该周期成交量。 用法: V OPEN 开盘价 返回该周期开盘价。 用法: OPEN O:开盘价 返回该周期开盘价。 用法: O ADVANCE 上涨家数 返回该周期上涨家数。 用法: ADVANCE (本函数仅对大盘有效) DECLINE 下跌家数 返回该周期下跌家数。 用法: DECLINE (本函数仅对大盘有效) AMOUNT 成交额 返回该周期成交额。 用法: AMOUNT ASKPRICE 委卖价 返回委卖1--委卖3价格。

用法: ASKPRICE(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) ASKVOL 委卖量 返回委卖1--委卖3量。 用法: ASKVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDPRICE 委买价 返回委买1--委买3价格。 用法: BIDPRICE(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDVOL 委买量 返回委买1--委买3量。 用法: BIDVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BUYVOL 主动性买盘 返回主动性买单量。 用法:BUYVOL 当本笔成交为主动性买盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) SELLVOL 主动性卖盘 返回主动性卖单量。 用法:SELLVOL 当本笔成交为主动性卖盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) ISBUYORDER 主动性买单 返回该成交是否为主动性买单。 用法: ISBUYORDER 当本笔成交为主动性买盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) ISSELLORDER 主动性卖单 返回该成交是否为主动性卖单。 用法:ISSELLORDER 当本笔成交为主动性卖盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) 二、时间函数 DATE 日期 取得该周期从1900以来的年月日。 用法: DATE 例如函数返回1000101,表示2000年1月1日。 TIME 时间 取得该周期的时分秒。 用法: TIME 函数返回有效值范围为(000000-235959)。 YEAR 年份 取得该周期的年份。 用法:YEAR MONTH 月份 取得该周期的月份。 用法:MONTH 函数返回有效值范围为(1-12)。

Java中传值与传引用的三种情况

java传值与传引用的三种情况大家先看一个例子: public class Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.print(ex.str+" and "); System.out.print(ex.ch); } public void change(String str,char ch[]){ str="test ok"; ch[0]='g'; } } 看看输出结果? good and gbc java中没有了c++中这样的引用符号,也没像c#中那样提供了out与ref 那么它是怎么做的呢 做什么事情都要去除例外的东西,String类就是此类问题的一个特殊情况 为什么特殊呢?

因为它是一个引用类型,确执行的是值传递。这样说有些抽象,还是举个例子吧 值传递: class Str { public static void main(String[] args) { int i = 900; System.out.println(i); changeInt(i); System.Out.println(i); } public static void changeInt(int s) { s = 34234; } } 结果: 900 900 这就是所谓的值传递。i把自己的副本给了函数changeInt的形参,而在changeInt中虽然将s赋值34234。但是对原来的i值并没有影响,因为它所修改的只是i的copy品而已。

c#中ref和out参数使用时需要注意的问题

c#中ref和out参数使用时需要注意的问题 C#方法中的ref和out {大部分参照<<21天学通C#>>,小部分写了自己的感受,编程功底比较差,只能写这么多,多包涵} ref 通常我们向方法中传递的是值.方法获得的是这些值的一个拷贝,然后使用这些拷贝,当方法运行完毕后,这些拷贝将被丢弃,而原来的值不将受到影响.此外我们还有其他向方法传递参数的形式,引用(ref)和输出(out). 有时,我们需要改变原来变量中的值,这时,我们可以向方法传递变量的引用,而不是变量的值.引用是一个变量,他可以访问原来变量的值,修改引用将修改原来变量的值.变量的值存储在内存中,可以创建一个引用,他指向变量在内存中的位置.当引用被修改时,修改的是内存中的值,因此变量的值可以将被修改.当我们调用一个含有引用参数的方法时,方法中的参数将指向被传递给方法的相应变量,因此,我们会明白,为什么当修改参数变量的修改也将导致原来变量的值. 创建参数按引用传递的方法,需使用关键字ref.例; using System; class gump { public double square(ref double x) { x=x*x; return x; } } class TestApp { public static void Main() { gump doit=new gump(); double a=3; double b=0; Console.WriteLine("Before square->a={0},b={1}",a,b); b=doit.square(ref a); Console.WriteLine("After square->a={0},b={1}",a,b);

通达信函数大全(整理)

通达信函数大全 4.1行情函数 HIGH 最高价返回该周期最高价。用法:HIGH H 最高价返回该周期最高价。用法:H LOW 最低价返回该周期最低价。用法:LOW L 最低价返回该周期最低价。用法:L CLOSE 收盘价返回该周期收盘价。用法:CLOSE C 收盘价返回该周期收盘价。用法:C VOL 成交量返回该周期成交量。用法:VOL V 成交量返回该周期成交量。用法:V OPEN 开盘价返回该周期开盘价。用法:OPEN O:开盘价返回该周期开盘价。用法:O ADV ANCE 上涨家数返回该周期上涨家数。用法:ADV ANCE(本函数仅对大盘有效) DECLINE 下跌家数返回该周期下跌家数。用法:DECLINE(本函数仅对大盘有效) AMOUNT 成交额返回该周期成交额。用法:AMOUNT ASKPRICE 委卖价返回委卖1--委卖3价格。用法:ASKPRICE(N)N取1—3。 (本函数仅个股在分笔成交分析周期有效) ASKVOL 委卖量返回委卖1--委卖3量。用法:ASKVOL(N)N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDPRICE 委买价返回委买1--委买3价格。用法:BIDPRICE(N)N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDVOL 委买量返回委买1--委买3量。用法:BIDVOL(N)N取1—3。 (本函数仅个股在分笔成交分析周期有效) BUYVOL 主动性买盘返回主动性买单量。用法:BUYVOL当本笔成交为主动性买盘时, 其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) SELLVOL 主动性卖盘返回主动性卖单量。用法:SELLVOL当本笔成交为主动性卖盘时, 其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) ISBUYORDER 主动性买单返回该成交是否为主动性买单。用法:ISBUYORDER当本笔成交 为主动性买盘时,返回1,否则为0。(本函数仅个股在分笔成交分析周期有效) ISSELLORDER 主动性卖单返回该成交是否为主动性卖单。用法:ISSELLORDER当本笔成交为主动性卖盘时,返回1,否则为0。(本函数仅个股在分笔成交分析周期有效)] 4.2时间函数 DATE 日期取得该周期从1900以来的年月日。用法:DATE 例如函数返回1000101,表示2000年1月1日。TIME 时间取得该周期的时分秒。用法:TIME函数返回有效值范围为(000000-235959)。YEAR 年份取得该周期的年份。用法:YEAR MONTH 月份取得该周期的月份。用法:MONTH函数返回有效值范围为(1-12)。 WEEK 星期取得该周期的星期数。用法:WEEK函数返回有效值范围为(0-6),0表示星期天。DAY 日期取得该周期的日期。用法:DAY函数返回有效值范围为(1-31)。 HOUR 小时取得该周期的小时数。用法:HOUR函数返回有效值范围为(0-23),对于日线及 更长的分析周期值为0。

String是类似值传递、String数组是引用传递

首先、我们必须牢记的一点是:java语言规范规定,String型变量指向的内存空间中的内容是不能被改变的,即String是不可改变的类! 示例一: public class TestConstant{ public static void main(String args[]){ String str=new String("hello"); str="Welcome to Here"; System.out.println(str); } } 解析:毋庸置疑,此程序输出的将是“Welcome to Here”,但是给str重新赋值的操作(str="Welcome to Here"),不是简单的将str指向的原内存地址内容改为"Welcome to Here",而是从新分配一块内存用来存放"Welcome to Here",然后将str指向该新分配的内存地址。而原来的"hello"如果没有其他String变量指向它,那么他将被java的垃圾收集器回收;如果有其他的String变量指向它,它将在内存继续存在,比如: 示例二: public class TestConstant{ public static void main(String args[]){ String str=new String("hello"); String str1=str; str="123"; System.out.println(str); System.out.println(str1); } }

解析:上面的程序会先后输出123和hello,由于str1仍然指向hello,所以hello所在内存没有被回收。 一、普通的类对象作为函数参数是引用传递 示例三: class Common{ private int a; public Common(int a){ this.a=a; } public void setA(int a){ this.a=a; } public void disp(){ System.out.println(a); } } public class TestCommon{ public static void main(String args[]){ Common c=new Common(1); set(c,3); c.disp(); }

最新最全通达信公式函数说明大全

通达信公式函数说明 一、行情函数 HIGH 最高价 返回该周期最高价。 用法: HIGH H 最高价 返回该周期最高价。 用法: H LOW 最低价 返回该周期最低价。 用法: LOW L 最低价 返回该周期最低价。 用法: L CLOSE 收盘价 返回该周期收盘价。 用法: CLOSE C 收盘价 返回该周期收盘价。 用法: C VOL 成交量 返回该周期成交量。 用法: VOL V 成交量 返回该周期成交量。 用法: V OPEN 开盘价 返回该周期开盘价。 用法: OPEN O:开盘价 返回该周期开盘价。 用法: O ADVANCE 上涨家数 返回该周期上涨家数。 用法: ADVANCE (本函数仅对大盘有效) DECLINE 下跌家数 返回该周期下跌家数。 用法: DECLINE (本函数仅对大盘有效) AMOUNT 成交额 返回该周期成交额。 用法: AMOUNT ASKPRICE 委卖价 返回委卖1--委卖3价格。 用法: ASKPRICE(N) N取1—3。

(本函数仅个股在分笔成交分析周期有效) ASKVOL 委卖量 返回委卖1--委卖3量。 用法: ASKVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDPRICE 委买价 返回委买1--委买3价格。 用法: BIDPRICE(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDVOL 委买量 返回委买1--委买3量。 用法: BIDVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BUYVOL 主动性买盘 返回主动性买单量。 用法:BUYVOL 当本笔成交为主动性买盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) SELLVOL 主动性卖盘 返回主动性卖单量。 用法:SELLVOL 当本笔成交为主动性卖盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) ISBUYORDER 主动性买单 返回该成交是否为主动性买单。 用法: ISBUYORDER 当本笔成交为主动性买盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) ISSELLORDER 主动性卖单 返回该成交是否为主动性卖单。 用法:ISSELLORDER 当本笔成交为主动性卖盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) 二、时间函数 DATE 日期 取得该周期从1900以来的年月日。 用法: DATE 例如函数返回1000101,表示2000年1月1日。 TIME 时间 取得该周期的时分秒。 用法: TIME 函数返回有效值范围为(000000-235959)。 YEAR 年份 取得该周期的年份。 用法:YEAR MONTH 月份 取得该周期的月份。 用法:MONTH 函数返回有效值范围为(1-12)。 WEEK 星期

引用传递的用法

引用是C++引入的新语言特性,是C++常用的一个重要内容之一,正确、灵活地使用引用,可以使程序简洁、高效。 引用简介 引用就是某一变量(目标)的一个别名,对引用的操作与对变量直接操作完全一样。 引用的声明方法:类型标识符&引用名=目标变量名; 【例1】:int a; int &ra=a; //定义引用ra,它是变量a 的引用,即别名 说明: (1)&在此不是求地址运算,而是起标识作用。 (2)类型标识符是指目标变量的类型。 (3)声明引用时,必须同时对其进行初始化。 (4)引用声明完毕后,相当于目标变量名有两个名称,即该目标原名称和引用名,且不能再把该引用名作为其他变量名的别名。 ra=1; 等价于a=1; (5)声明一个引用,不是新定义了一个变量,它只表示该引用名是目标变量名的一个别名,它本身不是一种数据类型,因此引用本身不占存储单元,系统也不给引

用分配存储单元。故:对引用求地址,就是对目标变量求地址。&ra与&a相等。 (6)不能建立数组的引用。因为数组是一个由若干个元素所组成的集合,所以无法建立一个数组的别名。引用应用 1、引用作为参数 引用的一个重要作用就是作为函数的参数。以前的C语言中函数参数传递是值传递,如果有大块数据作为参数传递的时候,采用的方案往往是指针,因为这样可以避免将整块数据全部压栈,可以提高程序的效率。但是现在(C++中)又增加了一种同样有效率的选择(在某些特殊情况下又是必须的选择),就是引用。 【例2】: void swap(int &p1, int &p2) //此处函数的形参p1, p2都是引用 { int p; p=p1; p1=p2; p2=p; } 为在程序中调用该函数,则相应的主调函数的调用

(完整版)通达信指标函数说明大全

通达信指标函数说明大全 一、行情函数 HIGH 最高价返回该周期最高价。用法: HIGH H 最高价返回该周期最高价。用法: H LOW 最低价返回该周期最低价。用法: LOW L 最低价返回该周期最低价。用法: L CLOSE 收盘价返回该周期收盘价。用法: CLOSE C 收盘价返回该周期收盘价。用法: C VOL 成交量返回该周期成交量。用法: VOL V 成交量返回该周期成交量。用法: V OPEN 开盘价返回该周期开盘价。用法: OPEN O 开盘价返回该周期开盘价。用法: O ADVANCE 上涨家数返回该周期上涨家数。用法: ADVANCE(本函数仅对大盘有效) DECLINE 下跌家数返回该周期下跌家数。用法: DECLINE(本函数仅对大盘有效) AMOUNT 成交额返回该周期成交额。用法: AMOUNT ASKPRICE 委卖价返回委卖1--委卖3价格。用法: ASKPRICE(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) ASKVOL 委卖量返回委卖1--委卖3量。用法: ASKVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDPRICE 委买价返回委买1--委买3价格。用法: BIDPRICE(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BIDVOL 委买量返回委买1--委买3量。用法: BIDVOL(N) N取1—3。 (本函数仅个股在分笔成交分析周期有效) BUYVOL 主动性买盘返回主动性买单量。 用法:BUYVOL 当本笔成交为主动性买盘时,其数值等于成交量, 否则为0。(本函数仅个股在分笔成交分析周期有效) SELLVOL 主动性卖盘返回主动性卖单量。 用法:SELLVOL 当本笔成交为主动性卖盘时,其数值等于成交量, 否则为0。 (本函数仅个股在分笔成交分析周期有效) ISBUYORDER 主动性买单返回该成交是否为主动性买单。 用法: ISBUYORDER 当本笔成交为主动性买盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) ISSELLORDER 主动性卖单返回该成交是否为主动性卖单。 用法:ISSELLORDER 当本笔成交为主动性卖盘时,返回1,否则为0。 (本函数仅个股在分笔成交分析周期有效) 二、时间函数 DATE 日期取得该周期从1900以来的年月日。 用法: DATE 例如函数返回,表示2000年1月1日。 TIME 时间取得该周期的时分秒。 用法: TIME 函数返回有效值范围为(-)。 YEAR 年份取得该周期的年份。用法:YEAR

1C#的按值传递和按引用传递

C#的按值传递和按引用传递 C#在调用函数有按值传递和按引用传递两种方法。那么这两者有什么区别呢?下面就来简单介绍一下。 C#中的按值传递与大多数编程语言相同,只要在调用方法(有些语言可能为函数)的参数括号中写入要传入的变量名就好了,当然,传入的变量类型要与该方法的参数类型一致。这样,我们就把变量的值传到进所调用的方法里了。但是,参数按值传递(C#默认)时,传递的是参数的副本,且副本的改变并不影响调用者的原始变量值,也就是说,如果我们在在方法中改变了该参数的值,按值传递的方法并不会改变原变量的值。那么,如果我们想要改变的是原变量的值,那应该怎么做呢?这时,就需要使用到引用传递了。C#为此提供了关键字ref和out。对于ref,我们在传递中只要在参数前面使用ref时就可以将变量传递给方法,被调方法这时修改的就是原变量的值了。而在参数前面加上out,则可以建立输出参数,告诉编译器这个变元是按引用传入被调方法的,这样,该变元在被调方法中发生的改变都会反映到原变元。当然,ref和out也是有区别的,使用ref型参数时,传入的参数必须先初始化,而对out型参数而言,则要在方法内完成初始化,这是因为ref可以把参数的数值传进去,而out参数会在传进去前先将参数清空。下面就让我们来看一下例子。 这里创建了一个ReferenceAndOutParameters类,该类包含了三个方法,如下:

方法SquareRef()将参数refparam的值自乘,由于变元按引用传递,因此将改变调用者的原变元值。 方法SquareOut()先将outparam的值赋为6,再自乘,它也将调用者的原变元值。 方法Square()也将参数自乘,但因为调用的是原变元的副本,所以并不会改变原变元的值。 运行结果如下:

通达信公式教程大全(函数+指标+实例)

公式教程 简介 TDX的公式系统是一套功能强大、使用简单的计算机描述系统。用户可以通过对每日深沪两地交易所和历史上发送的行情数据按照简单的运算法则进行分析、选股、测试,在TDX当中一共提供了四大类公式编辑器: 1 技术指标公式编辑器 技术指标公式即通常所说画线指标,此类公式的主要目的是通过对数据采取一定的运算,将输出结果直观的显现在分析图上,为投资者提供研判行情的基本依据。此类指标至少要有一条输出线,本系统允许最多6条的输出线。 技术指标公式编辑器实现对技术图表分析中各类技术指标和自我定义的技术分析指标的编写,并且通过TDX的分析界面形成图表、曲线,以方便和寻找有意义的技术图形和技术特征。 2 条件选股公式编辑器 也就是通常意义上解释的智能选股。但我们的目的在于建立一个完全开放、自由的选股平台,可以通过对该平台的熟练使用,借助计算机的高速和准确的检索功能寻找满足您的理解的股票形态和技术特征,作到先知先觉,快人一步!并且提供相应的同样开放式的结果检测报告。 3 五彩K线公式编辑器 准确讲,该编辑器的功能是附属于条件选股功能之上的,我们可以通过该功能将满足条件的连续K线形态赋予颜色,区别了其它的K 线。 条件选股公式与五彩K线公式的区别: 条件选股公式和五彩K线公式都有且仅有一个输出,其目的都是为投资者提供买入或卖出点的指示,不同之处在于:条件选股公式仅对最近数据提示买入或卖出,而五彩K线公式则对输入的所有历史数据进行提示。另外,五彩K线公式的输出是在K线图上,通过各种颜色对提示数据进行标识,条件选股公式的输出是找出符合最近条件的所有股票。 4 交易系统公式编辑器 交易系统公式是通过设定买入和卖出点(有且仅有这两个输出),由计算机进行模拟操作。以此为依据,系统一方面可以进行五彩K线公式的功能,同时提示买入和卖出;另一方面可以通过模拟操作,对指标买卖的收益、指标的最佳参数及最佳指标等各情形进行测试。 交易系统是在条件选股功能上的一次大的延伸,旨在建立一套完整的交易规则体系,通过该编辑器对各个相关的交易环节,包括买入的切入、卖出、止损以及整体的交易性能检验等等作出定量的规定,帮助投资者建立一套属于自己的买卖规则和理论。 TDX系统所有的分析方法,包括技术指标、条件选股、交易系统和五彩K线,均采用开放平台进行描述。也就是说,所有分析方法的算法对用户时开放的,任何人都可以对原算法进行修改,或增加自己的新算法。 5 公式管理器

C++中引用传递和指针传递函数参数的详解

先来分析指针这个东东: 从概念上讲,指针本质上就是存放变量地址的一个变量,在逻辑上是独立的,它可以被改变,包括其所指向的地址的改变和其指向的地址中所存放的数据的改变。 上面的图表示了程序运行时变量的值和地址,这时的内存长什么样子呢? 注意指针是一个变量,它当然有内存空间,里面存的就是一个地址,通过这个地址我们就能找到它所指向的对象。

说明:上图中两个字母p和n在最左边,代表什么?后面在介绍程序的编译过程中用到,先卖个官司。如果下面的写的东西你看不懂,没关系,往下看,我不相信你看完最后的编译原理的一点点知识,你仍然不懂! 再来分析引用这个东东: 而引用是一个别名,它在逻辑上不是独立的,它的存在具有依附性,所以引用必须在一开始就被初始化,而且其引用的对象在其整个生命周期中是不能被改变的(自始至终只能依附于同一个变量)。 上面的这段话,如果不理解,没关系,往下看。 在C++中,指针和引用经常用于函数的参数传递,然而,指针传递参数和引用传递参数是有本质上的不同的: 指针传递参数本质上是值传递的方式,它所传递的是一个地址值。值传递过程中,被调函数的形式参数作为被调函数的局部变量处理,即在栈中开辟了内存空间以存放由主调函数放进来的实参的值,从而成为了实参的一个副本。值传递的特点是被调函数对形式参数的任何操作都是作为局部变量进行,不会影响主调函数的实参变量的值。(这里是在说实参指针本身的地址值不会变)

说明:红线上面是另一个函数的占空间,该函数可以通过指针的方式修改n的值,或者修改自己的值,让自己指向其他的地址,不再指向n。但是不管怎样,它永远修改不了p的值。因为参数传递的方式是值传递。 注意:什么叫能修改p值?能修改p这个变量标识符对应的内存空间就叫做修改了p的值。 而在引用传递过程中,被调函数的形式参数虽然也作为局部变量在栈中开辟了内存空间,但是这时存放的是由主调函数放进来的实参变量的地址。被调函数对形参的任何操作都被处理成间接寻址,即通过栈中存放的地址访问主调函数中的实参变量。正因为如此,被调函数对形参做的任何操作都影响了主调函数中的实参变量。

典型环节及其阶跃响应.

自动控制原理实验 典型环节及其阶跃相应 .1 实验目的 1. 学习构成典型环节的模拟电路,了解电路参数对环节特性的影响。 2. 学习典型环节阶跃响应的测量方法,并学会由阶跃响应曲线计算典型环节的传递函数。 3. 学习用Multisim 、MATLAB 仿真软件对实验内容中的电路进行仿真。 .2 实验原理 典型环节的概念对系统建模、分析和研究很有用,但应强调典型环节的数学模型是对各种物理系统元、部件的机理和特性高度理想化以后的结果,重要的是,在一定条件下, 典型模型的确定能在一定程度上忠实地描述那些元、部件物理过程的本质特征。 1.模拟典型环节是将运算放大器视为满足以下条件的理想放大器: (1) 输入阻抗为∞。流入运算放大器的电流为零,同时输出阻抗为零; (2) 电压增益为∞: (3) 通频带为∞: (4) 输入与输出之间呈线性特性: 2.实际模拟典型环节: (1) 实际运算放大器输出幅值受其电源限制是非线性的,实际运算放大器是有惯性的。 (2) 对比例环节、惯性环节、积分环节、比例积分环节和振荡环节,只要控制了输入量的大小或是输入量施加的时间的长短(对于积分或比例积分环节),不使其输出工作在工作期间内达到饱和值,则非线性因素对上述环节特性的影响可以避免.但对模拟比例微分环节和微分环节的影响则无法避免,其模拟输出只能达到有限的最高饱和值。 (3) 实际运放有惯性,它对所有模拟惯性环节的暂态响应都有影响,但情况又有较大的不同。 3.各典型环节的模拟电路及传递函数 (1) 比例环节的模拟电路如图.1所示,及传递函数为: 1 2)(R R S G -=

.1 比例环节的模拟电路 2. 惯性环节的模拟电路如图.2所示,及传递函数为: 其中1 2R R K = T=R 2 C 图.2 惯性环节的模拟电路 3. 积分环节的模拟电路如图.3所示,其传递函数为: 1 11R /1/)(21212212+-=+-=+-=-=TS K CS R R R CS R CS R Z Z S G

c中通过值和引用传递参数

c#中通过值和引用传递参数 在 C# 中,既可以通过值也可以通过引用传递参数。通过引用传递参数允许函数成员(方法、属性、索引器、运算符和构造函数)更改参数的值,并保持该更改。若要通过引用传递参数,请使用ref或out 关键字。为简单起见,本主题的示例中只使用了 ref 关键字。有关ref和out之间的差异的信息,请参见、使用 ref 和 out 传递数组。 本主题包括下列章节: ?传递值类型参数 ?传递引用类型参数 它还包括以下示例: 示例演示是否使用 ref 或 out 1 通过值传递值类型否 2 通过引用传递值类型是 3 交换值类型(两个整数)是 4 通过值传递引用类型否 5 通过引用传递引用类型是 6 交换引用类型(两个字符串)是 传递值类型参数 值类型变量直接包含其数据,这与引用类型变量不同,后者包含对其数据的引用。因此,向方法传递值类型变量意味着向方法传递变量的一个副本。方法内发生的对参数的更改对该变量中存储的原始数据无任何影响。如果希望所调用的方法更改参数值,必须使用ref或out关键字通过引用传递该参数。为了简单起见,以下示例使用ref。 示例 1:通过值传递值类型 下面的示例演示通过值传递值类型参数。通过值将变量myInt传递给方法SquareIt。方法内发生的任何更改对变量的原始值无任何影响。 // PassingParams1.cs using System; class PassingValByVal { static void SquareIt(int x) // The parameter x is passed by value. // Changes to x will not affect the original value of myInt. { x *= x;

最新最全通达信公式教程大全(函数-指标-实例).

简介 TDX的公式系统是一套功能强大、使用简单的计算机描述系统。用户可以通过对每日深沪两地交易所和历史上发送的行情数据按照简 单的运算法则进行分析、选股、测试,在TDX当中一共提供了四大类公式编辑器: 1 技术指标公式编辑器 技术指标公式即通常所说画线指标,此类公式的主要目的是通过对数据采取一定的运算,将输出结果直观的显现在分析图上,为投 资者提供研判行情的基本依据。此类指标至少要有一条输出线,本系统允许最多6条的输出线。 技术指标公式编辑器实现对技术图表分析中各类技术指标和自我定义的技术分析指标的编写,并且通过TDX的分析界面形成图表、曲线,以方便和寻找有意义的技术图形和技术特征。 2 条件选股公式编辑器 也就是通常意义上解释的智能选股。但我们的目的在于建立一个完全开放、自由的选股平台,可以通过对该平台的熟练使用,借助 计算机的高速和准确的检索功能寻找满足您的理解的股票形态和技术特征,作到先知先觉,快人一步!并且提供相应的同样开放式的结 果检测报告。 3 五彩K线公式编辑器 准确讲,该编辑器的功能是附属于条件选股功能之上的,我们可以通过该功能将满足条件的连续K线形态赋予颜色,区别了其它的K 线。 条件选股公式与五彩K线公式的区别: 条件选股公式和五彩K线公式都有且仅有一个输出,其目的都是为投资者提供买入或卖出点的指示,不同之处在于:条件选股公式仅 对最近数据提示买入或卖出,而五彩K线公式则对输入的所有历史数据进行提示。另外,五彩K线公式的输出是在K线图上,通过各种颜 色对提示数据进行标识,条件选股公式的输出是找出符合最近条件的所有股票。 4 交易系统公式编辑器 交易系统公式是通过设定买入和卖出点(有且仅有这两个输出),由计算机进行模拟操作。以此为依据,系统一方面可以进行五彩K线公式的功能,同时提示买入和卖出;另一方面可以通过模拟操作,对指标买卖的收益、指标的最佳参数及最佳指标等各情形进行测试。 交易系统是在条件选股功能上的一次大的延伸,旨在建立一套完整的交易规则体系,通过该编辑器对各个相关的交易环节,包括买 入的切入、卖出、止损以及整体的交易性能检验等等作出定量的规定,帮助投资者建立一套属于自己的买卖规则和理论。 TDX系统所有的分析方法,包括技术指标、条件选股、交易系统和五彩K线,均采用开放平台进行描述。也就是说,所有分析方法的 算法对用户时开放的,任何人都可以对原算法进行修改,或增加自己的新算法。 5 公式管理器

(C#)方法参数关键字:ref、out、params详解

ref(C# 参考) ref关键字使参数按引用传递。其效果是,当控制权传递回调用方法时,在方法中对参数的任何更改都将反映在该变量中。若要使用ref参数,则方法定义和调用方法都必须显式使用ref关键字。例如: class RefExample { static void Method(ref int i) { i = 44; } static void Main() { int val = 0; //使用ref val必须先初始化 Method(ref val); // val is now 44 } } 传递到 ref 参数的参数必须最先初始化。这与 out 不同,后者的参数在传递之前不需要显式初始化。 尽管ref和out在运行时的处理方式不同,但在编译时的处理方式相同。因此,如果一个方法采用ref参数,而另一个方法采用out参数,则无法重载这两个方法。例如,从编译的角度来看,以下代码中的两个方法是完全相同的,因此将不会编译以下代码: class CS0663_Example { // Compiler error CS0663: "cannot define overloaded // methods that differ only on ref and out". public void SampleMethod(ref int i) { } public void SampleMethod(out int i) { } } 但是,如果一个方法采用ref或out参数,而另一个方法不采用这两个参数,则可以进行重载,如下例所示: class RefOutOverloadExample { public void SampleMethod(int i) { } public void SampleMethod(ref int i) { } }

通达信函数大全

通达信函数大全 一,行情函数 1,HIGH 最高价返回该周期最高价。用法:HIGH 2,H 最高价返回该周期最高价。用法:H 3,LOW 最低价返回该周期最低价。用法:LOW 4,L 最低价返回该周期最低价。用法:L 5、CLOSE 收盘价返回该周期收盘价。用法:CLOSE 6,C 收盘价返回该周期收盘价。用法:C 7,VOL 成交量返回该周期成交量。用法:VOL 8,V 成交量返回该周期成交量。用法:V 9,OPEN 开盘价返回该周期开盘价。用法:OPEN 10,O:开盘价返回该周期开盘价。用法:O 11,ADVANCE 上涨家数返回该周期上涨家数。用法:ADVANCE(本函数仅对大盘有效) 12,DECLINE 下跌家数返回该周期下跌家数。用法:DECLINE(本函数仅对大盘有效) 13,AMOUNT 成交额返回该周期成交额。用法:AMOUNT 14,ASKPRICE 委卖价返回委卖1--委卖3价格用法:ASKPRICE(N)N取1—3。(本函数仅个股在分笔成交分析周期有效) 15,ASKVOL 委卖量返回委卖1--委卖3量。用法:ASKVOL(N)N取1—3。(本函数仅个股在分笔成交分析周期有效) 16,BIDPRICE 委买价返回委买1--委买3价格。用法:BIDPRICE(N)N取1—3。(本函数仅个股在分笔成交分析周期有效) 17,BIDVOL 委买量返回委买1--委买3量。用法:BIDVOL(N)N取1—3。(本函数仅个股在分笔成交分析周期有效) 18,BUYVOL 主动性买盘返回主动性买单量。用法:BUYVOL当本笔成交为主动性买盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) 19,SELLVOL 主动性卖盘返回主动性卖单量。用法:SELLVOL当本笔成交为主动性卖盘时,其数值等于成交量,否则为0。(本函数仅个股在分笔成交分析周期有效) 20,ISBUYORDER 主动性买单返回该成交是否为主动性买单。

Action Script 3.0 值传递和引用传递

Action Script 3.0 值传递和引用传递 函数的参数可以是任何数据类型的变量,数据类型可以分为简单数据类型和复杂数据类型。当使用简单数据类型变量作为参数时,传递的是值;当使用复杂数据类型变量作为参数时,传递的是引用。值和引用是简单数据类型和复杂数据类型的最大区别。 对于简单数据类型的参数来说,当调用函数开始时,发生了从实参向形参的值传递。当函数调用结束后,形参并未向实参进行值传递,这种数据传递称为值传递。 例如,创建一个名为myTest()的函数,该函数定义了两个数据类型均为int 型的xParam 和yParam 参数。当使用mValue 和nValue 参数调用函数时,xParam 和yParam 参数将用对int 对象的引用进行初始化,int 对象由mValue 和nValue 表示,代码如下所示。 function myTest(xParam:int,yParam:int):void { xParam++; yParam++; trace(xParam,yParam); } var mValue:int = 3; var nValue:int = 7; trace(mValue,nValue); //输出结果为3和7 myTest(mValue,nValue); //输出结果为4和8 trace(mValue,nValue); //输出结果为3和7 从测试结果可以看出,调用函数时,形参的值开始时是由实参传递来的值3 和7,递增后变为4和8。但形参的值改变后并没有传递给实参,所以调用函数前后实参的值都是3和7。 当调用函数开始时,发生了从实参向形参的数据传递,当调用函数结束时形参也会向实参进行数据传递,这种类型传递称为引用传递或地址传递。 例如,创建一个名为myObj 的对象,该对象具有两个属性:x 和y 。该对象作为参数传递给myTest()函数。因为该对象不是基元类型,所以它不但按引用传递,而且还保持一个引用,代码如下所示。 function myTest(Obj:Object):void { Obj.x+=100; Obj.y+=100; trace(Obj.x,Obj.y); }

相关文档
最新文档