About This Guide
This guide explains the AMQP 0-9-1 model used by RabbitMQ. The original version was written and kindly contributed by Michael Klishin and edited by Chris Duncan.
High-level Overview of AMQP 0-9-1 and the AMQP Model
What is AMQP?
AMQP (Advanced Message Queuing Protocol) is a networking protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.
AMQP 0-9-1 Model in Brief
AMQP 0-9-1 模型的世界观:生产者产生消息,并发送到交换机--可以类比邮局或者邮箱。交换机根据绑定规则将消息分发到队列。要么由AMQP broker将消息递送到订阅队列的消费者,要么由消费者按需主动的从队列中获取。
When publishing a message, producers may specify various message attributes (message meta-data). Some of this meta-data may be used by the broker, however, the rest of it is completely opaque to the broker and is only used by applications that receive the message.
网络的不可靠导致应用可能不能正常的处理消息,为此AMQP模型引入了“消息应答”的概念:当消息递送到消费者后,消费者通知broker;应答可以是自动的或者由应用的开发者自行来决定。当启用应答机制后,broker只有在收到应答后才从队列中删除消息。
某些情况下,例如消息因找不到路由规则而无法被转发,则处理方式包括返还给生产者、丢弃或者暂存到“死信队列”。 生产者通过在发送消息的时候设置参数来决定如何处理这些问题。
队列、交换机、绑定,这些都是 AMQP模型中的实体。
AMQP is a Programmable Protocol
AMQP 0-9-1 is a programmable protocol in the sense that AMQP entities and routing schemes are defined by applications themselves, not a broker administrator. Accordingly, provision is made for protocol operations that declare queues and exchanges, define bindings between them, subscribe to queues and so on.
这给应用程序开发者带来了极大的自由,但同时他们也应该注意到潜在的定义冲突。实际上,定义冲突很少发生,一旦发生通常意味着错误的配置。应用定义了所需要的AMQP实体好必要的路由schema,并可能在不需要的时候删除它们。
Exchanges and Exchange Types
Exchanges是一种AMQP实体,它是消息的发送对象。它接收消息并路由给零个或者多个queue。所使用的路由机制,依赖于exchange的类型和规则,又叫binds。 AMQP 0-9-1提供了四种exchange类型:
Direct exchange | (Empty string) and amq.direct |
Fanout exchange | amq.fanout |
Topic exchange | amq.topic |
Headers exchange | amq.match (and amq.headers in RabbitMQ) |
除了类型,exchanges还定义了一些属性,最重要的属性包括:
- Name
- Durability (exchanges survive broker restart)
- Auto-delete (exchange is deleted when all queues have finished using it)
- Arguments (these are broker-dependent)
Exchanges可以是durable或transient。前者当broker重启后仍然有效,而后者当broker重启后即消失。并非所有场景和用例都需要durable的exchange。
Default Exchange
broker预定义了一个默认的交换机,它是一个direct类型的无名交换机。它有一个特殊的属性从而非常适用于简单的应用场景:每个队列创建后,自动以队列名称作为key绑定到此交换机上。
例如,假设你定义了一个名为 "search-indexing-online"的queue,broker会以 "search-indexing-online"为routing key,将此queue绑定到默认的exchange上。因而,若一个message以 "search-indexing-online"为routing key发布到默认的exchange,就会被路由到此queue。换句话说,默认的exchange看上去可以直接将消息路由到队列,其实并非如此(有一个自动的绑定动作)
Direct Exchange
A direct exchange delivers messages to queues based on the message routing key. A direct exchange is ideal for the unicast routing of messages (although they can be used for multicast routing as well). Here is how it works:
- A queue binds to the exchange with a routing key K
- When a new message with routing key R arrives at the direct exchange, the exchange routes it to the queue if K = R
direct exchanges最适用于以RR的方式在多个worker之间分发任务。在AMQP 0.9.1模型中,有一点非常重要:消息是在多个消费者之间进行负载均衡的,而并非在多个队列之间。
A direct exchange can be represented graphically as follows:
Fanout Exchange
fanout exchange,将消息路由给所有绑定到它的queue,路由key被完全忽略。如果有N个queue绑定到fanout exchange上,当一个消息发布到该exchange,在会为每个queue拷贝一份消息并递送给它。Fanout exchange非常适合广播消息。
Because a fanout exchange delivers a copy of a message to every queue bound to it, its use cases are quite similar:
- Massively multi-player online (MMO) games can use it for leaderboard updates or other global events
- Sport news sites can use fanout exchanges for distributing score updates to mobile clients in near real-time
- Distributed systems can broadcast various state and configuration updates
- Group chats can distribute messages between participants using a fanout exchange (although AMQP does not have a built-in concept of presence, so XMPP may be a better choice)
A fanout exchange can be represented graphically as follows:
Topic Exchange
Topic exchanges根据路由key和绑定模式来转发消息到一个或多个queue,它适合于多播类型的消息。
topic exchanges 有大量的使用场景。当涉及到多个消费者/应用需要选择性的接收消息时,就可以考虑topic exchange。
实例场景:
- Distributing data relevant to specific geographic location, for example, points of sale
- Background task processing done by multiple workers, each capable of handling specific set of tasks
- Stocks price updates (and updates on other kinds of financial data)
- 股票价格变动
- News updates that involve categorization or tagging (for example, only for a particular sport or team)
- Orchestration of services of different kinds in the cloud
- Distributed architecture/OS-specific software builds or packaging where each builder can handle only one architecture or OS
Headers Exchange
A headers exchange is designed to for routing on multiple attributes that are more easily expressed as message headers than a routing key. Headers exchanges ignore the routing key attribute. Instead, the attributes used for routing are taken from the headers attribute. A message is considered matching if the value of the header equals the value specified upon binding.
It is possible to bind a queue to a headers exchange using more than one header for matching. In this case, the broker needs one more piece of information from the application developer, namely, should it consider messages with any of the headers matching, or all of them? This is what the "x-match" binding argument is for. When the "x-match" argument is set to "any", just one matching header value is sufficient. Alternatively, setting "x-match" to "all" mandates that all the values must match.
Headers exchanges can be looked upon as "direct exchanges on steroids". Because they route based on header values, they can be used as direct exchanges where the routing key does not have to be a string; it could be an integer or a hash (dictionary) for example.
Queues
AMQP中的queue,同其它消息队列或者任务队列中的queue的概念非常相似:它们存储消息,这些消息最终将提供给作为消费者的应用。Queue共享了exchanges的一些属性,但也具有自己额外的属性:
- Name
- Durable (the queue will survive a broker restart)
- Exclusive (used by only one connection and the queue will be deleted when that connection closes)
- Auto-delete (queue is deleted when last consumer unsubscribes)
- Arguments (some brokers use it to implement additional features like message TTL)
首先要定义Queue然后才能使用。定义Queue会创建它。如果一个queue已经存在且属性完全一样,则定义Queue的操作不起作用。如果queue名称一样,但属性不一样,则会抛出一个channel级别的异常,异常代号为406 (PRECONDITION_FAILED) 。
Queue Names
Applications may pick queue names or ask the broker to generate a name for them. Queue names may be up to 255 bytes of UTF-8 characters. To ask an AMQP broker to generate a unique queue name for you, pass an empty string as the queue name argument: The same generated name may be obtained by subsequent methods in the same channel by using the empty string where a queue name is expected. This works because the channel remembers the last server-generated queue name.
Queue names starting with "amq." are reserved for internal use by the broker. Attempts to declare a queue with a name that violates this rule will result in a channel-level exception with reply code 403 (ACCESS_REFUSED).
Queue Durability
Durable queues are persisted to disk and thus survive broker restarts. Queues that are not durable are called transient. Not all scenarios and use cases mandate queues to be durable.
Note that only durable queues can be bound to durable exchanges. This guarantees that it is possible to restore bindings on broker restart.
Durability of a queue does not make messages that are routed to that queue durable. If broker is taken down and then brought back up, durable queue will be re-declared during broker startup, however, only persistent messages will be recovered.
Bindings
Bindings are rules that exchanges use (among other things) to route messages to queues. To instruct an exchange E to route messages to a queue Q, Q has to be bound to E. Bindings may have an optional routing key attribute used by some exchange types. The purpose of the routing key is to select certain messages published to an exchange to be routed the bound queue. In other words, the routing key acts like a filter.
To draw an analogy:
- Queue is like your destination in New York city
- Exchange is like JFK airport
- Bindings are routes from JFK to your destination. There can be zero or many ways to reach it
Having this layer of indirection enables routing scenarios that are impossible or very hard to implement using publishing directly to queues and also eliminates certain amount of duplicated work application developers have to do.
If AMQP message cannot be routed to any queue (for example, because there are no bindings for the exchange it was published to) it is either dropped or returned to the publisher, depending on message attributes the publisher has set.
Consumers
仅仅把消息保存在queue中是没有意义的,必须有应用来消费它们。AMQP提供了两种方式让应用来消费消息:
- 推送消息到消费者 ("push API")
- 消费者主动来拉消息 ("pull API")
使用"push API",应用必须标明想从哪个queue 获取消息。此时,我们说queue上注册了一个消费者,或者说一个消费者订阅了一个queue。可以在一个queue上注册多个消费者,也可以注册一个排他性的消费者(当它在消费的时候,不允许其它消费者来获取消息)。
每个消费者都有一个唯一的consumer tag,可用于取消订阅消息。consumer tag 实质是一个字符串。
Message Acknowledgements
消费者,可能在偶然情况下,处理消息失败,或者有时候它会异常退出。在网络故障情况下,也可能导致问题。这带来一个问题:什么情况下,broker可以确信能从queue中删除一个消息? AMQP规范提供了两种选择:
- 当broker将消息发送到一个应用(通过 basic.deliver 或 basic.get-ok 操作)
- 当收到消费者的应答后(通过 basic.ack AMQP method).
前者称作自动应答模型,后者称作显示应答模型。采用后一种模型,消费者需要决定何时发送应答。可以在收到消息后立刻应答,也可以在将消息持续化到存储系统但尚没有处理时,或者是在处理结束后。
如果消费者挂掉了,来不及应答,broker可以讲消息投递给其它消费者,或者等待其它消费者注册上来再重新投递。
Rejecting Messages
When a consumer application receives a message, processing of that message may or may not succeed. An application can indicate to the broker that message processing has failed (or cannot be accomplished at the time) by rejecting a message. When rejecting a message, an application can ask the broker to discard or requeue it. When there is only one consumer on a queue, make sure you do not create infinite message delivery loops by rejecting and requeueing a message from the same consumer over and over again.
Negative Acknowledgements
Messages are rejected with the basic.reject AMQP method. There is one limitation that basic.reject has: there is no way to reject multiple messages as you can do with acknowledgements. However, if you are using RabbitMQ, then there is a solution. RabbitMQ provides an AMQP 0-9-1 extension known as negative acknowledgements or nacks. For more information, please refer to the Rabbit-specific extensions.
Prefetching Messages
For cases when multiple consumers share a queue, it is useful to be able to specify how many messages each consumer can be sent at once before sending the next acknowledgement. This can be used as a simple load balancing technique or to improve throughput if messages tend to be published in batches. For example, if a producing application sends messages every minute because of the nature of the work it is doing.
Note that RabbitMQ only supports channel-level prefetch-count, not connection or size based prefetching.
Message Attributes and Payload
Messages in the AMQP model have attributes. Some attributes are so common that the AMQP 0-9-1 specification defines them and application developers do not have to think about the exact attribute name. Some examples are
- Content type
- Content encoding
- Routing key
- Delivery mode (persistent or not)
- Message priority
- Message publishing timestamp
- Expiration period
- Producer application id
Some attributes are used by AMQP brokers, but most are open to interpretation by applications that receive them. Some attributes are optional and known as headers. They are similar to X-Headers in HTTP. Message attributes are set when a message is published.
AMQP messages also have a payload (the data that they carry), which AMQP brokers treat as an opaque byte array. The broker will not inspect or modify the payload. It is possible for messages to contain only attributes and no payload. It is common to use serialisation formats like JSON, Thrift, Protocol Buffers and MessagePack to serialize structured data in order to publish it as the message payload. AMQP peers typically use the "content-type" and "content-encoding" fields to communicate this information, but this is by convention only.
Messages may be published as persistent, which makes AMQP broker persist them to disk. If the server is restarted the system ensures that received persistent messages are not lost. Simply publishing message to a durable exchange or the fact that queue(s) they are routed to is durable doesn't make messages persistent: it all depends on persistence mode of the messages itself. Publishing messages as persistent affects performance (just like with data stores, durability comes at a certain cost in performance).
Message Acknowledgements
Since networks are unreliable and applications fail, it is often necessary to have some kind of processing acknowledgement. Sometimes it is only necessary to acknowledge the fact that a message has been received. Sometimes acknowledgements mean that a message was validated and processed by a consumer, for example, verified as having mandatory data and persisted to a data store or indexed.
This situation is very common, so AMQP 0-9-1 has a built-in feature called message acknowledgements (sometimes referred to as acks) that consumers use to confirm message delivery and/or processing. If an application crashes (AMQP broker notices this when connection is closed), if an acknowledgement for a message was expected but not received by the AMQP broker, the message is re-queued (and possibly immediately delivered to another consumer, if any exists).
Having acknowledgements built into the protocol helps developers to build more robust software.
AMQP 0-9-1 Methods
AMQP 0-9-1由一组methods组成。方法是一种操作(类似于HTTP 方法),而跟 OOP完全无关。方法被组合成类。类是方法逻辑上的组合。
下面看看 exchange class (一组跟exchanges相关的操作),它包含了以下操作:
- exchange.declare
- exchange.declare-ok
- exchange.delete
- exchange.delete-ok
(注意,RabbitMQ针对exchange class,定义了自己的扩展的方法,本文不予讨论)。
The operations above form logical pairs: exchange.declare and exchange.declare-ok, exchange.delete and exchange.delete-ok. These operations are "requests" (sent by clients) and "responses" (sent by brokers in response to the aforementioned "requests").
As an example, the client asks the broker to declare a new exchange using the exchange.declare method:
As shown on the diagram above, exchange.declare carries several parameters. They enable the client to specify exchange name, type, durability flag and so on.
If the operation succeeds, the broker responds with the exchange.declare-ok method:
exchange.declare-ok does not carry any parameters except for the channel number (channels will be described later in this guide).
The sequence of events is very similar for another method pair on the AMQP queue class: queue.declare and queue.declare-ok:
Not all AMQP methods have counterparts. Some (basic.publish being the most widely used one) do not have corresponding "response" methods and some others (basic.get, for example) have more than one possible "response".
Connections
APMQ的连接通常要保持一段时间。它是一种应用层协议,底层采用TCP来保证可靠性。AMQP连接需要身份认证,且可通过TLS(SSL)来保护安全。若应用不再需要连接到一个AMQP broker,则它应该优雅的关闭连接,而不是粗暴的直接关闭底层的TCP连接。
Channels
有些应用需要与一个broker建立多个连接。但是,同时维持大量TCP连接是不明智的,那样会耗费系统资源,同时也对防火墙配置带来麻烦。 AMQP连接是可复用的,可以把channels看做“共享单条TCP连接的轻量级连接”。
对于使用多线程/多进程的应用,通常是为每个线程/进程打开一个channel,而不是在它们之间共享channel.
在一个channel内的通信,是与其它channel内的通信完全隔离的。因此,每个AMQP操作消息都携带一个channel number,指定了该操作作用于哪个channel。
Virtual Hosts
为了让一个broker能提供多个隔离的“环境”(一组用户、exchanges,queues等等),AMQP提供了虚拟主机的概念。这个跟web server的虚拟主机的概念很相似,可以为AMQP实体提供完全隔离的环境。AMQP客户端负责在创建AMQP连接的过程中指定所使用的虚拟主机。
AMQP is Extensible
AMQP 0-9-1 has several extension points:
- Custom exchange types let developers implement routing schemes that exchange types provided out-of-the-box do not cover well, for example, geodata-based routing.
- Declaration of exchanges and queues can include additional attributes that the broker can use. For example, per-queue message TTL in RabbitMQ is implemented this way.
- Broker-specific extensions to the protocol. See, for example, extensions that RabbitMQ implements.
- New AMQP 0-9-1 method classes can be introduced.
- Brokers can be extended with additional plugins, for example, the RabbitMQ management frontend and HTTP API are implemented as a plugin.
These features make the AMQP 0-9-1 Model even more flexible and applicable to a very broad range of problems.
AMQP 0-9-1 Clients Ecosystem
There are many AMQP 0-9-1 clients for many popular programming languages and platforms. Some of them follow AMQP terminology closely and only provide implementation of AMQP methods. Some others have additional features, convenience methods and abstractions. Some of the clients are asynchronous (non-blocking), some are synchronous (blocking), some support both models. Some clients support vendor-specific extensions (for example, RabbitMQ-specific extensions).
Because one of the main AMQP goals is interoperability, it is a good idea for developers to understand protocol operations and not limit themselves to terminology of a particular client library. This way communicating with developers using different libraries will be significantly easier.
相关推荐
It leverages the actor model of computation, enabling developers to write scalable and resilient applications that can handle massive amounts of traffic and data. The core of Akka lies in its ...
5.2.3. Passing model data to the view 5.3. Accepting request input 5.3.1. Taking query parameters 5.3.2. Taking input via path parameters 5.4. Processing forms 5.4.1. Writing a form-handling ...
Using the Component Object Model Interface (IBM MQ Automation Classes for ActiveX).................. 634 Designing and programming using IBM MQ Automation Classes for ActiveX...........................
内容概要:本文详细介绍了基于松下AFPX-C38AT PLC平台的双切刀三边封制袋机控制系统。该系统通过PLC控制四台伺服电机进行切刀和移刀动作以及二轴送袋定位,同时管理两台变频器实现主机和放料电机的同步调速,并利用WK8H模块进行16路温控输出。文中展示了具体的PLC编程实例,如伺服电机的DRVI指令、变频器的同步控制、温控模块的PID调节等。此外,还讨论了硬件配置、触摸屏界面设计、通信协议设置等方面的内容,强调了系统的灵活性和稳定性。 适合人群:从事工业自动化控制领域的工程师和技术人员,尤其是对PLC编程和伺服电机控制感兴趣的读者。 使用场景及目标:适用于需要深入了解PLC控制系统的开发人员,帮助他们掌握伺服电机控制、变频器同步调速和温控模块编程的具体方法,提高实际项目中的应用能力。 其他说明:文章不仅提供了详细的编程示例,还分享了许多实际调试的经验和技巧,有助于读者更好地理解和应用相关技术。
计算机审计软件的特点与应用.pdf
离散傅里叶变换(DFT)分析 函数[F,FT,Phase]=DFT(T,Signal,Fi,FF,Res,P,Cursor)计算离散傅里叶变换(DFT) 功能概述:离散傅立叶变换(DFT)分析 函数[F,FT,Phase]=DFT(T,Signal,Fi,FF,Res,P,Cursor)是频率域信号分析的通用工具。它在指定的频率范围内计算信号的离散傅立叶变换(DFT),提供可定制的可视化选项。 输入 T(采样时间向量,秒):表示与正在分析的信号样本相对应的时间点。 信号:您希望在频域中检查的数据集或信号。 FI(以赫兹为单位的初始频率):频率分析的起点。 FF(最终频率(Hz):频率分析范围的上限。 Res(分辨率以赫兹为单位):确定傅立叶变换的精度。较小的值会增加分辨率。 P(打印选项): 0:没有生成图。 1: 仅显示震级图。 2: 显示大小和相位图。 光标(在绘图上启用光标)(可选): 1: 当P不
内容概要:本文详细介绍了如何在Matlab中构建一个综合了垃圾焚烧、碳捕集和电转气(P2G)技术的虚拟电厂优化调度系统。该系统旨在通过合理的设备参数设置、多能流耦合约束以及分段碳价机制的目标函数设计,实现环保与经济效益的最大化。文中展示了具体的数学模型建立方法,如设备参数初始化、能量平衡约束、碳捕集与P2G物料平衡、分时碳成本计算等,并讨论了求解技巧,包括变量定义、求解器选择和约束条件处理等方面的内容。此外,还探讨了垃圾焚烧发电占比变化对P2G设备启停策略的影响,以及不同时间段内的最优调度策略。 适合人群:从事能源系统优化研究的专业人士,特别是那些熟悉Matlab编程并希望深入了解虚拟电厂调度机制的人群。 使用场景及目标:适用于希望提高虚拟电厂运行效率的研究机构或企业。通过本项目的实施,能够更好地理解如何整合多种能源技术,在满足电力供应需求的同时减少碳排放,降低成本。具体应用场景包括但不限于:制定更加科学合理的发电计划;评估新技术引入后的潜在效益;探索不同政策环境下的最佳运营模式。 其他说明:文中提到的一些关键技术点,如碳捕集与P2G的协同工作、垃圾焚烧发电的灵活应用等,对于推动清洁能源的发展具有重要意义。同时,作者也在实践中遇到了一些挑战,如约束条件之间的冲突等问题,并分享了解决这些问题的经验。
入栈和出栈的基本操作
内容概要:本文详细探讨了V型永磁同步电机中永磁体参数调整的方法和技术,特别是在Maxwell软件中的应用。首先介绍了V型永磁体的关键参数(如V型夹角、磁钢厚度、极弧系数等)及其对电机性能的影响。接着讨论了利用Maxwell进行参数化建模、参数扫描、优化方法(如响应面法、多目标遗传算法)的具体步骤和注意事项。文中还提供了多个实用脚本,涵盖从几何建模、材料属性设置到求解器配置、后处理分析等多个方面。此外,强调了优化过程中应注意的问题,如退磁校验、磁密饱和、涡流损耗等,并给出了一些实战技巧。 适合人群:从事电机设计与仿真的工程师、研究人员,尤其是熟悉Maxwell软件的用户。 使用场景及目标:帮助用户掌握V型永磁同步电机永磁体参数调整的技术要点,提高电机性能指标(如降低齿槽转矩、减少谐波失真、优化转矩波动等)。通过实例和脚本指导,使用户能够在Maxwell中高效地完成仿真和优化任务。 其他说明:文章不仅提供了详细的理论解释,还包括大量实践经验分享和常见问题解决方案,有助于读者更好地理解和应用相关技术。
内容概要:本文详细介绍了光伏发电系统的仿真建模及其控制策略。主要内容分为四个部分:首先是光伏发电系统仿真模型的搭建,通过数学公式和Python代码实现了太阳电池特性的模拟;其次,探讨了扰动观察法(PO)作为最大功率点跟踪(MPPT)的方法,展示了其实现逻辑和代码示例;第三部分讨论了带储能控制策略的设计,利用状态机管理储能系统的充放电过程,确保电力供应平稳;最后进行了负载突变验证实验,评估了系统在极端条件下的稳定性和可靠性。通过这些步骤,作者不仅解释了理论背景,还提供了具体的实现细节和技术挑战。 适合人群:对光伏发电系统感兴趣的研究人员、工程师以及相关领域的学生。 使用场景及目标:适用于希望深入了解光伏发电系统工作原理的人群,尤其是关注最大功率点跟踪技术和储能控制系统设计的应用开发者。目标是帮助读者掌握光伏系统仿真的关键技术,为实际项目提供理论支持和技术指导。 其他说明:文中提供的代码片段可以直接用于实验环境,便于读者动手实践。此外,针对可能出现的问题如耦合振荡等,给出了相应的解决方案。
内容概要:本文详细介绍了8极48槽辐条型电机转子桥的参数化建模方法及其优化过程。通过将桥的厚度、过渡圆弧半径和倒角角度作为变量进行参数化处理,利用Maxwell软件实现了自动化仿真和优化。文中展示了具体的Python和VBScript代码示例,用于动态调整桥部尺寸并监控磁密分布,最终通过参数扫描找到最佳设计参数组合,显著降低了磁密峰值和扭矩波动,提高了电机的整体性能。 适合人群:从事电机设计与仿真的工程师和技术人员,尤其是熟悉Maxwell软件的用户。 使用场景及目标:适用于需要优化电机转子桥结构的设计项目,旨在提高电机性能,降低磁密峰值和扭矩波动,确保机械强度的同时提升电磁性能。 其他说明:文章提供了详细的代码示例和操作步骤,帮助读者快速掌握参数化建模技巧,并强调了网格设置和多参数联动优化的重要性。
内容概要:本文详细介绍了用于风电调频并网系统的4机2区模型,该模型能够在短时间内完成长时间跨度的仿真,极大提高了科研和工程分析的效率。文中具体阐述了模型的结构特点,包括两个区域内的发电机组分布、连接方式以及风电场的虚拟惯量控制机制。此外,文章深入解析了四种PSS(电力系统稳定器)模式的工作原理及其在不同工况下的表现,特别是针对风电接入带来的低频振荡问题进行了讨论。通过实例展示了PSS模式对系统稳定性的显著提升效果,并分享了一些实用的调参技巧。 适合人群:从事电力系统仿真、风电并网研究的专业技术人员及高校相关专业师生。 使用场景及目标:适用于需要进行大规模风电调频并网系统仿真的场合,旨在帮助研究人员更好地理解和解决风电接入对电网稳定性的影响,优化风电并网友好度。 其他说明:文章不仅提供了理论分析,还包括具体的Python和Matlab代码示例,便于读者理解和实践。同时强调了在高风电渗透率条件下选择合适PSS模式的重要性。
内容概要:本文详细介绍了如何使用LabVIEW的Excel工具包来高效生成带有特定格式的测试报告。首先,准备一个Excel模板文件,设置好表头样式、公司LOGO和合并单元格,并用特殊标记占位。然后,通过LabVIEW代码进行Excel操作,如初始化Excel应用、打开和复制模板文件、写入测试数据、设置条件格式、调整列宽以及保存和关闭文件。文中强调了使用二维数组批量写入数据、条件格式设置超标数据标红、精确控制列宽、避免文件覆盖等问题。此外,还提到了一些常见问题及其解决方案,如Excel进程卡死、数据错位等。最终,通过这些方法可以将原本复杂的报告生成过程大幅简化,提高工作效率。 适合人群:熟悉LabVIEW编程的工程师和技术人员,尤其是从事自动化测试和数据分析工作的人员。 使用场景及目标:适用于需要频繁生成格式一致的测试报告的场景,如汽车电子测试、环境监测等领域。目标是通过LabVIEW的Excel工具包实现自动化、高效的报告生成,节省时间和精力。 阅读建议:读者可以通过本文学习如何利用LabVIEW的Excel工具包快速生成带格式的测试报告,掌握关键技术和最佳实践,从而提升工作效率。同时,在实践中应注意模板的设计和代码的优化,以应对各种复杂的需求变化。
main (4).ipynb
计算机数学基础(下).pdf
内容概要:本文详细介绍了如何利用MATLAB实现基于多智能体系统一致性算法的电力系统分布式经济调度策略。首先,通过构建邻接矩阵生成函数,处理电网拓扑结构,确保每个节点能够正确获取邻居信息。接着,定义发电机成本函数和负荷效用函数,将两者统一为二次函数形式,以便更好地兼顾发电侧和用电侧的经济性。然后,重点展示了核心的一致性迭代算法,通过拉普拉斯矩阵实现信息扩散,使发电机和负荷之间的增量成本和效益逐步趋于一致。此外,文中还提供了具体的测试案例,包括10台发电机和19个柔性负荷组成的系统,展示了算法的高效性和鲁棒性。最后,强调了通信拓扑设计对收敛速度的影响,并分享了一些调试经验和潜在的应用前景。 适合人群:电力系统研究人员、自动化控制工程师、MATLAB开发者以及对分布式优化算法感兴趣的学者。 使用场景及目标:适用于电力系统经济调度的研究与开发,旨在提高调度效率、降低成本的同时保障系统的稳定性。通过分布式算法替代传统的集中式调度方式,增强系统的隐私保护能力和计算效率。 其他说明:文中提供的MATLAB代码不仅可用于学术研究,还可以进一步应用于实际工程项目中,特别是在含有大量新能源接入的现代电力系统中,展现出更大的优势。
计算机数控装置课件.pdf
内容概要:本文详细介绍了RRT(快速扩展随机树)路径规划算法的多个优化方法及其具体实现。首先指出原始RRT存在的缺陷,如路径质量差、计算时间长等问题。然后提出了一系列改进措施,包括目标偏向采样、自适应步长控制、路径平滑处理以及椭圆约束采样等。每个改进都附有具体的Python代码片段,并解释了其实现思路和技术细节。此外,文中还讨论了不同改进方案之间的协同使用效果,强调了实际应用中的注意事项。 适合人群:从事机器人路径规划研究的技术人员,尤其是有一定编程基础并希望深入了解RRT算法优化的人群。 使用场景及目标:适用于各种需要高效路径规划的应用场合,如仓储机器人、无人机避障、机械臂运动规划等。主要目标是提高路径规划的速度和质量,同时减少计算资源消耗。 其他说明:尽管这些改进显著提升了RRT的表现,但在实际部署时仍需考虑传感器噪声和系统延迟等因素的影响。作者分享了许多个人实践经验,为读者提供了宝贵的参考。
计算机试题实例分析.pdf