وظیفه
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یکی از شناخته شده ترین مسائل بهینه سازی ترکیبی مسئله انتساب است. یک مثال در اینجا آمده است: فرض کنید گروهی از کارگران باید مجموعه ای از وظایف را انجام دهند و برای هر کارگر و وظیفه، هزینه ای برای انتساب کارگر به کار وجود دارد. مشکل این است که هر کارگر را حداکثر به یک کار اختصاص دهید، بدون اینکه دو کارگر یک کار را انجام دهند، در حالی که هزینه کل را به حداقل می رساند.
شما می توانید این مشکل را با نمودار زیر تجسم کنید که در آن چهار کارگر و چهار وظیفه وجود دارد. لبه ها نشان دهنده تمام راه های ممکن برای انتساب کارگران به وظایف هستند. برچسب های روی لبه ها هزینه های اختصاص کارگران به وظایف است.

یک انتساب مربوط به زیرمجموعه ای از لبه ها است که در آن هر کارگر حداکثر یک یال منتهی به بیرون دارد و هیچ دو کارگری دارای لبه هایی هستند که به یک کار منتهی می شوند. یکی از تکالیف ممکن در زیر نشان داده شده است.

کل هزینه تکلیف 70 + 55 + 95 + 45 = 265
است.
بخش بعدی نحوه حل یک مسئله انتساب را با استفاده از حل کننده MIP و حل کننده CP-SAT نشان می دهد.
OR-Tools همچنین چند ابزار دیگر را برای حل مشکلات تخصیص ارائه می دهد که می توانند سریعتر از حل کننده های MIP یا CP باشند:
با این حال، این ابزارها فقط می توانند انواع ساده مشکلات انتساب را حل کنند. بنابراین برای حلکنندههای عمومی که میتوانند طیف گستردهای از مشکلات را حل کنند (و برای اکثر برنامهها به اندازه کافی سریع هستند)، حلکنندههای MIP و CP-SAT را توصیه میکنیم.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-08-09 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-08-09 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe assignment problem focuses on optimally assigning workers to tasks to minimize the total cost, where each worker is assigned at most one task and no task is assigned to multiple workers.\u003c/p\u003e\n"],["\u003cp\u003eThis problem can be visualized using a graph where edges represent worker-task assignments and edge labels represent the cost of each assignment.\u003c/p\u003e\n"],["\u003cp\u003eOR-Tools offers various solvers like MIP, CP-SAT, Linear Sum Assignment, and Minimum Cost Flow, but MIP and CP-SAT are recommended for their versatility and efficiency in handling a broader range of assignment problems.\u003c/p\u003e\n"]]],["The content describes the assignment problem, a combinatorial optimization challenge where workers are assigned to tasks to minimize total cost. Each worker is assigned to at most one task, and each task is done by at most one worker. The example shows how the problem can be represented graphically, with edges representing possible assignments and their costs. The total cost is calculated by adding up the costs of the assigned edges. OR-Tools offer multiple tools to solve such problems, among which the MIP and CP-SAT are the most general.\n"],null,["# Assignment\n\nOne of the most well-known combinatorial optimization problems is the\n[*assignment problem*](https://en.wikipedia.org/wiki/Assignment_problem). Here's an example: suppose a group of workers needs to perform a set of tasks, and for\neach worker and task, there is a cost for assigning the worker to the task.\nThe problem is to assign each worker to at most one task, with no two workers\nperforming the same task, while minimizing the total cost.\n\nYou can visualize this problem by the graph below, in which there are four\nworkers and four tasks. The edges represent all possible ways to assign workers\nto tasks. The labels on the edges are the costs of assigning workers to tasks.\n\nAn assignment corresponds to a subset of the edges, in which each worker has at\nmost one edge leading out, and no two workers have edges leading to the same\ntask. One possible assignment is shown below.\n\nThe total cost of the assignment is `70 + 55 + 95 + 45 = 265`.\n\nThe [next section](/optimization/assignment/assignment_example) shows how solve\nan assignment problem, using both the MIP solver and the CP-SAT solver.\n\n### Other tools for solving assignment problems\n\nOR-Tools also provides a couple of other tools for solving assignment problems,\nwhich can be faster than the MIP or CP solvers:\n\n- [Linear sum assignment solver](/optimization/assignment/linear_assignment)\n- [Minimum cost flow solver](/optimization/flow/assignment_min_cost_flow)\n\nHowever, these tools can only solve simple types of assignment problems.\nSo for general solvers that can handle a wide variety of problems (and are fast\nenough for most applications), we recommend the MIP and CP-SAT solvers."]]