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

本站现有博文340篇,共被浏览1019210次

本站已经建立2719天!

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