首页 > 其他分享 >5.7

5.7

时间:2024-10-13 19:33:36浏览次数:1  
标签:prev cost 5.7 state production demand total

点击查看代码
import numpy as np  
  
demands = [40, 60, 80]  
max_production = 100  
total_demand = sum(demands)  
  
dp = np.full((4, total_demand + 1), float('inf'))  
dp[0][0] = 0  
  
prev_production = np.full((4, total_demand + 1), -1) 
  
for i in range(1, 4):  
    prev_demand = sum(demands[:i-1])  
    for j in range(total_demand + 1):  
        if j < prev_demand + demands[i-1]:  
            
            continue  
        for x in range(max(0, j - prev_demand - demands[i-1] + 1), min(max_production + 1, j - prev_demand + 1)):  
            production_cost = 50 * x + 0.2 * x**2  
            storage_cost = 4 * (j - prev_demand - x)  
            total_cost = dp[i-1][j-x] + production_cost + storage_cost  
            if total_cost < dp[i][j]:  
                dp[i][j] = total_cost  
                prev_production[i][j] = x  
   
min_cost = float('inf')  
final_state = -1  
for j in range(total_demand, total_demand + 1):  
    if dp[3][j] < min_cost:  
        min_cost = dp[3][j]  
        final_state = j  
  
production_plan = [0] * 3  
current_state = final_state  
for i in range(3, 0, -1):  
    production_plan[i-1] = prev_production[i][current_state]  
    current_state -= prev_production[i][current_state]  

print(f"最小总费用为: {min_cost} 元")  
print("生产计划为:")  
for i, plan in enumerate(production_plan, 1):  
    print(f"第{i}季度生产: {plan} 台")

print("学号:3004")

标签:prev,cost,5.7,state,production,demand,total
From: https://www.cnblogs.com/howoo0808/p/18462811

相关文章

  • MySQL 5.7增强半同步AFTER SYNC&AFTER COMMIT
    今天主要剖析一下MySQL5.7增强半同步的AFTERSYNC和AFTERCOMMIT的区别。    如果我们生产库对数据的一致性要求比较高,那么我们一般会开启了半同步复制,但在MySQL5.5/5.6里,会存在数据不一致的风险。比如有如下场景,客户端提交了一个事务,master把binlog发送给slave,在发送的期间......
  • linux中mysql5.7安装
    系统要求:CentOS7.664位卸载系统自带mariadb-lib1、rpm-qa|grepmariadb2、rpm-emariadb-libs-5.5.68-1.el7.x86_64 --nodeps 解压tar包:tar-xvfmysql*.tar以下加粗rpm包需要安装:mysql-community-common-5.7.23-1.el7.x86_64.rpmmysql-community-libs-co......
  • 125.785 S1  Binary Model practice
    125.785S12024-- Assignment 2 (Part A and Part B)Duedate:18th October2024Theassignmentis30%tothecourseassessment, including two parts:PartA. Practice binary and paneldata regressions (15%), Part B.Critical Reading (15%).......
  • dedecms5.7后台卡,造成浏览器假死的解决方法
    当你遇到织梦CMS后台菜单点击后卡死的情况时,可以通过屏蔽相关代码来解决这一问题。以下是具体的步骤:1.找到并屏蔽相关代码定位文件:打开织梦CMS安装目录下的 dede/templates/index_body.htm 文件。 直接删除这段代码:<scripttype="text/javascript">function......
  • 虚拟机最后支持 Windows 7的版本是 VMware Workstation 15.5.7
    最新版的VMware已经不再支持Windows7系统了。通过搜寻官网的描述说明,最后的支持版本应该是 VMwareWorkstation15.5.717171714,Win7依然没有放弃使用,于是立即找出了该版本的官方下载地址:VMwareWorkstation15.5.7 | VMwareWorkstationfull15.5.7安装过程中需......
  • 15.7 创建prometheus的statsfulset配置
    本节重点介绍:prometheusstatsfulsetyaml配置设置statsfulset副本反亲和性设置pod运行优先级设置volumeClaimTemplates设置配置文件热更新容器configmap-reload设置prometheus主容器statsfulset设置元信息apiVersion:apps/v1kind:StatefulSetmetadata:name:prometheus......
  • MySQL 5.7 Command Line Client 闪屏退出
    MySQL5.7CommandLineClient 闪屏退出 解释:MySQL5.7CommandLineClient闪屏退出可能是因为缺少某些环境变量配置,或者是MySQL安装过程中出现了问题。解决方法:   检查环境变量:确保PATH环境变量中包含了MySQL的bin目录路径。在Windows系统中,可以在系统属性的“高级”......
  • mysql5.7.40升级到5.7.44
    1.软件下载https://www.mysql.com/downloads/找到mysqlcommunityGPLdownload--mysqlcommunityserver--选择5.7.44和rhel/oracle下载mysql-5.7.44-1.el7.x86_64.rpm-bundle.tar2.停服备份systemctlstopmysqldcp/etc/my.cnf/etc/my.cnf.bak20240801配置文件tar-z......
  • 基于windows的mysql5.7安装配置教程
    目录0.写在前面的话1.下载安装包2.进行目录选择和解压操作3.配置环境变量4.创建my.ini文件5.管理员运行终端6.安装mysqld7.初始化数据库8.启动mysql服务9.进入mysql管理终端10.修改root密码11.刷新权限12.注销内容13.重启mysql14.输入密码测试15.我的总结0......
  • 全网最简单ubuntu18.04+mysql5.7+nginx+uwsgi一次性部署Django!!!!!
    ubuntu18.04,自带python3.6,mysql5.7 Nginx*******************************1.安装nginx apt-getupdate apt-getupgrade apt-getinstallnginx 2.修改端口为81(可选),是一个链接 /etc/nginx/sites-enabled/default3.servicenginxreload4.servicenginx......