当前位置:文档之家› Optimal and suboptimal singleton arc consistency algorithms

Optimal and suboptimal singleton arc consistency algorithms

Optimal and suboptimal singleton arc consistency algorithms
Optimal and suboptimal singleton arc consistency algorithms

Optimal and Suboptimal Singleton Arc Consistency Algorithms

Christian Bessiere

LIRMM(CNRS/University of Montpellier) 161rue Ada,Montpellier,France

bessiere@lirmm.fr

Romuald Debruyne

′Ecole des Mines de Nantes/LINA 4rue Alfred Kastler,Nantes,France romuald.debruyne@emn.fr

Abstract

Singleton arc consistency(SAC)enhances the

pruning capability of arc consistency by ensuring

that the network cannot become arc inconsistent af-

ter the assignment of a value to a variable.Algo-

rithms have already been proposed to enforce SAC,

but they are far from optimal time complexity.We

give a lower bound to the time complexity of en-

forcing SAC,and we propose an algorithm that

achieves this complexity,thus being optimal.How-

ever,it can be costly in space on large problems.

We then propose another SAC algorithm that trades

time optimality for a better space complexity.Nev-

ertheless,this last algorithm has a better worst-case

time complexity than previously published SAC al-

gorithms.An experimental study shows the good

performance of the new algorithms.

1Introduction

Ensuring that a given local consistency does not lead to a failure when we enforce it after having assigned a variable to a value is a common idea in constraint reasoning.It has been applied(sometimes under the name’shaving’)in con-straint problems with numerical domains by limiting the as-signments to bounds in the domains and ensuring that bounds consistency does not fail[Lhomme,1993].In SAT,it has been used as a way to compute more accurate heuristics for DPLL[Freeman,1995;Li and Ambulagan,1997].Finally, in constraint satisfaction problems(CSPs),it has been intro-duced under the name Singleton Arc Consistency(SAC)in [Debruyne and Bessi`e re,1997b]and further studied,both theoretically and experimentally in[Prosser et al.,2000; Debruyne and Bessi`e re,2001].

Some nice properties give to SAC a real advantage over the other local consistencies enhancing the ubiquitous arc consis-tency.Its de?nition is much simpler than restricted path con-sistency[Berlandier,1995],max-restricted-path consistency [Debruyne and Bessi`e re,1997a],or other exotic local con-sistencies.Its operational semantics can be understood by a non-expert of the?eld.Enforcing it only removes values in domains,and thus does not change the structure of the prob-lem,as opposed to path consistency[Montanari,1974],k-consistency[Freuder,1978],etc.Finally,implementing it can be done simply on top of any AC algorithm.

Algorithms enforcing SAC were already proposed in the past(SAC1[Debruyne and Bessi`e re,1997b],and SAC2 [Bart′a k and Erben,2004])but they are far from optimal time

complexity.Moreover,singleton arc consistency lacks an analysis of its complexity.In this paper,we study the com-plexity of enforcing SAC(in Section3)and propose an algo-rithm,SAC-Opt,enforcing SAC with optimal worst-case time complexity(Section4).However,optimal time complexity is reached at the cost of a high space complexity that prevents the use of this algorithm on large problems.In Section5,we propose SAC-SDS,a SAC algorithm with better worst-case space complexity but no longer optimal in time.Neverthe-less,its time complexity remains better than the SAC algo-rithms proposed in the past.The experiments presented in Section6show the good performance of both SAC-Opt and SAC-SDS compared to previous SAC algorithms.

2Preliminaries

A constraint network P consists of a?nite set of n variables X={i,j,...},a set of domains D={D(i),D(j),...}, where the domain D(i)is the?nite set of at most d val-ues that variable i can take,and a set of e constraints C= {c1,...,c e}.Each constraint c k is de?ned by the ordered set var(c k)of the variables it involves,and the set sol(c k) of combinations of values satisfying it.A solution to a con-straint network is an assignment of a value from its domain to each variable such that every constraint in the network is satis?ed.When var(c)=(i,j),we use c ij to denote sol(c) and we say that c is binary.

A value a in the domain of a variable i(denoted by(i,a)) is consistent with a constraint c k iff there exists a support for(i,a)on c k,i.e.,an instantiation of the other variables in var(c k)to values in their domain such that together with (i,a)they satisfy c k.Otherwise,(i,a)is said arc inconsis-tent.A constraint network P=(X,D,C)is arc consistent iff D does not contain any arc inconsistent value.AC(P)de-notes the network where all arc inconsistent values have been removed from P.If AC(P)has empty domain,we say that P is arc inconsistent

De?nition1(Singleton arc consistency)A constraint net-work P=(X,D,C)is singleton arc consistent iff?i∈

X,?a∈D(i),the network P|i=a=(X,D|i=a,C)obtained by replacing D(i)by the singleton{a}is not arc inconsis-tent.If P|i=a is arc inconsistent,we say that(i,a)is SAC inconsistent.

3Complexity of SAC

Both SAC1[Debruyne and Bessi`e re,1997b]and SAC2 [Bart′a k and Erben,2004]have an O(en2d4)time complexity on binary constraints.But it is not optimal.

Theorem1The best time complexity we can expect from an algorithm enforcing SAC on binary constraints is in O(end3). Proof.According to[McGregor,1979],we know that check-ing whether a value(i,a)is such that AC does not fail in P|i=a is equivalent to verifying if in each domain D(j)there is at least one value b such that((i,a),(j,b))is“path con-sistent on(i,a)”.(A pair of values((i,a)(j,b))is path con-sistent on(i,a)iff it is not deleted when enforcing path con-sistency only on pairs involving(i,a).)For each variable j, we have to?nd a value b∈D(j)such that((i,a),(j,b))is path consistent on(i,a).In the worst case,all the values b in D(j)have to be considered.So,the path consistency of each pair((i,a),(j,b))may need to be checked against every third variable k by looking for a value(k,c)compatible with both (i,a)and(j,b).However,it is useless to consider variables k not linked to j since in this partial form of path consis-tency only pairs involving(i,a)can be removed.By using an optimal time path consistency technique(storing supports), we are guaranteed to consider at most once each value(k,c) when seeking compatible value on k for a pair((i,a),(j,b)). The worst-case complexity of proving that path consistency

on(i,a)does not fail is thusΣb∈D(j)Σc

kj ∈CΣc∈D(k)=ed2.

Furthermore,enforcing path consistency on(i,a)is com-pletely independent from enforcing path consistency on an-

other value(j,b).Indeed,a pair((i,a),(j,b))can be path

consistent on(i,a)while becoming path inconsistent after the deletion of a pair((k,c),(j,b))thus being path inconsistent

on(j,b).Therefore,the worst case time complexity of any

SAC algorithm is at least in O(Σ(i,a)∈D ed2)=O(end3).2 4Optimal Time Algorithm for SAC

SAC1has no data structure storing which values may become

SAC inconsistent when a given value is removed.Hence,it

must check again the SAC consistency of all remaining val-ues.SAC2has data structures that use the fact that if AC

does not lead to a wipe out in P|i=a then the SAC consis-

tency of(i,a)holds as long as all the values in AC(P|i=a) are in the domain.After the removal of a value(j,b),SAC2

checks again the SAC consistency of all the values(i,a)such

that(j,b)was in AC(P|i=a).This leads to a better average time complexity than SAC1but the data structures of SAC2 are not suf?cient to reach optimality since SAC2may waste time re-enforcing AC in P|i=a several times from scratch. Algorithm1,called SAC-Opt,is an algorithm that enforces SAC in O(end3),the lowest time complexity which can be expected(see Theorem1).

The idea behind such an optimal algorithm is that we don’t

want to do and redo(potentially nd times)arc consistency

function SAC-Opt(inout P:Problem):Boolean;

/*init phase*/;

1if AC(P)then PendingList←?else return false;

2foreach(i,a)∈D do

3P ia←P/*copy only domains and data structures*/;

4D ia(i)←{a};

5if?propagAC(P ia,D(i)\{a})then

6D←D\{(i,a)};

7if propagAC(P,{(i,a)})then

8foreach P jb such that(i,a)∈D jb do

9Q jb←Q jb∪{(i,a)};

10PendingList←PendingList∪{(j,b)};

11else return false;

/*propag phase*/;

12while PendingList=?do

13pop(i,a)from PendingList;

14if propagAC(P ia,Q ia)then Q ia←?;

15else

16D←D\{(i,a)};

17if D(i)=?then return false;

18foreach(j,b)∈D such that(i,a)∈D jb do

19D jb(i)←D jb(i)\{a};Q jb←Q jb∪{(i,a)}; 20PendingList←PendingList∪{(j,b)};

21return true;

for future propagation(lines9–10).

Once the initialisation phase has?nished,we know that PendingList contains all values(i,a)for which some SAC

inconsistent value removals(contained in Q ia)have not yet

been propagated in P ia.The loop in line12propagates these removals(line14).When propagation fails,this means that

(i,a)itself is SAC inconsistent.It is removed from the do-main D of the master problem in line16and each subproblem P jb containing(i,a)is updated together with its propagation

list Q jb for future propagation(lines18–20).

When PendingList is empty,all removals have been propa-gated in the subproblems.So,all the values in D are SAC. Theorem2SAC-Opt is a correct SAC algorithm with O(end3)optimal time complexity and O(end2)space com-plexity on binary constraints.

Proof.Soundness.A value a is removed from D(i)either in

line6or in line16because P ia was found arc inconsistent.

If P ia was found arc inconsistent in the initialisation phase (line5),SAC inconsistency of(i,a)follows immediately.Let us proceed by induction for the remaining case.Suppose all values already removed in line16were SAC inconsistent.If P ia is found arc inconsistent in line14,this means that P ia cannot be made arc consistent without containing some SAC inconsistent values.So,(i,a)is SAC inconsistent and SAC-Opt is sound.

Completeness.Thanks to the way PendingList and Q ia are

updated in lines8–10and18–20,we know that at the end of the algorithm,all P ia are arc consistent.Thus,for any value (i,a)remaining in P at the end of SAC-Opt,P|i=a is not arc inconsistent and(i,a)is therefore SAC consistent. Complexity.The complexity analysis is given for networks of binary constraints since the optimality proof was given for networks of binary constraints only.(But SAC-Opt works on constraints of any arity.)Since any AC algorithm can be used to implement our SAC algorithm,the space and time com-plexities will obviously depend on this choice.Let us?rst discuss the case where an optimal time algorithm such as AC-6[Bessi`e re,1994]or AC2001[Bessi`e re and R′e gin,2001; Zhang and Yap,2001]is used.Line3tells us that the space complexity will be nd times the complexity of the AC algo-rithm,namely O(end2).Regarding time complexity,the?rst loop copies the data structures and propagates arc consistency on each subproblem(line5),two tasks which are respectively in nd·ed and nd·ed2.In the while loop(line12),each sub-problem can be called nd times for arc consistency,and there are nd subproblems.Now,AC-6and AC2001are both incre-mental,which means that the complexity of nd restrictions on the same problem is ed2and not nd·ed2.Thus the total cost of arc consistency propagation on the nd subproblems is nd·ed2.We have to add the cost of updating the lists in lines 8and18.In the worst case,each value is removed one by one,and thus,nd values are put in nd Q lists,leading to n2d2 updates of PendingList.If n

5Losing Time Optimality to Save Space

SAC-Opt cannot be used on large constraint networks because of its O(end2)space complexity.Moreover,it seems dif-?cult to reach optimal time complexity with smaller space requirements.A SAC algorithm has to maintain AC on nd subproblems P|i=a,and to guarantee O(ed2)total time on these subproblems we need to use an optimal time AC algo-rithm.Since there does not exist any optimal AC algorithm requiring less than O(ed)space,we obtain nd·ed space for the whole SAC process.

We propose to relax time optimality to reach a satisfac-tory trade-off between space and time.To avoid discussing in too general terms,we instantiate this idea on a AC2001-based SAC algorithm for binary constraints,but the same idea could be implemented with other optimal AC algorithms such as AC-6,and with constraints of any arity.The algorithm SAC-SDS(Sharing Data Structures)tries to use as much as possi-ble the incrementality of AC to avoid redundant work,with-out duplicating on each subproblem P|i=a the data structures required by optimal AC algorithms.This algorithm requires less space than SAC-Opt but is not optimal in time.

As in SAC-Opt,for each value(i,a)SAC-SDS stores the lo-cal domain D ia of the subproblem P|i=a and its propagation list Q ia.Note that in our AC2001-like presentation,Q ia is a list of variables j for which the domain D ia(j)has changed (in SAC-Opt it is a list of values(j,b)removed from D ia). As in SAC-Opt,thanks to these local domains D ia,we know which values(i,a)may no longer be SAC after the removal of a value(j,b):those for which(j,b)was in D ia.These local domains are also used to avoid starting each new AC propagation phase from scratch,since D ia is exactly the do-main from which we should start when enforcing again AC on P|i=a after a value removal.By comparison,SAC1and SAC2restart from scratch for each new propagation.

But the main idea in SAC-SDS is that as opposed to SAC-Opt,it does not duplicate to all subproblems P ia the data structures of the optimal AC algorithm used.The data structure is maintained only in the master problem P.In the case of AC2001,the Last structure which maintains in Last(i,a,j)the smallest value in D(j)compatible with (i,a)on c ij is built and updated only in P.Nevertheless,it is used by all subproblems P ia to avoid repeating constraint checks already done in P.

SAC-SDS(Algorithm2)works as follows:After some initialisations(lines1–4),SAC-SDS repeatedly pops a value from PendingList and propagates AC in P ia(lines6–9).Note that’D ia=nil’means that this is the?rst enforcement of AC in P ia,so D ia must be initialised(line8).1If P ia is arc in-

function SAC-SDS-2001(inout P:problem):Boolean;

1if AC2001(P)then PendingList←?else return false;

2foreach(i,a)∈D do

3D ia←nil;Q ia←{i};

4PendingList←PendingList∪{(i,a)};

5while PendingList=?do

6pop(i,a)from PendingList;

7if a∈D(i)then

8if D ia=nil then D ia←(D\D(i))∪{(i,a)};

9if propagSubAC(D ia,Q ia)then Q ia←?;

10else

11D(i)←D(i)\{a};Deleted←{(i,a)};

12if propagMainAC(D,{i},Deleted)then

13updateSubProblems(Deleted)

14else return false;

15return true;

function Propag Main/Sub AC(inout D:domain;in Q:set;

inout Deleted:set):Boolean; 16while Q=?do

17pop j from Q;

18foreach i∈X such that?c ij∈C do

19foreach a∈D(i)such that Last(i,a,j)∈D(j)do 20if?b∈D(j),b>Last(i,a,j)∧c ij(a,b)then 21Last(i,a,j)←b

22else

23D(i)←D(i)\{a};Q←Q∪{i};

24Deleted←Deleted∪{(i,a)};

25if D(i)=?then return false;

26return true;

/*···:in propagMainAC but not in propagSubAC*/; procedure updateSubProblems(in Deleted:set);

27foreach(j,b)∈D|D jb∩Deleted=?do

28Q jb←Q jb∪{i∈X/D jb(i)∩Deleted=?};

29D jb←D jb\Deleted;

30PendingList←PendingList∪{(j,b)};

it in a former loop as in SAC-Opt.problems faster(lines19–20)since we know that there is no support for(i,a)on c ij lower than Last(i,a,j)in P, and so in any subproblem as well.But this data structure is shared by all subproblems.Thus it must not be modi?ed by propagSubAC.Otherwise,Last(i,a,j)would not be guar-anteed to be the smallest support in the other subproblems and in P.When achieving AC in P,propagMainAC does update the Last data structure.The only difference with AC2001is line24where it needs to store in Deleted the values removed from D during the propagation.Those removals performed in P can directly be transferred in the subproblems without the effort of proving their inconsistency in each subproblem. This is done via function updateSubProblems,which re-moves values in Deleted from all the subproblems.It also updates the local propagation lists Q ia and PendingList for future propagation in the subproblems.

Theorem3SAC-SDS is a correct SAC algorithm with O(end4)time complexity and O(n2d2)space complexity on binary constraints.

Proof.Soundness.Note?rst that the structure Last is up-dated only when achieving AC in P so that any support of(i,a)in D(j)is greater than or equal to Last(i,a,j). The domains of the subproblems being subdomains of D, any support of a value(i,a)on c ij in a subproblem is also greater than or equal to Last(i,a,j).This explains that propagSubAC can bene?t from the structure Last without losing any support(lines19–20).Once this observation is made,soundness comes from the same reason as in SAC-Opt. https://www.doczj.com/doc/8c14346789.html,pleteness comes from the fact that any deletion is propagated.After initialisation(lines2-4), PendingList=D and so,the main loop of SAC-SDS pro-cesses any subproblem P|i=a at least once.Each time a value(i,a)is found SAC inconsistent in P because P|i=a is arc inconsistent(line9)or because the deletion of some SAC-inconsistent value makes it arc inconsistent in P(line 23of propagMainAC called in line12),(i,a)is removed from the subproblems(line29),and PendingList and the local propagation lists are updated for future propagation(lines28 and30).At the end of the main loop,PendingList is empty, so all the removals have been propagated and for any value (i,a)∈D,D ia is a non empty arc consistent subdomain of P|i=a.

Complexity.The data structure Last requires a space in O(ed).Each of the nd domains D ia can contain nd values and there is at most n variables in the nd local propagation lists Q ia.Since e

Regarding time complexity,SAC-SDS-2001?rst duplicates the domains and propagates arc consistency on each subprob-lem(lines8and9),two tasks which are respectively in nd·nd and nd·ed2.Each value removal is propagated to all P|i=a problems via an update of PendingList,Q ia and D ia(lines 27–30).This requires nd·nd operations.Each subproblem can in the worst case be called nd times for arc consistency, and there are nd subproblems.The domains of each subprob-lem are stored so that the AC propagation is launched with the domains in the state in which they were at the end of the

1E0

Figure1:cpu time with n=100,d=20,and density=.05. previous AC propagation in the subproblem.Thus,in spite of the several AC propagations on a subproblem,a value will

be removed at most once and,thanks to incrementality of arc

consistency,the propagation of these nd value removals is in O(ed3).(Note that we cannot reach the optimal ed2com-plexity for arc consistency on these subproblems since we do

not duplicate the data structures necessary for AC optimal-ity.)Therefore,the total cost of arc consistency propagations is nd·ed3.The total time complexity is O(end4).2 As with SAC2,SAC-SDS performs a better propagation than SAC1since after the removal of a value(i,a)from D,SAC-SDS checks the arc consistency of the subproblems P|j=b only if they have(i,a)in their domains(and not all the subproblems as SAC1).But this is not suf?cient to have a bet-ter worst-case time complexity than SAC1.SAC2has indeed the same O(en2d4)time complexity as SAC1.SAC-SDS im-proves this complexity because it stores the current domain of each subproblem,and so,does not propagate in the subprob-lems each time from scratch.2Furthermore,we can expect a better average time complexity since the shared structure Last reduces the number of constraint checks required,even if it does not permit to obtain optimal worst-case time com-plexity.This potential gain can only be assessed by an exper-imental comparison of the different SAC versions.Finally, in SAC1and SAC2each AC enforcement in a subproblem must be done on a new copy of D built at runtime(potentially nd·nd times)while such duplication is performed only once for each value in SAC-SDS(by creating subdomains D ia).

6Experimental Results

We compared the performance of the SAC algorithms on ran-dom uniform constraint networks of binary constraints gener-ated by[Frost et al.,1996],which produces instances accord-

6.2Experiments on dense constraint networks Fig.2presents performance on constraint networks having 100variables,20values in each domain and a complete graph of binary constraints.

SAC1and SAC2show very close performance.When all values are SAC consistent(tightness lower than.37)the addi-tional data structure of SAC2is useless since there is no prop-agation.However the cost of building this data structure is not important compared to the overall time and the time required by SAC2is almost the same as SAC1.Around the peak of complexity,SAC2-X(with X∈{4,6,2001})requires a little less time than SAC1-X.SAC2has to repeatedly recheck the arc consistency of less subproblems than SAC1but the cost of testing a subproblem remains the same.On very tight con-straints,SAC1requires less time than SAC2since the incon-sistency of the problem is found with almost no propagation and building the data structure of SAC2is useless. Conversely to what was expected in[Bart′a k and Erben, 2004],using AC-4in SAC1(or in SAC2)instead of AC-6or AC2001is not worthwhile.The intuition was that since the data structure of AC-4does not have to be updated,the cost of its creation would be low compared to the pro?t we can ex-pect.However,SAC1-4and SAC2-4are far more costly than the versions based on AC-6or AC2001.

The best results are obtained with SAC-Opt-2001and SAC-SDS-2001which are between2.6and17times faster than the others at the peak.These two algorithms have a better prop-agation between subproblems than SAC1but they also avoid some redundant work and so reduce the work performed on each subproblem.

7Summary and Conclusion

We have presented SAC-Opt,the?rst optimal time SAC algo-rithm.However,the high space complexity of this algorithm prevents its use on large constraint networks.Hence,we have proposed SAC-SDS,a SAC algorithm that is not optimal in time but that requires less space than SAC-Opt.Experiments show the good performance of these new SAC algorithms compared to previous versions available in the literature.This opens again the issue of using SAC as an alternative to AC for pruning values in a constraint network,or at least in’promis-ing’parts of the network.SAC could also be used to compute variable selection heuristics,as this had been done with suc-cess in SAT[Li and Ambulagan,1997].

References

[Bart′a k and Erben,2003]R.Bart′a k and R.Erben.Singleton arc consistency revised.In ITI Series2003-153,Prague, 2003.

[Bart′a k and Erben,2004]R.Bart′a k and R.Erben.A new algorithm for singleton arc consistency.In Proceedings FLAIRS’04,Miami Beach FL,2004.AAAI Press. [Berlandier,1995]P.Berlandier.Improving domain?ltering using restricted path consistency.In Proceedings IEEE-CAIA’95,1995.[Bessi`e re and R′e gin,2001]C.Bessi`e re and J.C.R′e gin.Re-?ning the basic constraint propagation algorithm.In Pro-ceedings IJCAI’01,pages309–315,Seattle W A,2001. [Bessi`e re,1994]C.Bessi`e re.Arc-consistency and arc-consistency again.Arti?cial Intelligence,65:179–190, 1994.

[Debruyne and Bessi`e re,1997a]R.Debruyne and

C.Bessi`e re.From restricted path consistency to

max-restricted path consistency.In Proceedings CP’97, pages312–326,Linz,Austria,1997.

[Debruyne and Bessi`e re,1997b]R.Debruyne and

C.Bessi`e re.Some practicable?ltering techniques

for the constraint satisfaction problem.In Proceedings IJCAI’97,pages412–417,Nagoya,Japan,1997. [Debruyne and Bessi`e re,2001]R.Debruyne and

C.Bessi`e re.Domain?ltering consistencies.Jour-

nal of Arti?cial Intelligence Research,14:205–230, 2001.

[Freeman,1995]J.W.Freeman.Improvements to proposi-tional satis?ability search algorithms.PhD thesis,Univer-sity of Pennsylvania,Philadelphia PA,1995. [Freuder,1978]E.C.Freuder.Synthesizing constraint https://www.doczj.com/doc/8c14346789.html,munications of the ACM,21(11):958–966, Nov1978.

[Frost et al.,1996]D.Frost,C.Bessi`e re,R.Dechter,and J.C.R′e gin.Random uniform csp generators.URL: http://www.lirmm.fr/?bessiere/generator.html,1996. [Lhomme,1993]O.Lhomme.Consistency techniques for numeric csps.In Proceedings IJCAI’93,pages232–238, Chamb′e ry,France,1993.

[Li and Ambulagan,1997]C.M.Li and Ambulagan.Heuris-tics based on unit propagation for satis?ability problems.

In Proceedings IJCAI’97,pages366–371,Nagoya,Japan, 1997.

[Mackworth,1977]A.K.Mackworth.Consistency in net-works of relations.Arti?cial Intelligence,8:99–118,1977. [McGregor,1979]J.J.McGregor.Relational consistency al-gorithms and their application in?nding subgraph and graph https://www.doczj.com/doc/8c14346789.html,rmation Science,19:229–250, 1979.

[Montanari,1974]https://www.doczj.com/doc/8c14346789.html,works of constraints: Fundamental properties and applications to picture https://www.doczj.com/doc/8c14346789.html,rmation Science,7:95–132,1974. [Prosser et al.,2000]P.Prosser,K.Stergiou,and T Walsh.

Singleton consistencies.In Proceedings CP’00,pages 353–368,Singapore,2000.

[Prosser,1996]P.Prosser.An empirical study of phase tran-sition in binary constraint satisfaction problems.Arti?cial Intelligence,81:81–109,1996.

[Zhang and Yap,2001]Y.Zhang and R.H.C.Yap.Making AC-3an optimal algorithm.In Proceedings IJCAI’01, pages316–321,Seattle W A,2001.

singleton模式和prototype模式

spring 的单例模式 singleton---单例模式 单例模式,在spring 中其实是scope(作用范围)参数的缺省设定值 每个bean定义只生成一个对象实例,每次getBean请求获得的都是此实例 单例模式分为饿汉模式和懒汉模式 饿汉模式 spring singleton的缺省是饿汉模式:启动容器时(即实例化容器时),为所有spring配置文件中定义的bean都生成一个实例 懒汉模式 在第一个请求时才生成一个实例,以后的请求都调用这个实例 spring singleton设置为懒汉模式: 另一种和singleton对应的scope值---prototype多实例模式 调用getBean时,就new一个新实例 singleton和prototype的比较 singleton xml配置文件: 测试代码: ctx = new ClassPathXmlApplicationContext("spring-hibernate-mysql.xml"); DvdTypeDAO tDao1 = (DvdTypeDAO)ctx.getBean("dvdTypeDAO"); DvdTypeDAO tDao2 = (DvdTypeDAO)ctx.getBean("dvdTypeDAO"); 运行: true com.machome.hibernate.impl.DvdTypeDAOImpl@15b0333 com.machome.hibernate.impl.DvdTypeDAOImpl@15b0333 说明前后两次getBean()获得的是同一实例,说明spring缺省是单例 prototype 执行同样的测试代码 运行: false com.machome.hibernate.impl.DvdTypeDAOImpl@afae4a com.machome.hibernate.impl.DvdTypeDAOImpl@1db9852

清华大学开题报告ppt

清华大学开题报告ppt 篇一:毕业论文开题报告 武汉工程大学计算机科学与工程学院 毕业论文开题报告 第 1 页共 4 页 (5)可以随时修改系统口令。 (6)灵活的数据备份、还原功能。 (7)系统最大限度地实现易安装性、易维护性和易操作性。 (8)系统运行稳定,安全可靠。 通过使用超市管理系统可以迅速提升超市的管理水平,降低经营成本,为提高效益和增强超市扩张能力,提供了有效的技术保障。本系统就是在这样的背景下提出的。另外在技术方面采用了较为先进的Java Swing技术和SQL Server XX,用来实现超市管理信息系统,包括系统登陆、基本资料、进货管理、销售管理、库存管理、系统维护、信息查询7个模块。 要求能够自觉运用数据库系统课程学习的理论知识指导软件设计;掌握信息管理系统的开发方法和步骤。整个应用系统的设计严格按照数据库设计的方法来进行,包括数据库的设计和应用程序的设计,两部分相辅相成。 数据库设计过程包含以下步骤:

需求分析:系统的目的、用户的各种需求、业务流程图、数据流程图; 概念结构设计:用E-R图来描述实体及实体间的联系; 逻辑结构设计:确定关系模式,各种约束的声明,如主码外码约束、唯一性约束、非空约束等。同时给出系统的功能模块组成图,系统各模块功能; 物理结构设计; 数据库实施; 数据库的实施阶段:数据库用SQL Server XX等创建,前端开发使用Java、.NET等实现。 通过此次课程设计提高自己独立分析问题、解决问题的能力。掌握从需求分析、数据库设计(概念设计、逻辑设计、物理设计)、编写程序、测试分析,撰写文档到最终答辩的整个过程。 参考文献: [1] 刘京华等. JAVA WEB整合开发王者归来[M].北京:清华大学出版社,XX [2] 王俊杰. 精通JAVA SCRIPT动态网页编程[M].北京:人民邮电出版社,XX [3] 李宁. Java Web编程实战宝典[M].北京:清华大学出版社,XX [4] 孙更新. Java程序开发大全[M].北京:中国铁道出

建筑工程学院虚拟仿真实验室建设方案要求

建筑工程学院虚拟仿真实验室建设方案要求 一、硬件设备及功能要求 在针对BIM设计/办公场景评估并实现能够替代PC电脑/工作站方案,降低学校设备运维成本,优化使用体验,提升设计/教学效率和效果。结合目前学校现状、需求及挑战,建设一个完善的软件定义的BIM云平台,最终将达到以下目标: 1、统一的BIM云平台 根据BIM业务需要建设统一的基础设施云平台(IaaS),整合计算、存储、GPU和网络资源,将业务应用整合,云化部署迁移到数据中心的云计算平台,在实现数据统一的基础上通过统一的云平台管理界面进行资源的调度和管理。通过集中管理的桌面云提供随时随地的桌面访问、灵活的教育教学和统一的后端运维管理,同时实现更高的安全性、控制能力并节省IT运维费用。 2、资源全面池化 将计算、存储、GPU、网络资源整合成为可以统一管理、弹性调度、灵活分配的资源池,每个应用系统不再占用独立的物理服务器、存储和网络资源,而是与其他应用系统一起,共享基础平台的资源,以虚拟机的形式独占其中部分逻辑资源。 3、提供标准化的资源服务 合理划分计算存储网络等资源,针对各类业务需求提供标准化且可按需调整的支撑资源配置,进行自动化部署和维护,快速提供标准、安全和稳定的资源服务。统一管理各种资源,并根据业务系统对计算能力、存储I/O、网络带宽等需求,提供不同级别的资源服务。 4、随需分配和回收资源 未来新建应用系统或扩容、迁移应用系统,只需根据需求从资源池中直接获取资源即可快速完成,而不必额外申请购买硬件设备。在业务系统生命周期完结后,也可释放资源回到资源池。这样既提升了业务部署效率,又提升了资源利用率,降低了运维复杂度,从而降低了总体拥有成本。

小学、初中英语词汇表(带读音)

Pep小学、初中英语词汇表(共619个单词) 名词n ,noun[naun] 形容词adj ,adjective['?d?iktiv] 数词num ,numeral['nu:m?r?l, 'nju:-] 代词pron ,pronoun['pr?unaun] 动词v ,verb[v?:b] 副词adv ,adverb['?dv?:b] 冠词art ,article['ɑ:tikl] 介词prep ,preposition[,prep?'zi??n] 连词conj ,conjunction[k?n'd???k??n] 感叹词int ,interjection[,?nt?'d?ek??n] a,[?n,?n]一(在元音字母前代替不定代词a) an, [?n,?n]一(在元音字母前代替不定代词a) about[?'baut](关于,大约), after['ɑ:ft?](之后), afternoon[,ɑ:ft?'nu:n](下午), again[?'ɡen, ?'ɡein]再一次, ago[?'ɡ?u]以前, air[??]空气,空中, v t. & vi. 晾晒, 烘干 all[?:l]全部, along[?'l??]沿着, 向前,往前 am, [?m]是(用于第一人称) and, [?nd, ?nd, ?n]和, 与, 及,然后,接着angry['??ɡri]生气的, 恶劣的, 狂怒的 animal['?nim?l]动物, 兽, 牲畜 answer['ɑ:ns?]回答,答案, ant[?nt]蚂蚁, any['eni]任何的, 一点, 一些 apple, ['?pl]苹果; 苹果树 April['eipr?l]四月, are, [ɑ:]是(用于二三人称的复数) ask[ɑ:sk问要求, 请求,at, August['?:ɡ?st]八月, aunt[ɑ:nt]阿姨,姑母, 姨母; 伯母, 婶母, 舅母auntie aunty['?nti:, 'ɑ:n-](aunt的昵称)伯母;婶母;姑母;姨母;舅母 autumn['?:t?m]秋天,秋季,成熟期, 渐衰期 B Back[b?k](后面), bad[b?d]坏的, bag[b?ɡ]包,书包, ball[b?:l]球, 舞会 banana[b?'nɑ:n?]香蕉, bank[b??k]银行,河岸, basketball['bɑ:skitb?:l]篮球, bathroom['bɑ:θrum]浴室, be, [bi:, bi][be to-v]表示必要、打算、可能性、假设等或用来表示将来安排 bean[bi:n]菜豆,豆 bear[b??]n熊, vt. & vi.1 承担, 负担 beautiful['bju:t?ful]美丽的,很好的 bed[bed]床, 河床,苗圃, 花坛 bee[bi:]蜜蜂, before[bi'f?:]conj以前, prep. (表示位置)在…前面 begin[bi'ɡin]开始, best[best]最好的, between[bi'twi:n]在….之间, big[biɡ]大的, 成功的,重要的, 重大的;bigger较大的;biggest 最大的 bike[baik]自行车, bird[b?:d]鸟, birthday['b?:θdei]生日, black[bl?k]黑色的, blackboard['bl?kb?:d]黑板, blue[blu:]蓝色的, blow[bl?u]吹, boat[b?ut]小船, book[buk]书, 书籍账簿,vt. 1 登记, 记账 borrow['b?r?u]借,借入, boots[bu:ts]靴子, n擦靴人 bowl[b?ul]碗, 钵, 盘 box[b?ks]盒子,箱子, pencil['pens?l]铅笔, 彩色铅笔 pencil box文具盒, boy.[b?i]男孩, 少年 bread[bred]面包, 生计 breakfast['brekf?st]早餐, bright[brait]明亮的,聪明的, 愉快的,鲜艳的 bring[bri?]带来,造成,引起 brother['br?e?]兄弟, bus[b?s]公共汽车,巴士 but[b?t, b?t]但是, prep. 除…以外 buy[bai]买, 交易, 买卖 by[ba?]乘, 在…近旁; 在身边 bye[ba?]int.再见adj. 次要的 C Cake[keik]蛋糕, can[k?n, k?n]v能,会, n罐, 罐头 car[kɑ:]小汽车, 轿车 card[kɑ:d]卡, 纸牌, 扑克牌,办法, 手段, 妙计careful['k??ful]仔细的, 小心的 carry['k?ri]运,搬,提, 挑, 背 cartoon[kɑ:'tu:n]漫画, 动画片 cat[k?t], 猫 chair[t???]椅子, 大学教授职位 cheap[t?i:p]便宜的, 低俗的, 卑鄙的 cheese[t?i:z]奶酪, chess[t?es]国际象棋, chick[t??k]小鸡, 少妇 chicken['t?ikin]鸡肉, child[t?aild]孩子, 儿童,子女 children['t??ldr?n]孩子们, chocolate['t??k?lit]巧克力, city['siti]城市,都市,全城居民 class[klɑ:s]班级, 阶级, 社会阶级 classroom['klɑ:sru:m]教室, clean[kli:n]干净的,打扫, 正派的, 正大光明的clear[kli?]清晰的, 清白的,畅通的 clearly['kl??l?]明朗地,明确地,明亮地 clever['klev?]聪明的, 灵巧的, 精巧的 climb[klaim]爬, 上升, 增长 clock[kl?k]钟, 挂钟;watch [w?t?] 手表,看,观察close[kl?uz]关, 终结, 结束 clothes[kloz, kloez]衣服, coat[k?ut]外套, coffee['k?fi]咖啡, 咖啡豆 coin[k?in]硬币, cold[k?uld]寒冷, heat[hi:t] 高温, 炎热 have a cold感冒, colour['k?l?]颜色, 脸色, 气色,肤色 come[k?m]来, come back回来, come out出来, come to school来到学校, computer[k?m'pju:t?]电脑, 计算机

单例模式介绍

1 单例(Singleton)模式:单例模式确保某一个类只有一个实例,而且该类只能是自己实例化自己并向其他类公开这个实例的对象创 建模式 采用单例模式的类:根据单例模式知道其要满足以下三点 1. 确保某一个类只有一个实例 2. 而且自己实例化 3. 并向其他类提供这个实例类。 2 确保以上三点的所采用的编程策略 * 把构造方法声明为Private。确保只能由自己创建,避免外部创建实例或者被子类继承从而创造额外实例; * 定义一个私有静态的该类的实例作为该类的数据域。确保一个类只能有一个实例; *定义一个静态工厂方法。外部类不能实例化一个该类的对象,所以只能用Static 的方法,提供给其他类调用,返回此单例类唯一的实例。 3、使用单例模式的条件: 使用单例模式有一个必要条件:在一个系统要求一个类只有一个实例时才应当使用单例模式,反过来说,如果一个类可以有几个实例共存,那么就没有必要使用单例模式类。

4 单例在JAVA中的3种(一般形式)形式 主动式单例类: public class ActiveSingleton { private static final ActiveSingleton m_instance = new ActiveSingleton(); //在类加载的时候就实例化一个自己的对象 private ActiveSingleton() { } //每次调用该工厂方法返回该实例 public static ActiveSingleton getInstance() { return m_instance; } } java语言中单例类的一个最重要的特点是类的构造方法是私有的,从而避免外界利用构造子直接创建出任意多的实例。因为构造是私有的,因此此类不能被继承。主动式单例类在类加载的时候就实例化一个自己的对象。 被动式单例类: public class LazySingleton { private static LazySingleton m_instance = null; private LazySingleton() { }

JavaScript设计模式

JavaScript设计模式的作用——提高代码的重用性,可读性,使代码更容易的维护和扩展。 1.单体模式,工厂模式,桥梁模式个人认为这个一个优秀前端必须掌握的模式,对抽象编程和接口编程都非常有好处。 2.装饰者模式和组合模式有很多相似的地方,它们都与所包装的对象实现同样的接口并且会把任何方法的调用传递给这些对象。装饰者模式和组合模式是本人描述的较吃力的两个模式,我个人其实也没用过,所以查了很多相关资料和文档,请大家海涵。 3.门面模式是个非常有意思的模式,几乎所有的JavaScript库都会用到这个模式,假如你有逆向思维或者逆向编程的经验,你会更容易理解这个模式(听起来有挑战,其实一接触你就知道这是个很简单的模式);还有配置器模式得和门面模式一块拿来说,这个模式对现有接口进行包装,合理运用可以很多程度上提高开发效率。这两个模式有相似的地方,所以一块理解的话相信都会很快上手的。 4.享元模式是一种以优化为目的的模式。 5.代理模式主要用于控制对象的访问,包括推迟对其创建需要耗用大量计算资源的类得实例化。 6.观察者模式用于对对象的状态进行观察,并且当它发生变化时能得到通知的方法。用于让对象对事件进行监听以便对其作出响应。观察者模式也被称为“订阅者模式”。 7.命令模式是对方法调用进行封装的方式,用命名模式可以对方法调用进行参数化和传递,然后在需要的时候再加以执行。 8.职责链模式用来消除请求的发送者和接收者之间的耦合。 JavaScript设计模式都有哪些? 单体(Singleton)模式:绝对是JavaScript中最基本最有用的模式。 单体在JavaScript的有多种用途,它用来划分命名空间。可以减少网页中全局变量的数量(在网页中使用全局变量有风险);可以在多人开发时避免代码的冲突(使用合理的命名空间)等等。 在中小型项目或者功能中,单体可以用作命名空间把自己的代码组织在一个全局变量名下;在稍大或者复杂的功能中,单体可以用来把相关代码组织在一起以便日后好维护。

虚拟仿真(虚拟现实)实验室解决方案设计

数虎图像提供虚拟仿真实验室硬件设备搭建和内容制作整体解决 方案 虚拟现实实验室是虚拟现实技术应用研究就的重要载体。 随着虚拟实验技术的成熟,人们开始认识到虚拟实验室在教育领域的应用价值,它除了可以辅助高校的科研工作,在实验教学方面也具有如利用率高,易维护等诸多优点.近年来,国内的许多高校都根据自身科研和教学的需求建立了一些虚拟实验室。数虎图像拥有多名虚拟现实软硬件工程师,在虚拟现实实验室建设方面有着无与伦比的优越性! 下面请跟随数虎图像一起,让我们从头开始认识虚拟现实实验室。【虚拟现实实验室系统组成】: 建立一个完整的虚拟现实系统是成功进行虚拟现实应用的关键,而要建立一个完整的虚拟现实系统,首先要做的工作是选择确实可行的虚拟现实系统解决方案。 数虎图像根据虚拟现实技术的内在含义和技术特征,并结合多年的虚拟现实实验室建设经验,最新推出的虚拟现实实验室系统提供以下组成:

虚拟现实开发平台: 一个完整的虚拟现实系统都需要有一套功能完备的虚拟现实应用开发平台,一般包括两个部分,一是硬件开发平台,即高性能图像生成及处理系统,通常为高性能的图形计算机或虚拟现实工作站;另一部分为软件开发平台,即面向应用对象的虚拟现实应用软件开发平台。开发平台部分是整个虚拟现实系统的核心部分,负责整个VR场景的开发、运算、生成,是整个虚拟现实系统最基本的物理平台,同时连接和协调整个系统的其它各个子系统的工作和运转,与他们共同组成一个完整的虚拟现实系统。因此,虚拟现实系统开发平台部分在任何一个虚拟现实系统中都不可缺少,而且至关重要。 虚拟现实显示系统: ·高性能图像生成及处理系统 ·具有沉浸感的虚拟三维显示系统 在虚拟现实应用系统中,通常有多种显示系统或设备,比如:大屏幕监视器、头盔显示器、立体显示器和虚拟三维投影显示系统,

目标任务型教学模式

目标任务型教学模式 -“网页制作技术”教学模式初探 The Task- And- Objective Mode Of Teaching Prof Yulaihu 一、引言 网上教育对各种类型和各种层次的教育所使用,对于教师,正在要求他们适应网上教学,而学生则被允许采用多种灵活的方式进行学习。于是学生和教师都在思考这样一个问题,他们通过网上教学可以获得那些好处呢?这篇文章的目地是探索在远程教育中如何建立适应学生学习的教学模式,在借鉴传统教学方式的基础上,倡导改变学生的学习方式,确立学生的主体地位,以促进学生积极主动地学习。这就要求我们必须关注学生的学习过程和学习方法,关注学生是用什么样的手段和方法、通过什么样的途径获得知识。要求我们改变以往的灌输式学习,构建一种新的课堂教学模式——目标任务型教学模式,以促进学生主动协调地发展。有效激发学生的学习兴趣,增强学生的信息意识和创新意识。 二、理论基础 在构建教学模式时,许多人只注重模式的形式,将各种媒体或活动的种类都放到教学环节中,认为这就是新的教学模式了,而从根本上忽略了如何在教学中选择媒体、或在学习内容中搭配学习的策略。

诺贝尔物理奖得主霍曼(R.P. Feynman,1985)曾说过一个生动的例子:二次大战期间,美军曾使用南太平洋中的某个小岛,做为飞机运送后勤物资的转运点,为了表示友好,美国政府送了一些物资给当地土箸人。大战结束后美军撤走,这些土箸人希望还会有天上的铁鸟飞来送东西给他们,因此,他们在原跑道上点上火把(模仿指示灯),盖了茅屋(模仿塔台)派人守在里面,耳朵上绑了两块木片(模仿耳罩),头上再插根树枝(模仿天线),就痴痴的等在那儿,结果当然是什么也没有发生。 这些南太平洋的土箸人,千方百计的模仿形式,学足了外表,但由于不懂事件发生的原因,落得什么也没得到。我们在构建新的教学模式时,千万不要模仿了外表,忘了实质,因此在提出新的教学模式前,我们要先来看看教学设计的理论基础。 (一)行为主义心理学 行为主义心理学反对抽象空洞的精神或意识的探讨,只研究具体、可观察的行为。它将学习定义为行为的长久改变,也就是在刺激与反应之间建立联结的关系。经过长期的实验与观察,行为主义心理学者以制约理论建立了一套有效、容易操作的行为改变程序。华森(J.B.Watson)曾很自豪的说:给我一百个孩子,我可以教他们成为医师、警察、小偷或流氓等任何职业;华森的信心来自于行为主义对教学内容的精密分析,要建立一个复杂的目的行为,他们的首要步骤就是将目的行为分析成为一个个连续而且容易完成的渐进目标,每个渐进目标再往下分析成为更细的目标,直到最小的目标对应到一个很

最新小学英语单词自然拼读法

一、循序渐进,逐步掌握自然拼读法 对于小学生而言,自然拼读法的掌握并不是一蹴而就的事情,而是一个循序渐进,逐渐积累熟练的过程,因此,作为小学英语教师,在引导学生掌握自然拼读法时,一定要由简到繁,由易到难。在自然拼读法的教学中,我一直坚持采用“五阶段分解法”,将自然拼读法的学习分成五个阶段,层层递进。第一阶段:引导学生建立字母与字母自然发音之间的直接联系,让学生掌握代表英语44个基本音的字母和字母组合,比如掌握单辅音(p,d,k…)、辅音字母组合(c h,sh,th…),元音包括短元音(a,e,i…)、长元音(ai,ee,ie…)和其他元音(er,or,oi…)的发音等等;第二阶段:引导学生能够成功拼读元音+辅音(辅音+元音)。如:m-ymy,g-ogo等等;第三阶段:引导学生能够成功拼读辅音+元音+辅音。如d-o-gdog,h-o-thot;第四阶段:引导学生成功拼读双音节或多音节单词。如sw-ea-t-ersweater;第五阶段:引导学生听音辨字,即听到单词读音就能拼出该单词。所以说在教学中,教师一定要分清层次,引导学生逐步去学习,一步步的打牢基础。 二、强化练习,熟练运用自然拼读法 学习是一个持续推进,反复强化的过程,最忌三天打鱼、两天晒网。不管哪一门学科,要想掌握相关知识,都必须不断的学习、练习、强化记忆。尤其是关于语言的学习,一定要不断回顾,不断练习。小学自然拼读法的学习,同样如此。在教学中,笔者发现许多教师在教学过程中,只传授给学生最基本的方法,然而却忽视引导学生进行认真的练习,导致学生学过之后,遗忘率很高,影响了教学效果。笔者认为,对于教师而言,一定要将强化练习融入自然拼读法的教学中,比如,在讲解字母和字母组合的基本音时,如果教师讲过之后,没有督促学生进行练习,加深记忆,学生肯定记不清、记不牢、容易混淆,只有不断加强督促,加强检查,引导学生去记忆,去练习,才能将44个字母和字母组合的基本音刻印在学生的脑子里。此外,掌握了基本的字母和字母组合的发音后,教师就应该引导学生进行单词的拼读和拼写练习。在教学过程中,在引导学生掌握字母和字母组合的发音后,我首先会组织学生进行拼读练习,每天都会在黑板上写出很多

为什么要使用单例模式

为什么要使用单例?有几种单例的认识 2010-11-14 16:10 为什么好多考官都要考单例模式,现将自已的理解做一下简单介绍:其实程序最初的思想是用NEW去创建一个实例对象,然后我们使用这个实例对象去做一些相关的操作,那如果有多个线程同时访问,那意味着要NEW多个实例对象,这样不仅使服务器性能下降,而且占用内存会越来越大,线程越多,占用内存越大。例:当我们需要访问的时候总是需要NEW一个CONNECT实例,然后才能用实例进行增删改的相关操作,然而这对于一个WEB客户端,启动一个线程,在每次访问的时候都会去与服务器后台打交道,这意味着,假如有一万个Web客户端将要启动一万个线程都去访问服务器那将会,NEW一万个实例对象,不公是非常占内存,而且性能也会急剧下降,后果可想而知......,因此优秀的程序员们绞尽脑汁的去优化自已的程序。有人提问:在这一万个WEB客户端线程间,是否能将CONNECT只用一个实例,让每一个WEB客户端都去访问这个连接?答案就是单例。如果我们创建一个单例程序,然后在服务器启动后,自始自终,服务器只对某个类进行一次实例,这就是单例。它不仅能节省服务器的内存,也能提高服务器的性能。如果平凡的使用NEW也会耗相当大的内存,所以在能够多个线程之间共用一个对象的时候,尽量用单例模式去实现该程序。 SPRING是我们每个人都非常熟知的开源框架。SPRING中大量使用了单例去初始化一些BEAN。这使得我们N多WEB客户端在请

求的时候不需要在NEW一些东西,只需要去得到单例的对象去操作,就可以了,它的依赖注入也只是将这些单例的实例对象得到然后进行注入到另一个对象,进行使用。 Ext JS中也使用了不少的单例模式,JS使用单例,可以对客户浏览器中的内存得到充分的利用。 单例模式的要点 显然单例模式的要点有三个;一是某个类只能有一个实例;二是它必须自行创建这个实例;三是它必须自行向整个系统提供这个实例。在下面的对象图中,有一个"单例对象",而"客户甲"、"客户乙" 和"客户丙"是单例对象的三个客户对象。可以看到,所有的客户对象共享一个单例对象。而且从单例对象到自身的连接线可以看出,单例对象持有对自己的引用。 一些资源管理器常常设计成单例模式。 在计算机系统中,需要管理的资源包括软件外部资源,譬如每台计算机可以有若干个打印机,但只能有一个Printer Spooler,以避免两个打印作业同时输出到打印机中。每台计算机可以有若干传真卡,但是只应该有一个软件负责管理传真卡,以避免出现两份传真作业同时传到传真卡中的情况。每台计算机可以有若干通信端口,系统应当集中管理这些通信端口,以避免一个通信端口同时被两个请求同时调用。

高中英语Unit3Underthesea练习试题人教版

Unit 3 Under the sea 【导语】捕鲸业是世界上古老的行业之一,它的历史发展和现状如何呢? The whaling industry is one of the oldest industries in existence.It has undergone vast changes since its beginning,primarily due to the creation of the International Whaling https://www.doczj.com/doc/8c14346789.html,mercial whaling still continues throughout the world,but the whaling quotas are restricted by the commission,thereby helping conserve the whale populations. Whaling refers to hunting wh ales primarily for their oil,meat and bones.Whaling dates back to prehistoric times,most prevalent in Norway and Japan.The hunt became an industry in the 1600s in the Arctic regions,mostly by the Dutch and British.American colonists started whaling in the 1700s.Nantucket whalers were the first to kill a sperm whale,and the discovery of spermaceti in the whale's head made the sperm whale one of the most highly prized catches.Whaling ships set out from New England into the Pacific for extremely long voyages to hunt down these whales. Whaling industry has been a part of a variety of countries' industries.The following countries were the earliest pioneers in the whaling industry:England,France,Germany,Iceland,Japan,the Netherlands,Norway and the American colonies (although they were not a country at the time).The following countries still practice whaling in some form or fashion:Canada,Greenland,the Grenadines,Iceland,Indonesia,Japan,the Netherlands,Norway,Russia and the United States. 【词海拾贝】 1.vast adj.广阔的;巨大的 2.primarily adv.首先;最初 3.commission n.委员会 4.commercial adj.商业的 5.quota n.配额 6.prevalent adj.盛行的 7.sperm whale 巨头鲸;抹香鲸 【问题思考】 1.What helps conserve the whale populations? _______________________________________________________ 答案:The whaling quotas.

远程虚拟仿真实验室教学系统

电力电子虚拟仿真教学实验平台 实验室建设背景 目前的高等教育中,越来越强调对学生实践能力的培养,实验教育成为理工科教育的一个至关重要的环节。然而,随着各学科实验项目和学生人数的增多,传统的电气实验室和实验仪器数量很难满足学生的需求,在教学和学生使用上的不便之处也慢慢凸现出来。如何解决传统实验教学资源分配不足、实验方式过于刻板、实验器材维护费时费力、实验内容固定难以拓展等问题,是目前新工科建设、课程改革内容中一个讨论的热点。 在对创新型实验建设的需求日益明确之际,仿真实验教学的概念开始成为学校关注的重点。仿真教学实验是一种基于软件技术构建的虚拟实验教学系统,是现有各种教学实验室的数字化和虚拟化,为开设各种专业实验课程提供了全新的教学与科研环境。因此建设仿真实验室可以与实物实验室互补,它除了可以辅助高校的科研工作,在实验教学方面也具有如利用率高,易维护等诸多优点。近年来,国内的许多高校都根据自身科研和教学的需求建立了一些高科技的仿真实验室。 远宽解决方案 远宽能源除了将仿真技术应用于科研与工业测试,也率先将该技术引入到了教学实验室建设中。对于不同的实验内容与实验类型,远宽能源提出了如下的仿真实验建设的解决方案:实时仿真实验和远程虚拟仿真实验。

1. 实时仿真实验 远宽能源将先进的FPGA小步长实时仿真技术应用到教学实验室建设中,小步长实时仿真技术使它能够覆盖电力电子、电机驱动、新能源等多个电力电子相关应用的创新教学实验以及研究的需求。基于图形化系统建模,模型一键下载,无需FPGA编程编译,大大增强了产品的易用性;同时实验平台还配置了硬件控制器(TI的DSP或者NI的GPIC),和仿真器构成完整的闭环系统。实时仿真实验系统如下图所示:

java单例模式精解

Singleton模式可以是很简单的,它的全部只需要一个类就可以完成(看看这章可怜的UML图)。但是如果在“对象创建的次数以及何时被创建”这两点上较真起来,Singleton模式可以相当的复杂,比头五种模式加起来还复杂,譬如涉及到DCL双锁检测(double checked locking)的讨论、涉及到多个类加载器(ClassLoader)协同时、涉及到跨JVM(集群、远程EJB等)时、涉及到单例对象被销毁后重建等。对于复杂的情况,本章中会涉及到其中一些[1] 目的: 希望对象只创建一个实例,并且提供一个全局的访问点。 场景: Kerrigan对于Zerg来说是个至关重要的灵魂人物,无数的Drone、Zergling、Hydralisk……可以被创造、被牺牲,但是Kerrigan得存在关系到Zerg在这局游戏中的生存,而且Kerrigan是不允许被多次创造的,必须有且只有一个虫族刀锋女王的实例存在,这不是游戏规则,但这是个政治问题。 分析: 如前面一样,我们还是尝试使用代码来描述访问Kerrigan的过程,看看下面的UML图,简单得我都不怎么好意思放上来占版面。 图6.1 单例模式的UML图 结构是简单的,只是我们还有一些小小的要求如下:

1.最基本要求:每次从getInstance()都能返回一个且唯一的一个Kerrigan 对象。 2.稍微高一点的要求:Kerrigan很忙,很多人找,所以希望这个方法能适应多线程并发访问。 3.再提高一点的要求:Zerg是讲究公务员效率的社会,希望找Kerrigan的方法性能尽可能高。 4.最后一点要求是Kerrigan自己提出的:体谅到Kerrigan太累,希望多些睡觉时间,因此Kerrigan希望实现懒加载(Lazy Load),在需要的时候才被构造。 5.原本打算说还提要处理多ClassLoader、多JVM等情况,不过还是不要把情况考虑的太复杂了,暂且先放过作者吧(-_-#)。 我们第一次写的单例模式是下面这个样子的: Java代码 1./** 2. * 实现单例访问Kerrigan的第一次尝试 3. */ 4.public class SingletonKerriganA { 5. 6. /** 7. * 单例对象实例 8. */ 9. private static SingletonKerriganA instance = null; 10. 11. public static SingletonKerriganA getInstance() { 12. if (instance == null) { // line A 13. instance = new SingletonKerriganA(); //lin e B 14. } 15. return instance; 16. }

23种模式详解

总体来说设计模式分为三大类: 创建型模式,共五种:工厂方法模式、抽象工厂模式、单例模式、建造者模式、原型模式。结构型模式,共七种:适配器模式、装饰器模式、代理模式、外观模式、桥接模式、组合模式、享元模式。 行为型模式,共十一种:策略模式、模板方法模式、观察者模式、迭代子模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式、中介者模式、解释器模式。 其实还有两类:并发型模式和线程池模式。用一个图片来整体描述一下: 二、设计模式的六大原则 1、开闭原则(Open Close Principle)

开闭原则就是说对扩展开放,对修改关闭。在程序需要进行拓展的时候,不能去修改原有的代码,实现一个热插拔的效果。所以一句话概括就是:为了使程序的扩展性好,易于维护和升级。想要达到这样的效果,我们需要使用接口和抽象类,后面的具体设计中我们会提到这点。 2、里氏代换原则(Liskov Substitution Principle) 里氏代换原则(Liskov Substitution Principle LSP)面向对象设计的基本原则之一。里氏代换原则中说,任何基类可以出现的地方,子类一定可以出现。LSP是继承复用的基石,只有当衍生类可以替换掉基类,软件单位的功能不受到影响时,基类才能真正被复用,而衍生类也能够在基类的基础上增加新的行为。里氏代换原则是对“开-闭”原则的补充。实现“开-闭”原则的关键步骤就是抽象化。而基类与子类的继承关系就是抽象化的具体实现,所以里氏代换原则是对实现抽象化的具体步骤的规范。—— From Baidu 百科 3、依赖倒转原则(Dependence Inversion Principle) 这个是开闭原则的基础,具体内容:真对接口编程,依赖于抽象而不依赖于具体。 4、接口隔离原则(Interface Segregation Principle) 这个原则的意思是:使用多个隔离的接口,比使用单个接口要好。还是一个降低类之间的耦合度的意思,从这儿我们看出,其实设计模式就是一个软件的设计思想,从大型软件架构出发,为了升级和维护方便。所以上文中多次出现:降低依赖,降低耦合。 5、迪米特法则(最少知道原则)(Demeter Principle) 为什么叫最少知道原则,就是说:一个实体应当尽量少的与其他实体之间发生相互作用,使得系统功能模块相对独立。 6、合成复用原则(Composite Reuse Principle) 原则是尽量使用合成/聚合的方式,而不是使用继承。 三、Java的23中设计模式 从这一块开始,我们详细介绍Java中23种设计模式的概念,应用场景等情况,并结合他们的特点及设计模式的原则进行分析。 1、工厂方法模式(Factory Method) 工厂方法模式分为三种:

高考英语一轮复习Unit3Underthesea词汇训练新人教版选修7

Unit 3 Underthesea 基础知识默写篇 一、分层单词 写作词汇 1. vt.放弃;遗弃;抛弃 2. vt.当场见到;目击 n.目击者;证人;证据 3. vi.& n.暂停;中止 4. vt.拖;拉;扯 5. vi.逃避;逃跑 vt.逃离 6. n.住所;住宿 7. n.关系;血缘关系;交往 8. adj.好的;整齐的;匀称的 9. adj.生动的;鲜明的;鲜艳的 10. adj.纯的;纯粹的;纯洁的 11. prep.在……对面 adj.相对的;相反的 12. vt.催促;极力主张;驱策 13. vi.思考 vt.映射;反射;思考 14. adj.意识到的;知道的 阅读词汇 1.jog vi.&vt. 2.dive vi.& n. 3.suck vt.& vi. 4.conservation n. 5.target n. 6.boundary n.

7.pension n. 8.annual adj. & n. 9.narrow adj. 10.shallow adj. 11.steep adj. 12.awesome adj. 13.seaside n.&adj. 14.telescope n. 15.teamwork n. 16.dimension n. 拓展词汇 1. n.深(度);深处→adj.深的adv. 深深地 2. adj.好吃的;可口的→ n.味道;品位;鉴赏力v.尝;品尝;有……的味道 3. adj.意识到的;知道的→ n.意识;认识 4. vi.思考vt.反射;思考→ n.反射;思考 5. adj.锐利的;锋利的;敏捷的→v.(使)变得锋利 6. vt.催促;极力主张;驱策→ n.紧急;迫切;催促→adj.紧急的;迫切的;催促的 7. vt.恐吓 vi.受惊吓→adj.害怕的 二、高频短语 1. 帮助(某人)摆脱困境或危难 2. 对……知道、明白;意识到…… 3. 举起;阻碍 4. 整理;收拾 5. 在此期间;与此同时 6. 靠近 7. upside down 8. (be) scared to death 9. aim at

单例模式设计与实现

实验报告 课程名称: 专业班级: 姓名: 学号: 指导老师: 日期: 福州理工学院工学院 二〇一七年三月

实验7 [单例模式的应用] 一、实验目的 1.理解单例模式的定义 2.掌握单例模式的结构类图和典型代码 二、实验准备与环境 1.实验准备 单例模式类图 2.实验环境 StarUML (或Visio...) 三、实验要求 1、世界上只有一个月亮,月亮的直径是3476.28km ,无论在中国还是在美国,我们所看到的都是同一个月亮。使用单例模式实现无论我们在哪所看到的月亮是同一个月亮(饿汉单例模式、懒汉单例模式),绘制类图并编程实现。 2、使用单例模式的思想模拟实现数据库连接池功能,确保系统中连接类的对象只能存在有限个,如两个或三个,设计并编写代码实现一个多例类。 四、实验步骤 1.1单例模式的结构与实现: 结构如图所示。 Singleton -instance : Singleton -+Singleton () getInstance ()... : Singleton

1.2 单例模式的实现 单例模式的两种模式: 第一种:懒汉式单例 该模式的特点是类加载时没有生成单例,只有当第一次调用getMood 方法时才去创建这个单例。代码如下: public class Mood { private static Mood mood=null; private static double distance=3476.28; private Mood() { System.out.println("产生一个月亮"); } public static synchronized Mood getMood() { //在getMood方法上加上同步 if(mood==null) { mood=new Mood(); }else { System.out.println("已经产生了一个月亮,不能产生新的月亮!"); } return mood; } public void getDistance() { System.out.println("我是月亮,我的直径是:"+distance+"km."); } } 运行结果如下:

十 大 经 典 排 序 算 法 总 结 超 详 细

前端资源收集 前端资-源收集 收集的资-源 44个 Javascript 变态题解析 javascript 变态题解析 正则表达式收集 正则表达式收集 十大经典排序算法总结(JavaScript描述)排序算法的总结 前端工具库汇总 前端工具库总结 怎么学JavaScript? 学习javascript 的学习指导 不定期更新 JavaScript技巧 javascript 编码技巧总结 H5项目常见问题汇总及解决方案 高质量的常见问题汇总 廖雪峰的 git 教-程 Git忽略规则.gitignore梳理 git 配置提交规则 全局环境,执行环境

setTimeout promises 很酷,但很多人并没有理解就在用了 promises 使用错误汇总 promises webpack 2 中文文档 输入url后的加载过程 详细解答从输入URL 到页面显示的过程 数组Array.prototype方法 介绍了数组的一些新的方法 移动端真机调试 Web 客户端存储 ESLint中文指南 webpack 2 集成ESLint react-webpack2-skeleton webpack 2 react 成功案例,包括热加载 cookie 小结 CSS定制多行省略 Ajax 知识体系大梳理 js+nodejs完成文件上传 用 webpack 实现持久化缓存 搜罗一切webpack的好文章好工具 深入理解 CSS:字体度量、line-height 和 vertical-align

原生JS中DOM节点相关API合集 正则表达式前端使用手册 聊一聊H5应用缓存-Manifest fetch进阶指南 mozilla 开发者网络 深入理解javascript原型和闭包系列JavaScript深入系列 深度长文 JavaScript数组所有API全解密你真的懂 JavaScript 的正则吗?webpack2 终极优化 文件上传那些事儿 写给前端工程师的DNS基础知识 初识weex(前端视角) - 环境搭建 前端命名规范 正则表达式 总有你要的编程书单(GitHub )JavaScript深入系列 javascript 的一些功能点 如何在小程序中调用本地接口 移动端浏览器调试方法汇总 HTML5移动开发中的input输入框类型 互联网协议入门

相关主题
文本预览
相关文档 最新文档