For comparison, here is how I would write a version of your model in JuMP:
using JuMP
import Ipopt
using DelimitedFiles
using LinearAlgebra
a = 1
K = readdlm("K.csv", ',', header=false)
g = vec(readdlm("g.csv", ',', header=false))
m, n = size(K)
@assert (m,) == size(g)
model = JuMP.Model(Ipopt.Optimizer)
@variable(model, c[1:m])
@variable(model, x[1:n])
@constraint(model, x == K'c)
@objective(model, Min,
0.5*a*c'c + 0.5*x'x - g'c
)
optimize!(model)
This one for now ignores the modification of the matrix
but I have some ideas on how to handle with this with integer programming if necessary.