Giao diện MPSolver
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
bộ phần mềm nguồn mở của Google để tối ưu hoá,
OR-Tools (Công cụ) cung cấp trình bao bọc MPSolver
để giải quyết vấn đề lập chương trình tuyến tính và
bài toán lập trình số nguyên hỗn hợp.
Để giải các bài toán lập trình số nguyên thuần tuý, bạn cũng có thể sử dụng
Trình giải toán CP-SAT.
Ví dụ
Các trang sau đây cung cấp ví dụ minh hoạ cách sử dụng MPSolver:
Các thao tác phổ biến
Phần sau đây trình bày các công việc phổ biến liên quan đến việc giải quyết
LP và MIP.
Giới hạn thời gian
Ví dụ bên dưới trình bày cách đặt giới hạn thời gian tìm kiếm là 15 mili giây khi
bằng cách sử dụng Glop.
Python
solver.set_time_limit(15)
C++
solver->set_time_limit(15);
Java
solver.setTimeLimit(15)
C#
solver.SetTimeLimit(15);
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-08-29 UTC."],[[["\u003cp\u003eGoogle's OR-Tools provides the MPSolver for solving linear programming (LP) and mixed integer programming (MIP) problems.\u003c/p\u003e\n"],["\u003cp\u003eThe CP-SAT solver can be used for pure integer programming problems.\u003c/p\u003e\n"],["\u003cp\u003eOR-Tools offers various examples demonstrating MPSolver usage with different solvers like Glop and SCIP for LP, MIP, bin packing, and assignment problems.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can control the search time limit for solvers using the \u003ccode\u003eset_time_limit\u003c/code\u003e function across different programming languages like Python, C++, Java, and C#.\u003c/p\u003e\n"]]],["OR-Tools offers MPSolver for linear and mixed integer programming, and CP-SAT for pure integer programming. It provides examples for solving problems like the Stigler diet, LP and MIP problems, bin packing, and assignment. Common tasks include setting search time limits, demonstrated with `set_time_limit` methods in Python, C++, Java, and C#; the example shows how to set the limit to 15 milliseconds. MPSolver can be used with Glop or SCIP.\n"],null,["# MPSolver Interface\n\nGoogle's open source software suite for optimization,\n[OR-Tools](https://github.com/google/or-tools), provides the MPSolver wrapper\nfor solving [linear programming](/optimization/lp) and\n[mixed integer programming](/optimization/mip) problems.\n\nTo solve pure integer programming problems you can also use the\n[CP-SAT](/optimization/cp/cp_solver) solver.\n\nExamples\n--------\n\nThe following pages provide examples that illustrate MPSolver usage:\n\n- [Solving the Stigler diet problem](/optimization/lp/stigler_diet) using Glop\n- [Solving an LP problem](/optimization/lp/lp_example) using Glop\n- [Solving a MIP problem](/optimization/mip/mip_example) using SCIP\n- [Solving a bin packing problem](/optimization/pack/bin_packing) using SCIP\n- [Solving an assignment problem](/optimization/assignment/assignment_example) using CP-SAT\n- [Using arrays to define a model](/optimization/mip/mip_var_array)\n\nCommon tasks\n------------\n\nThe following section demonstrates common tasks related to solving\nand .\n\n### Time limits\n\nThe example below shows how to set a search time limit of 15 milliseconds when\nusing . \n\n### Python\n\n```python\nsolver.set_time_limit(15)\n```\n\n### C++\n\n```c++\nsolver-\u003eset_time_limit(15);\n```\n\n### Java\n\n```java\nsolver.setTimeLimit(15)\n```\n\n### C#\n\n```c#\nsolver.SetTimeLimit(15);\n```\n\n*[Glop]: Google Linear Optimization\n*[MIPs]: Mixed Integer Programming\n*[LPs]: Linear Programming"]]