- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试最小化以下问题:
对于笔记本电脑,手机和平板电脑的生产,存在库存成本(每个项目每月1美元)和加班时间(每小时10美元)的成本。有一个需要满足的需求方案,它是对特定月份中最小数量的小工具的约束。除此之外,每月最多可生产20000小时,加上每月3000个加班时间。
问题是python / pulp给我的结果(除一个例外)是LpVariables中插入的所有上限值:不是最小化的成本!
from pulp import *
# Define the LP problem: minimize costs
prob = LpProblem("Minimize costs of production and inventory", LpMinimize)
# Demand schemes
demand_laptops = [75, 125, 1000, 1500, 1000, 500, 1250, 1500, 1000, 500, 500, 400, 300] # Demand laptops
demand_phones = [120, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000] # Demand phones
demand_tablets = [50, 2000, 3000, 2000, 3000, 4000, 5000, 2000, 3000, 4000, 5000, 4000, 5000] # Demand tablets
# Defining variables: normal production hours and overtime production hours.
production_laptop = {x: LpVariable("Production hours for laptop in month {}".format(x), 0, 20000)
for x in range(1, 13)}
production_phone = {x: LpVariable("Production hours for phone in month {}".format(x), 0, 20000)
for x in range(1, 13)}
production_tablet = {x: LpVariable("Production hours for tablet in month {}".format(x), 0, 20000)
for x in range(1, 13)}
overtime_laptop = {x: LpVariable("Overtime hours for laptop in month {}".format(x), 0, 3000)
for x in range(1, 13)}
overtime_phone = {x: LpVariable("Overtime hours for phone in month {}".format(x), 0, 3000)
for x in range(1, 13)}
overtime_tablet = {x: LpVariable("Overtime hours for tablet in month {}".format(x), 0, 3000)
for x in range(1, 13)}
# defining a list of names for the inventory of products
inventory_laptops = {x: "inventory of laptops in month {}".format(x)
for x in range(1, 13)}
inventory_phones = {x: "inventory of phones in month {}".format(x)
for x in range(1, 13)}
inventory_tables = {x: "inventory of tablets in month {}".format(x)
for x in range(1, 13)}
# Inventory (to be minimized)
inventory_laptops[1] = demand_laptops[0] + (1 / 5) * production_laptop[1] + (1 / 5) * overtime_laptop[1] - demand_laptops[1]
inventory_laptops[2] = inventory_laptops[1] + (1 / 5) * production_laptop[2] + (1 / 5) * overtime_laptop[2] - demand_laptops[2]
inventory_laptops[3] = inventory_laptops[2] + (1 / 5) * production_laptop[3] + (1 / 5) * overtime_laptop[3] - demand_laptops[3]
inventory_laptops[4] = inventory_laptops[3] + (1 / 5) * production_laptop[4] + (1 / 5) * overtime_laptop[4] - demand_laptops[4]
inventory_laptops[5] = inventory_laptops[4] + (1 / 5) * production_laptop[5] + (1 / 5) * overtime_laptop[5] - demand_laptops[5]
inventory_laptops[6] = inventory_laptops[5] + (1 / 5) * production_laptop[6] + (1 / 5) * overtime_laptop[6] - demand_laptops[6]
inventory_laptops[7] = inventory_laptops[6] + (1 / 5) * production_laptop[7] + (1 / 5) * overtime_laptop[7] - demand_laptops[7]
inventory_laptops[8] = inventory_laptops[7] + (1 / 5) * production_laptop[8] + (1 / 5) * overtime_laptop[8] - demand_laptops[8]
inventory_laptops[9] = inventory_laptops[8] + (1 / 5) * production_laptop[9] + (1 / 5) * overtime_laptop[9] - demand_laptops[9]
inventory_laptops[10] = inventory_laptops[9] + (1 / 5) * production_laptop[10] + (1 / 5) * overtime_laptop[10] - demand_laptops[10]
inventory_laptops[11] = inventory_laptops[10] + (1 / 5) * production_laptop[11] + (1 / 5) * overtime_laptop[11] - demand_laptops[11]
inventory_laptops[12] = inventory_laptops[11] + (1 / 5) * production_laptop[12] + (1 / 5) * overtime_laptop[12] - demand_laptops[12]
inventory_phones[1] = demand_phones[0] + (1 / 2) * production_phone[1] + (1 / 2) * overtime_phone[1] - demand_phones[1]
inventory_phones[2] = inventory_phones[1] + (1 / 2) * production_phone[2] + (1 / 2) * overtime_phone[2] - demand_phones[2]
inventory_phones[3] = inventory_phones[2] + (1 / 2) * production_phone[3] + (1 / 2) * overtime_phone[3] - demand_phones[3]
inventory_phones[4] = inventory_phones[3] + (1 / 2) * production_phone[4] + (1 / 2) * overtime_phone[4] - demand_phones[4]
inventory_phones[5] = inventory_phones[4] + (1 / 2) * production_phone[5] + (1 / 2) * overtime_phone[5] - demand_phones[5]
inventory_phones[6] = inventory_phones[5] + (1 / 2) * production_phone[6] + (1 / 2) * overtime_phone[6] - demand_phones[6]
inventory_phones[7] = inventory_phones[6] + (1 / 2) * production_phone[7] + (1 / 2) * overtime_phone[7] - demand_phones[7]
inventory_phones[8] = inventory_phones[7] + (1 / 2) * production_phone[8] + (1 / 2) * overtime_phone[8] - demand_phones[8]
inventory_phones[9] = inventory_phones[8] + (1 / 2) * production_phone[9] + (1 / 2) * overtime_phone[9] - demand_phones[9]
inventory_phones[10] = inventory_phones[9] + (1 / 2) * production_phone[10] + (1 / 2) * overtime_phone[10] - demand_phones[10]
inventory_phones[11] = inventory_phones[10] + (1 / 2) * production_phone[11] + (1 / 2) * overtime_phone[11] - demand_phones[11]
inventory_phones[12] = inventory_phones[11] + (1 / 2) * production_phone[12] + (1 / 2) * overtime_phone[12] - demand_phones[12]
inventory_tables[1] = demand_tablets[0] + (1 / 4) * production_tablet[1] + (1 / 4) * overtime_tablet[1] - demand_tablets[1]
inventory_tables[2] = inventory_tables[1] + (1 / 4) * production_tablet[2] + (1 / 4) * overtime_tablet[2] - demand_tablets[2]
inventory_tables[3] = inventory_tables[2] + (1 / 4) * production_tablet[3] + (1 / 4) * overtime_tablet[3] - demand_tablets[3]
inventory_tables[4] = inventory_tables[3] + (1 / 4) * production_tablet[4] + (1 / 4) * overtime_tablet[4] - demand_tablets[4]
inventory_tables[5] = inventory_tables[4] + (1 / 4) * production_tablet[5] + (1 / 4) * overtime_tablet[5] - demand_tablets[5]
inventory_tables[6] = inventory_tables[5] + (1 / 4) * production_tablet[6] + (1 / 4) * overtime_tablet[6] - demand_tablets[6]
inventory_tables[7] = inventory_tables[6] + (1 / 4) * production_tablet[7] + (1 / 4) * overtime_tablet[7] - demand_tablets[7]
inventory_tables[8] = inventory_tables[7] + (1 / 4) * production_tablet[8] + (1 / 4) * overtime_tablet[8] - demand_tablets[8]
inventory_tables[9] = inventory_tables[8] + (1 / 4) * production_tablet[9] + (1 / 4) * overtime_tablet[9] - demand_tablets[9]
inventory_tables[10] = inventory_tables[9] + (1 / 4) * production_tablet[10] + (1 / 4) * overtime_tablet[10] - demand_tablets[10]
inventory_tables[11] = inventory_tables[10] + (1 / 4) * production_tablet[11] + (1 / 4) * overtime_tablet[11] - demand_tablets[11]
inventory_tables[12] = inventory_tables[11] + (1 / 4) * production_tablet[12] + (1 / 4) * overtime_tablet[12] - demand_tablets[12]
# Constraints to meet demand scheme
prob += demand_laptops[0] + (1 / 5) * production_laptop[1] + (1 / 5) * overtime_laptop[1] >= demand_laptops[1]
prob += inventory_laptops[1] + (1 / 5) * production_laptop[2] + (1 / 5) * overtime_laptop[2] >= demand_laptops[2]
prob += inventory_laptops[2] + (1 / 5) * production_laptop[3] + (1 / 5) * overtime_laptop[3] >= demand_laptops[3]
prob += inventory_laptops[3] + (1 / 5) * production_laptop[4] + (1 / 5) * overtime_laptop[4] >= demand_laptops[4]
prob += inventory_laptops[4] + (1 / 5) * production_laptop[5] + (1 / 5) * overtime_laptop[5] >= demand_laptops[5]
prob += inventory_laptops[5] + (1 / 5) * production_laptop[6] + (1 / 5) * overtime_laptop[6] >= demand_laptops[6]
prob += inventory_laptops[6] + (1 / 5) * production_laptop[7] + (1 / 5) * overtime_laptop[7] >= demand_laptops[7]
prob += inventory_laptops[7] + (1 / 5) * production_laptop[8] + (1 / 5) * overtime_laptop[8] >= demand_laptops[8]
prob += inventory_laptops[8] + (1 / 5) * production_laptop[9] + (1 / 5) * overtime_laptop[9] >= demand_laptops[9]
prob += inventory_laptops[9] + (1 / 5) * production_laptop[10] + (1 / 5) * overtime_laptop[10] >= demand_laptops[10]
prob += inventory_laptops[10] + (1 / 5) * production_laptop[11] + (1 / 5) * overtime_laptop[11] >= demand_laptops[11]
prob += inventory_laptops[11] + (1 / 5) * production_laptop[12] + (1 / 5) * overtime_laptop[12] >= demand_laptops[12]
prob += demand_phones[0] + (1 / 2) * production_phone[1] + (1 / 2) * overtime_phone[1] >= demand_phones[1]
prob += inventory_phones[1] + (1 / 2) * production_phone[2] + (1 / 2) * overtime_phone[2] >= demand_phones[2]
prob += inventory_phones[2] + (1 / 2) * production_phone[3] + (1 / 2) * overtime_phone[3] >= demand_phones[3]
prob += inventory_phones[3] + (1 / 2) * production_phone[4] + (1 / 2) * overtime_phone[4] >= demand_phones[4]
prob += inventory_phones[4] + (1 / 2) * production_phone[5] + (1 / 2) * overtime_phone[5] >= demand_phones[5]
prob += inventory_phones[5] + (1 / 2) * production_phone[6] + (1 / 2) * overtime_phone[6] >= demand_phones[6]
prob += inventory_phones[6] + (1 / 2) * production_phone[7] + (1 / 2) * overtime_phone[7] >= demand_phones[7]
prob += inventory_phones[7] + (1 / 2) * production_phone[8] + (1 / 2) * overtime_phone[8] >= demand_phones[8]
prob += inventory_phones[8] + (1 / 2) * production_phone[9] + (1 / 2) * overtime_phone[9] >= demand_phones[9]
prob += inventory_phones[9] + (1 / 2) * production_phone[10] + (1 / 2) * overtime_phone[10] >= demand_phones[10]
prob += inventory_phones[10] + (1 / 2) * production_phone[11] + (1 / 2) * overtime_phone[11] >= demand_phones[11]
prob += inventory_phones[11] + (1 / 2) * production_phone[12] + (1 / 2) * overtime_phone[12] >= demand_phones[12]
prob += demand_tablets[0] + (1 / 4) * production_tablet[1] + (1 / 4) * overtime_tablet[1] >= demand_tablets[1]
prob += inventory_phones[1] + (1 / 4) * production_tablet[2] + (1 / 4) * overtime_tablet[2] >= demand_tablets[2]
prob += inventory_phones[2] + (1 / 4) * production_tablet[3] + (1 / 4) * overtime_tablet[3] >= demand_tablets[3]
prob += inventory_phones[3] + (1 / 4) * production_tablet[4] + (1 / 4) * overtime_tablet[4] >= demand_tablets[4]
prob += inventory_phones[4] + (1 / 4) * production_tablet[5] + (1 / 4) * overtime_tablet[5] >= demand_tablets[5]
prob += inventory_phones[5] + (1 / 4) * production_tablet[6] + (1 / 4) * overtime_tablet[6] >= demand_tablets[6]
prob += inventory_phones[6] + (1 / 4) * production_tablet[7] + (1 / 4) * overtime_tablet[7] >= demand_tablets[7]
prob += inventory_phones[7] + (1 / 4) * production_tablet[8] + (1 / 4) * overtime_tablet[8] >= demand_tablets[8]
prob += inventory_phones[8] + (1 / 4) * production_tablet[9] + (1 / 4) * overtime_tablet[9] >= demand_tablets[9]
prob += inventory_phones[9] + (1 / 4) * production_tablet[10] + (1 / 4) * overtime_tablet[10] >= demand_tablets[10]
prob += inventory_phones[10] + (1 / 4) * production_tablet[11] + (1 / 4) * overtime_tablet[11] >= demand_tablets[11]
prob += inventory_phones[11] + (1 / 4) * production_tablet[12] + (1 / 4) * overtime_tablet[12] >= demand_tablets[12]
# Objective function: inventory costs and overtime costs (10 per hour)
prob += sum(inventory_laptops) + sum(inventory_phones) + sum(inventory_tables) + (10 * (sum(overtime_laptop) + sum(overtime_phone) + sum(overtime_tablet)))
# Solve the problem
prob.solve()
print("Status:", LpStatus[prob.status])
for v in prob.variables():
print(v.name, "=", v.varValue)
print("total costs:", value(prob.objective))
Status: Optimal
Overtime_hours_for_laptop_in_month_1 = 3000.0
Overtime_hours_for_laptop_in_month_10 = 3000.0
Overtime_hours_for_laptop_in_month_11 = 3000.0
Overtime_hours_for_laptop_in_month_12 = 3000.0
Overtime_hours_for_laptop_in_month_2 = 3000.0
Overtime_hours_for_laptop_in_month_3 = 3000.0
Overtime_hours_for_laptop_in_month_4 = 3000.0
Overtime_hours_for_laptop_in_month_5 = 3000.0
Overtime_hours_for_laptop_in_month_6 = 3000.0
Overtime_hours_for_laptop_in_month_7 = 3000.0
Overtime_hours_for_laptop_in_month_8 = 3000.0
Overtime_hours_for_laptop_in_month_9 = 3000.0
Overtime_hours_for_phone_in_month_1 = 3000.0
Overtime_hours_for_phone_in_month_10 = 3000.0
Overtime_hours_for_phone_in_month_11 = 3000.0
Overtime_hours_for_phone_in_month_12 = 3000.0
Overtime_hours_for_phone_in_month_2 = 3000.0
Overtime_hours_for_phone_in_month_3 = 3000.0
Overtime_hours_for_phone_in_month_4 = 3000.0
Overtime_hours_for_phone_in_month_5 = 3000.0
Overtime_hours_for_phone_in_month_6 = 3000.0
Overtime_hours_for_phone_in_month_7 = 3000.0
Overtime_hours_for_phone_in_month_8 = 3000.0
Overtime_hours_for_phone_in_month_9 = 3000.0
Overtime_hours_for_tablet_in_month_1 = 0.0
Overtime_hours_for_tablet_in_month_10 = 3000.0
Overtime_hours_for_tablet_in_month_11 = 3000.0
Overtime_hours_for_tablet_in_month_12 = 3000.0
Overtime_hours_for_tablet_in_month_2 = 3000.0
Overtime_hours_for_tablet_in_month_3 = 3000.0
Overtime_hours_for_tablet_in_month_4 = 3000.0
Overtime_hours_for_tablet_in_month_5 = 3000.0
Overtime_hours_for_tablet_in_month_6 = 3000.0
Overtime_hours_for_tablet_in_month_7 = 3000.0
Overtime_hours_for_tablet_in_month_8 = 3000.0
Overtime_hours_for_tablet_in_month_9 = 3000.0
Production_hours_for_laptop_in_month_1 = 20000.0
Production_hours_for_laptop_in_month_10 = 20000.0
Production_hours_for_laptop_in_month_11 = 20000.0
Production_hours_for_laptop_in_month_12 = 20000.0
Production_hours_for_laptop_in_month_2 = 20000.0
Production_hours_for_laptop_in_month_3 = 20000.0
Production_hours_for_laptop_in_month_4 = 20000.0
Production_hours_for_laptop_in_month_5 = 20000.0
Production_hours_for_laptop_in_month_6 = 20000.0
Production_hours_for_laptop_in_month_7 = 20000.0
Production_hours_for_laptop_in_month_8 = 20000.0
Production_hours_for_laptop_in_month_9 = 20000.0
Production_hours_for_phone_in_month_1 = 20000.0
Production_hours_for_phone_in_month_10 = 20000.0
Production_hours_for_phone_in_month_11 = 20000.0
Production_hours_for_phone_in_month_12 = 20000.0
Production_hours_for_phone_in_month_2 = 20000.0
Production_hours_for_phone_in_month_3 = 20000.0
Production_hours_for_phone_in_month_4 = 20000.0
Production_hours_for_phone_in_month_5 = 20000.0
Production_hours_for_phone_in_month_6 = 20000.0
Production_hours_for_phone_in_month_7 = 20000.0
Production_hours_for_phone_in_month_8 = 20000.0
Production_hours_for_phone_in_month_9 = 20000.0
Production_hours_for_tablet_in_month_1 = 7800.0
Production_hours_for_tablet_in_month_10 = 20000.0
Production_hours_for_tablet_in_month_11 = 20000.0
Production_hours_for_tablet_in_month_12 = 20000.0
Production_hours_for_tablet_in_month_2 = 20000.0
Production_hours_for_tablet_in_month_3 = 20000.0
Production_hours_for_tablet_in_month_4 = 20000.0
Production_hours_for_tablet_in_month_5 = 20000.0
Production_hours_for_tablet_in_month_6 = 20000.0
Production_hours_for_tablet_in_month_7 = 20000.0
Production_hours_for_tablet_in_month_8 = 20000.0
Production_hours_for_tablet_in_month_9 = 20000.0
__dummy = None
total costs: None
最佳答案
有一些语法错误会导致求解器获得的模型与您期望的模型不同。另外,我还要指出一些句法建议。
怎么了?
首先,将production
变量定义为字典,其值为LpVariables
。我建议您使用为此作业设计的pulp
数据结构LpVariable.dicts
。定义如下:
production_laptop = LpVariable.dicts(
"Production hours for laptop in month ", range(1, 13),
lowBound = 0, upBound = 20000)
inventory_
变量。然后,您重新定义这些词典的值以指向变量和约束的组合。我将这些变量定义为先前的变量:
inventory_laptops = LpVariable.dicts(
"inventory of laptops in month ", range(1,13), lowBound = 0)
sum(inventory_laptops)
代替
sum(inventory_laptops[i] for i in range(1,13))
,否则我们将尝试使用字典,尤其是
over the keys of the dictionary来使用
sum
。
prob += inventory_phones[1] + (1 / 4) * production_tablet[2] + (1 / 4) * overtime_tablet[2] >= demand_tablets[2]
phones
替换为
tablets
。您可以轻松地将这些行写为
for i in range(1,13):
prob += (demand_tablets[i - 1] if i == 1 else inventory_tables[i - 1]) + \
(1 / 4) * production_tablet[i] + (1 / 4) * overtime_tablet[i] >= \
demand_tablets[i], "demand tablets {}".format(i)
# Demand laptops
时为何注释
demand_laptops
?
demand_tablets, inventory_tables, overtime_tablet
和
production_tablet
都非常相似并且容易混淆。尝试坚持一个更一致的表示法。
_dummy
的变量,该变量是偶然完成的。这是通过
prob.writeLP("DebugThis.lp")
完成的。我还将使用长度较短的变量,以便我可以了解约束和目标函数中的情况。最后,请尽量避免在模型中使用硬数字。您现在拥有的实例的库存成本可能是10,但是将来可能会改变(在非分配环境中会改变)。因此,最好定义一个清单成本清单(每个产品和/或期间一个),并仅更新该清单。如果要添加更多产品,这将很有帮助,因为约束和变量将自动生成。
from pulp import * # I would not import the entire workspace - you might end up shadowing variables names that you need
# Problem formulation starts here
prob = LpProblem("Minimize costs of production and inventory", LpMinimize)
# Problem data: Product Demands
demand_laptops = [75, 125, 1000, 1500, 1000, 500, 1250, 1500, 1000, 500, 500, 400, 300]
demand_phones = [120, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]
demand_tablets = [50, 2000, 3000, 2000, 3000, 4000, 5000, 2000, 3000, 4000, 5000, 4000, 5000]
# Defining variables: normal production, overtime, and inventories
production_laptop = LpVariable.dicts(
"Production hours for laptop in month ", range(1, 13),
lowBound = 0, upBound = 20000)
production_phone = LpVariable.dicts(
"Production hours for phone in month ", range(1, 13),
lowBound = 0, upBound = 20000)
production_tablet = LpVariable.dicts(
"Production hours for tablet in month ", range(1, 13),
lowBound = 0, upBound = 20000)
overtime_laptop = LpVariable.dicts(
"Overtime hours for laptop in month ", range(1, 13),
lowBound = 0, upBound = 3000)
overtime_phone = LpVariable.dicts(
"Overtime hours for phone in month ", range(1, 13),
lowBound = 0, upBound = 3000)
overtime_tablet = LpVariable.dicts(
"Overtime hours for tablet in month ", range(1, 13),
lowBound = 0, upBound = 3000)
inventory_laptops = LpVariable.dicts(
"inventory of laptops in month ", range(1,13), lowBound = 0)
inventory_phones = LpVariable.dicts(
"inventory of phones in month ", range(1,13), lowBound = 0)
inventory_tables = LpVariable.dicts(
"inventory of tables in month ", range(1,13), lowBound = 0)
# Objective function: inventory costs and overtime costs
prob += (sum(
inventory_laptops[i] + inventory_phones[i] + inventory_tables[i]
for i in range(1,13)) + \
10 * sum(overtime_laptop[i] + overtime_phone[i] + overtime_tablet[i]
for i in range(1,13)))
# Constraint definition part
for i in range(1,13):
# Inventory definition for laptops, phones and tablets
prob += inventory_laptops[i] == (demand_laptops[i - 1] if i == 1 else \
inventory_laptops[i - 1]) + \
(1 / 5) * production_laptop[i] + (1 / 5) * overtime_laptop[i] - \
demand_laptops[i], "inventory_laptops definition {}".format(i)
prob += inventory_phones[i] == (demand_phones[i - 1] if i == 1 else \
inventory_phones[i - 1]) + \
(1 / 2) * production_phone[i] + (1 / 2) * overtime_phone[i] - \
demand_phones[i], "inventory_phones definition {}".format(i)
prob += inventory_tables[i] == (demand_tablets[i - 1] if i == 1 else \
inventory_tables[i - 1]) + \
(1 / 4) * production_tablet[i] + (1 / 4) * overtime_tablet[i] - \
demand_tablets[i], "inventory_tables definition {}".format(i)
# Demand-covering constraints for laptops, phones, tablets
prob += (demand_laptops[i - 1] if i == 1 else inventory_laptops[i - 1]) + \
(1 / 5) * production_laptop[i] + (1 / 5) * overtime_laptop[i] >= \
demand_laptops[i], "demand laptops {}".format(i)
prob += (demand_phones[i - 1] if i == 1 else inventory_phones[i - 1]) + \
(1 / 2) * production_phone[i] + (1 / 2) * overtime_phone[i] >= \
demand_phones[i], "demand phones {}".format(i)
prob += (demand_tablets[i - 1] if i == 1 else inventory_tables[i - 1]) + \
(1 / 4) * production_tablet[i] + (1 / 4) * overtime_tablet[i] >= \
demand_tablets[i], "demand tablets {}".format(i)
# Solve the problem
prob.solve()
# Take a look at what was solved
prob.writeLP("SO40113557.lp")
print("Status:", LpStatus[prob.status])
for v in prob.variables():
print(v.name, "=", v.varValue)
print("total costs:", value(prob.objective))
('Status:', 'Optimal')
('total costs:', 0.0)
关于python-3.x - 显示最小化的LpVariable的上限值的PuLP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40113557/
问题故障解决记录 -- Java RMI Connection refused to host: x.x.x.x .... 在学习JavaRMI时,我遇到了以下情况 问题原因:可
我正在玩 Rank-N-type 并尝试输入 x x .但我发现这两个函数可以以相同的方式输入,这很不直观。 f :: (forall a b. a -> b) -> c f x = x x g ::
这个问题已经有答案了: How do you compare two version Strings in Java? (31 个回答) 已关闭 8 年前。 有谁知道如何在Java中比较两个版本字符串
这个问题已经有答案了: How do the post increment (i++) and pre increment (++i) operators work in Java? (14 个回答)
下面是带有 -n 和 -r 选项的 netstat 命令的输出,其中目标字段显示压缩地址 (127.1/16)。我想知道 netstat 命令是否有任何方法或选项可以显示整个目标 IP (127.1.
我知道要证明 : (¬ ∀ x, p x) → (∃ x, ¬ p x) 证明是: theorem : (¬ ∀ x, p x) → (∃ x, ¬ p x) := begin intro n
x * x 如何通过将其存储在“auto 变量”中来更改?我认为它应该仍然是相同的,并且我的测试表明类型、大小和值显然都是相同的。 但即使 x * x == (xx = x * x) 也是错误的。什么
假设,我们这样表达: someIQueryable.Where(x => x.SomeBoolProperty) someIQueryable.Where(x => !x.SomeBoolProper
我有一个字符串 1234X5678 我使用这个正则表达式来匹配模式 .X|..X|X. 我得到了 34X 问题是为什么我没有得到 4X 或 X5? 为什么正则表达式选择执行第二种模式? 最佳答案 这里
我的一个 friend 在面试时遇到了这个问题 找到使该函数返回真值的 x 值 function f(x) { return (x++ !== x) && (x++ === x); } 面试官
这个问题在这里已经有了答案: 10年前关闭。 Possible Duplicate: Isn't it easier to work with foo when it is represented b
我是 android 的新手,我一直在练习开发一个针对 2.2 版本的应用程序,我需要帮助了解如何将我的应用程序扩展到其他版本,即 1.x、2.3.x、3 .x 和 4.x.x,以及一些针对屏幕分辨率
为什么案例 1 给我们 :error: TypeError: x is undefined on line... //case 1 var x; x.push(x); console.log(x);
代码优先: # CASE 01 def test1(x): x += x print x l = [100] test1(l) print l CASE01 输出: [100, 100
我正在努力温习我的大计算。如果我有将所有项目移至 'i' 2 个空格右侧的函数,我有一个如下所示的公式: (n -1) + (n - 2) + (n - 3) ... (n - n) 第一次迭代我必须
给定 IP 字符串(如 x.x.x.x/x),我如何或将如何计算 IP 的范围最常见的情况可能是 198.162.1.1/24但可以是任何东西,因为法律允许的任何东西。 我要带198.162.1.1/
在我作为初学者努力编写干净的 Javascript 代码时,我最近阅读了 this article当我偶然发现这一段时,关于 JavaScript 中的命名空间: The code at the ve
我正在编写一个脚本,我希望避免污染 DOM 的其余部分,它将是一个用于收集一些基本访问者分析数据的第 3 方脚本。 我通常使用以下内容创建一个伪“命名空间”: var x = x || {}; 我正在
我尝试运行我的test_container_services.py套件,但遇到了以下问题: docker.errors.APIError:500服务器错误:内部服务器错误(“ b'{” message
是否存在这两个 if 语句会产生不同结果的情况? if(x as X != null) { // Do something } if(x is X) { // Do something } 编
我是一名优秀的程序员,十分优秀!