Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 variable problem and the solver is inaccurate #5

Closed
byronsit opened this issue Feb 19, 2024 · 2 comments
Closed

4 variable problem and the solver is inaccurate #5

byronsit opened this issue Feb 19, 2024 · 2 comments

Comments

@byronsit
Copy link

byronsit commented Feb 19, 2024

here is my gen code:

% 80 solutions, but I also cal a Q.   [664,744]
clc
clear all
close all
cd ('/home/xbh/gaps');
setpath
opt = default_options();
opt.M2_path = '/usr/bin/M2';
opt.optimize_coefficients = true;
%opt.use_sym = true;%
opt.use_sym = false;
%opt.eigen_solver = 'sturm';
%opt.default_opt.syzygy_reduction = 0;
%default_opt.find_sym = 0;
%default_opt.cg_max_stack_alloc_size = 10000;

 %random seed  len = 5

%opt.use_sym = true;%bohuan,change here 

%opt.prime_field = 999983
% opt.force_vars_in_reducibles = true;
%opt.remove_extra_columns = false;
% opt.find_upper_trianglar = true;
opt.M2_gbTrace = 3;
config.rand_seed = 4;

prob_fn = @() prob_sQPEP_pTop_merge_scale_opt(config);
[solv, opt] = generate_solver(prob_fn, opt);

solv_fun = str2func(['solver_' solv.name]);
stats = benchmark_solver(solv_fun,solv.prob,1);
stats.res_mean

and here is prob code

classdef prob_sQPEP_pTop_merge_scale_opt < problem
    methods
        function [in_subs, out_subs] = gen_arg_subs(obj)
            in_subs.V = sym('V%d', [4, 24]);    %W
            out_subs.q = sym('q', [4, 1]);
        end
        function [eqs_sym, abbr_subs] = gen_eqs_sym(obj)
            [in, out] = obj.gen_arg_subs();
            q0 = out.q(1); q1 = out.q(2); q2 = out.q(3); q3 = out.q(4);
            V = in.V;
            mon = [q0^3, q0^2*q1, q0^2*q2, q0^2*q3, q0*q1^2, q0*q1*q2, q0*q1*q3, q0*q2^2, q0*q2*q3, q0*q3^2, q0, q1^3, q1^2*q2, q1^2*q3, q1*q2^2, q1*q2*q3, q1*q3^2, q1, q2^3, q2^2*q3, q2*q3^2, q2, q3^3, q3];

            eqs_sym = sym(zeros(1, 4));

            eqs_sym(1:4) = V*mon.';

 
            abbr_subs = struct;
        end
        function [in_zp, out_zp] = rand_arg_zp(obj, p)
            %in_zp.W = sym(randi(p,[4, 364]) - 1);
            pnum = firstNPrimes(3000);
            in_zp.V  = sym(reshape(pnum(end-96+1:end),4,24));
            %in_zp.V  = reshpae(in_zp.V, 4,24);
            %in_zp.V = sym(randi(p,[1, 85]) - 1);
            out_zp = struct;
            return;
        end
        function [in_rl, out_rl] = rand_arg_rl(obj)
            load gap_test_coef.mat
            load gap_test_q.mat
            in_rl.V = eval(gap_test_coef);

            out_rl.q = (gap_test_q);
            %out_rl.q(1) = 5;
            %out_rl.q = rand(4,1);
            return;
        end
    end
    
end

and I also have a test code
`

    function [ret] = test_raw_sQPEP_pTop_merge_scale_opt(q, V)
        q0 = q(1); q1 = q(2); q2 = q(3); q3 = q(4);
        
        mon = [q0^3, q0^2*q1, q0^2*q2, q0^2*q3, q0*q1^2, q0*q1*q2, q0*q1*q3, q0*q2^2, q0*q2*q3, q0*q3^2, q0, q1^3, q1^2*q2, q1^2*q3, q1*q2^2, q1*q2*q3, q1*q3^2, q1, q2^3, q2^2*q3, q2*q3^2, q2, q3^3, q3];

        eqs_sym = sym(zeros(1, 4));

        eqs_sym(1:4) = V*mon.';
        ret = eqs_sym(1:4);

    end

`

here is the input q and coefs for test:

q=[ 1.96311188200896 -4.30421002705708 0.489905513962989 -1.54271201754741];

gap_test_coef =
 
[                  1.4076645091570793962010288424835, 0.000000000000000006661338147750939242541715621793,                  4.3108136395448599947899381845673, 0.000000000000000053290705182007513940334310560157,                  12.247142407671135946323204279906, -0.00000000000000064837024638109141960740054151673,                  3.5735565960713346966848291685892,                 10.539531399935745601403880300495, -0.00000000000000049737991503207013010978708097689,                 -0.5732433005076007176414876198578, -32.034416345755692316632501359663, 0.000000000000000048849813083506887778639787426689,                 0.8422582412477041224896368021291, -0.00000000000000068833827526759705506265216686219,  0.00000000000000010214051826551440171897416672894,                -1.0000956079901343853677531114954, -0.00000000000000018651746813702629879117012666774,   91.44232599024140386523296086807,                  -1.1333355319246022700763187884831, 0.00000000000000035083047578154946677386777609401,                 -1.7530652850187575819695950940513, -102.68918282876377806700496364556,                -1.946123307254305948098875645273e-41,  5.5144855338041046968755587442956]
[0.0000000000000000022204460492503130808472385405977,                  12.247142407671135946323204279906, -0.00000000000000032418512319054570980370027075837,                  1.7867782980356673483424145842946,  0.00000000000000014654943925052066333591936228007,                  1.6845164824954082449792736042582,  -0.0000000000000013766765505351941101253043337244, 0.00000000000000010214051826551440171897416672894,                 -1.0000956079901343853677531114954, -0.00000000000000018651746813702629879117012666774,   91.44232599024140386523296086807,                  1.6028662771392940157726722354148, 0.00000000000000023980817331903381273150446148718,                  2.6794279003955300068329226093056,              -0.0060847964642836838145001365774078, 0.00000000000000024868995751603506505489356344732,                  9.3867675919457851885230326161036, -42.808146834907816889233961310524, -0.000000000000000059952043329758453182876112143203,               -0.78384809634842548597966072065901,  0.00000000000000043964831775156199000775823607288,   1.222937027661787420251826574713,                   -1.2274527006942574247627675276817, -97.648788369199031787898368506262]
[                  1.4369378798482866649299793948558, -0.00000000000000032418512319054570980370027075837,                  10.539531399935745601403880300495, -0.00000000000000024868995751603506505489354048845,                  0.8422582412477041224896368021291,  0.00000000000000020428103653102880343794833345789,                 -1.0000956079901343853677531114954,                -3.4000065957738068102289563654494,  0.00000000000000070166095156309893354773555218802,                 -1.7530652850187575819695950940513, -102.68918282876377806700496364556, 0.000000000000000079936057773011270910501487162393,             -0.0060847964642836838145001365774078,  0.00000000000000012434497875801753252744678172366, -0.00000000000000017985612998927535954862833642961,                 -1.567696192696850971959321441318,  0.00000000000000043964831775156199000775823607288,   1.222937027661787420251826574713,                   1.2135224215174643009689219984998, 0.00000000000000032640556923979602288454768149052,                   12.26241016654666465379719397788,  37.557016213761340110936087777205, -0.0000000000000000044408920985006261616945229989434, -91.136182312818443795321421418976]
[ 0.000000000000000017763568394002504646778103520052,                  1.7867782980356673483424145842946, -0.00000000000000024868995751603506505489354048845,                 -0.5732433005076007176414876198578, -0.00000000000000068833827526759705506265216686219,                 -1.0000956079901343853677531114954, -0.00000000000000037303493627405259758234025333549, 0.00000000000000035083047578154946677386777609401,                 -3.5061305700375151639391901881027,             -5.8383699217629178442966269358191e-41,  5.5144855338041046968755587442956,                 0.89314263346517666894430753643519, 0.00000000000000012434497875801753252744678172366,                  9.3867675919457851885230326161036,                -0.78384809634842548597966072065901, 0.00000000000000087929663550312398001551647214576,                 -3.6823581020827722742883025830452, -97.648788369199031787898368506262,   0.00000000000000010880185641326534096151589383017,                  12.26241016654666465379719397788, -0.00000000000000001332267629550187848508356899683, -91.136182312818443795321421418976,                     1.786829858861890293411645025401,  37.285546966902169835345048909403]
 
@byronsit
Copy link
Author

I have solved the problem, thank you very much!

@Chastj
Copy link

Chastj commented Sep 7, 2024

I have solved the problem, thank you very much!

can you tell how you solved it? I faced same problems, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants