constraint-programming

Need Help In Solving A Constraint Problem

百般思念 提交于 2019-12-10 16:54:25
问题 I would like to solve the following problem using constraints but i actually don't know where to begin so i decided to post it here for help. *** Fitting squares *** Given the set of black squares of Figure 1 (a 2x2, 3x3, 4x4 and a 5x5 square), fit them all into the white rectangle of Figure 1 (a 7x9 rectangle), and this in such a way that there is no overlap between the squares. Note that the black squares can only be put on integer coordinates. Formulate the problem above as a constraint

Assigning people to beds - approaches to automate [closed]

一笑奈何 提交于 2019-12-10 14:01:33
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I help with a youth camp every year. Assigning attendees to bedrooms is a massive task - there are 92 bedrooms and the event runs for a week, with attendees staying for varying lengths of time, and beds needing to be reused. It currently takes a volunteer ~a week to assign people

Finding the smallest solution set, if one exists (n multipliers)

流过昼夜 提交于 2019-12-08 13:23:44
问题 Note: This is the n-multipliers variation of this problem. Given a set A , consisting of decimal values between 0.0 and 1.0, find the set B , such that each b in B is a set consisting of decimal values between 0.0 and 1.0, such that for each a in A , there is a set of unique values where a is the product of a subset of elements in B . For example, given $ A = [0.125, 0.25, 0.5, 0.75, 0.9] A possible (but probably not smallest) solution for B is $ B = solve(A) $ print(B) [[0.25, 0.5, 0.75, 0.9

Optimization in R for multiple variables

霸气de小男生 提交于 2019-12-08 09:48:41
问题 I want to solve an optimization problem in R; The dummy data for the same is given below. # Input Data DTM <- sample(1:30,10,replace=T) DIM <- rep(30,10) Price <- 100 - seq(0.4,1,length.out=10) # Variables that shall be changed to find optimal solution Hike <- sample(0:1,10,replace=T) Position <- sample(-2:2,10,replace=T) # Objective function hikes_till_now <- cumsum(Hike) - Hike PostHike <- numeric(10) for (i in seq_along(Hike)){ PostHike[i] <- 99.60 - 0.25*(Hike[i]*(1-DTM[i]/DIM[i])) if(i>1

Optimizing working scheduling MiniZinc code - constraint programming

◇◆丶佛笑我妖孽 提交于 2019-12-08 02:53:46
问题 Please can you help optimize this working MiniZinc code: Task: There is a conference which has 6x time slots. There are 3 speakers attending the conference who are each available at certain slots. Each speaker will present for a predetermined number of slots. Objective: Produce the schedule that has the earliest finish of speakers. Example: Speakers A, B & C. Talk durations = [1, 2, 1] Speaker availability: +---+------+------+------+ | | Sp.A | Sp.B | Sp.C | +---+------+------+------+ | 1 | |

Constraint programming suitable for extracting OneToMany relationships from records

廉价感情. 提交于 2019-12-08 01:56:34
问题 Maybe someone can help me to solve a problem with Prolog or any constraint programming language. Imagine a table of projects (school projects where pupils do something with their mothers). Each project has one or more children participating. For each child we store its name and the name of its mother. But for each project there is only one cell that contains all mothers and one cell that contains all children. Both cells are not necessarily ordered in the same way. Example: +-----------+-----

Get multiple solutions for 0/1-Knapsack MILP with lpSolveAPI

。_饼干妹妹 提交于 2019-12-07 16:43:17
问题 Reproducable Example: I described a simple 0/1-Knapsack problem with lpSolveAPI in R, which should return 2 solutions: library(lpSolveAPI) lp_model= make.lp(0, 3) set.objfn(lp_model, c(100, 100, 200)) add.constraint(lp_model, c(100,100,200), "<=", 350) lp.control(lp_model, sense= "max") set.type(lp_model, 1:3, "binary") lp_model solve(lp_model) get.variables(lp_model) get.objective(lp_model) get.constr.value((lp_model)) get.total.iter(lp_model) get.solutioncount(lp_model) Problem: But get

Prolog: foreach or forall for constraint solving?

夙愿已清 提交于 2019-12-07 04:07:01
问题 I'm attempting project scheduling with SWI prolog and CLP. I managed to support sequential dependencies but I'm struggling with avoiding double booking people. I have a list called Schedule containing elements like [taskname, starttime] where starttime is a free variable for the constraint solver. They're already constrained by sequential dependencies. I'm trying to write a loop like this to rule out double bookings: forall /* or maybe foreach*/ (isa(P,person), ( % Filter scheduled tasks on

retrieve the matched model in Z3py?

匆匆过客 提交于 2019-12-06 15:07:40
问题 In the following working example , How to retrieve the matched model? S, (cl_3,cl_39,cl_11, me_32,m_59,m_81) = EnumSort('S', ['cl_3','cl_39','cl_11','me_32','me_59','me_81']) h1, h2 = Consts('h1 h2', S) def fun(h1 , h2): conds = [ (cl_3, me_32), (cl_39, me_59), (cl_11, me_81), # ... ] and_conds = (And(h1==a, h2==b) for a,b in conds) return Or(*and_conds) For Example: as the following solver s = Solver() x1 = Const('x1', S) x2 = Const('x2', S) s.add(fun(x1,x2)) print s.check() print s.model()

Constraint programming suitable for extracting OneToMany relationships from records

人盡茶涼 提交于 2019-12-06 13:13:51
Maybe someone can help me to solve a problem with Prolog or any constraint programming language. Imagine a table of projects (school projects where pupils do something with their mothers). Each project has one or more children participating. For each child we store its name and the name of its mother. But for each project there is only one cell that contains all mothers and one cell that contains all children. Both cells are not necessarily ordered in the same way. Example: +-----------+-----------+------------+ | | | | | Project | Parents | Children | | | | | +-----------+-----------+--------