Skip to main content

ficomo: a pyomo-like framework for the FICO xpress solver

Project description

Logo


Coverage PyPI Python License

ficomo: a pyomo-like framework for the FICO xpress solver

ficomo is a library that provides a set of tools for using the FICO xpress solver in the same way as pyomo. ficomo supports the following features:

Features

Declarative syntax: ficomo uses a declarative syntax for defining variables, expressions and constraints.

🚀 Native support for FICO xpress: ficomo provides a native interface to the xpress solver.

🔍 Diagnostics: ficomo provides tools for analyzing optimization problems, such as finding infeasible constraints, finding relaxations that will make the problem feasible, "force" solving an infeasible problem, etc.

⛓️ Remote execution: ficomo provides an easy way to run optimization problems on a remote executor node in both sync and async modes.

💾 Save and load: ficomo provides a way to save and load optimization problems and solutions without depending on xpress implementation details.

Usage Example

Here's a basic example of using ficomo to solve a simple optimization problem. The model determines the optimal number of chairs and tables to produce given manufacturing time and storage space constraints, while maximizing profit.

from ficomo.environ import Problem, Remote, SearchFor, Sense, var

USE_REMOTE = False # change to True to use remote execution
REMOTE_URL = None # None runs a local executor and connects to it

# Define decision variables
x1 = var(name="chairs", lb=0)  # number of chairs to produce
x2 = var(name="tables", lb=0)  # number of tables to produce

# Define objective: maximize profit
# Profit = 20 per chair + 30 per table
objective = 20 * x1 + 30 * x2

# Add constraints
# Resource constraints: time available for manufacturing
# Each chair takes 4 hours, each table takes 6 hours
# Total time available is 48 hours
time_constraint = 4 * x1 + 6 * x2 <= 48

# Storage space constraint:
# Each chair takes 0.2 sq m, each table takes 0.4 sq m
# Available space is 5 sq m
space_constraint = 0.2 * x1 + 0.4 * x2 <= 5.0

# Create the problem
variables = [x1, x2]
constraints = [time_constraint, space_constraint]
problem = Problem(variables, constraints, objective, sense=Sense.maximize)

if USE_REMOTE:
    # Solve the problem on a remote executor node
    with Remote(REMOTE_URL) as remote:
        solution = problem.to(remote).solve(search_for=SearchFor.optimal)

else:
    # Solve the problem localy
    solution = problem.solve(search_for=SearchFor.optimal)

# Print solution status
print(f"Solve status: {solution.solve_status!r}")
print(f"Solution status: {solution.solution_status!r}")

# Print solution
print(f"Optimal production plan: {solution.value({x1: x1, x2: x2})}")
print(f"Total profit: ${solution.value(objective)}")

# Output:
# Solve status: <SolveStatus.COMPLETED: 3>
# Solution status: <SolutionStatus.OPTIMAL: 1>
# Optimal production plan: {chairs: 12.0, tables: 0.0}
# Total profit: $240.0

# Save the problem to production-problem.fxp
problem.dump("production-problem.fxp")

# Save the solution to solution.fxs
# NOTE: the solution contains the problem
solution.dump("production-plan.fxs")

# Load the problem from production-problem.fxp
# problem = Problem.load("production-problem.fxp")

# Load the solution from solution.fxs
# solution = Solution.load("production-plan.fxs")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ficomo-0.1.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ficomo-0.1.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file ficomo-0.1.2.tar.gz.

File metadata

  • Download URL: ficomo-0.1.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for ficomo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 89f69609a82b20742ab03c3b0c6eab0212fa7be53157c4e7b712b9190d6da6c7
MD5 0bff2a698d084422ad5470737abb614f
BLAKE2b-256 684b32872625a21975a46324086cc969b9ee66ac5695c2861dd4e0fab6bf5d25

See more details on using hashes here.

File details

Details for the file ficomo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ficomo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for ficomo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca482f13b1c8f3ab203d30926c76fa9f6c258ad466bdfb9529b4bdcc200ff4b
MD5 13159bd948326511ab1a7a3c2a34e03e
BLAKE2b-256 94f4999263aede2d660aaa27340cc5d2e4109a8362fc2b32965d75fa7efc67fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page