Observer Pattern - An Enterprise JavaBean Implementation

YOLO26算法城市道路车辆与行人目标检测+训练好的模型+261张数据集+pyqt可视化界面.zip 附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[路障(barrier), 自行车(bicycle), 公交车(bus), 小汽车(car), 施工车辆(construction_vehicle), 摩托车(motorcycle), 行人(pedestrian), 交通锥(traffic_cone), 拖车(trailer), 卡车(truck)] · 总计:261 张 · 测试集:44 张 · 验证集:146 张 · 训练集:71 张 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 92 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.1446** mAP50-95 | 0.0706 Precision | 0.4273 Recall | 0.1741 train/box_loss | 2.0121 train/cls_loss | 2.1335 val/box_loss | 2.1985 val/cls_loss | 2.2913 【训练过程分析】 这轮训练从一开始就没有给我太多惊喜。训练曲线显示,train/box_loss 和 train/cls_loss 都在前 40 轮快速下降,这让我一度觉得模型很快就能收敛,然而后续的曲线却让我感到有些无奈。从第 41 轮开始,train/box_loss 只是在缓慢下降,而 train/cls_loss 则一直保持在一个较高的水平,这表明模型在... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。 立即下载

Observer Pattern - An Enterprise JavaBean Implementation

Greg Comeau

Download: EJBObserverPattern.zip

Motivation

I recently needed an infrastructure that would allow an arbitrary number of Enterprise JavaBeans to observe changes to a collection of central business entities. The application environment in which I am developing consists of a number of EJB applications running on more than one host. All of the applications are designed to work together as a single, integrated suite. The database environment is distributed. A central store of data is shared by the entire suite while each application maintains a separate store of data that is specific to that application.

One part of the suite is responsible for accepting transactions from the outside world. Each transaction arrives in the form of an XML document. A typical transaction might require changes to the central data store as well as one or more application data stores. All changes must be done within the scope of a single transaction, i.e. if one application aborts the transaction then all participants must abort the transaction. 

Also, there are some data constraints that cross application boundaries. It is possible for one application to abort a transaction because a change made to the central repository is unacceptable within the context of some application specific data. e.g. Application X may require that a customer has a fax number. If a transaction attempts to grant Customer A permission to use Application X and Customer A does not have a fax number then Application X must abort the transaction.

It was the enforcement of these distributed data constraints that motivated my use of the observer pattern. Each application needs to observe changes in the shared repository as they occur -- and within the transaction in which they occur. If a proposed change to the shared data is unacceptable to any given application then the transaction must be aborted before the change is made permanent.

Implementation

What follows is essentially the process that I went through to implement this pattern. I have omitted some of the more glaring mistakes to protect the stupid guilty.

Note: All of the source files are available for download. The java classes are contained within a package called EJBObserverPattern. 

The java.util.Observable class and the java.util.Observer interface work great within the scope of a single Java VM. But I discovered that they aren't much use in implementing the observer pattern across VMs with EJBs as implementations of Observer. The first step in creating an EJB observer might be to extend java.util.Observer to create a remote interface:

public interface RemoteObserver extends javax.ejb.EJBObject, java.util.Observer
{
}

If you did this you'd quickly find out that java.util.Observer.update(...) does not declare java.rmi.RemoteException, something required of all methods of a remote interface. At this point I found it necessary to create a new observer interface and observable class that would work in the EJB universe. I created my own observer and observable classes which parallel the respective classes in java.util. 

The EJBObserver Interface

A new interface is required that I called EJBObserver:

package EJBObserverPattern;

public interface EJBObserver
{
    /**
     * @param   observable  a reference to the object being observed
     * @param   arg         the arguments being passed to the observer
     */
    public void update (EJBObservable observable, Object arg)
        throws java.rmi.RemoteException, javax.ejb.EJBException;

}

Note: A common pattern in EJB implementations is to define a superinterface to be extended by both the remote interface and the bean itself. This is commonly called a business interface. EJBObserver is a business interface.

Yet Another Note: My development environment adheres to the EJB 1.0 specification. Thus, I have to explicitly declare javax.ejb.EJBException. EJB 1.1 and later redefines EJBException as a subclass of RuntimeException making it unnecessary to explicitly declare it in a method signature.

The EJBObservable Class

My new class EJBObservable defines all the same methods as java.util.Observable (why change a paradigm that works.) Thus, my EJBObserver update method takes an EJBObservable object; this mirrors java.util.Observer, which takes a java.util.Observable object. I marked EJBObservable as serializable by implementing java.io.Serializable. This is necessary since instances of this class will be sent to remote EJB observers:

package EJBObserverPattern;

import java.rmi.RemoteException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.ejb.EJBException;

/**
 * A class to be subclassed by any entity which may be observed
 * by instances of EJBObserver.
 *
 * @see     java.util.Observable
 */
public class EJBObservable implements java.io.Serializable
{
    /**
     * The collection of observers. Using a Set will guarantee
     * no duplicate observers.
     */
    protected Set mObservers = new HashSet();

    protected boolean mChanged = false;

    /*
        The methods for adding, deleting, and counting observers are
        all trivial, as are the methods for checking and setting the
        'changed' indicator.

        Their semantics are identical to the respective
        methods in java.util.Observable.
    */
    public void addObserver (EJBObserver observer)
    {
        mObservers.add (observer);
    }

    public void deleteObserver (EJBObserver observer)
    {
        mObservers.remove (observer);
    }

    public void deleteObservers ()
    {
        mObservers.clear();
    }

    public int countObservers ()
    {
        return mObservers.size();
    }

    public boolean hasChanged ()
    {
        return mChanged;
    }

    public void clearChanged ()
    {
        this.setChanged (false);
    }

    protected void setChanged (boolean changed)
    {
        mChanged = changed;
    }

    /**
     * An overloaded form of notifyObservers that takes no argument. The semantics
     * are identical to calling notifyObservers (..., null).
     * @exception   RemoteException     thrown by a remote implementation of EJBObserver
     * @exception   EJBException        thrown by a remote implementation of EJBObserver
     */
    public void notifyObservers () throws RemoteException, EJBException
    {
        this.notifyObservers (null);
    }

    /**
     * If this object has changed as indicated by the hasChanged method,
     * notify all observers and call clearChanged to reset the hasChanged indicator.
     * @param arg   any object
     * @exception   RemoteException     thrown by a remote implementation of EJBObserver
     * @exception   EJBException        thrown by a remote implementation of EJBObserver
     */
    public void notifyObservers (Object arg) throws RemoteException, EJBException
    {
        if (this.hasChanged())
        {
            for (Iterator i = mObservers.iterator(); i.hasNext(); )
            {
                EJBObserver obs = (EJBObserver) i.next();

                obs.update (this, arg);

            }

            this.clearChanged();

        }
    }
}
Foobar -- A Subclass of EJBObservable

For testing purposes I created a subclass of EJBObservable called Foobar. This is the thing that will be observed. Foobar has a single member variable with a corresponding setter method. Setting the member variable also sets the changed attribute inherited from the superclass EJBObservable. The semantics of the changed attribute are identical to the respective attribute of java.util.Observable:

package EJBObserverPattern;

public class Foobar extends EJBObservable
{
    String mSomething = null;

    public void setSomething (String s)
    {
        mSomething = s;
        setChanged (true);

        /*  We could call notifyObservers right here, but this may or may not
            be a good thing to do. Each call to notifyObservers will result in
            a remote method call for every registered observer. If there is
            more than one attribute to 'set' then it might be better
            for the caller to set them all and then call notifyObservers explicitly.
        */
    }

    public String toString ()
    {
        return mSomething;
    }
}

The Test Harness

Again for the purposes of testing, I created a test harness called Tester. This class simply creates an instance of Foobar, adds an observer, invokes the setter method of Foobar and calls notifyObservers:

package EJBObserverPattern;

public class Tester
{
    public static void main (String[] args)
    {
        try
        {
            Foobar f = new Foobar();

            f.addObserver (???);

            f.setSomething (args[0]);

            f.notifyObservers (args[1]);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

Note: Tester will go through several revisions later in the document. My intent is to show you the abstraction process as well as the final result.

As you can see I've put the cart before the horse after the barn door closed. I do not yet have an implementation of EJBObserver. This turned out to be the interesting part.

Note that updating a remote observer via EJBObserver.update(...) will involve a remote method invocation. The observer is located at some arbitrary location in the EJB universe. The local manifestation of a remote observer will be an instance of a remote interface obtained by the usual means -- by invoking the create method of a home interface obtained via JNDI.

So now I needed to implement the usual components of an EJB, the home and remote interfaces and the bean itself. I used a stateless session bean. Note that there can be an arbitrary number of EJBObserver implementations in use at one time but only one is required to demonstrate the pattern.

Remote Interface of EJBObserver Implementation

First I created the remote interface, which I subclassed from the business interface EJBObserver:

package EJBObserverPattern;

public interface RemoteObserver extends javax.ejb.EJBObject, EJBObserver
{
}
Home Interface of EJBObserver Implementation

Next I created the home interface, which is almost as trivial as the remote interface. There's nothing special about it:

package EJBObserverPattern;

public interface RemoteObserverHome extends javax.ejb.EJBHome
{
    public RemoteObserver create()
        throws java.rmi.RemoteException, javax.ejb.CreateException;
}

The astute reader may notice that I'm going to have a problem with this home interface. Rest assured that I was not astute. (What is a stute?) I didn't recognize the problem until I ran into it. I'll describe the exact problem and my solution later.

A stute is the adult form of a ware.

RemoteObserverBean

Now for the bean itself. Again, I implemented the superinterface EJBObserver. The implementation of the update method simply writes to the system output stream so I know that it worked:

package EJBObserverPattern;

import javax.ejb.*;

public class RemoteObserverBean implements EJBObserver, SessionBean
{
    /**
     * @param   observable  a reference to the object being observed
     * @param   arg      the arguments being passed to the observer
     */
    public void update (EJBObservable observable, Object arg)
    {
        System.out.println ("Hey! I've been updated! " +
            "observable = " + observable.toString() +
            " arg = " + arg.toString());
    }

    public void ejbCreate () { }

    public void ejbActivate() { }

    public void ejbPassivate() { }

    public void ejbRemove() { }

    public void setSessionContext(SessionContext ctx) { }
}

There is nothing special about the deployment descriptor for this bean. I've included it in the download file. The only detail worth noting is that the EJB must be a well-behaved transactional component, preferably using Component Managed Transactions. Otherwise any persistence operations performed by an instance of EJBObserver may not be rolled back if some other EJBObserver aborts the transaction.

I used Weblogic to build and deploy it. It all worked perfectly the first time. Really. ... Why do you look skeptical?

Instantiate the Remote EJBObserver

At this point I cannibalized the appropriate code to get the new home and remote interfaces. Plugging this code into Tester I ended up with the following:

package EJBObserverPattern;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class Tester
{
    public static void main (String[] args)
    {
        try
        {
            Foobar f = new Foobar();

            Properties p = new Properties();

            p.put(Context.INITIAL_CONTEXT_FACTORY,
                "weblogic.jndi.WLInitialContextFactory");

            p.put(Context.PROVIDER_URL,
                "t3://localhost:7003");

            InitialContext namingContext = new InitialContext(p);

            RemoteObserverHome obsHome =
                (RemoteObserverHome) PortableRemoteObject.narrow (
                    namingContext.lookup (RemoteObserver.class.getName()),
                    RemoteObserverHome.class );

            RemoteObserver obs =
                (RemoteObserver) PortableRemoteObject.narrow (
                    obsHome.create(),
                    RemoteObserver.class);

            f.addObserver (obs);

            f.setSomething (args[0]);

            f.notifyObservers (args[1]);

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

When I ran the above it worked as expected. The update method of the remote observer was called and I got the expected output on the console. But this isn't exactly what I wanted. Notice that I coupled myself directly to a specific implementation of EJBObserver, namely RemoteObserver. My intention from the beginning was to query some semi-static registry to obtain the JNDI parameters that identify one or more observers. The parameters stored in each entry of the registry would be the initial context factory, the provider url, and the JNDI name of the home interface. 

In other words, I wanted to invoke an arbitrary EJBObserver implementation via remote polymorphism.

Decoupling from RemoteObserver was easy enough. I simply changed every reference to EJBObserver -- which I should have done in the first place. Then I ran into a problem with the home interface. 

The aforementioned astute reader has by now realized that my home interface RemoteObserverHome does not have some convenient superinterface to use. Any such interface would have to define the create method in order for polymorphism to work. EJBHome doesn't define the create method. Casting the home interface to EJBHome and invoking the create method will generate a compile error.

Reflection of the Home Interface

When you know a class implements a method with a given signature but you can't use polymorphism, reflection works great. Here's how Tester looked after I used reflection to find and invoke the create method of an arbitrary home interface:

package EJBObserverPattern;

import java.lang.reflect.Method;
import java.util.Properties;
import javax.ejb.EJBHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class Tester
{
    public static void main (String[] args)
    {
        try
        {
            Foobar f = new Foobar();

            String initialContextFactory = "weblogic.jndi.WLInitialContextFactory";
            String providerUrl = "t3://localhost:7003";
            String homeName = RemoteObserver.class.getName();

            Properties p = new Properties();

            p.put(Context.INITIAL_CONTEXT_FACTORY,
                initialContextFactory);

            p.put(Context.PROVIDER_URL,
                providerUrl);

            InitialContext namingContext = new InitialContext(p);

            //  Get a home interface and narrow it to EJBHome

            EJBHome obsHome =
                (EJBHome) PortableRemoteObject.narrow (
                    namingContext.lookup (homeName),
                    EJBHome.class );

            //  Find the create method via reflection

            Method createMethod = obsHome.getClass().getDeclaredMethod (
                "create", new Class[0] );

            //  Invoke the reflected create method to get a remote interface

            Object remoteRef = createMethod.invoke (obsHome, new Class[0]);

            //  Narrow the remote reference to EJBObserver

            EJBObserver obs =
                (EJBObserver) PortableRemoteObject.narrow (
                    remoteRef,
                    EJBObserver.class);

            f.addObserver (obs);

            f.setSomething (args[0]);

            f.notifyObservers (args[1]);

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

The initial context factory, provider url, and EJB home name can easily be retrieved from some external repository via JDBC. I won't show that implementation. One could also imagine an additional mechanism by which a remote application could register itself in the above repository. I won't show that either. Such details aren't really part of this pattern.

Why Not Subclass EJBHome?

You might be asking yourself, "Self, why resort to reflection when I can subclass EJBHome to define the create method that I need to make polymorphism work?"

That's a reasonable question, Self. Let's try it. I did.

First let's create a new interface EJBObserverHome that extends EJBHome. This will be the superinterface to be extended by any home interface of a remote EJBObserver:

package EJBObserverPattern;

public interface EJBObserverHome extends javax.ejb.EJBHome
{
    public EJBObserver create()
        throws java.rmi.RemoteException, javax.ejb.CreateException;
}

Now let's redefine RemoteObserverHome to extend this interface:

package EJBObserverPattern;

public interface RemoteObserverHome extends EJBObserverHome
{
}

Looking good. Now let's rebuild RemoteObserverBean.

(build, build, build ... oops.)

DDCreator RemoteObserverBeanDD.ser
Error: Bean EJBObserverPattern.RemoteObserverBean does not comply with the EJB 1.0 specification
Bean class: EJBObserverPattern.RemoteObserverBean
-----------------------------------------------
home.create() must always return the remote interface type

(Sound of hand slapping forehead.) Of course, a create method of a home interface can't return some abstract class; it must return the exact remote interface type of the EJB that lives there. And if you try to override the create method in RemoteObserverHome to return the right interface type then the compiler will remind you that you can't change the return type of an overridden method. Catch-22. And you can't reuse the same home interface for every remote EJBObserver because there must be a one-to-one correspondence between a home interface and a specific EJB implementation. Otherwise how would the home implementation know which bean to create? Catch-23. (That last bit may have seemed obvious to you. I actually tried it.)

If anybody has another solution to this quandry -- besides reflection -- please enlighten me.

One More Abstraction

There was one detail of this that bothered me. Looking up the home interface and creating a remote interface is a lot of work to go through every time I want to add an observer. What if the observable instance never changes? That's a lot of work for nothing. When I add an observer I simply want to save the minimum amount of information that will be necessary to instantiate and invoke the remote observer when and if the time comes to do so. There's one more abstraction to make.

EJBObserverProxy

Patterns can be addictive. You can't eat just one. A proxy pattern was a perfect fit. I created a new class called EJBObserverProxy that implemented EJBObserver. EJBObserverProxy was designed to save all the information needed to instantiate and invoke a remote observer. It also encapsulated the reflective mechanism by which this was accomplished:

package EJBObserverPattern;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.Set;
import java.util.Iterator;
import java.util.HashSet;
import javax.ejb.EJBException;
import javax.ejb.EJBHome;
import javax.rmi.PortableRemoteObject;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EJBObserverProxy implements java.io.Serializable, EJBObserver
{
    private Properties mContextValues = null;
    private String mJNDIName = null;

    public EJBObserverProxy (
        String initialContextFactory,
        String providerUrl,
        String jndiName)
    {
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,
            initialContextFactory);

        p.put(Context.PROVIDER_URL,
            providerUrl);

        init (p, jndiName);
    }

    public EJBObserverProxy (
        Properties contextValues,
        String jndiName )
    {
        init (contextValues, jndiName);
    }

    protected void init (
        Properties contextValues,
        String jndiName )
    {
        mContextValues = contextValues;
        mJNDIName = jndiName;
    }

    public String getName ()
    {
        return mJNDIName;
    }

    public Properties getContextValues ()
    {
        return mContextValues;
    }

    public int hashCode ()
    {
        return (mContextValues.toString() + mJNDIName).hashCode();
    }

    public boolean equals (Object o)
    {
        EJBObserverProxy loc = (EJBObserverProxy) o;
        return (
            (mContextValues.equals (loc.getContextValues())) &&
            (mJNDIName.equals (loc.getName()))
            );
    }

    /**
     * Instantiate the remote observer referenced by this object and update it.
     */
    public void update (EJBObservable object, Object arg) throws RemoteException, EJBException
    {
        try
        {
            String beanHomeName = this.getName();

            Properties p = this.getContextValues();

            InitialContext namingContext = new InitialContext(p);

            /*  Get a reference to the named object and narrow it to EJBHome
                to make sure it is a home interface.
            */

            EJBHome obsHome = (EJBHome) PortableRemoteObject.narrow (
                namingContext.lookup (beanHomeName), EJBHome.class );

            /*  We can't directly cast this reference to a home interface because each
                EJB implementation will have its own home interface in some arbitrary
                class hierarchy. EJBHome doesn't define a create() method
                so we can't invoke it via polymorphism.

                Let's use reflection to find and invoke the create() method.
                Look for a method named 'create' which takes no parameters.

            */

            Method createMethod = obsHome.getClass().getDeclaredMethod (
                "create", new Class[0] );

            /*  Invoke the 'create' method of the home interface via our reflected Method.
            */

            Object remoteObj = createMethod.invoke (obsHome, new Object[0]);

            /*  Narrow the resulting reference to the EJBObserver
                interface, which each remote observer is obligated to implement.
            */

            EJBObserver obs = (EJBObserver) PortableRemoteObject.narrow (
                remoteObj, EJBObserver.class);

            /*  Update this observer with an EJBObservable instance and some argument.
                Foobar is an instance of EJBObservable.
            */

            obs.update (object, arg);
        }
        catch (NoSuchMethodException e)
        {
            throw new EJBException (e);
        }
        catch (NamingException e)
        {
            throw new EJBException (e);
        }
        catch (InvocationTargetException e)
        {
            throw new EJBException (e);
        }
        catch (IllegalAccessException e)
        {
            throw new RuntimeException (e.toString());
        }
    }
}

There are a number of things to note about EJBObserverProxy:

  • It encapsulates member variables that store the settings required to lookup a home interface.
  • It defines hashCode and equals methods so that EJBObserverProxy will be a well-behaved member of a Set. Recall that instances of EJBObserver are stored in a HashSet within EJBObservable. The semantics defined by Observable dictate that any given Observer must be unique within an instance of Observable. A Set implementation uses the hashCode and equals method to enforce uniqueness.
  • It implements java.io.Serializable since instances of this class will be stored inside EJBObservable, which will be serialized as an argument of a remote method call.
  • The update method encapsulates all of the nasty JNDI and reflection that we need to remotely invoke the associated EJBObserver instance.

A reader suggested the use of javax.ejb.Handle to maintain a persistent relationship to a remote observer. You can get a Handle to a remote object and serialize it to persistent storage. The Handle can be materialized from storage at any time to recreate the remote object. I considered encapsulating a Handle object inside EJBObserverProxy but I couldn't figure out how to implement hashCode such that two Handle objects that pointed to the same remote interface would evaluate to the same hash code. Remember that duplicate observers cannot be added to a single observable. The HashSet implementation first compares hash codes to determine if two objects might be equal. If the hash codes are different then it doesn't bother calling the equals method. So there was no way (that I found) to eliminate duplicate observers using Handle objects.

Of course, the act of writing the above paragraph guarantees that it can be done. Such is the nature of the universe.

New Tester using EJBObserverProxy

Now I could use EJBObserverProxy to greatly simplify Tester, thus simplifying the eventual client code that will use this pattern:

package EJBObserverPattern;

public class Tester
{
    public static void main (String[] args)
    {
        try
        {
            Foobar f = new Foobar();

            EJBObserverProxy obs =
                new EJBObserverProxy (
                    "weblogic.jndi.WLInitialContextFactory",
                    "t3://localhost:7003",
                    RemoteObserver.class.getName());

            f.addObserver (obs);

            f.setSomething (args[0]);

            f.notifyObservers (args[1]);

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

The term client in this context means the party that instantiates the EJBObservable object. The client could easily be another EJB.

Motivation Redux

Recall that my motivation was to allow an arbitrary collection of EJBs to observe changes in a central data repository. Any such EJB can now simply extend EJBObserver to define its remote interface and register its JNDI information with the manager of the central repository via some simple database table. If a business entity within the central repository is changed then the central repository manager, after making the change, instantiates a subclass of EJBObservable which encapsulates the updated business entity. The EJBObserver registry is then used to add the appropriate observers and notifyObservers is called. 

If you look again real close you might recognize a mediator pattern in the above paragraph.

Any remote EJBObserver may abort the transaction by simply throwing a system exception or calling setRollbackOnly on its EJBContext object. Recall that a system exception is a java.lang.RuntimeException or java.rmi.RemoteException, or any subclass directly or indirectly thereof. Note that Tester doesn't start a new transaction before it calls notifyObservers. This is an academic example. If I really wanted a single transaction context I'd have to start a new client demarcated transaction. In reality, the role of Tester will usually be filled by an EJB and container managed transactions would be used.

This implementation can be used in any distributed application where an Observer pattern makes sense -- not just in the distributed transaction scenario that I've outlined.

 

About the Author

Greg Comeau is a Senior Software Engineer at Webb Interactive Services, Inc. with offices in Denver and Boulder, Colorado. The author prefers the latter but harbors no ill will against the former.

Comments on this article are welcome. Flames will go unanswered. I'd rather be skiing. Have a nice day.

基于统一环境建模与可行性约束一致化的三维路径规划A星RRT星与粒子群优化对比研究(Matlab代码实现) 内容概要:本文系统研究了基于统一环境建模与可行性约束一致化的三维路径规划问题,对A*算法、RRT*算法与粒子群优化(PSO)算法在三维空间中的路径规划性能进行了深入对比分析。通过构建标准化的仿真环境与统一的可行性约束条件,从路径长度、规划耗时、避障能力及路径平滑性等多个维度对三种算法进行定量评估,全面揭示其各自的优势与局限性。研究旨在为不同应用场景下的路径规划算法选型提供科学依据与技术指导,并配套提供了完整的Matlab代码实现,便于读者复现结果与进一步研究。; 适合人群:具备一定算法基础和Matlab编程能力,从事机器人、自动驾驶、无人机或智能系统等相关领域研究的研发人员及研究生。; 使用场景及目标:① 掌握A*、RRT*、PSO等主流路径规划算法的核心思想与实现细节;② 学习如何在统一标准下对不同算法进行公平、有效的性能对比与评估;③ 获取可直接用于科研或项目开发的三维路径规划Matlab代码框架。; 阅读建议:建议读者在阅读过程中结合提供的Matlab代码进行实践操作,通过修改环境参数和算法配置来观察不同算法的表现差异,从而加深对算法原理与适用场景的理解。 立即下载

相关推荐

Android Profiler 帧率优化实战与性能调优

本文详细介绍了使用Android Profiler进行帧率优化与性能调优的实战方法。通过分析主线程状态、FPS曲线和渲染阶段耗时,精准定位卡顿根源,并提供减少过度绘制、优化绘制命令及改善资源使用的具体策略。文章结合电商、游戏等真实案例,帮助开发者有效解决卡顿问题,提升应用流畅度。

palm99的专栏 548

设计模式(二)The Observer Pattern 观察者模式

问题引入         生成一个公告板显示当时的天气状况,当天气状况发生改变的时候公告板可以实时的更新。 模式定义         定义对象之间的一对多的依赖,当一个对象改变状态时,它的所有依赖者都会自动收到通知并自动更新。 认识模式         该模式在生活中是很常见的。想想生活中的各种各样的检测系统,报警系统,一旦有重要事件发生时,有关系统总能及时的收到

francisshi的专栏 1321

NS3入门教程 以及 NS3 IEEE 802.15.7 CSMA/CA仿真代码

本文初衷 当我发现我必须要做NS3网络仿真的时候,我内心是拒绝的,一方面NS3完全没接触过,另一方面,C++语言接触也不是太多,感觉工作量好大。但是,真的是不做不行了。然后,我就到网上查一些关于NS3的仿真内容,入门什么的,感觉真的是好混乱啊,这个东西没有一个明确的教程,都是一些杂乱的CSDN和技术博客,看起来十分混乱,而且有些现成的代码都是好多好多年前的,让人很难受。所以,我就写了本文,希望...

逆水行舟,不进则退 6763

Observer Pattern - An Enterprise JavaBean Implementation (转)

Observer Pattern - An Enterprise JavaBean Implementation (转)[@more@]Observer Pattern - An Enterprise JavaBean Impl...

csd3176的博客 133

Cadence SpectreRF仿真避坑指南:PSS和Pnoise设置详解(附实战案例)

本文详细解析了Cadence SpectreRF中PSS(周期稳态分析)和Pnoise(周期噪声分析)的关键设置技巧,帮助模拟IC设计工程师避开常见仿真陷阱。通过实战案例分享,涵盖引擎选择、Beat Frequency计算、噪声类型配置等核心参数优化策略,提升仿真精度与效率。特别针对开关电容电路和振荡器等复杂场景提供专业解决方案。

weixin_42613501的博客 621

【YOLOv11工业级实战】15. YOLOv11海洋监测实战:珊瑚礁健康评估(水下图像增强|机器人搭载)

摘要:本文针对珊瑚礁健康评估的海洋监测需求,基于YOLOv11提出解决方案,聚焦水下色偏、悬浮物干扰、珊瑚形态复杂三大难题。引用全球珊瑚礁监测网络(GCRMN)标准,采用CoralNet数据集,通过Jaffe-McGlamery物理模型引导增强与悬浮物去除算法,在浑浊水域(能见度<5m)实现87.3%的健康珊瑚识别率,藻类误判率低至7.2%。介绍了以BlueROV2水下机器人和Jetson AGX Orin为核心的部署方案,结合水下SLAM定位技术,实现珊瑚健康的实时评估与三维覆盖率计算。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1658

Kali渗透测试:sqlmap自动化SQL注入检测与利用实战指南

SQL注入是Web安全中最危险的漏洞之一,攻击者通过构造恶意参数操控数据库查询,可能导致数据泄露甚至服务器沦陷。在渗透测试中,手工拼接Payload效率低、覆盖范围有限,自动化工具因此成为安全人员的必备技能。sqlmap作为业界广泛使用的开源注入检测与利用工具,能够自动完成注入点探测、数据库指纹识别、库表字段枚举及数据导出等流程,并支持多种注入技术与WAF绕过脚本,显著提升测试效率与结果可复现性。在授权评估、漏洞复现、安全审计等场景中,sqlmap都发挥着关键作用。本文基于Kali Linux环境,通过本地

cuiji1279的博客 324

Codex 100个真实案例 - 全系列总结与Codex最佳实践全解析

历经100个案例的淬炼,我们终于来到了终点!本篇是整个系列的压轴之作——全面回顾100个案例的分类统计、提炼Codex使用的核心技巧和最佳实践、总结Prompt工程的精华要点、剖析常见错误及解决方案、展望AI编程的未来趋势,并为不同水平的读者规划学习路径。这不仅是一篇总结,更是一本Codex实战手册!

yueyeguzhuo的专栏 153

使用JBuilder来制作EXE文件(白云原创)

倘若说看到标题后,以为jb真的提供了一种把java应用程序打包成exe文件的主流方法的话 , 你会失望的,下面的一个小技巧只是一个技巧而已。   使用JBuilder来制作可执行文件 ---白云黄鹤 jack 这个是Borland不公开的使用技巧,能够通过JBuilder来制作exe文件来启动Java文件。JBui lder并不支持本地编译机制。但是有一个隐藏的技巧可以让你从可执行文件来启动Jav

xxcc的专栏 8947

仿真学习系列(四十九):Sigrity仿真之电容库制作

在高速电路设计中,电源完整性(PI)是确保系统稳定、可靠运行的关键因素。随着电子产品对性能的要求不断提升,PDN(电源分配网络)的设计与优化变得尤为重要。为了确保电源网络在高速工作状态下不会引发电压波动和信号干扰,我们需要在设计中精确地选择电容器进行优化,而电容库的制作则是这一过程的核心。 OptimizePI作为一个强大的电源完整性优化工具,能够帮助设计师根据不同的目标,批量进行PDN仿真,以得出最佳电容选择。

案例文章,高速信号 236

MIKE水动力笔记17_MIKE文件转shp、统计每个单元格的面积

MIKE的工具箱中自带一个转shp的工具,然后可以拖进ArcGIS中很方便的统计每个单元格的面积和每个网格点的水深。

晏长街的博客 4166

Session Facade with EJB && .net

Session FacadeProvides a coarse grained facade on fine grained objects to improve efficiency over a network. In an object-oriented model, you do best with small objects that have small metho

xxcc的专栏 8886

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

EJB设计模式之Data Transfer Object

Data Transfer Object 在一个ejb系统中的客户端层需要一种向服务器往返 传输大块(bulk)数据的方法。 客户端怎样能和服务器交换大块数据而无需多个细粒 度网络调用呢? 在一个分布式应用中,客户端和服务器交互通常可能 有两个原因。第一个是从服务器上读取一些数据来显 示;第二个是通过创建,更新,删除数据来改变服务 器上的数据。在一个ejb环境,这些类型的操作通常 涉及和客户端(s

xxcc的专栏 4730

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

最新EJB设计模式中文版之Session Facade(会话外观)

session facade一个EJB客户端为了完成一个用例需要执行一个商业逻辑。EJB客户端怎样才能在一个事务(transaction)和一个大批(bulk)网络调用中执行一个用例的商业逻辑呢?为了执行一个典型的用例的商业逻辑,多个服务器端对象(如session或entity bean)通常需要被存取和可能的修改。问题是session和entity bean的多个细粒度(fine-grain

xxcc的专栏 4293

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

java中的高速缓存和连接池对访问数据库性能的影响

一.初识高速缓存和连接池   设想这样一种情形:你突然口渴,需要一杯水来缓解,从心情上来讲,当然是越快越好 了。通常,一杯水的产生包括从水源(井水、河水或江水、甚至海水等)抽取,通过管 道传输和设备净化,才到达你饮水的容器中。上述过程是必须的,但并不是每一杯水的 产生都必须把上述过程重复一次。你可以用一个大一点的容器(例如缸或罐等)来盛大 量的水,喝水之前分到杯子小部分中即可,你的代价只是把水从缸

xxcc的专栏 2822

什么时候用有状态session bean,什么时候用无状态session bean

什么时候用有状态session bean,什么时候用无状态session bean最近,有关于无状态的许多大惊小怪。无状态的缺陷常常被夸大,它的优点也一样。许多无状态的支持者盲目的宣称无状态能带来更大的伸缩性;而有状态的支持者争论说必须为了适应无状态而重建整个系统。真实的情况是什么呢?通过正确地设计,无状态有以下两个优点:1.使用stateless bean,EJB容器能容易的poolin

xxcc的专栏 2254

EJB设计模式(第二版)之EJB Command

EJB Command 一个ejb客户端为了完成一个用例需要执行商业逻辑。 怎样让一个开发者用一个轻量级的态度实现一个用例的 商业逻辑,使客户端和ejb解耦并且用一个事务和一次 网络调用执行用例? 设计ejb系统时的一个重要的架构决定是把商业逻辑 放到什么地方?一个用例的商业逻辑是代表你的领域 模型中的合适的方法或跨多个其它entity bean 和/或 session bean执行逻辑(工作流逻

xxcc的专栏 2204

Message Driven Bean Proxy

Message Driven Beans consume messages from predefined JMS Topics or Queues. Applications that may need to utilize several Message Driven Beans to handle various messages are faced with a problem

xxcc的专栏 2168

EJB设计模式(第二版)之Message Facade

message facade 一个ejb客户端想要在一个环境的用例中调用多个ejb的 方法,并且不需要从服务器的立即的反映。 怎样才能让ejb客户端在一个事务中调用多个session bean或entity bean的方法,不需要被阻塞并且等待 每个bean的反映? 特别在大型系统中,伸缩性指明一个用例的商业逻辑 与客户端的分离执行,不需要客户端等待执行完毕。 这种类型的行为,叫做异步行为,允

xxcc的专栏 2091

SMTH Java FAQ (4) 2D作图以及文字处理

1 如何在2D Graphics中使用双缓冲?     首先你需要知道的是,如果你是在一个Swing组件上作图的画,Swing已经自动的为你   实现了双缓冲,因此没有必要在这个问题上上脑筋了。//感谢上帝     如果你使用的是AWT组件的话,你可以根据下面的流程使用双缓冲:         利用该组件之createImage()方法创建一个BufferedImage对象       利用Buf

xxcc的专栏 1699

Transient Entity

Transient Entity Posted By: Toby Hede on August 16, 2001 Anecdotal evidence suggests that many developers remain skeptical about the value of Entity Beans, especially prior to the

xxcc的专栏 1686

EJB2.0中什么时候用local interface,什么时候用remote interface

EJB2.0中什么时候用local interface,什么时候用remote interfacelocal interface是EJB2.0的新特性,它让你无需反复的网络通信就可以存取你的EJB组件。它也让你去传递非可序列化参数,非常顺手。因此remote interface的价值是什么?好,它实际上不是一个有价值的东东,除非:    1.你需要远程存取你的系统(就是说从一个远程web层),

xxcc的专栏 1682

Lazy Load with EJB

Lazy LoadAn object that doesnt contain all of the data you need, but knows how to get it. class Supplier... public List getProducts() { if (products == null) products = Product.findForS

xxcc的专栏 1654

EJB2.0系统中什么时候使用messaging或者RMI/IIOP

EJB2.0系统中什么时候使用messaging或者RMI/IIOP以下几条是messaging的优势,和你需要去使用它的原因:1.数据库性能。如果你去完成一个关系型数据库工作,如对一个数据库持久化一个定单,使用messaging更有优势。传送一个消息到一个二级消息队列去被晚些时候处理减轻了在高峰时刻的主数据库压力。在早上负荷较低的早上,当通信量比较小时,你能在消息队列中取出并处理那个消息,并

xxcc的专栏 1619

重构模式2

refactoring Patterns:第二部分 内容:简化测试更简单的设计Refactoring增进软件可理解性Refactoring 改进了软件的设计Refactoring 帮助你寻找BugRefactoring 让您

xxcc的专栏 1471
下一篇: Coarse Grained BMP beans with Dependent Value Objects
xxcc
博客等级 码龄26年 1粉丝 86原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址