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

本站现有博文330篇,共被浏览860873

本站已经建立2569天!

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