add passage attribute to item and bundles generation method for solver run
This commit is contained in:
parent
ae8f303269
commit
a827312ef5
@ -9,14 +9,15 @@ def build_constraints(solver_run, problem, items):
|
|||||||
min = constraint.minimum
|
min = constraint.minimum
|
||||||
max = constraint.maximum
|
max = constraint.maximum
|
||||||
|
|
||||||
con = dict(zip([item.id for item in solver_run.items],
|
if attribute.type == 'metadata':
|
||||||
[item.attribute_exists(attribute)
|
con = dict(zip([item.id for item in solver_run.items],
|
||||||
for item in solver_run.items]))
|
[item.attribute_exists(attribute)
|
||||||
problem += lpSum([con[item.id]
|
for item in solver_run.items]))
|
||||||
* items[item.id]
|
problem += lpSum([con[item.id]
|
||||||
for item in solver_run.items]) >= round(total_form_items * (min / 100)), f'{attribute.id} - {attribute.value} - min'
|
* items[item.id]
|
||||||
problem += lpSum([con[item.id]
|
for item in solver_run.items]) >= round(total_form_items * (min / 100)), f'{attribute.id} - {attribute.value} - min'
|
||||||
* items[item.id]
|
problem += lpSum([con[item.id]
|
||||||
for item in solver_run.items]) <= round(total_form_items * (max / 100)), f'{attribute.id} - {attribute.value} - max'
|
* items[item.id]
|
||||||
|
for item in solver_run.items]) <= round(total_form_items * (max / 100)), f'{attribute.id} - {attribute.value} - max'
|
||||||
|
|
||||||
return problem
|
return problem
|
||||||
|
@ -19,9 +19,9 @@ class ServiceListener(SqsListener):
|
|||||||
logging.info('Process complete for %s', service.file_name)
|
logging.info('Process complete for %s', service.file_name)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.info('Starting Solver Service (v1.0.1)...')
|
logging.info('Starting Solver Service (v1.1.0)...')
|
||||||
listener = ServiceListener(
|
listener = ServiceListener(
|
||||||
'measure-development-solver-ingest',
|
os.environ['SQS_QUEUE'],
|
||||||
region_name=os.environ['AWS_REGION'],
|
region_name=os.environ['AWS_REGION'],
|
||||||
aws_access_key=os.environ['AWS_ACCESS_KEY_ID'],
|
aws_access_key=os.environ['AWS_ACCESS_KEY_ID'],
|
||||||
aws_secret_key=os.environ['AWS_SECRET_ACCESS_KEY'],
|
aws_secret_key=os.environ['AWS_SECRET_ACCESS_KEY'],
|
||||||
@ -31,6 +31,6 @@ def main():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
myname=os.path.basename(sys.argv[0])
|
myname=os.path.basename(sys.argv[0])
|
||||||
pidfile='/tmp/%s' % myname # any name
|
pidfile='/tmp/%s' % myname
|
||||||
daemon = Daemonize(app=myname,pid=pidfile, action=main, foreground=True)
|
daemon = Daemonize(app=myname,pid=pidfile, action=main, foreground=True)
|
||||||
daemon.start()
|
daemon.start()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
from models.attribute import Attribute
|
from models.attribute import Attribute
|
||||||
|
|
||||||
@ -8,6 +8,7 @@ from lib.irt.item_information_function import ItemInformationFunction
|
|||||||
|
|
||||||
class Item(BaseModel):
|
class Item(BaseModel):
|
||||||
id: int
|
id: int
|
||||||
|
passage: Optional[int]
|
||||||
attributes: List[Attribute]
|
attributes: List[Attribute]
|
||||||
b_param: float = 0.00
|
b_param: float = 0.00
|
||||||
|
|
||||||
|
@ -27,3 +27,17 @@ class SolverRun(BaseModel):
|
|||||||
def remove_items(self, items):
|
def remove_items(self, items):
|
||||||
self.items = [item for item in self.items if item not in items]
|
self.items = [item for item in self.items if item not in items]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def bundles(self, type_attribute):
|
||||||
|
bundles = []
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
attribute_id = getattr(item, type_attribute)()
|
||||||
|
bundle_index = next((index for (index, bundle) in enumerate(bundles) if bundle['id'] == attribute_id), None)
|
||||||
|
|
||||||
|
if bundle_index == None:
|
||||||
|
bundles.append({ 'id': item.passage, 'count': 1, 'type': type_attribute })
|
||||||
|
else:
|
||||||
|
bundles[bundle_index]['count'] += 1
|
||||||
|
|
||||||
|
return bundles
|
||||||
|
Loading…
x
Reference in New Issue
Block a user