Skip to content

Commit

Permalink
Logic for validating AMPL license
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-quintero committed Feb 27, 2024
1 parent 80cf57a commit 8868926
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions knapsack-ampl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@

# Duration parameter for the solver.
SUPPORTED_PROVIDER_DURATIONS = {
"cbc": "timelimit",
"copt": "timelimit",
"gcg": "timelimit",
"gurobi": "timelimit",
"highs": "timelimit",
"lgo": "timelim",
"scip": "timelimit",
"xpress": "timelimit",
}

# Open source solvers.
OSS_SOLVERS = ["cbc", "gcg", "gecode", "highs", "scip"]

# Status of the solver after optimizing.
STATUS = [
{"lb": 0, "ub": 99, "status": "optimal"},
Expand Down Expand Up @@ -96,8 +101,9 @@ def solve(input_data: dict[str, Any], duration: int, provider: str) -> dict[str,
start_time = time.time()

# Activate license.
license = read_license_uuid()
modules.activate(license)
if provider not in OSS_SOLVERS:
license = read_license_uuid()
modules.activate(license)

# Defines the model.
ampl = AMPL()
Expand Down

0 comments on commit 8868926

Please sign in to comment.