`
zh_harry
  • 浏览: 102428 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
877aca81-daac-33c8-8bf9-3a886cebc6c3
自己动手写java 框架
浏览量:28407
社区版块
存档分类
最新评论

Sparrow算法篇 从日期取交集到思维模式-2

    博客分类:
  • JAVA
阅读更多

接上一篇

Sparrow算法篇 从日期取交集到思维模式

  • 这样的时间段有成百上千条该如何处理?
  • 如果我们需要根据具有日期交集的时间段分组呢?
  • 如果我们的业务不是日期,而是其他数据类型呢?如何抽象出计算模型?非日期型数据也可以进行分组?

上一篇分享日期取交集的核心逻辑。 但映射到具体业务上可能有更复杂的场景,比如第一个问题,两个日期取交集还好搞好,但日期段很多的情况下,如何按每一个时间段相同的数据进行分组呢。

 

 

即每两个红点之间的日期不能出现断点,要么没有交集,有交集就一定是连续的。 所以解决这个问题的第一步就是如何确定红点(这一点很重要,凭直觉,遵照人脑思维落点,如果根据日期探测,逻辑将变得非常困难)。

  • 第一步确定之后,我们根据所有日期段的开始和截止点进行坐标落点
  • 第二步根据坐标点,确定我们将要拆分的日期段组。
  • 第三步 日期段组的起始时间确定后,再依次根据日期取交集,即可实现多日期段下的日期交集逻辑。
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.sparrow.core.algorithm.gouping;

import java.util.*;

/**
 * E 为段类型 D为点类型
 * @author harry
 */
public class Coordinate<E extends Segment<D>, D extends Comparable> {
    public Coordinate(List<E> dataList) {
        this.dataList = dataList;
    }

    private List<E> dataList = new ArrayList<E>();

    protected List<Segment<D>> segments = new ArrayList<Segment<D>>();

    protected List<Point<D>> coordinate = new ArrayList<Point<D>>();

    public List<Point<D>> getCoordinate() {
        return coordinate;
    }

    //画从标点
    public void draw() {
        Map<Comparable, Point<D>> coordinate = new TreeMap<Comparable, Point<D>>();
        for (E segment : this.dataList) {
            Point<D> point = coordinate.get(segment.getStart().getPoint());
            if (point == null) {
                point = new Point<D>(segment.getStart().getPoint(), true, null);
                coordinate.put(segment.getStart().getPoint(), point);
            }

            point = coordinate.get(segment.getEnd().getPoint());
            if (point == null) {
                point = new Point<D>(segment.getEnd().getPoint(), null, true);
                coordinate.put(segment.getEnd().getPoint(), point);
            }
        }
        this.coordinate = new ArrayList<Point<D>>(coordinate.values());
    }

    //分组,可被重写实现
    public void section() {
        for (int i = 0; i < this.coordinate.size() - 1; i++) {
            Point<D> current = this.coordinate.get(i);
            Point<D> next = this.coordinate.get(i + 1);
            this.segments.add(new Segment<D>(current, next));
        }
    }

    //对每组数据聚合操作
    public Map<Segment<D>, List<E>> aggregation() {
        Map<Segment<D>, List<E>> segmentMap = new HashMap<Segment<D>, List<E>>();
        for (Segment<D> segment : this.segments) {
            segmentMap.put(segment, this.aggregation(segment));
        }
        return segmentMap;
    }

    private List<E> aggregation(Segment<D> s) {
        List<E> segments = new ArrayList<E>();
        for (E segment : this.dataList) {
            if (segment.getStart().getPoint().compareTo(s.getStart().getPoint()) > 0) {
                continue;
            }
            if (segment.getEnd().getPoint().compareTo(s.getStart().getPoint()) > 0) {
                segments.add(segment);
            }
        }
        return segments;
    }

    public List<Segment<D>> getSegments() {
        return segments;
    }
}

类封装之后可供上层业务端调用,为考虑其他业务场景,非日期类型数据的取交集我们将日期段类定义为泛型(类型参数化)

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.sparrow.core.algorithm.gouping;

/**
 * @author by harry
 */
public class Segment<T extends Comparable> {
    private Point<T> start;
    private Point<T> end;

    public Segment(T start, T end) {
        if (end.compareTo(start) < 0) {
            throw new IllegalArgumentException("this.end<this.start");
        }
        this.start = new Point<T>(start);
        this.end = new Point<T>(end);
    }

    public Segment(Point<T> start, Point<T> end) {
        if (end.getPoint().compareTo(start.getPoint()) < 0) {
            throw new IllegalArgumentException("end=" + end.getPoint() + "< start=" + start.getPoint());
        }
        this.start = start;
        this.end = end;
    }

    public Point<T> getStart() {
        return start;
    }

    public void setStart(Point<T> start) {
        this.start = start;
    }

    public Point<T> getEnd() {
        return end;
    }

    public void setEnd(Point<T> end) {
        this.end = end;
    }

    public boolean equals(Segment<T> segment) {
        if (this.start.getPoint().compareTo(segment.start.getPoint()) != 0) {
            return false;
        }
        return this.end.getPoint().compareTo(segment.end.getPoint()) == 0;
    }

    public Segment<T> intersection(Segment<T> segment) {
        if (segment.getEnd().getPoint().compareTo(segment.getStart().getPoint()) < 0) {
            throw new IllegalArgumentException("segment.end < segment.start");
        }
        //取大的起始节点
        Point<T> start = this.start.getPoint().compareTo(segment.start.getPoint()) > 0 ? this.start : segment.start;
        //取小的截止节点
        Point<T> end = this.end.getPoint().compareTo(segment.end.getPoint()) < 0 ? this.end : segment.end;

        if (start.getPoint().compareTo(end.getPoint()) <= 0) {
            return new Segment(start, end);
        }
        return null;
    }

    public Segment union(Segment<T> segment) {
        if (segment.getEnd().getPoint().compareTo(segment.getStart().getPoint()) < 0) {
            throw new IllegalArgumentException("segment.end < segment.start");
        }
        //取小的起始节点
        Point<T> start = this.start.getPoint().compareTo(segment.start.getPoint()) < 0 ? this.start : segment.start;
        //取大的截止节点
        Point<T> end = this.end.getPoint().compareTo(segment.end.getPoint()) > 0 ? this.end : segment.end;

        if (start.getPoint().compareTo(end.getPoint()) <= 0) {
            return new Segment<T>(start, end);
        }
        return null;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Segment<?> segment = (Segment<?>) o;
        return start.equals(segment.start) && end.equals(segment.end);
    }

    @Override
    public int hashCode() {
        int result = start.hashCode();
        result = 31 * result + end.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "Segment{" +
                "start=" + start.getPoint() +
                ", end=" + end.getPoint() +
                '}';
    }
}

如果segment还有其他的属性,可以继承实现segment类

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.sparrow.facade.segment;

import com.sparrow.constant.DATE_TIME;
import com.sparrow.core.algorithm.gouping.Segment;
import com.sparrow.utility.DateTimeUtility;

/**
 * @author harry
 */
public class BusinessSegment extends Segment<Long> {
    public BusinessSegment(Long id, String type, Long start, Long end) {
        super(start, end);
        this.id = id;
        this.type = type;
    }

   //自定义属 性 
    private Long id;
    //自定义属 性 
    private String type;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        String start=DateTimeUtility.getFormatTime((Long) this.getStart().getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD);
        String end=DateTimeUtility.getFormatTime((Long)this.getEnd().getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD);
        return "cat-record{" +
            "id=" + id +
            ", type='" + type + '\'' +
            "} " +  start+"-"+end;
    }
}

具体业务的分组逻辑可能不同,继承重写section方法即可

static class IntegerCoordinate extends Coordinate<BusinessSegment, Long> {

        public IntegerCoordinate(List<BusinessSegment> dataList) {
            super(dataList);
        }

        @Override
        public void section() {
            for (Point<Long> point : this.coordinate) {
                System.out.println(DateTimeUtility.getFormatTime(point.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS));
            }
            for (int i = 0; i < this.coordinate.size() - 1; i++) {

                Point<Long> current = this.coordinate.get(i);
                Point<Long> start = Point.copy(current);
                Calendar calendar = Calendar.getInstance();
                calendar.setTimeInMillis(start.getPoint());
                if (calendar.get(Calendar.HOUR_OF_DAY) == 23) {
                    calendar.add(Calendar.SECOND, 1);
                    start.setPoint(calendar.getTimeInMillis());
                }

                Point<Long> next = this.coordinate.get(i + 1);
                Point<Long> end = Point.copy(next);
                if (DateTimeUtility.getInterval(start.getPoint(), next.getPoint(), DATE_TIME_UNIT.SECOND) <= 5) {
                    i++;
                    continue;
                }

                calendar.setTimeInMillis(end.getPoint());
                if (calendar.get(Calendar.HOUR_OF_DAY) == 0) {
                    calendar.add(Calendar.SECOND, -1);
                    end.setPoint(calendar.getTimeInMillis());
                }
                System.out.println(DateTimeUtility.getFormatTime(start.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS) + "-" +
                        DateTimeUtility.getFormatTime(end.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS));
                this.segments.add(new Segment<Long>(start, end));
            }
        }
    }

demo示例

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.sparrow.facade.segment;

import com.sparrow.constant.DATE_TIME;
import com.sparrow.core.algorithm.gouping.Point;
import com.sparrow.core.algorithm.gouping.Segment;
import com.sparrow.core.algorithm.gouping.Coordinate;
import com.sparrow.enums.DATE_TIME_UNIT;
import com.sparrow.utility.DateTimeUtility;

import java.util.*;

/**
 * @author harry
 */
public class Main {
    static class IntegerCoordinate extends Coordinate<BusinessSegment, Long> {

        public IntegerCoordinate(List<BusinessSegment> dataList) {
            super(dataList);
        }

        @Override
        public void section() {
            for (Point<Long> point : this.coordinate) {
                System.out.println(DateTimeUtility.getFormatTime(point.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS));
            }
            for (int i = 0; i < this.coordinate.size() - 1; i++) {

                Point<Long> current = this.coordinate.get(i);
                Point<Long> start = Point.copy(current);
                Calendar calendar = Calendar.getInstance();
                calendar.setTimeInMillis(start.getPoint());
                if (calendar.get(Calendar.HOUR_OF_DAY) == 23) {
                    calendar.add(Calendar.SECOND, 1);
                    start.setPoint(calendar.getTimeInMillis());
                }

                Point<Long> next = this.coordinate.get(i + 1);
                Point<Long> end = Point.copy(next);
                if (DateTimeUtility.getInterval(start.getPoint(), next.getPoint(), DATE_TIME_UNIT.SECOND) <= 5) {
                    i++;
                    continue;
                }

                calendar.setTimeInMillis(end.getPoint());
                if (calendar.get(Calendar.HOUR_OF_DAY) == 0) {
                    calendar.add(Calendar.SECOND, -1);
                    end.setPoint(calendar.getTimeInMillis());
                }
                System.out.println(DateTimeUtility.getFormatTime(start.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS) + "-" +
                        DateTimeUtility.getFormatTime(end.getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS));
                this.segments.add(new Segment<Long>(start, end));
            }
        }
    }

    enum SEGMENT_TYPE {
        TYPE_001,
        TYPE_002,

        TYPE_003,
        TYPE_004,

        TYPE_005,
        TYPE_006,

        TYPE_007,
        TYPE_008,

        TYPE_009,
        TYPE_010
    }

    public static void main(String[] args) {
        List<BusinessSegment> list = new ArrayList<BusinessSegment>();

        //Long id, String type, Integer start, Integer end
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_001.name(), DateTimeUtility.parse("2018-02-05 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-11 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_002.name(), DateTimeUtility.parse("2018-02-06 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-10 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_004.name(), DateTimeUtility.parse("2018-02-07 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-09 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_005.name(), DateTimeUtility.parse("2018-02-08 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-08 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_006.name(), DateTimeUtility.parse("2018-02-05 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-19 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_007.name(), DateTimeUtility.parse("2018-02-20 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-22 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_008.name(), DateTimeUtility.parse("2018-02-21 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-23 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_009.name(), DateTimeUtility.parse("2018-02-22 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-24 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_010.name(), DateTimeUtility.parse("2018-02-23 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-25 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));
        list.add(new BusinessSegment(1L, SEGMENT_TYPE.TYPE_010.name(), DateTimeUtility.parse("2018-02-25 00:00:00", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS), DateTimeUtility.parse("2018-02-28 23:59:59", DATE_TIME.FORMAT_YYYY_MM_DD_HH_MM_SS)));


        Coordinate<BusinessSegment, Long> coordinate = new IntegerCoordinate(list);
        coordinate.draw();
        coordinate.section();

        Map<Segment<Long>, List<BusinessSegment>> map = coordinate.aggregation();
        for (Segment segment : coordinate.getSegments()) {
            System.out.print(DateTimeUtility.getFormatTime((Long) segment.getStart().getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD) + "-");
            System.out.println(DateTimeUtility.getFormatTime((Long) segment.getEnd().getPoint(), DATE_TIME.FORMAT_YYYY_MM_DD));
            System.out.println(map.get(segment));
        }
    }
}

示例运行结果

2018-02-05->2018-02-05
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-06->2018-02-06
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_002'} 2018-02-06-2018-02-10, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-07->2018-02-07
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_002'} 2018-02-06-2018-02-10, cat-record{id=1, type='TYPE_004'} 2018-02-07-2018-02-09, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-08->2018-02-08
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_002'} 2018-02-06-2018-02-10, cat-record{id=1, type='TYPE_004'} 2018-02-07-2018-02-09, cat-record{id=1, type='TYPE_005'} 2018-02-08-2018-02-08, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-09->2018-02-09
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_002'} 2018-02-06-2018-02-10, cat-record{id=1, type='TYPE_004'} 2018-02-07-2018-02-09, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-10->2018-02-10
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_002'} 2018-02-06-2018-02-10, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-11->2018-02-11
[cat-record{id=1, type='TYPE_001'} 2018-02-05-2018-02-11, cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-12->2018-02-19
[cat-record{id=1, type='TYPE_006'} 2018-02-05-2018-02-19]
2018-02-21->2018-02-21
[cat-record{id=1, type='TYPE_007'} 2018-02-20-2018-02-22, cat-record{id=1, type='TYPE_008'} 2018-02-21-2018-02-23]
2018-02-22->2018-02-22
[cat-record{id=1, type='TYPE_007'} 2018-02-20-2018-02-22, cat-record{id=1, type='TYPE_008'} 2018-02-21-2018-02-23, cat-record{id=1, type='TYPE_009'} 2018-02-22-2018-02-24]
2018-02-24->2018-02-24
[cat-record{id=1, type='TYPE_009'} 2018-02-22-2018-02-24, cat-record{id=1, type='TYPE_010'} 2018-02-23-2018-02-25]
2018-02-26->2018-02-28
[cat-record{id=1, type='TYPE_010'} 2018-02-25-2018-02-28]

完整示例代码下载 https://github.com/sparrowzoo/sparrow

sparrow-test项目下的

com.sparrow.facade.segmen.Main方法

1
0
分享到:
评论

相关推荐

    麻雀算法优化Sparrow-Search-Algorithm-Matlab-main.zip

    麻雀搜索算法(Sparrow Search Algorithm, SSA)是一种基于生物行为的优化算法,灵感来源于麻雀群体的行为特征,如觅食、避险和集体防御等。这种算法在解决复杂优化问题时展现出强大的能力,特别是在工程领域和数据...

    麻雀搜索算法(Sparrow Search Algorithm,python简洁明了,含详细解释)

    麻雀搜索算法(Sparrow Search Algorithm,SSA)是一种基于生物行为的优化算法,源自于麻雀在寻找食物过程中的行为模式。该算法在解决复杂优化问题时表现出优秀的性能,尤其是在工程应用和多模态优化问题上。SSA的...

    Sparrow-Framework官网源代码

    通过分析Sparrow-Framework的源代码,我们可以了解到以下关键知识点: - **对象管理**:理解Sparrow如何使用对象池和自动释放池来有效地管理内存,避免内存泄漏和频繁的内存分配。 - **渲染流程**:分析渲染管线,...

    麻雀搜索算法(Sparrow Search Algorithm,python)(简洁明了,含详细解释)

    麻雀搜索算法(Sparrow Search Algorithm,SSA)是一种新兴的优化算法,灵感来源于麻雀群体的行为。这种算法在解决复杂优化问题时表现出色,尤其适用于全局优化和多模态函数。Python作为一门广泛应用于科学计算和...

    SPARROW

    综上所述,尽管"SPARROW"的具体含义不明,但我们可以从“字体”这一主题出发,了解到字体设计的重要性、类型、技术发展以及在IT行业中的广泛应用。对于“927”这个文件,如果它是一个字体文件,那么可能需要进一步的...

    麻雀搜索算法(Sparrow Search Algorithm , SSA)的python实现_python_代码_下载

    麻雀搜索算法(Sparrow Search Algorithm,SSA)是一种基于生物行为的全局优化方法,由研究人员在2020年提出。该算法模仿了麻雀群体的行为模式,包括觅食策略和对抗捕食者的防御机制,以解决复杂的优化问题。在实际...

    Python库 | sparrow-tool-0.3.5.dev2.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:sparrow-tool-0.3.5.dev2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Sparrow Search algorithm (SSA).zip

    从麻雀的群体智慧、觅食行为和反捕食行为出发,提出了一种新的群体优化算法——麻雀搜索算法。在19个基准函数上进行了实验,测试了SSA算法的性能,并与其他算法如灰狼优化算法(GWO)、引力搜索算法(GSA)和粒子群...

    【定位优化】基于麻雀搜索算法优化无线传感器非测距定位算法DVHop附matlab代码.zip

    本资源主要介绍了一种基于麻雀搜索算法(Sparrow Search Algorithm, SSA)优化的非测距定位算法——Distance Vector Hop (DV-Hop)。DV-Hop是一种典型的多跳路由定位方法,适用于没有全球定位系统(GPS)或其他测距...

    进销存管理程序 Sparrow

    《Sparrow进销存管理程序详解》 在IT领域,高效的管理工具是企业运营不可或缺的一部分,其中进销存管理程序扮演着至关重要的角色。本文将深入探讨名为"Sparrow"的进销存管理程序,旨在帮助用户更好地理解和利用这款...

    Sparrow是一款针对移动webapp开发的前端轻量级框架

    在压缩包文件"sparrow-master"中,我们可以预见到包含以下内容:源代码文件(如JavaScript、CSS和HTML),可能的示例项目或者文档,以及可能的构建脚本和配置文件。通过这些文件,开发者可以深入了解Sparrow的架构和...

    麻雀搜索算法(SSA)优化bp网络.zip

    麻雀搜索算法(Sparrow Search Algorithm, SSA)是一种新兴的优化算法,灵感来源于麻雀群体的行为模式。这种算法在解决复杂优化问题时表现出高效性和适应性,尤其在处理非线性、多模态和不连续的问题上。SSA通过模拟...

    麻雀搜算算法(SSA)优化核极限学习机(KELM)分类MATLAB程序

    麻雀搜索算法( sparrow search algorithm, SSA)在2020年,是受麻雀觅食行为和反捕食行为启发而由Xue等[提出的一种新型群体智能优化算法。搜索过程可抽象为发现者-加入者-警戒者模型。发现者拥有更广阔的搜索范围,...

    基于麻雀算法优化xgboost的数据回归预测(SSA-XGboost)(Matlab完整程序和数据)

    在本项目中,我们探讨了如何使用麻雀算法(Sparrow Search Algorithm, SSA)来优化XGBoost(Extreme Gradient Boosting)模型进行数据回归预测。这是一个基于Matlab的实现,要求运行环境为2018年或更新的版本。...

    前端基础库Sparrow.js.zip

    Sparrow.js是一个短小精悍的前端基础库,它包含对DOM、CSS基本操作、多平台浏览器移动设备判断、Cookies操作、事件的绑定、日期、数字、字符串相关判断、以及浏览器自身函数不足所扩展的一系列功能。开发技术说明...

    SSA-LSTM麻雀算法优化LSTM超参数-优化神经网络神经元个数-dropout-batch-size

    麻雀搜索算法(Sparrow Search Algorithm, SSA)是一种新型的群智能优化算法,在2020年提出,主要是受麻雀的觅食行为和反捕食行为的启发 。 博客链接:https://data-mining.blog.csdn.net/article/details/123806007 ...

    麻雀_sparrowsearch_麻雀优化_麻雀优化算法_麻雀算法matlab_麻雀搜索

    麻雀搜索算法(Sparrow Search Algorithm,SSA)在解决工程中的优化问题时表现出高效性和鲁棒性。 麻雀优化算法的核心在于其群体行为模型。在麻雀群体中,个体麻雀的行为可以分为两种主要模式:觅食和防御。觅食...

    sparrow-wifi:适用于Linux的基于GUI的下一代WiFi和Bluetooth分析仪

    sparrow-wifi-用于Linux的图形WiFi分析器 ...Wifi信号源搜寻-从正常模式切换到搜寻模式,每秒可获取多个样本,并使用遥测窗口跟踪wifi信号源 2.4 GHz和5 GHz频谱视图-在wifi频谱之上实时来自Ubertooth(2.4

    【优化算法】多目标麻雀搜索优化算法(MSSA)【含Matlab源码 1366期】.zip

    多目标麻雀搜索优化算法(MSSA,Multiple Objective Sparrow Search Algorithm)是一种现代的优化技术,灵感来源于麻雀群体的行为。在自然界中,麻雀群体具有高度的智慧和协作能力,这种特性被巧妙地应用到解决复杂...

    麻雀搜索算法(SSA)可以很好对算法进行解读

    麻雀搜索算法(Sparrow Search Algorithm,SSA)是一种基于生物行为的优化算法,源自对麻雀群体觅食行为的模拟。麻雀在寻找食物的过程中展现出的智能和协作特性,为解决复杂优化问题提供了灵感。SSA的核心在于其动态...

Global site tag (gtag.js) - Google Analytics