Formulation of Equations for Complementarity.jl

Dear community. I’m new to Julia and trying to code a Computable General Equilibrium Model. I have a question about Complementarity that I still can’t fully understand from going through various sources on the web.
I know I can have only one complementarity constraint per equation, right? But what I’m not totally sure of is if I have to specify all equations in @mapping setting them equal to zero, which would force me to rethink all equations such that I make sure they are all set equal to 0.

Example:
m=MCPModel()

@mapping(m, equation1, x^a - bq^2 + 5c …) equation is just an example
@complementarity(m, equation1, x)

now does equation1 (featuring x) here have to be set equal to zero ALWAYS or doesn’t it need to be? What alternatives do I have? Sorry if the question is stupid.
Thank you very much.
Best!

Hi @Alio0712, welcome to the forum!

Complementarity.jl is quite an old package. You can now use JuMP directly.

Here’s a tutorial with some MCP examples:

Let me know if you have any questions after reading the tutorial

1 Like

Hi @odow. Thank you very much. As I’m not so familiar with coding per se (only used R and a bit MATLAB for econometrics) I looked for some examples of General Equilibrium in Julia and the simplest approach I found was using complementarity, not knowing if there was/is something better.
So you recommend to just drop the complementarity package? I will start br trying to readapt the examples I have to JUMP only (as in the documentation you shared) and see if I get the idea. Since I see you’re the core contributor to JUMP (congratulations!), do you happen to know of anyone who works on computable general equilibrium using JUMP? Thank you very much.
Best!

1 Like

Thank you very much @mthelm85. I have the second reference and will look into it and start small. Best!

So you recommend to just drop the complementarity package?

Yes

do you happen to know of anyone who works on computable general equilibrium using JuMP

In addition to Matt’s links, @EliLazarus is working on GitHub - julia-mpsge/MPSGE.jl: MPSGE for Julia

1 Like

Yes, check out our package. We’ve built a Julia update of the MPSGE package (originally built in GAMS) so it’s pre-structured for CGE, MCP by default. Documentation is still a bit sparse, but the examples and test code should give a good idea, and I’d be happy to talk more.

2 Likes

Thank you very much @EliLazarus and @odow! I will definitely look into these resources. Maybe two quick questions that I’m still not absolutely certain about.

1. In order to be able to apply MCP, do I have to express ALL equations in the model setting them equal to 0?
2. Does the complementarity condition for each equation have to feature a variable that is present in this equation or can any equation have a complementarity variable that is not necessarily present in this equation?

Thanks! Best!

In order to be able to apply MCP, do I have to express ALL equations in the model setting them equal to 0?

I don’t understand the question. We don’t have any `== 0` constraints in a MCP. Do you have a small example of the problem you are trying to solve?

Does the complementarity condition for each equation have to feature a variable that is present in this equation

No. But you need one complementarity condition for every variable in the model.

No, I don’t, because I haven’t yet tried to write my model as an MCP problem, but in the model I saw written with the complementarity package all equations are expressed such that, in equilibrium, there value would be 0. This is where my question comes from. In this small model I saw, it made sense, but I think in my larger model some equations might not be naturally 0 in equilibrium. I will come back to you after I try to write my own model if I’m still unsure about this.

Perfect. Thank you very much!

1 Like