You can initialize the model parameters randomly to fit the constraints, and then run a form of gradient descent where you project the resulting coefficients onto the nearest plane that satisfies the constraints, as well. Since this is done with smaller steps at a time (ideally smaller steps as the number of iterations grows), it should converge.
A simpler(?) solution would be to construct a "wall" function that heavily penalizes constraint violations, and then project the final solution onto the constraints if you need an exact match.
I would recommend theano for this, since it makes iterative models relatively easy and compiles the code in C for faster performance.
Note that projecting on a convex hull is a bit more complicated than just a plane, but this paper outlines the algorithm. Because your constraints are a bit different than the one in the paper, I would impose the constraints on the two cutoff points ( i < K, i >= K) separately. The second constraint is not exact, so I think you can just omit points from the algorithm that already satisfy the constraints. Someone please correct me if I am wrong on this.