Skip to content

Commit

Permalink
Merge branch 'main' of github.com:davidrzs/HackOptimize
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrzs committed Sep 28, 2024
2 parents f67efcd + 9aa9179 commit 6137d53
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions src/translate_to_math.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
# from ai21 import AI21Client
from ai21 import AI21Client
from ai21.logger import set_verbose
from ai21.models.chat import ChatMessage, ToolMessage
from ai21.models.chat.function_tool_definition import FunctionToolDefinition
from ai21.models.chat.tool_defintions import ToolDefinition
from ai21.models.chat.tool_parameters import ToolParameters
import json, requests

# messages = [ChatMessage(content="Who was the first emperor of rome", role="user")]
client = AI21Client(api_key='kXftEvJYqotOSkpTw1e2KNUhvYX0EvU1')

# client = AI21Client()
def translate_to_math(input):

# response = client.chat.completions.create(
# messages=messages,
# model="jamba-1.5-mini",
# stream=True
# )
messages = [ChatMessage(content=
"""
You are an Operations Research scientist. You are trying to solve a scheduling problem.
You will be given a problem and you will need to translate it into mathematical notation.
Your task is to translate the problem into an optimization problem.
# for chunk in response:
# print(chunk.choices[0].delta.content, end="")
The problem should be formulated with one the following objectives:
1. Minimize time from start to finish of all required jobs
2. Minimize resource consumed
3. Minimize downtime between jobs
4. Maximize an output like number of items produced or profit
def translate_to_math(input):
return input
Decisions variables can for example be:
1. Start time for each job, machine pair
2. Makespan completion
3. Number of items produced by each machine
Constraints can for example be:
1. Each job must be done once
2. Each machine can only do one job at a time
3. Each job must be done in a certain order
4. Each job must be done within a certain time frame
5. Maximum number of jobs that can be done in a day
6. There might be downtime required between jobs
The problem should be formulated in the following format, :
Objective function: Minimize or Maximize
Decision variables: x1, x2, x3, ...
Constraints: c1, c2, c3, ...
""", role="system")]
messages.append(ChatMessage(content="This is the problem: " + input, role="user"))
response = client.chat.completions.create(
messages=messages,
model="jamba-1.5-large",
stream=True
)
for chunk in response:
print(chunk.choices[0].delta.content, end="")

0 comments on commit 6137d53

Please sign in to comment.