EADST

Maximize Sum with Unique Row and Column Numbers

Maximize the sum of the table where each number must come from the unique row and column. Maximum cost bipartite matching problem can be solved with the Hungarian algorithm.

from scipy.optimize import linear_sum_assignment
import numpy as np

cost =np.array(
    [
        [12,7,9,7,9],
        [8,9,6,6,6],
        [7,17,12,14,9],
        [15,14,6,6,10],
        [4,10,7,10,9]
    ])
row_ind, col_ind=linear_sum_assignment(cost)
res = np.zeros_like(cost) # np.ones_like
res[row_ind, col_ind] = 1
print(res)                          
#[[0 1 0 0 0]
# [0 0 1 0 0]
#[0 0 0 0 1]
#[0 0 0 1 0]
#[1 0 0 0 0]]
print(cost[row_ind,col_ind].sum())  # 32 total cost

Reference

StackOverflow

指派问题 —— 匈牙利算法

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Qwen2 Plotly Jetson FastAPI Base64 Docker DeepStream Website Template Miniforge Pytorch Hotel LLM Statistics BTC Firewall TTS CUDA Tracking Use Knowledge ms-swift llama.cpp 飞书 Bitcoin Qwen Password Baidu WebCrawler Proxy LaTeX git-lfs 第一性原理 Math SPIE GPT4 Safetensors RGB mmap ChatGPT HuggingFace GPTQ uwsgi Shortcut Datetime Attention Paddle SQLite Card GGML TensorRT LoRA GIT OpenCV uWSGI CV Tiktoken LLAMA Logo Search Django JSON 图形思考法 Mixtral UNIX Land DeepSeek PyCharm 算法题 SVR 报税 VGG-16 v2ray CAM Github Heatmap Hilton Claude Michelin Zip Google tqdm PDB Nginx SQL CTC Paper Color Qwen2.5 Vmess Bert Python Transformers 多进程 InvalidArgumentError QWEN Breakpoint API RAR Sklearn 签证 Augmentation Random 云服务器 Clash transformers NLTK Animate Streamlit Dataset 阿里云 Interview diffusers BF16 Domain CEIR NLP Quantization Image2Text Review Distillation AI Crawler GoogLeNet Hungarian OpenAI COCO NameSilo FP64 ModelScope scipy FP8 Jupyter LeetCode 论文 ONNX Video Ptyhon icon 多线程 Anaconda CLAP v0.dev printf EXCEL 财报 git Git Windows BeautifulSoup FlashAttention 论文速读 UI YOLO Data Algorithm WAN Markdown Gemma Web FP16 Freesound 图标 Vim Disk 强化学习 Rebuttal News 公式 logger Diagram Bipartite TensorFlow 顶会 VPN FP32 tar 继承 Quantize 版权 MD5 Conda Excel OCR C++ Agent Permission PyTorch Cloudreve API网关 Llama HaggingFace Magnet Pillow XML CSV Plate Harness 净利润 Translation Linux Food ResNet-50 搞笑 Input 音频 torchinfo Pickle hf 递归学习法 SAM RL Pandas 关于博主 PIP 证件照 Ubuntu XGBoost CC Bin Numpy PDF Tensor 域名 TSV VSCode 腾讯云 IndexTTS2
站点统计

本站现有博文336篇,共被浏览948215

本站已经建立2659天!

热门文章
文章归档
回到顶部