MCPcopy Create free account
hub / github.com/dds-bridge/dds / example_mixed_usage

Function example_mixed_usage

examples/calc_par_context_example.cpp:115–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114
115void example_mixed_usage()
116{
117 printf("\n=== Context for Sequential Operations ===\n\n");
118
119 // Create a context - useful for managing resources across calls
120 SolverContext context;
121
122 printf("Best practices when using SolverContext:\n\n");
123
124 printf("1. Create context once:\n");
125 printf(" SolverContext context;\n\n");
126
127 printf("2. Reuse for multiple calculations:\n");
128 for (int i = 0; i < 3; i++) {
129 DdTableDeal table_deal{};
130 for (int h = 0; h < DDS_HANDS; ++h) {
131 for (int s = 0; s < DDS_SUITS; ++s) {
132 table_deal.cards[h][s] = holdings_[i][s][h];
133 }
134 }
135
136 DdTableResults ddtable;
137 ParResults pres;
138 int res = calc_par(
139 context,
140 table_deal,
141 vulnerability_[i],
142 &ddtable,
143 &pres);
144 if (res == RETURN_NO_FAULT) {
145 printf(" Hand %d Par: Score = %s\n", i + 1, pres.par_score[0]);
146 }
147 }
148
149 printf("\n3. Solver resources are reused across operations\n");
150 printf(" This is active now: calc_par(ctx, ...) uses the provided context\n\n");
151}
152
153
154void print_python_example()

Callers 1

mainFunction · 0.85

Calls 1

calc_parFunction · 0.85

Tested by

no test coverage detected