理解Computer中memory-mapped file

  • 内存映射

    内存映射:将内核空间的一段内存区域映射到用户空间。可以将内核空间的一段内存区域同时映射到多个进程,实现进程间的共享内存通信

    《理解内核空间、内存区域、用户空间》

    《Memory-mapped I/O》

    《理解Computer中slack space, page cache, thrash》

  • memory map in computer science

    Wikipedia

    A memory map is a structure of data(which usually resides in memory itself) that indicates how memory is laid out.

  • Memory-mapped file

    wikipedia

    A memory-mapped file is a segment of virtual memory that has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource.

    This resource is typically a file that is physically present on disk, but can also be a device, shared momory object, or other resource that the OS can reference through a file descriptor.

    Once present, this correlation between the file and the memory space permits applications to treat the mapped portion as if it were primary memory.

  • Benefits

    The benefit of memory mapping a file is increasing I/O performance, especially when used on large files.

    For small files, memory-mapped files can result in a waste result in a waste of slack space as memory maps are always aligned

Partial-Mapped Crossover(PMX)是一种常用于遗传算法的交叉操作。其目的是在两个父代个体交换一部分基因片段,以产生新的个体作为下一代的可能解。 PMX首先选择两个随机位置作为交叉点,然后将这两个位置之间的基因片段进行交换。交换后,每个子代个体仍然可能存在相同的基因,但不同基因的顺序被改变了。接下来,我们需要对子代个体进行处理,以确保没有重复的基因。 具体来说,我们从交叉点之后的基因片段开始,将其的重复基因对应到另一个父代个体的相同位置,并将其相映射的基因也进行相应的交换。这一过程同样适用于交叉点之前的基因片段。这样,我们就得到了一个没有重复基因的子代个体。 举个例子来说,假设有两个父代个体分别为A = [1, 2, 3, 4, 5, 6]和B=[4, 2, 6, 1, 3, 5],选择的交叉点为2和4。在交换了交叉点2和4之间的基因片段之后,得到的子代个体为C=[1, 2, 6, 4, 3, 5]。我们需要处理C的重复基因。 首先,我们找到C重复的基因2和6,对应到A的位置为2和3,于是交换A2和3位置的基因,得到A’=[1, 6, 3, 4, 5, 2]。然后,我们找到C重复的基因4和3,对应到B的位置为4和3,于是交换B4和3位置的基因,得到B’=[4, 2, 5, 1, 6, 3]。最终,我们得到了没有重复基因的子代个体C’=[1, 6, 5, 4, 3, 2]作为下一代的可能解。 通过进行PMX交叉操作可以保留父代个体的一些有用特征,并产生新的个体,增加了遗传算法搜索解空间的多样性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值