def create_problem(assignment_id): questions = request.json['questions'] qdocs = [question.Question(_id=q['_id'], text=q['text']) for q in questions] pdoc = problem.Problem( order=int(request.json['order']), assignment_id=ObjectId(assignment_id), text=request.json['text'], questions=qdocs, visible=request.json['visible']) pdoc.save() return jsonify(code=200, data=pdoc)
# Discretized sampled distribution in order to have real q⋆ X, R = l.M_true.sample(l.n_true) l.M = synth.MarketDiscreteDistribution(X, R) l.n_experiments = 100 l.λ = 3 l.δ = 0.2 l.ns = np.arange(25, 2025, 25) l.Rf = 0 β = 1 r_threshold = 60 l.u = ut.LinearPlateauUtility(β, r_threshold) print('Computing q⋆ for the discretized problem...') p_star = pr.Problem(X, R, λ=0, u=l.u) p_star.solver = cvx.SCS R_star_q_star = p_star.solve() q_star = p_star.q R_star = p_star.insample_cost R_star_q_star = R_star(q_star) CE_star = p_star.insample_CE CE_star_q_star = CE_star(q_star) print('Done.') qs = np.zeros(shape=(len(l.ns), l.n_experiments, l.p + 1)) Rs_ins = np.empty(shape=(l.n_experiments, len(l.ns))) Rs_oos = np.empty(shape=(l.n_experiments, len(l.ns))) # Rs_lb = np.empty(shape=(len(l.ns)))
X, R = M.sample(n_true) M = synth.MarketDiscreteDistribution(X, R) X = DiscreteDistribution(X) R = DiscreteDistribution(R) n_experiments = 800 λs = np.arange(0, 13.2, 0.2) n = 200 δ = 0.2 βs = [1, 0.99, 0.5, 0.1, 0.01] for β in βs: u = ut.LinearPlateauUtility(β, 60) p = pr.Problem(X.points, R.points, λ=0, u=u) print('Computing q⋆ for the discretized problem...') p.solver = None p.solve() q_star = p.q print('Done.') def R_star(q, λ=0): return p.total_cost(X.points, R.points, q, λ) def CE(q, λ=0): return u.inverse(-R_star(q, λ)) R_star_q_star = R_star(q_star)