【Android12】Monkey压力测试源码执行流程分析

Monkey压力测试源码执行流程分析

Monkey是Android提供的用于应用程序自动化测试、压力测试的测试工具。
其源码路径(Android12)位于

/development/cmds/monkey/

部署形式为Java Binary

# development/cmds/monkey/Android.bp
// Copyright 2008 The Android Open Source Project
//package {default_applicable_licenses: ["development_cmds_monkey_license"],
}// See: http://go/android-license-faq
license {name: "development_cmds_monkey_license",visibility: [":__subpackages__"],license_kinds: ["SPDX-license-identifier-Apache-2.0",],license_text: ["NOTICE",],
}//###############################################################
java_binary {name: "monkey",srcs: ["**/*.java"],wrapper: "monkey",
}

通过Monkey,可以模拟用户的Touch(单指、多指、手势)、按键(key)事件等,检测应用程序发生的ANR、Crash事件,并收集相关Debug信息等。
例如测试应用com.package.linduo,

adb shell monkey -p com.package.linduo --pct-touch 10 --pct-motion 20 10000
# 该命令表示,执行1万次测试事件,其中Touch事件占10%,Motion事件占20%# 或者adb shell进入android终端,直接使用monkey命令

Monkey支持的命令

    private void showUsage() {StringBuffer usage = new StringBuffer();usage.append("usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]\n");usage.append("              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]\n");usage.append("              [--ignore-crashes] [--ignore-timeouts]\n");usage.append("              [--ignore-security-exceptions]\n");usage.append("              [--monitor-native-crashes] [--ignore-native-crashes]\n");usage.append("              [--kill-process-after-error] [--hprof]\n");usage.append("              [--match-description TEXT]\n");usage.append("              [--pct-touch PERCENT] [--pct-motion PERCENT]\n");usage.append("              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]\n");usage.append("              [--pct-nav PERCENT] [--pct-majornav PERCENT]\n");usage.append("              [--pct-appswitch PERCENT] [--pct-flip PERCENT]\n");usage.append("              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]\n");usage.append("              [--pct-permission PERCENT]\n");usage.append("              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]\n");usage.append("              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]\n");usage.append("              [--wait-dbg] [--dbg-no-events]\n");usage.append("              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...]\n");usage.append("              [--port port]\n");usage.append("              [-s SEED] [-v [-v] ...]\n");usage.append("              [--throttle MILLISEC] [--randomize-throttle]\n");usage.append("              [--profile-wait MILLISEC]\n");usage.append("              [--device-sleep-time MILLISEC]\n");usage.append("              [--randomize-script]\n");usage.append("              [--script-log]\n");usage.append("              [--bugreport]\n");usage.append("              [--periodic-bugreport]\n");usage.append("              [--permission-target-system]\n");usage.append("              COUNT\n");Logger.err.println(usage.toString());}

Monkey执行测试的源码分析

这里主要关注模式事件的执行流程

  • Monkey启动
  • Monkey生成模拟事件
  • Monkey向系统发送模拟事件
    在这里插入图片描述
Monkey启动

Monkey.java中定义了程序入口函数main,该函数中启动了Monkey程序。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.javapublic static void main(String[] args) {// Set the process name showing in "ps" or "top"Process.setArgV0("com.android.commands.monkey");Logger.err.println("args: " + Arrays.toString(args));int resultCode = (new Monkey()).run(args);System.exit(resultCode);
}
// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java/*** Run the command!** @param args The command-line arguments* @return Returns a posix-style result code. 0 for no error.*/
private int run(String[] args) {// Default values for some command-line optionsmVerbose = 0;// 默认的测试次数mCount = 1000;// 生成radom的seedmSeed = 0;// 记录事件之间的延迟,就是每个事件执行的间隔mThrottle = 0;// prepare for command-line processingmArgs = args;// 解析参数if (!processOptions()) {return -1;}// 确定待测试的Packageif (!loadPackageLists()) {return -1;}// now set up additional data in preparation for launchif (mMainCategories.size() == 0) {mMainCategories.add(Intent.CATEGORY_LAUNCHER);mMainCategories.add(Intent.CATEGORY_MONKEY);}if (mSeed == 0) {mSeed = System.currentTimeMillis() + System.identityHashCode(this);}// 获取系统服务接口(AMS、PMS、WMS)if (!getSystemInterfaces()) {return -3;}// 获取用于启动应用的Activityif (!getMainApps()) {return -4;}if (mScriptFileNames != null && mScriptFileNames.size() == 1) {// script mode, ignore other options} else if (mScriptFileNames != null && mScriptFileNames.size() > 1) {} else if (mServerPort != -1) {} else {// 创建用于产生模拟器事件的Source对象mEventSource = new MonkeySourceRandom(mRandom, mMainApps,mThrottle, mRandomizeThrottle, mPermissionTargetSystem);mEventSource.setVerbose(mVerbose);// 设置各测试类型的测试比例// set any of the factors that has been setfor (int i = 0; i < MonkeySourceRandom.FACTORZ_COUNT; i++) {if (mFactors[i] <= 0.0f) {((MonkeySourceRandom) mEventSource).setFactors(i, mFactors[i]);}}// 产生activity事件,该事件用来启动应用// in random mode, we start with a random activity((MonkeySourceRandom) mEventSource).generateActivity();}try {// 执行模拟测试事件crashedAtCycle = runMonkeyCycles();} finally {// Release the rotation lock if it's still held and restore the// original orientation.new MonkeyRotationEvent(Surface.ROTATION_0, false).injectEvent(mWm, mAm, mVerbose);}}
Monkey解析输入参数

processOptions函数解析输入参数(就是monkey命令后跟着的参数信息),根据入参设置Monkey类中相关成员变量。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
private boolean processOptions() {// quick (throwaway) check for unadorned commandif (mArgs.length < 1) {showUsage();return false;}try {String opt;Set<String> validPackages = new HashSet<>();while ((opt = nextOption()) != null) {if (opt.equals("-s")) {mSeed = nextOptionLong("Seed");} else if (opt.equals("-p")) {validPackages.add(nextOptionData());} else if (opt.equals("-c")) {// 省略} else {Logger.err.println("** Error: Unknown option: " + opt);showUsage();return false;}}// 根据输入参数,设置待测试的应用MonkeyUtils.getPackageFilter().addValidPackages(validPackages);} catch (RuntimeException ex) {Logger.err.println("** Error: " + ex.toString());showUsage();return false;}// If a server port hasn't been specified, we need to specify// a countif (mServerPort == -1) {// 省略}return true;
}
Monkey获取系统服务

getSystemInterfaces函数用于获取Android系统服务,包括AMS、PMS、WMS服务。调用AMS服务的setActivityController接口,通过该接口向AMS设置IActivityController.Stub对象,通过该对象监听应用(Activity)的ANR和Crash事件。

/*** Attach to the required system interfaces.** @return Returns true if all system interfaces were available.*/
private boolean getSystemInterfaces() {mAm = ActivityManager.getService();if (mAm == null) {Logger.err.println("** Error: Unable to connect to activity manager; is the system "+ "running?");return false;}mWm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));if (mWm == null) {Logger.err.println("** Error: Unable to connect to window manager; is the system "+ "running?");return false;}mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));if (mPm == null) {Logger.err.println("** Error: Unable to connect to package manager; is the system "+ "running?");return false;}try {mAm.setActivityController(new ActivityController(), true);mNetworkMonitor.register(mAm);} catch (RemoteException e) {Logger.err.println("** Failed talking with activity manager!");return false;}return true;
}/*** Monitor operations happening in the system.*/
private class ActivityController extends IActivityController.Stub {public boolean activityStarting(Intent intent, String pkg) {// 省略}private boolean isActivityStartingAllowed(Intent intent, String pkg) {// 省略}public boolean activityResuming(String pkg) {// 省略}public boolean appCrashed(String processName, int pid,String shortMsg, String longMsg,long timeMillis, String stackTrace) {// 省略}public int appEarlyNotResponding(String processName, int pid, String annotation) {return 0;}public int appNotResponding(String processName, int pid, String processStats) {// 省略}public int systemNotResponding(String message) {// 省略}
}
Monkey获取待测试应用的Activity

monkey通过PackageManager的queryIntentActivities接口,查询带有 Intent.CATEGORY_LAUNCHERIntent.CATEGORY_MONKEY信息的Activity,并判断Activity是否属于待测试应用。将待测试应用的Activity添加到mMainApps变量中。

// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
/*** Using the restrictions provided (categories & packages), generate a list* of activities that we can actually switch to.** @return Returns true if it could successfully build a list of target*         activities*/
private boolean getMainApps() {try {final int N = mMainCategories.size();for (int i = 0; i < N; i++) {Intent intent = new Intent(Intent.ACTION_MAIN);String category = mMainCategories.get(i);if (category.length() > 0) {intent.addCategory(category);}// 查找带有 Intent.CATEGORY_LAUNCHER、Intent.CATEGORY_MONKEY的ActivityList<ResolveInfo> mainApps = mPm.queryIntentActivities(intent, null, 0,ActivityManager.getCurrentUser()).getList();final int NA = mainApps.size();for (int a = 0; a < NA; a++) {ResolveInfo r = mainApps.get(a);String packageName = r.activityInfo.applicationInfo.packageName;if (MonkeyUtils.getPackageFilter().checkEnteringPackage(packageName)) {// 如果Activity属于待测试Package,将其添加到mMainApps中。mMainApps.add(new ComponentName(packageName, r.activityInfo.name));} else {}}}} catch (RemoteException e) {Logger.err.println("** Failed talking with package manager!");return false;}if (mMainApps.size() == 0) {Logger.out.println("** No activities found to run, monkey aborted.");return false;}return true;
}
Monkey生成模拟测试事件,并执行
// development/cmds/monkey/src/com/android/commands/monkey/Monkey.java
private int run(String[] args) {// 创建该对象,用于产生测试事件mEventSource = new MonkeySourceRandom(mRandom, mMainApps,mThrottle, mRandomizeThrottle, mPermissionTargetSystem);for (int i = 0; i < MonkeySourceRandom.FACTORZ_COUNT; i++) {if (mFactors[i] <= 0.0f) {((MonkeySourceRandom) mEventSource).setFactors(i, mFactors[i]);}}try {// 执行Monkey测试crashedAtCycle = runMonkeyCycles();} finally {// Release the rotation lock if it's still held and restore the// original orientation.new MonkeyRotationEvent(Surface.ROTATION_0, false).injectEvent(mWm, mAm, mVerbose);}
}

runMonkeyCycles函数中调用MonkeySourceRandom的getNextEvent函数生成模拟测试事件(MonkeyEvent),调用MonkeyEventinjectEvent执行模拟测试。

private int runMonkeyCycles() {int eventCounter = 0;int cycleCounter = 0;boolean shouldReportAnrTraces = false;boolean shouldReportDumpsysMemInfo = false;boolean shouldAbort = false;boolean systemCrashed = false;try {// TO DO : The count should apply to each of the script file.while (!systemCrashed && cycleCounter < mCount) {synchronized (this) {// 注意:因为先执行过generateActivity,所以第一次调用会,会获得启动Activity的模拟测试事件MonkeyEvent ev = mEventSource.getNextEvent();if (ev != null) {int injectCode = ev.injectEvent(mWm, mAm, mVerbose);} else {}}} catch (RuntimeException e) {Logger.error("** Error: A RuntimeException occurred:", e);}Logger.out.println("Events injected: " + eventCounter);return eventCounter;
}

MonkeySourceRandom的getNextEvent,会在事件队列(存储模拟测试事件)为空时,产生测试对象。生成测试事件时,先生成一个随机数,然后根据测试类型所占比例(比例越大,生成该测试类型的概率越大),生成不同测试类型。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
/*** generate an activity event*/
public void generateActivity() {MonkeyActivityEvent e = new MonkeyActivityEvent(mMainApps.get(mRandom.nextInt(mMainApps.size())));mQ.addLast(e);
}/*** if the queue is empty, we generate events first* @return the first event in the queue*/
public MonkeyEvent getNextEvent() {if (mQ.isEmpty()) {generateEvents();}mEventCount++;MonkeyEvent e = mQ.getFirst();mQ.removeFirst();return e;
}/*** generate a random event based on mFactor*/
private void generateEvents() {// 生成随机数float cls = mRandom.nextFloat();int lastKey = 0;// 根据Factor,即不同测试类型所占的比例,生成测试事件if (cls < mFactors[FACTOR_TOUCH]) {generatePointerEvent(mRandom, GESTURE_TAP);return;} else if (cls < mFactors[FACTOR_MOTION]) {generatePointerEvent(mRandom, GESTURE_DRAG);return;} else if (cls < mFactors[FACTOR_PINCHZOOM]) {generatePointerEvent(mRandom, GESTURE_PINCH_OR_ZOOM);return;} else if (cls < mFactors[FACTOR_TRACKBALL]) {generateTrackballEvent(mRandom);return;} else if (cls < mFactors[FACTOR_ROTATION]) {generateRotationEvent(mRandom);return;} else if (cls < mFactors[FACTOR_PERMISSION]) {mQ.add(mPermissionUtil.generateRandomPermissionEvent(mRandom));return;}// The remaining event categories are injected as key eventsfor (;;) {if (cls < mFactors[FACTOR_NAV]) {lastKey = NAV_KEYS[mRandom.nextInt(NAV_KEYS.length)];} else if (cls < mFactors[FACTOR_MAJORNAV]) {lastKey = MAJOR_NAV_KEYS[mRandom.nextInt(MAJOR_NAV_KEYS.length)];} else if (cls < mFactors[FACTOR_SYSOPS]) {lastKey = SYS_KEYS[mRandom.nextInt(SYS_KEYS.length)];} else if (cls < mFactors[FACTOR_APPSWITCH]) {MonkeyActivityEvent e = new MonkeyActivityEvent(mMainApps.get(mRandom.nextInt(mMainApps.size())));mQ.addLast(e);return;} else if (cls < mFactors[FACTOR_FLIP]) {MonkeyFlipEvent e = new MonkeyFlipEvent(mKeyboardOpen);mKeyboardOpen = !mKeyboardOpen;mQ.addLast(e);return;} else {lastKey = 1 + mRandom.nextInt(KeyEvent.getMaxKeyCode() - 1);}if (lastKey != KeyEvent.KEYCODE_POWER&& lastKey != KeyEvent.KEYCODE_ENDCALL&& lastKey != KeyEvent.KEYCODE_SLEEP&& lastKey != KeyEvent.KEYCODE_SOFT_SLEEP&& PHYSICAL_KEY_EXISTS[lastKey]) {break;}}MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, lastKey);mQ.addLast(e);e = new MonkeyKeyEvent(KeyEvent.ACTION_UP, lastKey);mQ.addLast(e);
}

以Ttouch事件为例子,调用generatePointerEvent函数。通过DMS获取Display对象(用于得知屏幕大小),生成MonkeyTouchEvent对象。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
private void generatePointerEvent(Random random, int gesture) {Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);PointF p1 = randomPoint(random, display);PointF v1 = randomVector(random);long downAt = SystemClock.uptimeMillis();mQ.addLast(new MonkeyTouchEvent(MotionEvent.ACTION_DOWN).setDownTime(downAt).addPointer(0, p1.x, p1.y).setIntermediateNote(false));// 省略randomWalk(random, display, p1, v1);mQ.addLast(new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downAt).addPointer(0, p1.x, p1.y).setIntermediateNote(false));
}

调用MonkeyTouchEvent的injectEvent函数,使用InputManager向系统派发TouchEvent。

// development/cmds/monkey/src/com/android/commands/monkey/MonkeyMotionEvent.java
@Override
public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {MotionEvent me = getEvent();if ((verbose > 0 && !mIntermediateNote) || verbose > 1) {StringBuilder msg = new StringBuilder(":Sending ");msg.append(getTypeLabel()).append(" (");switch (me.getActionMasked()) {case MotionEvent.ACTION_DOWN:msg.append("ACTION_DOWN");break;case MotionEvent.ACTION_MOVE:msg.append("ACTION_MOVE");break;case MotionEvent.ACTION_UP:msg.append("ACTION_UP");break;case MotionEvent.ACTION_CANCEL:msg.append("ACTION_CANCEL");break;case MotionEvent.ACTION_POINTER_DOWN:msg.append("ACTION_POINTER_DOWN ").append(me.getPointerId(me.getActionIndex()));break;case MotionEvent.ACTION_POINTER_UP:msg.append("ACTION_POINTER_UP ").append(me.getPointerId(me.getActionIndex()));break;default:msg.append(me.getAction());break;}msg.append("):");int pointerCount = me.getPointerCount();for (int i = 0; i < pointerCount; i++) {msg.append(" ").append(me.getPointerId(i));msg.append(":(").append(me.getX(i)).append(",").append(me.getY(i)).append(")");}Logger.out.println(msg.toString());}try {// 派发TouchEventif (!InputManager.getInstance().injectInputEvent(me,InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT)) {return MonkeyEvent.INJECT_FAIL;}} finally {me.recycle();}return MonkeyEvent.INJECT_SUCCESS;
}
Monkey主要相关类图

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/266284.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【树莓派系统配置+python3.8+环境配置踩坑点汇总】raspberrypi

最近又开始搞树莓派的深度学习模型。很多windows端的环境需要在树莓派上重新部署&#xff0c;中间出现了非常多的问题。主要以各种库的下载安装为主要。 首先&#xff0c;第一个问题&#xff1a; 树莓派系统烧录之后&#xff0c;默认apt一般需要升级看&#xff0c;而默认下载…

Docker基础篇(六) dockerfile体系结构语法

FROM&#xff1a;基础镜像&#xff0c;当前新镜像是基于哪个镜像的 MAINTAINER &#xff1a;镜像维护者的姓名和邮箱地址 RUN&#xff1a;容器构建时需要运行的命令 EXPOSE &#xff1a;当前容器对外暴露出的端口号 WORKDIR&#xff1a;指定在创建容器后&#xff0c;终端默认登…

k8s(5)

目录 使用Kubeadm安装k8s集群&#xff1a; 初始化操作&#xff1a; 每台主从节点&#xff1a; 升级内核&#xff1a; 所有节点安装docker &#xff1a; 所有节点安装kubeadm&#xff0c;kubelet和kubectl&#xff1a; 修改了 kubeadm-config.yaml&#xff0c;将其传输给…

(正规api接口代发布权限)短视频账号矩阵系统实现开发--技术全自动化saas营销链路生态

短视频账号矩阵系统实现开发--技术全自动化saas营销链路生态源头开发&#xff08;本篇禁止抄袭复刻&#xff09; 一、短视频矩阵系统开发者架构 云罗短视频矩阵系统saas化系统&#xff0c;开发层将在CAP原则基础上使用分布式架构,对此网站的整体架构采用了基于B/S三层架构模式…

MySQL锁机制【重点】

参考链接 【1】https://xiaolincoding.com/mysql/lock/mysql_lock.html 【2】https://learnku.com/articles/39212?order_byvote_count& 重要的锁&#xff1a; 表级锁&#xff08;Table-level locks&#xff09;&#xff1a; 表级锁是对整个表进行加锁&#xff0c;当一个事…

【通信基础知识】完整通信系统的流程图及各模块功能详解

2024.2.29 抱歉最近在写毕设大论文&#xff0c;因此没有太多时间更新。然而&#xff0c;在写论文的过程中&#xff0c;发现自己对通信系统的了解还不够全明白&#xff0c;因此差了一些硕博论文总结了一个完整的通信系统流程图。若有不对的地方请多多指正//部分内容有参考ChatGP…

TeXiFy IDEA 编译后文献引用为 “[?]“

文章目录 1. 问题描述2. 原因分析3. 解决方案3.1 添加自动化脚本3.2 附录——配置一览表 1. 问题描述 在 IDEA 中使用 TeXiFy IDEA 编译后的文章文献引用是 [?] 2. 原因分析 根据网上教程所生成的目录结构如下&#xff1a; 报错日志&#xff1a; 根据 /out 目录结构&#x…

Qt注册类对象单例与单类型区别

1.实现类型SingletonTypeExample #ifndef SINGLETONTYPEEXAMPLE_H #define SINGLETONTYPEEXAMPLE_H#include <QObject>class SingletonTypeExample : public QObject {Q_OBJECT public://只能显示构造类对象explicit SingletonTypeExample(QObject *parent nullptr);//…

Linux Shell脚本练习(三)

1、测试用户名与密码是否正确。 2、输出1-1000内的素数。 3、对 100 以内的所有正整数相加求和(1234...100)。 4、输出9*9 乘法表。 5、编写脚本,显示进度条。 、 6、输入三个数并进行升序排序

金融帝国实验室(CapLab)官方更新_V9.1.65版本(2024年第13次)

〖金融帝国实验室〗&#xff08;Capitalism Lab&#xff09;游戏更新记录&#xff08;2024年度&#xff09; ————————————— ◎游戏开发&#xff1a;Enlight Software Ltd.&#xff08;微启软件有限公司&#xff09; ◎官方网站&#xff1a;https://www.capitalism…

鸿蒙Harmony应用开发—ArkTS声明式开发(鼠标事件)

在鼠标的单个动作触发多个事件时&#xff0c;事件的顺序是固定的&#xff0c;鼠标事件默认透传。 说明&#xff1a; 从API Version 8开始支持。后续版本如有新增内容&#xff0c;则采用上角标单独标记该内容的起始版本。目前仅支持通过外接鼠标触发。 onHover onHover(event: …

Oracle中序列

1. Sequence 定义 在Oracle中可以用SEQUENCE生成自增字段。Sequence序列是Oracle中用于生成数字序列的对象&#xff0c;可以创建一个唯一的数字作为主键。 2. 为什么要用 Sequence 你可能有疑问为什么要使用序列&#xff1f; 不能使用一个存储主键的表并每次递增吗&#xf…

亿道信息新三防平板EM-I10J,性能和价格成最大亮点

亿道信息近期推出了一款新三防平板电脑名为EM-I10J&#xff0c;这款设备上市的初衷是为了在满足客户作业需求的同时为其提供更合适的价格选择&#xff0c;但这并不意味着EM-I10J的实力可以被小觑。 外观上I10J与之前的I10U并无不同之处&#xff0c;同样是10.1英寸高清电容式触…

编写科技项目验收测试报告需要注意什么?第三方验收测试多少钱?

科技项目验收测试是一个非常重要的环节&#xff0c;它对于确保科技项目的质量和可用性起着至关重要的作用。在项目完成后&#xff0c;进行科技项目验收测试可以评估项目的功能、性能和可靠性等方面&#xff0c;并生成科技项目验收测试报告&#xff0c;以提供给项目的相关方参考…

XUbuntu22.04之如何定制:已经绑定的快捷键?(二百一十五)

简介&#xff1a; CSDN博客专家&#xff0c;专注Android/Linux系统&#xff0c;分享多mic语音方案、音视频、编解码等技术&#xff0c;与大家一起成长&#xff01; 优质专栏&#xff1a;Audio工程师进阶系列【原创干货持续更新中……】&#x1f680; 优质专栏&#xff1a;多媒…

【免费】两阶段鲁棒优化matlab实现——CCG和benders

目录 1 主要内容 2 部分代码 3 程序结果 4 下载链接 1 主要内容 程序采用matlab复现经典论文《Solving two-stage robust optimization problems using a column-and-constraint generation method》算例&#xff0c;实现了C&CG和benders算法两部分内容&#xff0c;通过…

2024-02-29(Flink)

1.Flink原理&#xff08;角色分工&#xff09; 2.Flink执行流程 on yarn版&#xff1a; 3.相关概念 1&#xff09;DataFlow&#xff1a;Flink程序在执行的时候会被映射成一个数据流模型&#xff1b; 2&#xff09;Operator&#xff1a;数据流模型中的每一个操作被称作Operat…

1.1 创建第一个vue项目

cmd命令窗口运行 vue init webpack hellovue 注意&#xff0c;hellovue是项目名称&#xff0c;项目名称不能保存大写字母否者会报错 Sorry, name can no longer contain capital letters. 运行设个命令的时候可能会报错&#xff0c;根据提示先运行 npm i -g vue/cli-init …

Python中的os库

一.OS库简介 OS是Operating System的简写&#xff0c;即操作系统。 OS库是一个操作系统接口模块&#xff0c;提供一些方便使用操作系统相关功能的函数。 二.OS库常用函数 2.1文件和目录 2.1.1&#xff1a;os.getcwd() 作用&#xff1a;返回当前工作目录&#xff0c;结果是…

机器学习|决策树

左图的点是一种线性不可分的情况&#xff0c;无法拿一条直线去将进行分开。 每一个节点都代表一个决策&#xff0c;从而导致节点的分流。 最终的目标肯定是要达到分类。 但取得目标的过程是有所谓的好坏。 而这个好坏用熵/信息增益来衡量。 熵是一种用于反映系统混乱程度的物理…