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

本站现有博文337篇,共被浏览961740次

本站已经建立2673天!

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