11/8/2023 0 Comments How to generate zmatrix![]() ![]() Matrix A = nullmat(A), (r(invcube), r(P_invcube), r(invsq), r(P_invsq), r(inv), r(P_inv), r(invsqrt), /// ![]() ) matrix, which I also generated with missing values. In the following step, I plan to then combine the 5 x 18 matrices of 9 different variables in a larger J(45, 18. Is there a different way of merging the matrices to input my newly generated data and replace the missing values, so that the new data is inputted in iterative rows? My code is as follows:įoreach var_sub in `var_subs' However, the new values do not replace the '.' missing values of the empty matrix. ![]() ) matrix, then running ladder command in a loop to generate the data which is to be stored in the matrix, then generating a matrix from this data (I also wonder if it is better at this stage to make a vector instead of a matrix?), then merging the 2 matrices. I have done this by first creating the empty J(5, 18. You can study these constraints to determine why they are allowing a wrong solution, and then based on what you find, you can fix the model formulation.Hi guys, I'm very new to Stata and very stuck! I am trying to generate an empty matrix (which I have filled with '.' missing values) and then fill it row by row vertically with 18 values generated for 5 categories of a variable in a loop. Use "expand E " to see exactly the constraints that AMPL generated. The output of display shows that there are two E constraints, and that both have a slack of zero in the solution that CPLEX returned - meaning that the solution does satisfy these constraints. Thus you can check whether CPLEX's solution satisfies the E constraints by using a display statement like this:ĬPLEX 12.10.0.0: optimal integer solution objective 4 When the current solution does not satisfy a constraint, AMPL shows the "slack" on the constraint to be negative. Anyhow, for whatever you write, you can try some tests to see whether the ARCS matrix is coming out correctly.Ģ. But you could also consider changing other entries in order to adjust the number of 1s in ARCS. You are only considering a change to ARCS when ord(j) equals 2*ord(i) - 1 or 2*ord(i). I apologize for having so many questions.ġ. Do you think if I specify 'option cplex_options 'concurrentopt,' this would solve the memory overload issue?įor your convenience and concrete reference, attached is my fully working code. But I have not tried using all 12 threads available in MacAir (I am not sure how cplex solver solves my Integer Programming problem, and how many threads it uses to solve primal, dual and barrier, if any). ![]() The obtained result is straightforward, and the same as other cases with smaller value of n). My current AMPL code runs out of memory usage when n:= 5000 (my laptop is MacAir 2014, and the AMPL's Cplex took 2.5 - 3 hours to solve when n = 4000. But rewriting the entire definition of set X and Y in terms of the indices of n is way too complicated for me, and I am not sure if it works).ģ. I would like to conduct a Monte Carlo simulation on the objective values and cplex solver's time for different values of n (for example, run the current code for n from 500 to 4500 with an incremental step = 500), how can we do this without changing the entire code in the model file? It seems to me I have to declare set n = 500.T by 500 in model file, but this will mess up with the cardinality of set X and set Y in the current working code (because set X:= 1.n, so n should be an integer, rather than a set. Rewriting the entire definition of X and Y in terms of the indices of fails to work either.Ģ. I would like to conduct a simulation on the objective values and cplex solver's time for different values of n (for example, run the current code for n from 500 to 4500 with an incremental step size = 500), how can we do this without changing the entire code in the model file? It seems to me I have to declare set n = 500.T by 500 in model file, but this does not work because n is used in the definition of set X and Y. Note that this would be placed at the bottom of your n above. How to adjust the resulting randomly-generated param ARCS with one additional constraint: the # of 1 to # of 0, in the randomly-generated matrix, satisfies a pre-defined ratio (for example, (# of 1s): (# of 0s) = 1:10) ? I posted the question and my best attempt already, but I think you were too busy that you overlooked it. I have two additional questions related to the param ARCS and n in the model file:ġ. Thanks to your great explanation and example file, I was finally able to make it run and solve the optimization problem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |