Skip to content
Snippets Groups Projects
Commit 0f5b1196 authored by Hailu, Dawit's avatar Hailu, Dawit
Browse files

more on feasible solution

parent 6b46720e
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -251,11 +251,9 @@ SCIP_RETCODE SCIPcreateprobdata
SCIP_VAR* varx = (*varbuffers)[j];
int varbufindex = SCIPvarGetIndex(varx);
assert(varbufindex != NULL);
(&listconsvarids)[counter]=varbufindex;
listconsvarids[counter]=varbufindex;
counter++;
printf("(%d,%d) \t",counter,(&listnconsvars)[counter]);
}
printf("\n");
}
// counter=0;
......
......@@ -158,6 +158,13 @@ SCIP_DECL_RELAXINIT(relaxInitlagr)
int* listnconsvars = SCIPlistnconsvars(probdata);
int* listconsvarids = SCIPlistconsvarids(probdata);
int* increasingorder; //example {2,4,6,9,12,...}
SCIP_CALL(SCIPallocBufferArray(relaxscip,&increasingorder,nSlotConss));
increasingorder[0] = listnconsvars[0];
for(int r=1; r<nSlotConss;r++)
{
increasingorder[r]=listnconsvars[r]+increasingorder[r-1];
}
/* we then create the vardata function for each variable, to see at which constraint the variable is found*/
FILE* TimeCollector;
TimeCollector = fopen("time.txt","w");
......@@ -229,9 +236,9 @@ SCIP_DECL_RELAXINIT(relaxInitlagr)
for(int t=0;t<NVarInBadConss;t++)
{
varids[t]=consids[t];
// printf("%d \t",varids[t]);
printf("%d \t",varids[t]);
}
// printf("\n");
// // vardata=SCIPvarGetData(var);
SCIP_CALL(SCIPallocBlockMemory(scip , &vardata));
SCIP_CALL(SCIPduplicateBlockMemoryArray(scip, &(vardata->varids), varids, NVarInBadConss));
......@@ -351,13 +358,15 @@ SCIP_DECL_RELAXINIT(relaxInitlagr)
SCIP_CALL(SCIPgetConsNVars(relaxscip, cons, &nconsvars, &valid));
SCIP_CALL(SCIPgetConsVars(relaxscip, cons, VARSinsidegoodconss, nconsvars, &valid));
if (!valid){abort(); }
printf("%s\n",SCIPconsGetName(cons));
printf("\n %s\t",SCIPconsGetName(cons));
for (int j = 0; j < nconsvars; ++j) /* (8) */
{
SCIP_VAR* varx = (VARSinsidegoodconss)[j];
printf("%s\t",SCIPvarGetName(varx));
int varbufindex = SCIPvarGetIndex(varx); //get the index, which will be used in assigning values to the feassol.
assert(varbufindex != NULL);
printf("%d\t",varbufindex);
if (feasol[varbufindex]==-1)
......@@ -371,23 +380,29 @@ SCIP_DECL_RELAXINIT(relaxInitlagr)
}
vardata=SCIPvarGetData(varx);
int NVarInBadConss = SCIPvardataGetNVarInBadConss(vardata);
if(NVarInBadConss==0){feasol[varbufindex]==1;} //which means if there is no restriction put for that variable.
//and now, we go to the other variables together found in the badconss.
int* varids = SCIPvardataGetvarids(vardata); //get the array containing the slots where the variable is located.
int* varids = SCIPvardataGetvarids(vardata);
assert(varids=!NULL);
for(int t=0; t<NVarInBadConss; ++t)
int NVarInBadConss = SCIPvardataGetNVarInBadConss(vardata);
printf("nvarincons = %d\t",NVarInBadConss);
for(int t=0;t<NVarInBadConss;t++)
{
printf("%d \n",varids[t]);
//varids[t] gives the constraint address. There we still would like to find out which variables are found.
for(int p=increasingorder[varids[t]]-NVarInBadConss; p<increasingorder[varids[t]]; ++p)
{
if(SCIPvarGetIndex(vars[listconsvarids[p]])!=varbufindex)
{
printf("var = %s\t",SCIPvarGetName(vars[listconsvarids[p]]));
if(feasol[listconsvarids[p]]!=1)
{
feasol[listconsvarids[p]]=0;
}
}
}
}
printf("\n");
}
printf("(%s,%d,%f)\n",SCIPvarGetName(varx), varbufindex,feasol[varbufindex]);
......@@ -396,20 +411,16 @@ SCIP_DECL_RELAXINIT(relaxInitlagr)
}
printf("\n");
// printf("\n");
}
// for(int v=0;v<nvars;v++)
// {
// SCIP_VAR* var = SCIPgetVars(scip)[i];
// id = SCIPvarGetIndex(var);
// vardata = SCIPvarGetData(var);
// printf(" %d ",id);
for(int v=0;v<nvars;v++)
{
printf(" %d ",feasol[v]);
// }
}
......
row and column identified in (sec) : 0.000053
row and column identified in (sec) : 0.000258
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment