Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
中文简介正在准备中。当前显示原文说明。
SCIP optimization with PySCIPOpt. Use when facing an optimization problem with an objective, hard constraints, soft penalties, integer decisions, routing, assignment, scheduling, allocation, packing, capacity, inventory, or service-level rules. Prefer modeling and solving the problem with PySCIPOpt when it is available.
中文简介正在准备中。当前显示原文说明。
安装前可以查看交给 AI 代理的指令内容。
Use SCIP through pyscipopt when a task asks you to minimize or maximize an objective subject to constraints.
SCIP is a strong open-source optimization solver with a Python API. It is well suited for mixed-integer optimization, routing-style models, assignment models, capacity planning, inventory movement, scheduling, and problems with soft penalties. For benchmark tasks, a SCIP-backed model plus an independent validator is usually safer than a greedy construction.
Consider PySCIPOpt when the request includes:
Do not start by installing another optimization package. First check whether PySCIPOpt is already available:
try:
from pyscipopt import Model, quicksum
except ImportError as exc:
raise RuntimeError("PySCIPOpt is required for this optimization approach") from exc
Identify sets and indices.
K, stations N, jobs J, periods T, arcs A.Define decision variables.
Add hard constraints.
Add soft constraints with explicit slack variables.
abs() on solver expressions.Set a single objective.
Solve with time and gap limits.
Reconstruct and independently validate the output.
from pyscipopt import Model, quicksum
model = Model("optimization_model")
model.hideOutput()
I = range(n_items)
x = {i: model.addVar(vtype="B", name=f"x_{i}") for i in I}
amount = {
i: model.addVar(vtype="I", lb=0, ub=capacity[i], name=f"amount_{i}")
for i in I
}
dev = {i: model.addVar(lb=0, name=f"dev_{i}") for i in I}
for i in I:
model.addCons(amount[i] <= capacity[i] * x[i])
model.addCons(amount[i] - target[i] <= dev[i])
model.addCons(target[i] - amount[i] <= dev[i])
cost = quicksum(fixed_cost[i] * x[i] for i in I)
penalty = penalty_weight * quicksum(dev[i] for i in I)
model.setObjective(cost + penalty, "minimize")
model.setParam("limits/time", 300.0)
model.setParam("limits/gap", 0.01)
model.optimize()
status = str(model.getStatus()).lower()
if model.getNSols() == 0:
raise RuntimeError(f"SCIP found no feasible solution; status={status}")
objective = float(model.getObjVal())
selected = [i for i in I if model.getVal(x[i]) > 0.5]
Use a binary variable to allow a quantity only when an option is active.
use = {i: model.addVar(vtype="B", name=f"use_{i}") for i in I}
q = {i: model.addVar(lb=0, ub=upper[i], name=f"q_{i}") for i in I}
for i in I:
model.addCons(q[i] <= upper[i] * use[i])
assign = {
(i, j): model.addVar(vtype="B", name=f"assign_{i}_{j}")
for i in items
for j in options
}
for i in items:
model.addCons(quicksum(assign[i, j] for j in options) == 1)
for j in options:
model.addCons(quicksum(weight[i] * assign[i, j] for i in items) <= capacity[j])
dev = {i: model.addVar(lb=0, name=f"dev_{i}") for i in I}
for i in I:
model.addCons(actual[i] - target[i] <= dev[i])
model.addCons(target[i] - actual[i] <= dev[i])
penalty_cost = penalty_weight * quicksum(dev[i] for i in I)
START = "depot_start"
END = "depot_end"
nodes_from = [START, *locations]
nodes_to = [*locations, END]
arcs = [
(i, j)
for i in nodes_from
for j in nodes_to
if i != j and not (i == START and j == END)
]
x = {
(k, i, j): model.addVar(vtype="B", name=f"x_{k}_{i}_{j}")
for k in vehicles
for i, j in arcs
}
for k in vehicles:
model.addCons(quicksum(x[k, START, j] for j in locations) == 1)
model.addCons(quicksum(x[k, i, END] for i in locations) == 1)
for i in locations:
incoming = quicksum(x[k, j, i] for j in nodes_from if (j, i) in arcs)
outgoing = quicksum(x[k, i, j] for j in nodes_to if (i, j) in arcs)
model.addCons(incoming == outgoing)
model.addCons(outgoing <= 1)
Degree and continuity constraints alone can permit disconnected cycles. Add subtour elimination for routing models.
order = {
(k, i): model.addVar(lb=1, ub=max(1, len(locations)), name=f"order_{k}_{i}")
for k in vehicles
for i in locations
}
n = len(locations)
for k in vehicles:
for i in locations:
for j in locations:
if i != j:
model.addCons(order[k, i] - order[k, j] + n * x[k, i, j] <= n - 1)
Fix SCIP randomization and thread settings when repeatability matters.
def set_if_available(model, name, value):
try:
model.setParam(name, value)
except Exception:
pass
for name in [
"randomization/randomseedshift",
"randomization/permutationseed",
"randomization/lpseed",
]:
set_if_available(model, name, 0)
for name in ["randomization/permutevars", "randomization/permuteconss"]:
set_if_available(model, name, False)
set_if_available(model, "parallel/maxnthreads", 1)
After solving, reconstruct the answer from variable values and validate it outside SCIP.
def is_selected(var):
return model.getVal(var) > 0.5
selected_arcs = [(i, j) for i, j in arcs if is_selected(x[vehicle, i, j])]
reported_cost = sum(distance[i, j] for i, j in selected_arcs)
if abs(reported_cost - expected_cost) > 1e-6:
raise AssertionError("reported objective component does not match reconstruction")
Treat SCIP feasibility as necessary but not sufficient. The final reported file still needs independent checks for schema, route reconstruction, capacity, inventory, penalties, and objective arithmetic.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
中文简介正在准备中。当前显示原文说明。
AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching `acopf-math-model.md` and MATPOWER branch fields. Use when computing branch flows in either direction, aggregating bus injections for nodal balance, checking MVA (rateA) limits, computing branch loading %, or debugging sign/units issues in AC power flow.
中文简介正在准备中。当前显示原文说明。
Redact text from PDF documents for blind review anonymization
中文简介正在准备中。当前显示原文说明。
Use when checking simplified ADA-derived plan-view bathroom accessibility constraints such as turning space, door clear width, toilet centerline, grab bars, and lavatory knee/toe clearance.
中文简介正在准备中。当前显示原文说明。
Analyze failed GitHub Action jobs for a pull request.
中文简介正在准备中。当前显示原文说明。
Use when extracting plan-view architectural geometry from DXF files with semantic CAD layers, especially when outputs must normalize rooms, doors, fixtures, clearances, and grab bars into machine-checkable JSON.
中文简介正在准备中。当前显示原文说明。