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

本站现有博文332篇,共被浏览898011

本站已经建立2599天!

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