You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

114 lines
3.3 KiB

from django.db.models import Q
from general.views import *
from menu.models import *
def search_menu(upperbound, lowerbound, openid):
menu_search = Dish.objects.filter(Q(time__gt=lowerbound) & Q(time__lte=upperbound))
return menu_search
"""
fridge = FoodStock.objects.filter(owner_id=openid, is_active=1).values()
quantity = fridge.count()
for menus in menu_search:
menu_material_id = Material.objects.filter(Q(dish_id=menus.id) & Q(is_important=1)).values("food_type_id")
for Id in menu_material_id:
i = 0
for food in fridge:
i += 1
if food['type_id'] == Id:
i = 0
break
if i == quantity:
menu_search.remove(menus)
"""
"""
menu_material = Material.objects.get(all)
fridge = FoodStock.objects.get(all)
quantity = fridge.count()
for menus in menu_search:
id_dish = menus.id
for menu in menu_material:
if menu.dish_id == id_dish:
if menu.is_important == 1:
id_material = menu.food_type_id
i = 0
for food in fridge:
i += 1
if food.type_id == id_material:
i = 0
break
if i == quantity:
menu_search = menu_search.remove(menus)
"""
"""
import numpy as np
RI_dict = {1: 0, 2: 0, 3: 0.58, 4: 0.90, 5: 1.12, 6: 1.24, 7: 1.32, 8: 1.41, 9: 1.45}
def get_w(array):
row = array.shape[0] # 计算出阶数
a_axis_0_sum = array.sum(axis=0)
# print(a_axis_0_sum)
b = array / a_axis_0_sum # 新的矩阵b
# print(b)
b_axis_0_sum = b.sum(axis=0)
b_axis_1_sum = b.sum(axis=1) # 每一行的特征向量
# print(b_axis_1_sum)
w = b_axis_1_sum / row # 归一化处理(特征向量)
nw = w * row
AW = (w * array).sum(axis=1)
# print(AW)
max_max = sum(AW / (row * w))
# print(max_max)
CI = (max_max - row) / (row - 1)
CR = CI / RI_dict[row]
if CR < 0.1:
# print(round(CR, 3))
# print('满足一致性')
# print(np.max(w))
# print(sorted(w,reverse=True))
# print(max_max)
# print('特征向量:%s' % w)
return w
else:
print(round(CR, 3))
print('不满足一致性,请进行修改')
def main(array):
if type(array) is np.ndarray:
return get_w(array)
else:
print('请输入numpy对象')
if __name__ == '__main__':
# 由于地方问题,矩阵我就写成一行了
e = np.array([[1, 5, 1/2],
[1/5, 1, 5],
[2, 1/5, 1]])
a = np.array([[1, 1 / 3, 1 / 8], [3, 1, 1 / 3], [8, 3, 1]])
b = np.array([[1, 2, 5], [1 / 2, 1, 2], [1 / 5, 1 / 2, 1]])
c = np.array([[1, 1, 3], [1, 1, 3], [1 / 3, 1 / 3, 1]])
d = np.array([[1, 3, 4], [1 / 3, 1, 1], [1 / 4, 1, 1]])
f = np.array([[1, 4, 1 / 2], [1 / 4, 1, 1 / 4], [2, 4, 1]])
e = main(e)
a = main(a)
b = main(b)
c = main(c)
d = main(d)
f = main(f)
try:
res = np.array([a, b, c, d, f])
ret = (np.transpose(res) * e).sum(axis=1)
print(ret)
except TypeError:
print('数据有误,可能不满足一致性,请进行修改')
"""